On Fri, 30 Aug 1996, Alex Romosan wrote:

> the links were okay, the problem is elsewhere. if i telnet into the
> machine and log in as alex gawk works fine. what i usually do is to
> rlogin from an sgi to a different account and then su to alex. under
> these circumstances gawk fails with permission denied. i have no idea
> if this is a bug or not.

Ok, now it's clear.  The difference between those two methods is who
owns the controlling terminal.  When you su, the old user still owns
it, so the new one can't write directly to the tty.  And /dev/fd/2 is
implemented as a link to the tty:

lrwx------   1 gmaor    gmaor          64 Aug 30 19:38 /dev/fd/2 -> [0802]:556

That means device 8,2 inode 556.  8,2 is my root partition, and 556 is
ttyp4.

556 crw--w----   1 gmaor    tty        4, 196 Aug 30 19:39 ttyp4

So if I su to someone else, I still own ttyp4 and the new user can't
write to ttyp4.

As is apparent, I was wrong about /dev/stderr being implemented
internally by gawk, at least under linux.  Using strace and from the
above, it's pretty obvious that gawk really is opening /dev/stderr,  If
it were just writing to fd 2, it would work.

This is one case where using fd 2 is not the same as writing to
/dev/stderr.

The solution is to switch user id's by doing 'exec login'.  You'll
transfer the controlling terminal also then.


Guy

Reply via email to