diff options
author | Karel Zak | 2013-03-26 16:05:07 +0100 |
---|---|---|
committer | Karel Zak | 2013-03-26 16:05:07 +0100 |
commit | 17206c059dc2e42e7081079b76eafda68cc9a5b8 (patch) | |
tree | 45162a64d2e47f7b4488b5da5fd2e4d13eab8ed8 /libmount/src | |
parent | docs: add note about /var/lib/hwclock to TODO (diff) | |
download | kernel-qcow2-util-linux-17206c059dc2e42e7081079b76eafda68cc9a5b8.tar.gz kernel-qcow2-util-linux-17206c059dc2e42e7081079b76eafda68cc9a5b8.tar.xz kernel-qcow2-util-linux-17206c059dc2e42e7081079b76eafda68cc9a5b8.zip |
libmount: fix user-mount by root for mount.<type> helpers
Append options like "exec" "suid" and "dev" to mount.<type> helpers
command line if the options are in fstab. This is relevant for root
user who calls mount(8) for fstab entries with "user,exec" etc.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-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 00738b4b5..3b280ab9b 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -275,6 +275,28 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr) if (!*optstr) return -ENOMEM; + if (cxt->user_mountflags & MNT_MS_USER) { + /* + * This is unnecessary for real user-mounts as mount.<type> + * helpers have to always follow fstab rather than mount + * options on command line. + * + * But if you call mount.<type> as root then the helper follows + * command line. If there is (for example) "user,exec" in fstab + * then we have to manually append the "exec" back to the options + * string, bacause there is nothing like MS_EXEC (we have only + * MS_NOEXEC in mount flags and we don't care about the original + * mount string in libmount for VFS options). + */ + if (!(cxt->mountflags & MS_NOEXEC)) + mnt_optstr_append_option(optstr, "exec", NULL); + if (!(cxt->mountflags & MS_NOSUID)) + mnt_optstr_append_option(optstr, "suid", NULL); + if (!(cxt->mountflags & MS_NODEV)) + mnt_optstr_append_option(optstr, "dev", NULL); + } + + if (cxt->flags & MNT_FL_SAVED_USER) rc = mnt_optstr_set_option(optstr, "user", cxt->orig_user); if (rc) |