Browse code

Export the 'short_source' function & don't keep PS4 in sudo

Export the 'short_source' function so that it will be present in the
environment for child shell scripts. Do this because we are passing PS4
to the child shell scripts and it is using 'short_source'

Don't do an 'env_keep' in the sudoers file for PS4, since it is
difficult to also pass along the 'short_source' function.

Change-Id: I9781010d6eb336d02939c7fd47f18bedeae5ccc6
Closes-Bug: #1563443

John L. Villalovos authored on 2016/05/06 04:50:52
Showing 3 changed files
... ...
@@ -41,6 +41,9 @@ function short_source {
41 41
     file=${file#$RC_DIR/}
42 42
     printf "%-40s " "$file:${called[1]}:${called[0]}"
43 43
 }
44
+# PS4 is exported to child shells and uses the 'short_source' function, so
45
+# export it so child shells have access to the 'short_source' function also.
46
+export -f short_source
44 47
 
45 48
 
46 49
 # Retrieve an image from a URL and upload into Glance.
... ...
@@ -240,7 +240,6 @@ echo "$STACK_USER ALL=(root) NOPASSWD:ALL" >$TEMPFILE
240 240
 # see them by forcing ``PATH``
241 241
 echo "Defaults:$STACK_USER secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
242 242
 echo "Defaults:$STACK_USER !requiretty" >> $TEMPFILE
243
-echo "Defaults env_keep += PS4" >> $TEMPFILE
244 243
 chmod 0440 $TEMPFILE
245 244
 sudo chown root:root $TEMPFILE
246 245
 sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
... ...
@@ -22,6 +22,9 @@ function short_source {
22 22
     file=${file#$RC_DIR/}
23 23
     printf "%-40s " "$file:${called[1]}:${called[0]}"
24 24
 }
25
+# PS4 is exported to child shells and uses the 'short_source' function, so
26
+# export it so child shells have access to the 'short_source' function also.
27
+export -f short_source
25 28
 
26 29
 set -o xtrace
27 30