Root: huge optimisation (and security feature) for VCS directories

If under root user, for VCS directories we do not collect anymore the
VCS status information. Before it was collected (even if
LP_ENABLE_VCS_ROOT=0, which is the default) but just not displayed.
This is a huge optimisation for VCS directories, and also a security
feature, as our shell code is absolutely not resistant to specially
crafted VCS content.
This commit is contained in:
Olivier Mengué 2013-06-11 22:54:44 +02:00
parent aad57e8497
commit cf2ff289c8

View File

@ -368,6 +368,8 @@ else # root!
LP_USER="${LP_COLOR_USER_ROOT}${_LP_USER_SYMBOL}${NO_COL}" LP_USER="${LP_COLOR_USER_ROOT}${_LP_USER_SYMBOL}${NO_COL}"
LP_COLOR_MARK="${LP_COLOR_MARK_ROOT}" LP_COLOR_MARK="${LP_COLOR_MARK_ROOT}"
LP_COLOR_PATH="${LP_COLOR_PATH_ROOT}" LP_COLOR_PATH="${LP_COLOR_PATH_ROOT}"
# Disable VCS info for all paths
[[ "$LP_ENABLE_VCS_ROOT" != 1 ]] && LP_DISABLED_VCS_PATH=/
fi fi
@ -1525,15 +1527,10 @@ _lp_set_prompt()
PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}" PS1="${PS1}${LP_PWD}${LP_BRACKET_CLOSE}${LP_VENV}${LP_PROXY}"
# if not root # Add VCS infos
if [[ "$EUID" -ne "0" ]] # If root, the info has not been collected unless LP_ENABLE_VCS_ROOT
then # is set.
# add VCS infos
PS1="${PS1}${LP_VCS}" PS1="${PS1}${LP_VCS}"
else
# do not add VCS infos unless told otherwise (LP_ENABLE_VCS_ROOT)
[[ "$LP_ENABLE_VCS_ROOT" = "1" ]] && PS1="${PS1}${LP_VCS}"
fi
# add return code and prompt mark # add return code and prompt mark
PS1="${PS1}${LP_ERR}${LP_MARK}${LP_PS1_POSTFIX}" PS1="${PS1}${LP_ERR}${LP_MARK}${LP_PS1_POSTFIX}"