From: Iain Patterson Date: Thu, 25 Mar 2010 17:04:46 +0000 (+0000) Subject: Preserve umask. X-Git-Url: http://git.iain.cx/?p=profile.git;a=commitdiff_plain;h=484d06da67a028c69e6ede83479b1bdbeccd5749 Preserve umask. We set umask 077 to ensure that the become script is not readable by other users. Set the mask back to what it was beforehand. --- diff --git a/opt/bin/became b/opt/bin/became index ca1a523..940e26e 100755 --- a/opt/bin/became +++ b/opt/bin/became @@ -1,7 +1,7 @@ #!/bin/bash file="${TMPDIR:-/tmp}/$SUDO_USER.became.$USER.$RANDOM.$$" -( umask 077; echo "unset ENV POSIXLY_CORRECT; set +o posix" > "$file"; cat >> "$file"; echo "/bin/rm -f '$file'" >> "$file" ) +( builtin umask 077; echo "unset ENV POSIXLY_CORRECT; set +o posix" > "$file"; cat >> "$file"; echo "/bin/rm -f '$file'" >> "$file" ) exec "$file" && exec <"$file" && rm "$file"; then + builtin $umask echo >&3 "cd" echo >&3 "PROFILE_HOME='$HOME'" if [ -n "$PRINCIPAL" ]; then