1) telnetd removed, so it won't be a parent process

2) Restricted shells can redirect window decor to > /dev/tty

3) In wcd(), only do _ignore() if cd (e.g: can't cd /root)


Index: ksh.kshrc
===================================================================
RCS file: /cvs/src/etc/ksh.kshrc,v
retrieving revision 1.19
diff -u -p -r1.19 ksh.kshrc
--- ksh.kshrc   11 Jul 2014 21:12:39 -0000      1.19
+++ ksh.kshrc   25 Oct 2014 16:32:36 -0000
@@ -82,14 +82,19 @@ case "$-" in
        xterm*)
                ILS='\033]1;'; ILE='\007'
                WLS='\033]2;'; WLE='\007'
-               parent="`ps -ax 2>/dev/null | grep $PPID | grep -v grep`"
-               case "$parent" in
-               *telnet*)
-               export TERM=xterms;;
-               esac
-               ;;
        *)      ;;
        esac
+
+       #[[ -o restricted ]] & $-r not set until after
+       # processing of shell init files. The best we can do:
+       # TODO: find a better way to test for restrictions on /bin/{k}sh
+       [[ ${SHELL} == '/bin/rksh' ]] &&
+       {
+               # Restricted shells can't cd, nor redirect output
+               print -n "${WLS}$USER@$HOST ($tty) ~${WLE}" > /dev/tty
+               unset ILS ILE WLS WLE
+       }
+
        # do we want window decorations?
        if [ "$ILS" ]; then
                function ilabel { print -n "${ILS}$*${ILE}">/dev/tty; }
@@ -103,7 +108,7 @@ case "$-" in
 
                function wftp { ilabel "ftp $*"; "ftp" "$@"; _ignore eval 
istripe; }
 
-               function wcd     { \cd "$@";     _ignore eval stripe; }
+               function wcd     { \cd "$@" &&   _ignore eval stripe; }
 
                function wssh    { \ssh "$@";    _ignore eval 'istripe; 
stripe'; }
                function wtelnet { \telnet "$@"; _ignore eval 'istripe; 
stripe'; }

Reply via email to