From: Karel Zak Date: Tue, 8 Jan 2013 12:13:40 +0000 (+0100) Subject: swapon: print warning about insecure owner/permissions X-Git-Tag: v2.23-rc1~382 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd04b26bf86d9987554aae02620d8f8172c66e16;p=thirdparty%2Futil-linux.git swapon: print warning about insecure owner/permissions 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 --- diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index 176be426e1..29f7a905d9 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -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)) {