summaryrefslogtreecommitdiffstats
path: root/mount/swapon.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:48 +0100
committerKarel Zak2006-12-07 00:25:48 +0100
commit364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed (patch)
treec60dfad813ca42bf619fe2ac8ce893d2331e508f /mount/swapon.c
parentImported from util-linux-2.11b tarball. (diff)
downloadkernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.tar.gz
kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.tar.xz
kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.zip
Imported from util-linux-2.11f tarball.
Diffstat (limited to 'mount/swapon.c')
-rw-r--r--mount/swapon.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/mount/swapon.c b/mount/swapon.c
index 829acadd4..b87a021ae 100644
--- a/mount/swapon.c
+++ b/mount/swapon.c
@@ -90,15 +90,22 @@ swap (const char *special, int prio)
if (streq (program_name, "swapon")) {
if (stat(special, &st) < 0) {
int errsv = errno;
- fprintf (stderr, _("swapon: cannot stat %s: %s\n"), special, strerror (errsv));
+ fprintf (stderr, _("swapon: cannot stat %s: %s\n"),
+ special, strerror (errsv));
return -1;
}
/* people generally dislike this warning - now it is printed
only when `verbose' is set */
- if (verbose && (st.st_mode & 07077) != 0) {
- fprintf(stderr, _("swapon: warning: %s has insecure permissions %04o, "
- "0600 suggested\n"), special, st.st_mode & 07777);
+ if (verbose) {
+ int permMask = (S_ISBLK(st.st_mode) ? 07007 : 07077);
+
+ if ((st.st_mode & permMask) != 0) {
+ fprintf(stderr,
+ _("swapon: warning: %s has insecure permissions %04o, "
+ "%04o suggested\n"),
+ special, st.st_mode & 07777, ~permMask & 0666);
+ }
}
/* test for holes by LBT */