Fix path setup in add_sudo_secure_path
There are two bugs in add_sudo_secure_path. Firstly we don't properly check if the file exists, so always append the new line. This will overwrite any existing changes. Secondly the logic for checking if the path exists is inverted, so we miss adding paths when we should. This particularly causes failures when installing with virtualenv's since the paths are inside the virtualenv, rather than the standard system locations. Change-Id: I646fe0c68958470d464fe4f3d81d5c17dd6f2ab6 Closes-bug: #1521241
This commit is contained in:
parent
bf81732b12
commit
e0ac37c257
@ -22,14 +22,14 @@ function add_sudo_secure_path {
|
|||||||
local line
|
local line
|
||||||
|
|
||||||
# This is pretty simplistic for now - assume only the first line is used
|
# This is pretty simplistic for now - assume only the first line is used
|
||||||
if [[ -r SUDO_SECURE_PATH_FILE ]]; then
|
if [[ -r $SUDO_SECURE_PATH_FILE ]]; then
|
||||||
line=$(head -1 $SUDO_SECURE_PATH_FILE)
|
line=$(head -1 $SUDO_SECURE_PATH_FILE)
|
||||||
else
|
else
|
||||||
line="Defaults:$STACK_USER secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin"
|
line="Defaults:$STACK_USER secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only add ``dir`` if it is not already present
|
# Only add ``dir`` if it is not already present
|
||||||
if [[ $line =~ $dir ]]; then
|
if [[ ! $line =~ $dir ]]; then
|
||||||
echo "${line}:$dir" | sudo tee $SUDO_SECURE_PATH_FILE
|
echo "${line}:$dir" | sudo tee $SUDO_SECURE_PATH_FILE
|
||||||
sudo chmod 400 $SUDO_SECURE_PATH_FILE
|
sudo chmod 400 $SUDO_SECURE_PATH_FILE
|
||||||
sudo chown root:root $SUDO_SECURE_PATH_FILE
|
sudo chown root:root $SUDO_SECURE_PATH_FILE
|
||||||
|
Loading…
Reference in New Issue
Block a user