]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
swapon: print warning about insecure owner/permissions
authorKarel Zak <kzak@redhat.com>
Tue, 8 Jan 2013 12:13:40 +0000 (13:13 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 8 Jan 2013 12:15:52 +0000 (13:15 +0100)
Let's make it more obvious if swap area is accessible for non-root
users. The old version prints the warning only if --verbose is
specified.

Reported-by: mp.lists@free.fr
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/swapon.c

index 176be426e14e509b00ec32f3c02d024a30570786..29f7a905d9eabd7377909901133159dcfdb3e6b9 100644 (file)
@@ -440,26 +440,22 @@ static int swapon_checks(const char *special)
        char *hdr = NULL;
        unsigned int pagesize;
        unsigned long long devsize = 0;
+       int permMask;
 
        if (stat(special, &st) < 0) {
                warn(_("stat failed %s"), special);
                goto err;
        }
 
-       /* people generally dislike this warning - now it is printed
-          only when `verbose' is set */
-       if (verbose) {
-               int permMask = (S_ISBLK(st.st_mode) ? 07007 : 07077);
-
-               if ((st.st_mode & permMask) != 0)
-                       warnx(_("%s: insecure permissions %04o, %04o suggested."),
+       permMask = S_ISBLK(st.st_mode) ? 07007 : 07077;
+       if ((st.st_mode & permMask) != 0)
+               warnx(_("%s: insecure permissions %04o, %04o suggested."),
                                special, st.st_mode & 07777,
                                ~permMask & 0666);
 
-               if (S_ISREG(st.st_mode) && st.st_uid != 0)
-                       warnx(_("%s: insecure file owner %d, 0 (root) suggested."),
+       if (S_ISREG(st.st_mode) && st.st_uid != 0)
+               warnx(_("%s: insecure file owner %d, 0 (root) suggested."),
                                special, st.st_uid);
-       }
 
        /* test for holes by LBT */
        if (S_ISREG(st.st_mode)) {