summaryrefslogtreecommitdiffhomepage
path: root/loginutils/login.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-26 13:35:09 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-26 13:35:09 +0000
commit53091ecd20c294f0e0757a5f4e0d5c8c7b23b555 (patch)
treef4ae0be26d5debff091d2c976e77fa8050c6758c /loginutils/login.c
parentec1a4b5a521b5adf295bc757c25231910f8c854b (diff)
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).
Diffstat (limited to 'loginutils/login.c')
-rw-r--r--loginutils/login.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 791e44d83..3d8b8e540 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);
}
}