diff options
author | Karel Zak | 2012-01-13 14:37:09 +0100 |
---|---|---|
committer | Karel Zak | 2012-01-13 14:37:09 +0100 |
commit | be3df3838a0c95ae0f7c56ee41e4bb03a97a856d (patch) | |
tree | b5f700b6e1f140ffdb47b1a52f73b8a79e97cd02 | |
parent | libmount: add functions to export syscall/helpers status (diff) | |
download | kernel-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>
-rw-r--r-- | libmount/src/context.c | 8 | ||||
-rw-r--r-- | libmount/src/context_mount.c | 24 |
2 files changed, 26 insertions, 6 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c index 11b44f2ae..594f090f4 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -1621,7 +1621,13 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt) * mnt_context_get_status: * @cxt: mount context * - * Returns: 1 if mount.type or mount(2) syscall was successful. + * Global libmount status. + * + * The real exit code of the mount.type helper has to be tested by + * mnt_context_get_helper_status(). The mnt_context_get_status() only inform + * that exec() has been sucessful. + * + * Returns: 1 if mount.type or mount(2) syscall has been succesfully called. */ int mnt_context_get_status(struct libmnt_context *cxt) { 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))) { |