Mercurial > hg > toybox
diff toys/other/login.c @ 1156:faf7117c4489 draft
Fix some issues raised (albeit indirectly) by Isaac Dunham.
POLL_IN defined as a constant by some libc.
Factor out login.c's change_identity() to xwrap.c as xsetuser().
Replace xsetuid() with xsetuser()
Put a space between argument globals and non-argument globals.
TT starts zeroed, don't need to re-zero entries in it.
STDIN_FILENO has been 0 since 1969, even DOS copied that. Just say 0.
Added an xchroot() using xchdir() to lib/xwrap.c.
Remove endgrent() call until somebody can explain why it was there.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 23 Dec 2013 06:49:38 -0600 |
parents | 0ed3351d91eb |
children | 667a65038e93 |
line wrap: on
line diff
--- a/toys/other/login.c Sun Dec 22 20:15:54 2013 -0600 +++ b/toys/other/login.c Mon Dec 23 06:49:38 2013 -0600 @@ -14,6 +14,7 @@ usage: login [-p] [-h host] [[-f] username] Establish a new session with the system. + -p Preserve environment -h The name of the remote host for this login -f Do not perform authentication @@ -109,15 +110,6 @@ fflush(stdout); } -int change_identity(const struct passwd *pwd) -{ - if (initgroups(pwd->pw_name,pwd->pw_gid)) return 1; - if (setgid(pwd->pw_uid)) return 1; - if (setuid(pwd->pw_uid)) return 1; - - return 0; -} - void spawn_shell(const char *shell) { const char * exec_name = strrchr(shell,'/'); @@ -214,7 +206,7 @@ if (pwd->pw_uid) handle_nologin(); - if (change_identity(pwd)) error_exit("Failed to change identity"); + xsetuser(pwd); setup_environment(pwd, !(toys.optflags & FLAG_p));