pld-ftp-admin: shell/bash_profile - reorganize to allow sudo for any user

glen glen at pld-linux.org
Mon Jan 10 21:20:56 CET 2011


Author: glen                         Date: Mon Jan 10 20:20:56 2011 GMT
Module: pld-ftp-admin                 Tag: HEAD
---- Log message:
- reorganize to allow sudo for any user

---- Files affected:
pld-ftp-admin/shell:
   bash_profile (1.8 -> 1.9) 

---- Diffs:

================================================================
Index: pld-ftp-admin/shell/bash_profile
diff -u pld-ftp-admin/shell/bash_profile:1.8 pld-ftp-admin/shell/bash_profile:1.9
--- pld-ftp-admin/shell/bash_profile:1.8	Mon Jan 10 21:12:17 2011
+++ pld-ftp-admin/shell/bash_profile	Mon Jan 10 21:20:50 2011
@@ -1,10 +1,22 @@
 # .bash_profile - file executed when logging in
 
+# identify via remote addr
 case "${SSH_CLIENT%% *}" in
 84.50.110.50) # glen ;)
-	export EDITOR=vim
-	export TZ=EET
 	export FTPADM=glen
+esac
+
+# identify via terminal last login (su, sudo)
+if [ -z "$FTPADM" ]; then
+	LAST_TTY=$(tty)
+	LAST_LOGIN=$(last -if /var/run/utmpx | awk -vtty="${LAST_TTY#/dev/}" '$2 == tty && $0 ~ /still logged in/ { print $1; exit; }')
+	export FTPADM=$LAST_LOGIN
+fi
+
+# per-admin defaults
+case "$FTPADM" in
+glen)
+	export TZ=EET
 	case $(id -un) in
 	pldth)
 		echo -ne "\033kth at ftp\033\\"
@@ -13,24 +25,14 @@
 		echo -ne "\033kac at ftp\033\\"
 		;;
 	esac
+	;;
+'')
+	export FTPADM=$USER
+	;;
 esac
 
-if [ -z "$FTPADM" ]; then
-	LAST_TTY=$(tty)
-	LAST_LOGIN=$(last -if /var/run/utmpx | awk -vtty="${LAST_TTY#/dev/}" '$2 == tty && $0 ~ /still logged in/ { print $1; exit; }')
-	case "$LAST_LOGIN" in
-		arekm)
-			export EDITOR=vim
-			export FTPADM=arekm
-		;;
-	esac
-fi
-
-if [ -z "$FTPADM" ]; then
-	FTPADM=$USER
-fi
-
 # let each ftp admin have own bash history
 if [ "$FTPADM" ]; then
 	export HISTFILE=$HOME/.history-$FTPADM
 fi
+export EDITOR=vim
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/shell/bash_profile?r1=1.8&r2=1.9&f=u



More information about the pld-cvs-commit mailing list