Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

SHTTY



Hi.

I have a problem with a change made to zsh between beta6 and beta9.

zsh-2.6-beta6-hzoli4		ok
zsh-2.6-beta9			problem
zsh-2.6-beta10			problem
zsh-2.6-beta10-hzolipre10	problem

If I su to another user, e.g. root su:ing to news, then the zle
option is unset and TTY is "".

root # echo $TTY
/dev/ttyp4
root # su news
news $ echo $TTY

news $

The reason can be found in init.c where SHTTY is opened with this code:

    if (isatty(0))
        SHTTY = movefd(open(ttyname(0), O_RDWR));
    else
        SHTTY = movefd(open("/dev/tty", O_RDWR));

In 2.5.01 and zsh-2.6-beta6-hzoli4 the code was:

        SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty", O_RDWR));

There is a VERY BIG difference between the old "dup(0)" and the new
"open(ttyname(0), O_RDWR)" if the su:ed to user don't have permission
to open the tty. In that case SHTTY is set to -1 and then the interactive
part of zsh just falls apart.

Why was this change made?

I made this change and the expected behaviour was restored:
---->8-------->8-------->8-------->8-------->8-------->8-------->8----
*** init.c.dist	Sat Jul  1 00:06:20 1995
--- init.c	Thu Jul  6 00:27:34 1995
***************
*** 334,343 ****
--- 334,347 ----
      }
  
      /* Make sure the tty is opened read/write. */
+ #if 1 /* HoH */
+     SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty", O_RDWR));
+ #else
      if (isatty(0))
  	SHTTY = movefd(open(ttyname(0), O_RDWR));
      else
  	SHTTY = movefd(open("/dev/tty", O_RDWR));
+ #endif
  
      if (SHTTY != -1) {
  #if defined(JOB_CONTROL) && defined(TIOCSETD) && defined(NTTYDISC)
---->8-------->8-------->8-------->8-------->8-------->8-------->8----

-- 
 Goran Larsson              Phone: +46 13 299588  FAX: +46 13 299022
 Approve AB                        +46 589 12810       +46 589 16901
 hoh@xxxxxxxxxx
           I was an atheist, until I found out I was God.



Messages sorted by: Reverse Date, Date, Thread, Author