From 53091ecd20c294f0e0757a5f4e0d5c8c7b23b555 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 26 Mar 2007 13:35:09 +0000 Subject: Attempt to get more applets compile for NOMMU. TODO_config_nommu documents what I managed to compile so far (yay! msh works! cool). inetd, telnetd, httpd still do not compile. TODO Also make fork(), daemon() produce warnings on compile stage (in addition to erros on link stage). --- loginutils/login.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'loginutils') diff --git a/loginutils/login.c b/loginutils/login.c index 791e44d..3d8b8e5 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -337,25 +337,24 @@ auth_failed: fchown(0, pw->pw_uid, pw->pw_gid); fchmod(0, 0600); -/* TODO: be nommu-friendly, use spawn? */ if (ENABLE_LOGIN_SCRIPTS) { - char *script = getenv("LOGIN_PRE_SUID_SCRIPT"); - if (script) { - char *t_argv[2] = { script, NULL }; - switch (fork()) { - case -1: break; - case 0: /* child */ - xchdir("/"); - setenv("LOGIN_TTY", full_tty, 1); - setenv("LOGIN_USER", pw->pw_name, 1); - setenv("LOGIN_UID", utoa(pw->pw_uid), 1); - setenv("LOGIN_GID", utoa(pw->pw_gid), 1); - setenv("LOGIN_SHELL", pw->pw_shell, 1); - BB_EXECVP(script, t_argv); - exit(1); - default: /* parent */ - wait(NULL); - } + char *t_argv[2]; + + t_argv[0] = getenv("LOGIN_PRE_SUID_SCRIPT"); + if (t_argv[0]) { + t_argv[1] = NULL; + setenv("LOGIN_TTY", full_tty, 1); + setenv("LOGIN_USER", pw->pw_name, 1); + setenv("LOGIN_UID", utoa(pw->pw_uid), 1); + setenv("LOGIN_GID", utoa(pw->pw_gid), 1); + setenv("LOGIN_SHELL", pw->pw_shell, 1); + xspawn(argv); /* NOMMU-friendly */ + unsetenv("LOGIN_TTY"); + unsetenv("LOGIN_USER"); + unsetenv("LOGIN_UID"); + unsetenv("LOGIN_GID"); + unsetenv("LOGIN_SHELL"); + wait(NULL); } } -- cgit v1.1