[26494] in Source-Commits
Re: /svn/athena r25590 - in trunk/debathena/debathena/dotfiles: .
daemon@ATHENA.MIT.EDU (Benjamin Kaduk)
Fri Jun 29 18:10:19 2012
Date: Fri, 29 Jun 2012 18:10:15 -0400 (EDT)
From: Benjamin Kaduk <kaduk@MIT.EDU>
To: Jonathan D Reed <jdreed@MIT.EDU>
cc: source-commits@MIT.EDU
In-Reply-To: <201206291845.q5TIjYV6020742@drugstore.mit.edu>
Message-ID: <alpine.GSO.1.10.1206291802190.18441@multics.mit.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
On Fri, 29 Jun 2012, Jonathan D Reed wrote:
> Author: jdreed
> Date: 2012-06-29 14:45:34 -0400 (Fri, 29 Jun 2012)
> New Revision: 25590
>
> Modified:
> trunk/debathena/debathena/dotfiles/bashrc
> trunk/debathena/debathena/dotfiles/cshrc
> trunk/debathena/debathena/dotfiles/debian/changelog
> Log:
> In dotfiles:
> * Prevent users from shooting themselves in the foot with PATH or
> LD_ASSUME_KERNEL
>
>
> Modified: trunk/debathena/debathena/dotfiles/bashrc
> ===================================================================
> --- trunk/debathena/debathena/dotfiles/bashrc 2012-06-29 16:50:48 UTC (rev 25589)
> +++ trunk/debathena/debathena/dotfiles/bashrc 2012-06-29 18:45:34 UTC (rev 25590)
> @@ -146,3 +146,33 @@
> . ~/.bashrc.mine
> fi
> fi
> +if [ "${skip_sanity_checks+set}" != set ]; then
> + IFS=:
> + bin=no
> + usrbin=no
> + for p in $PATH; do
> + case $p in
> + /bin)
> + bin=yes
> + ;;
> + /usr/bin)
> + usrbin=yes
> + ;;
> + esac
> + done
> + unset IFS
> + if [ "$bin" != "yes" ] || [ "$usrbin" != "yes" ]; then
> + text="You appear to have incorrectly modified your PATH variable in your dotfiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail. Please correct this problem."
> + echo -e "$text" >&2
> + [ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text"
> + fi
> + if [ -n "$LD_ASSUME_KERNEL" ]; then
> + unset LD_ASSUME_KERNEL
> + echo "In your shell customizations, you set LD_ASSUME_KERNEL. This is a bad idea." >&2
> + echo "We have unset it for you." >&2
It seems a little odd to use "we", here, instead of "It has been
automatically unset for you".
> + echo "If you really did want that, set skip_sanity_checks=y in your .bashrc.mine." >&2
> + [ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="You tried to set LD_ASSUME_KERNEL in your shell customizations. Don't do that.\nWe have unset it for you.\nSet skip_sanity_checks=y in your ~/.bashrc.mine if you really want that."
Also, you might reuse the $text trick from the PATH check above, here.
> + fi
> +fi
> +
> +
>
> Modified: trunk/debathena/debathena/dotfiles/cshrc
> ===================================================================
> --- trunk/debathena/debathena/dotfiles/cshrc 2012-06-29 16:50:48 UTC (rev 25589)
> +++ trunk/debathena/debathena/dotfiles/cshrc 2012-06-29 18:45:34 UTC (rev 25590)
> @@ -182,3 +182,30 @@
> source ~/.cshrc.mine
> endif
> endif
> +
> +if (! $?skip_sanity_checks) then
> + echo $path | /usr/bin/tr ':' '\n' | grep -Fqx /bin
> + missing=0
Does variable assignment change $? ?
The style would probably be better to move "missing=0" up one line,
regardless.
> + if ( $? != 0 ) then
> + missing=1
> + endif
> + echo $path | /usr/bin/tr ':' '\n' | grep -Fqx /usr/bin
When maintaining scripts with the same functionality in different
languages (shells), it's probably better for one's sanity to keep the
structure as parallel as possible, e.g., use this grep construct in the sh
script as well.
> + if ( $? != 0 ) then
> + missing=1
> + endif
> + if ( $missing == 1 ) then
> + text="You appear to have incorrectly modified your PATH variable in your dotiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail. Please correct this problem."
> + echo "$text" > /dev/stderr
> + if ( $?DISPLAY) then
> + /usr/bin/zenity --warning --text="$text"
> + endif
> + endif
> + if ( $?LD_ASSUME_KERNEL ) then
> + unsetenv LD_ASSUME_KERNEL
> + echo "Setting LD_ASSUME_KERNEL in your dotfiles is a bad idea." > /dev/stderr
> + echo "We have unset it for you. Set skip_sanity_checks=y if you really wanted it." > /dev/stderr
> + if ( $?DISPLAY) then
> + /usr/bin/zenity --warning --text="You set LD_ASSUME_KERNEL in your dotfiles which is a bad idea.\nWe have unset it for you.\nSet skip_sanity_checks=y if you really wanted it."
The same comments from the sh script apply here.
But, it should work...
-Ben
> + endif
> + endif
> +endif
>
> Modified: trunk/debathena/debathena/dotfiles/debian/changelog
> ===================================================================
> --- trunk/debathena/debathena/dotfiles/debian/changelog 2012-06-29 16:50:48 UTC (rev 25589)
> +++ trunk/debathena/debathena/dotfiles/debian/changelog 2012-06-29 18:45:34 UTC (rev 25590)
> @@ -1,3 +1,10 @@
> +debathena-dotfiles (10.0.30-0debathena2) unstable; urgency=low
> +
> + * Prevent users from shooting themselves in the foot with PATH or
> + LD_ASSUME_KERNEL
> +
> + -- Jonathan Reed <jdreed@mit.edu> Fri, 29 Jun 2012 14:45:43 -0400
> +
> debathena-dotfiles (10.0.30-0debathena1) unstable; urgency=low
>
> * Update logout alias for GNOME 3.0 (Trac: #1027)
>
>