summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_mount.c
diff options
context:
space:
mode:
authorKarel Zak2012-01-13 14:37:09 +0100
committerKarel Zak2012-01-13 14:37:09 +0100
commitbe3df3838a0c95ae0f7c56ee41e4bb03a97a856d (patch)
treeb5f700b6e1f140ffdb47b1a52f73b8a79e97cd02 /libmount/src/context_mount.c
parentlibmount: add functions to export syscall/helpers status (diff)
downloadkernel-qcow2-util-linux-be3df3838a0c95ae0f7c56ee41e4bb03a97a856d.tar.gz
kernel-qcow2-util-linux-be3df3838a0c95ae0f7c56ee41e4bb03a97a856d.tar.xz
kernel-qcow2-util-linux-be3df3838a0c95ae0f7c56ee41e4bb03a97a856d.zip
libmount: allow to use UUID and LABEL for owner/group mount options in fstab
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_mount.c')
-rw-r--r--libmount/src/context_mount.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index d4c20f41d..bb895425f 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -171,7 +171,6 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
static int evaluate_permissions(struct libmnt_context *cxt)
{
unsigned long u_flags = 0;
- const char *srcpath;
assert(cxt);
assert(cxt->fs);
@@ -200,7 +199,7 @@ static int evaluate_permissions(struct libmnt_context *cxt)
*/
if (!(cxt->flags & MNT_FL_TAB_APPLIED))
{
- DBG(CXT, mnt_debug_h(cxt, "fstab not applied, ignore user mount"));
+ DBG(CXT, mnt_debug_h(cxt, "perms: fstab not applied, ignore user mount"));
return -EPERM;
}
@@ -209,9 +208,6 @@ static int evaluate_permissions(struct libmnt_context *cxt)
* are applied by mnt_optstr_get_flags() from mnt_context_merge_mflags()
*/
- srcpath = mnt_fs_get_srcpath(cxt->fs);
- if (!srcpath)
- return -EINVAL;
/*
* MS_OWNER: Allow owners to mount when fstab contains the
@@ -222,6 +218,21 @@ static int evaluate_permissions(struct libmnt_context *cxt)
*/
if (u_flags & (MNT_MS_OWNER | MNT_MS_GROUP)) {
struct stat sb;
+ struct libmnt_cache *cache = NULL;
+ char *xsrc = NULL;
+ const char *srcpath = mnt_fs_get_srcpath(cxt->fs);
+
+ if (!srcpath) { /* Ah... source is TAG */
+ cache = mnt_context_get_cache(cxt);
+ xsrc = mnt_resolve_spec(
+ mnt_context_get_source(cxt),
+ cache);
+ srcpath = xsrc;
+ }
+ if (!srcpath) {
+ DBG(CXT, mnt_debug_h(cxt, "perms: src undefined"));
+ return -EPERM;
+ }
if (strncmp(srcpath, "/dev/", 5) == 0 &&
stat(srcpath, &sb) == 0 &&
@@ -229,6 +240,9 @@ static int evaluate_permissions(struct libmnt_context *cxt)
((u_flags & MNT_MS_GROUP) && mnt_in_group(sb.st_gid))))
cxt->user_mountflags |= MNT_MS_USER;
+
+ if (!cache && xsrc)
+ free(xsrc);
}
if (!(cxt->user_mountflags & (MNT_MS_USER | MNT_MS_USERS))) {