]> granicus.if.org Git - shadow/commitdiff
* src/sulogin.c: Ignore return value of setlocale(),
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 10 Jun 2008 19:36:05 +0000 (19:36 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 10 Jun 2008 19:36:05 +0000 (19:36 +0000)
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().

ChangeLog
src/sulogin.c

index 82c5c449e70b9fa5ef200f99b04c94ac0e40a3ba..6dea0654a70899a9fd5a4178ac55a3e6b5a07cab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/groups.c: Use a bool when possible instead of int integers.
index c628813da7b9ab7e432412ed1fb0a0ba914ad636..47720b3b0063a9eb8a76ed61f6bbee4f2f234cea 100644 (file)
@@ -99,9 +99,9 @@ static RETSIGTYPE catch_signals (unused int sig)
        tcsetattr (0, TCSANOW, &termio);
 #endif
 
-       setlocale (LC_ALL, "");
-       bindtextdomain (PACKAGE, LOCALEDIR);
-       textdomain (PACKAGE);
+       (void) setlocale (LC_ALL, "");
+       (void) bindtextdomain (PACKAGE, LOCALEDIR);
+       (void) textdomain (PACKAGE);
 
 #ifdef USE_SYSLOG
        OPENLOG ("sulogin");
@@ -140,7 +140,7 @@ static RETSIGTYPE catch_signals (unused int sig)
                exit (1);
        }
 #endif
-       if (!isatty (0) || !isatty (1) || !isatty (2)) {
+       if ((isatty (0) == 0) || (isatty (1) == 0) || (isatty (2) == 0)) {
 #ifdef USE_SYSLOG
                closelog ();
 #endif
@@ -149,18 +149,25 @@ static RETSIGTYPE catch_signals (unused int sig)
        /* If we were init, we need to start a new session */
        if (getppid() == 1) {
                setsid();
-               if (ioctl(0, TIOCSCTTY, 1))
+               if (ioctl(0, TIOCSCTTY, 1) != 0) {
                        fputs (_("TIOCSCTTY failed"), stderr);
+               }
+       }
+       while (NULL != *envp) {         /* add inherited environment, */
+               addenv (*envp, NULL);   /* some variables change later */
+               envp++;
        }
-       while (*envp)           /* add inherited environment, */
-               addenv (*envp++, NULL); /* some variables change later */
 
 #ifndef USE_PAM
 
-       if ((cp = getdef_str ("ENV_TZ")))
-               addenv (*cp == '/' ? tz (cp) : cp, NULL);
-       if ((cp = getdef_str ("ENV_HZ")))
+       cp = getdef_str ("ENV_TZ");
+       if (NULL != cp) {
+               addenv (('/' == *cp) ? tz (cp) : cp, NULL);
+       }
+       cp = getdef_str ("ENV_HZ");
+       if (NULL != cp) {
                addenv (cp, NULL);      /* set the default $HZ, if one */
+       }
 #endif                         /* !USE_PAM */
 
        (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 */
        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 */
                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). 
                 * --marekm
                 */
-               if (!cp || !*cp) {
+               if ((NULL == cp) || ('\0' == *cp)) {
 #ifdef USE_SYSLOG
                        SYSLOG (LOG_INFO, "Normal startup\n");
                        closelog ();
@@ -222,7 +229,7 @@ static RETSIGTYPE catch_signals (unused int sig)
                puts (_("Login incorrect"));
        }
        strzero (pass);
-       alarm (0);
+       (void) alarm (0);
        signal (SIGALRM, SIG_DFL);
        environ = newenvp;      /* make new environment active */
 
@@ -236,6 +243,7 @@ static RETSIGTYPE catch_signals (unused int sig)
 #endif
        /* exec the shell finally. */
        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);
 }
+