]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: fix compiler warning [-Wunused-result]
authorKarel Zak <kzak@redhat.com>
Mon, 22 Oct 2012 11:13:02 +0000 (13:13 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Oct 2012 11:13:02 +0000 (13:13 +0200)
It's probably unnecessary paranoia, but let's check if we're able to
restore the original IDs after ~/.hushlogin file check.

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

index f37718753f4ef10fc33d92abb4d1a4dc84a18818..53df1345ae668eb628c9183d3f340ecc91a7b5c5 100644 (file)
@@ -1031,13 +1031,17 @@ static int get_hushlogin_status(struct passwd *pwd)
                        gid_t egid = getegid();
 
                        sprintf(buf, "%s/%s", pwd->pw_dir, file);
-                       setregid(-1, pwd->pw_gid);
-                       setreuid(0, pwd->pw_uid);
-                       ok = effective_access(buf, O_RDONLY) == 0;
-                       setuid(0);      /* setreuid doesn't do it alone! */
-                       setreuid(ruid, 0);
-                       setregid(-1, egid);
 
+                       if (setregid(-1, pwd->pw_gid) == 0 &&
+                           setreuid(0, pwd->pw_uid) == 0)
+                               ok = effective_access(buf, O_RDONLY) == 0;
+
+                       if (setuid(0) != 0 ||
+                           setreuid(ruid, 0) != 0 ||
+                           setregid(-1, egid) != 0) {
+                               syslog(LOG_ALERT, _("hush login status: restore original IDs failed"));
+                               exit(EXIT_FAILURE);
+                       }
                        if (ok)
                                return 1;       /* enabled by user */
                }