aboutsummaryrefslogtreecommitdiff
path: root/toys/other/login.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/other/login.c')
-rw-r--r--toys/other/login.c12
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));