]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: cleanup get_hushlogin_status() use
authorKarel Zak <kzak@redhat.com>
Tue, 16 Jun 2020 12:00:58 +0000 (14:00 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Jun 2020 12:00:58 +0000 (14:00 +0200)
* use 1 bit for context->quiet
* get_hushlogin_status() return -1 on error, make sure we do not
  interpret it as "hush mode enabled"

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index 026c023c920b9d757a451c3c6fa0c9164ee02bd1..3f940018480a06e851ab075debad48a2b59aeb7c 100644 (file)
@@ -134,9 +134,9 @@ struct login_context {
        char            hostaddress[16];        /* remote address */
 
        pid_t           pid;
-       int             quiet;          /* 1 if hush file exists */
 
-       unsigned int    remote:1,       /* login -h */
+       unsigned int    quiet:1,        /* hush file exists */
+                       remote:1,       /* login -h */
                        nohost:1,       /* login -H */
                        noauth:1,       /* login -f */
                        keep_env:1;     /* login -p */
@@ -1339,7 +1339,7 @@ int main(int argc, char **argv)
                sleepexit(EXIT_FAILURE);
        }
 
-       cxt.quiet = get_hushlogin_status(pwd, 1);
+       cxt.quiet = get_hushlogin_status(pwd, 1) == 1 ? 1 : 0;
 
        /*
         * Open PAM session (after successful authentication and account check).