login: style fixes

This commit is contained in:
Denis Vlasenko 2006-09-08 17:22:45 +00:00
parent dd93abeaff
commit 2e502914b0
4 changed files with 39 additions and 9 deletions

View File

@ -111,6 +111,14 @@ config CONFIG_LOGIN
Note that Busybox binary must be setuid root for this applet to Note that Busybox binary must be setuid root for this applet to
work properly. work properly.
config CONFIG_LOGIN_SCRIPTS
bool "Support for login scripts"
depends on CONFIG_LOGIN
default n
help
Enable this if you want login to execute $LOGIN_PRE_SUID_SCRIPT
just prior to swithching from root to logged-in user.
config CONFIG_FEATURE_SECURETTY config CONFIG_FEATURE_SECURETTY
bool "Support for /etc/securetty" bool "Support for /etc/securetty"
default y default y

View File

@ -15,6 +15,7 @@
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
@ -258,6 +259,27 @@ auth_ok:
chown ( full_tty, pw-> pw_uid, pw-> pw_gid ); chown ( full_tty, pw-> pw_uid, pw-> pw_gid );
chmod ( full_tty, 0600 ); chmod ( full_tty, 0600 );
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);
execvp(script, t_argv);
exit(1);
default: /* parent */
wait(NULL);
}
}
}
change_identity ( pw ); change_identity ( pw );
tmp = pw-> pw_shell; tmp = pw-> pw_shell;
if(!tmp || !*tmp) if(!tmp || !*tmp)