diff options
author | Rob Landley <rob@landley.net> | 2013-12-23 06:49:38 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-12-23 06:49:38 -0600 |
commit | afba5b8efdf1bac2c02ca787840a2be053c800f7 (patch) | |
tree | 1af5b850e90663fb3be71597d02cd525bf5be4e8 /toys/other/login.c | |
parent | 5a73f3992d75dd4c7beefae2fa8a843d14372b19 (diff) | |
download | toybox-afba5b8efdf1bac2c02ca787840a2be053c800f7.tar.gz |
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.
Diffstat (limited to 'toys/other/login.c')
-rw-r--r-- | toys/other/login.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/toys/other/login.c b/toys/other/login.c index 54190d0f..100c665a 100644 --- a/toys/other/login.c +++ b/toys/other/login.c @@ -14,6 +14,7 @@ config LOGIN 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 @@ void handle_motd(void) 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 @@ query_pass: 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)); |