20090325

is there a environment variable that indicates if a session has been started via an ordinary login or via "su"? 

http://groups.google.de/group/comp.unix.shell/browse_frm/thread/1aabaddbf9215d81/0398881066c2d757<br class="khtml-block-placeholder">
if [ "$DISPLAY" != "" ]; then
&nbsp;&nbsp; echo Login via X
else
&nbsp;&nbsp; if [ "$SSH_CONNECTION" = "" ]; then
&nbsp;&nbsp; &nbsp; echo Login via su
&nbsp;&nbsp; else
&nbsp;&nbsp; &nbsp; echo Login via ssh
&nbsp;&nbsp; fi
fi&nbsp;
$ echo $0
-bash
$ su -
Password:
# echo $0
-su&nbsp;
ps $$|grep -q -- ' -su'&amp;&amp;echo SU&nbsp;<br>
[ "$0" = "-sh" ] &amp;&amp; echo SU&nbsp;<br>
Compare "who am i" with "id".<br>

No comments:

Post a Comment