summaryrefslogtreecommitdiffstats
path: root/shlibs/mount/src/optstr.c
diff options
context:
space:
mode:
authorKarel Zak2011-02-23 00:21:54 +0100
committerKarel Zak2011-02-23 00:21:54 +0100
commitddfc6f28a73afc823bb7ab5466a840d9fd5c5ad2 (patch)
tree7f7209a219b09075b884ede2cfa390b932c4f3f8 /shlibs/mount/src/optstr.c
parentlibmount: don't export functions for vfs/fs/userspace mount options (diff)
downloadkernel-qcow2-util-linux-ddfc6f28a73afc823bb7ab5466a840d9fd5c5ad2.tar.gz
kernel-qcow2-util-linux-ddfc6f28a73afc823bb7ab5466a840d9fd5c5ad2.tar.xz
kernel-qcow2-util-linux-ddfc6f28a73afc823bb7ab5466a840d9fd5c5ad2.zip
libmount: better "user" evaluation
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/optstr.c')
-rw-r--r--shlibs/mount/src/optstr.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c
index fd4a8610c..92abcdb1a 100644
--- a/shlibs/mount/src/optstr.c
+++ b/shlibs/mount/src/optstr.c
@@ -585,27 +585,49 @@ int mnt_optstr_get_options(const char *optstr, char **subset,
int mnt_optstr_get_flags(const char *optstr, unsigned long *flags,
const struct libmnt_optmap *map)
{
- struct libmnt_optmap const *maps[1];
+ struct libmnt_optmap const *maps[2];
char *name, *str = (char *) optstr;
size_t namesz = 0;
+ int nmaps = 0;
assert(optstr);
if (!optstr || !flags || !map)
return -EINVAL;
- maps[0] = map;
+ maps[nmaps++] = map;
+
+ if (map == mnt_get_builtin_optmap(MNT_LINUX_MAP))
+ /*
+ * Add userspace map -- the "user" is interpreted as
+ * MS_NO{EXEC,SUID,DEV}.
+ */
+ maps[nmaps++] = mnt_get_builtin_optmap(MNT_USERSPACE_MAP);
while(!mnt_optstr_next_option(&str, &name, &namesz, NULL, NULL)) {
const struct libmnt_optmap *ent;
+ const struct libmnt_optmap *m;
- if (mnt_optmap_get_entry(maps, 1, name, namesz, &ent)) {
- if (!ent->id)
- continue;
+ m = mnt_optmap_get_entry(maps, nmaps, name, namesz, &ent);
+ if (!m || !ent || !ent->id)
+ continue;
+
+ if (m == map) { /* requested map */
if (ent->mask & MNT_INVERT)
*flags &= ~ent->id;
else
*flags |= ent->id;
+
+ } else if (nmaps == 2 && m == maps[1]) {
+ /*
+ * Special case -- translate "user" to MS_ options
+ */
+ if (ent->mask & MNT_INVERT)
+ continue;
+ if (ent->id & (MNT_MS_OWNER | MNT_MS_GROUP))
+ *flags |= MS_OWNERSECURE;
+ else if (ent->id & (MNT_MS_USER | MNT_MS_USERS))
+ *flags |= MS_SECURE;
}
}