* src/sulogin.c: Ignore return value of setlocale(),
bindtextdomain(), and textdomain(). * src/sulogin.c: Avoid implicit conversion of pointers / integers / chars to booleans. * src/sulogin.c: Avoid assignments in comparisons. * src/sulogin.c: Ignore the return value of alarm().
This commit is contained in:
parent
46ce06791a
commit
3cbda4157b
@ -1,3 +1,12 @@
|
|||||||
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/sulogin.c: Ignore return value of setlocale(),
|
||||||
|
bindtextdomain(), and textdomain().
|
||||||
|
* src/sulogin.c: Avoid implicit conversion of pointers / integers
|
||||||
|
/ chars to booleans.
|
||||||
|
* src/sulogin.c: Avoid assignments in comparisons.
|
||||||
|
* src/sulogin.c: Ignore the return value of alarm().
|
||||||
|
|
||||||
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/groups.c: Use a bool when possible instead of int integers.
|
* src/groups.c: Use a bool when possible instead of int integers.
|
||||||
|
@ -99,9 +99,9 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
tcsetattr (0, TCSANOW, &termio);
|
tcsetattr (0, TCSANOW, &termio);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
#ifdef USE_SYSLOG
|
#ifdef USE_SYSLOG
|
||||||
OPENLOG ("sulogin");
|
OPENLOG ("sulogin");
|
||||||
@ -140,7 +140,7 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!isatty (0) || !isatty (1) || !isatty (2)) {
|
if ((isatty (0) == 0) || (isatty (1) == 0) || (isatty (2) == 0)) {
|
||||||
#ifdef USE_SYSLOG
|
#ifdef USE_SYSLOG
|
||||||
closelog ();
|
closelog ();
|
||||||
#endif
|
#endif
|
||||||
@ -149,18 +149,25 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
/* If we were init, we need to start a new session */
|
/* If we were init, we need to start a new session */
|
||||||
if (getppid() == 1) {
|
if (getppid() == 1) {
|
||||||
setsid();
|
setsid();
|
||||||
if (ioctl(0, TIOCSCTTY, 1))
|
if (ioctl(0, TIOCSCTTY, 1) != 0) {
|
||||||
fputs (_("TIOCSCTTY failed"), stderr);
|
fputs (_("TIOCSCTTY failed"), stderr);
|
||||||
}
|
}
|
||||||
while (*envp) /* add inherited environment, */
|
}
|
||||||
addenv (*envp++, NULL); /* some variables change later */
|
while (NULL != *envp) { /* add inherited environment, */
|
||||||
|
addenv (*envp, NULL); /* some variables change later */
|
||||||
|
envp++;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef USE_PAM
|
#ifndef USE_PAM
|
||||||
|
|
||||||
if ((cp = getdef_str ("ENV_TZ")))
|
cp = getdef_str ("ENV_TZ");
|
||||||
addenv (*cp == '/' ? tz (cp) : cp, NULL);
|
if (NULL != cp) {
|
||||||
if ((cp = getdef_str ("ENV_HZ")))
|
addenv (('/' == *cp) ? tz (cp) : cp, NULL);
|
||||||
|
}
|
||||||
|
cp = getdef_str ("ENV_HZ");
|
||||||
|
if (NULL != cp) {
|
||||||
addenv (cp, NULL); /* set the default $HZ, if one */
|
addenv (cp, NULL); /* set the default $HZ, if one */
|
||||||
|
}
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
|
|
||||||
(void) strcpy (name, "root"); /* KLUDGE!!! */
|
(void) strcpy (name, "root"); /* KLUDGE!!! */
|
||||||
@ -168,7 +175,7 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
signal (SIGALRM, catch_signals); /* exit if the timer expires */
|
signal (SIGALRM, catch_signals); /* exit if the timer expires */
|
||||||
alarm (ALARM); /* only wait so long ... */
|
alarm (ALARM); /* only wait so long ... */
|
||||||
|
|
||||||
while (1) { /* repeatedly get login/password pairs */
|
while (true) { /* repeatedly get login/password pairs */
|
||||||
pw_entry (name, &pwent); /* get entry from password file */
|
pw_entry (name, &pwent); /* get entry from password file */
|
||||||
if (pwent.pw_name == (char *) 0) {
|
if (pwent.pw_name == (char *) 0) {
|
||||||
/*
|
/*
|
||||||
@ -198,7 +205,7 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
* it will work with standard getpass() (no NULL on EOF).
|
* it will work with standard getpass() (no NULL on EOF).
|
||||||
* --marekm
|
* --marekm
|
||||||
*/
|
*/
|
||||||
if (!cp || !*cp) {
|
if ((NULL == cp) || ('\0' == *cp)) {
|
||||||
#ifdef USE_SYSLOG
|
#ifdef USE_SYSLOG
|
||||||
SYSLOG (LOG_INFO, "Normal startup\n");
|
SYSLOG (LOG_INFO, "Normal startup\n");
|
||||||
closelog ();
|
closelog ();
|
||||||
@ -222,7 +229,7 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
puts (_("Login incorrect"));
|
puts (_("Login incorrect"));
|
||||||
}
|
}
|
||||||
strzero (pass);
|
strzero (pass);
|
||||||
alarm (0);
|
(void) alarm (0);
|
||||||
signal (SIGALRM, SIG_DFL);
|
signal (SIGALRM, SIG_DFL);
|
||||||
environ = newenvp; /* make new environment active */
|
environ = newenvp; /* make new environment active */
|
||||||
|
|
||||||
@ -236,6 +243,7 @@ static RETSIGTYPE catch_signals (unused int sig)
|
|||||||
#endif
|
#endif
|
||||||
/* exec the shell finally. */
|
/* exec the shell finally. */
|
||||||
err = shell (pwent.pw_shell, (char *) 0, environ);
|
err = shell (pwent.pw_shell, (char *) 0, environ);
|
||||||
exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
exit ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
||||||
/*NOTREACHED*/ return (0);
|
/*NOTREACHED*/ return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user