From: Karel Zak Date: Fri, 13 Jan 2012 13:37:09 +0000 (+0100) Subject: libmount: allow to use UUID and LABEL for owner/group mount options in fstab X-Git-Tag: v2.21-rc1~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=be3df3838a0c95ae0f7c56ee41e4bb03a97a856d;p=thirdparty%2Futil-linux.git libmount: allow to use UUID and LABEL for owner/group mount options in fstab Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index 11b44f2ae5..594f090f45 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 d4c20f41d8..bb895425f6 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))) {