exec after seteuid

Corinna Vinschen cygwin-patches@cygwin.com
Mon Jun 9 14:51:00 GMT 2003

On Mon, Jun 09, 2003 at 09:34:49AM -0400, Pierre A. Humblet wrote:
> Corinna Vinschen wrote:
> > I'm wondering why a shell should use setuid at all.  It's not the
> > task of the shell to do this, it's supposed under the environment
> > it gets.  So this is entirely the task of the processes which
> > eventually start a shell (login, rshd, sshd, etc.)
> I agree 100%. If you look in bash code there is some explanation,
> involving a "privileged mode" (undocumented?). I don't recall the 
> details.

I had a look into tcsh and it turns out that it refuses to run in
interactive mode if euid != ruid.  It doesn't call any setuid(), it
just prints a message to stderr and exits.  No comment in the code

> > Which is not related to using the wrong token.  I've written something
> > on the cygwin ML.
> Are you running with gid 544 by any chance?

Argh, yes.

> What I saw in login.exe while stracing my patch was
> setegid(513)
> seteuid(new user) <= uses token from login with password
> seteuid(18)       <= creates a new token, discards token from login
> seteuid(new user) <= creates new token.
> If the first setegid was a 544, the seteuid(18) would reuse the process
> token and the final seteuid() would use the token from the login with 
> passwd.

Oh boy :-(  So I have to upload another version of login which drops the
call to setegid() entirely.  Switching back to uid 18 the just reverts
to self and the last call to setgid/setuid uses the logon token.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

More information about the Cygwin-patches mailing list