From: Iain Patterson Date: Mon, 15 Mar 2010 13:34:50 +0000 (+0000) Subject: Mantis 402. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=815c4966940595d1c924b0e01e82fe99fb1c4a29;p=profile.git Mantis 402. Don't use mktemp in become and became. Some systems don't have it and others want different arguments. --- diff --git a/opt/bin/became b/opt/bin/became index 245f75b..694810d 100755 --- a/opt/bin/became +++ b/opt/bin/became @@ -1,11 +1,8 @@ #!/bin/bash -file="$(mktemp)" -if [ -n "$file" ]; then - ( umask 077; cat > "$file"; echo "/bin/rm -f '$file'" >> "$file" ) - exec "$file"; echo "/bin/rm -f '$file'" >> "$file" ) +exec "$file" - exec <"$file" - rm "$file" - +file="${TMPDIR:-/tmp}/$USER.become.$user.$RANDOM.$$" +umask 077 +if exec 3>"$file" && exec <"$file" && rm "$file"; then echo >&3 "cd" echo >&3 "PROFILE_HOME='$HOME'" if [ -n "$PRINCIPAL" ]; then @@ -63,12 +60,14 @@ if [ -n "$file" ]; then else echo >&3 "unset DISPLAY" fi - - echo >&3 2>/dev/null ". $HOME/.bash_profile" - [ -f "$BECOME/all" ] && cat >&3 2>/dev/null "$BECOME/all" - [ -f "$BECOME/$user" ] && cat >&3 2>/dev/null "$BECOME/$user" +else + exit 111 fi +echo >&3 ". $HOME/.bash_profile" +[ -f "$BECOME/all" ] && cat >&3 2>/dev/null "$BECOME/all" +[ -f "$BECOME/$user" ] && cat >&3 2>/dev/null "$BECOME/$user" + dir=$(dirname "$0") [ "$dir" = "." ] && dir="$PWD" exec sudo -H -u "$user" "$dir/became"