bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Want to source ~/.bashrc when executed by kshd


From: Richard . Kandarian
Subject: Want to source ~/.bashrc when executed by kshd
Date: Tue, 14 Jan 2003 11:14:50 -0700 (MST)

Configuration Information [Automatically generated, do not change]:
Machine: mips
OS: irix6.5
Compiler: sgifwcompile -e -q -nostdinc -I. 
-I/xlv1/freeware/2002.Aug/bash/2.05a-root/usr/freeware/include 
-I/xlv1/freeware/2002.Aug/bash/2.05a-root/usr/include -O3 
-OPT:Olimit=0:space=ON -DEBUG:optimize_space=on  -TENV:X=1 -CG:unique_exit=on  
-OPT:IEEE_arithmetic=1:roundoff=0:wrap_around_unsafe_opt=off -n32 -mips3 
-nostdlib -L/xlv1/freeware/2002.Aug/bash/2.05a-root/usr/freeware/lib32  
-L/xlv1/freeware/2002.Aug/bash/2.05a-root/usr/lib32 -woff 
1009,1014,1107,1110,1116,1164,1185,1188,1204,1230,1233  -Wl,-woff,85,-woff,84 
-rpath /usr/freeware/lib32 -- 
/hosts/babylon.engr/usr/dist/new_toolroots/6.5/products/freeware/latest/ptoolroot/usr/bin/cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='mips' 
-DCONF_OSTYPE='irix6.5' -DCONF_MACHTYPE='mips-sgi-irix6.5' -DCONF_VENDOR='sgi' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib -g
uname output: IRIX64 sgirmk1 6.5 01091821 IP35
Machine Type: mips-sgi-irix6.5

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:
        bash advertizes that it tries to source ~/.bashrc when run by
        sshd or rshd. This ought to work as well for kshd (kerberos
        version of rshd), but it doesn't. The reason seems to be that
        kshd runs the shell on pipes instead of simply execing it with
        copies of stdin and stdout so isnetconn() in shell.c doesn't
        detect the network connection thus hidden. (Are there rshd's
        that do this too?) kshd sets some special environment variables
        and sets TERM=network so I used this to fix the problem.


Repeat-By:
        [Describe the sequence of events that causes the problem
        to occur.]

Fix:
--- shell.c.orig        Thu Nov  1 07:13:16 2001
+++ shell.c     Tue Jan 14 11:07:34 2003
@@ -922,7 +922,8 @@
 
       /* If we were run by sshd or we think we were run by rshd, execute
         ~/.bashrc if we are a top-level shell. */
-      if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)
+      if (shell_level < 2 && 
+         (run_by_ssh || isnetconn(fileno(stdin)) || runbykshd(fileno(stdin))))
        {
 #ifdef SYS_BASHRC
 #  if defined (__OPENNT)
@@ -1744,4 +1745,19 @@
 #    endif /* !S_ISSOCK || __BEOS__ */
 #  endif /* !SVR4 && !SVR4_2 */
 #endif /* !HAVE_GETPEERNAME || SVR4_2 || __BEOS__ */
+}
+static int
+runbykshd (fd)
+     int fd;
+{
+  struct stat st;
+  SHELL_VAR *term;
+
+  if( fstat(fd, &st) < 0) return (0);
+  if(!S_ISFIFO(st.st_mode)) return (0);
+  if(find_variable("KRB5LOCALADDR") != (SHELL_VAR *)NULL &&
+     find_variable("KRB5REMOTEADDR") != (SHELL_VAR *)NULL &&
+     (term = find_variable("TERM")) != (SHELL_VAR *)NULL &&
+     !strcmp(term->value, "network")) return 1;
+  return 0;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]