diff options
author | Karel Zak | 2013-11-12 15:07:12 +0100 |
---|---|---|
committer | Karel Zak | 2013-11-12 15:07:12 +0100 |
commit | b8095d25bae0588dfce8a62169f6db5496cf45c5 (patch) | |
tree | 5ea737db64009a3b633fdadc76b3d88ce97a3025 /libmount/src/context_mount.c | |
parent | sulogin: use dirent->d_type when scans /dev (diff) | |
download | kernel-qcow2-util-linux-b8095d25bae0588dfce8a62169f6db5496cf45c5.tar.gz kernel-qcow2-util-linux-b8095d25bae0588dfce8a62169f6db5496cf45c5.tar.xz kernel-qcow2-util-linux-b8095d25bae0588dfce8a62169f6db5496cf45c5.zip |
libmount: remove smackfs* option when SMACK not enabled
If there is no /sys/fs/smackfs then libmount removes smackfs*= mount
options when compiled --with-smack.
Note that we do the same for SELinux.
References: http://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg13740.html
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_mount.c')
-rw-r--r-- | libmount/src/context_mount.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index ffea65354..da6ea9b7d 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -115,6 +115,10 @@ static int fix_optstr(struct libmnt_context *cxt) #ifdef HAVE_LIBSELINUX int se_fix = 0, se_rem = 0; #endif +#ifdef HAVE_SMACK + int sm_rem = 0; +#endif + assert(cxt); assert(cxt->fs); assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED)); @@ -206,6 +210,10 @@ static int fix_optstr(struct libmnt_context *cxt) mnt_optstr_deduplicate_option(&fs->fs_optstr, "seclabel"); } #endif +#ifdef HAVE_SMACK + if (access("sys/fs/smackfs", F_OK) != 0) + sm_rem = 1; +#endif while (!mnt_optstr_next_option(&next, &name, &namesz, &val, &valsz)) { if (namesz == 3 && !strncmp(name, "uid", 3)) @@ -232,6 +240,20 @@ static int fix_optstr(struct libmnt_context *cxt) val, valsz, &next); } #endif +#ifdef HAVE_SMACK + else if (sm_rem && namesz >= 10 + && (!strncmp(name, "smackfsdef", 10) || + !strncmp(name, "smackfsfloor", 12) || + !strncmp(name, "smackfshat", 10) || + !strncmp(name, "smackfsroot", 11) || + !strncmp(name, "smackfstransmute", 16))) { + + next = name; + rc = mnt_optstr_remove_option_at(&fs->fs_optstr, + name, + val ? val + valsz : name + namesz); + } +#endif if (rc) goto done; } |