From: Karel Zak Date: Tue, 25 Jan 2011 00:11:37 +0000 (+0100) Subject: libmount: fix user= usage X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a669b12f84f85f7ace13712b20ce9592a08f157;p=util-linux libmount: fix user= usage Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/context.c b/shlibs/mount/src/context.c index ed9f223a..676552bf 100644 --- a/shlibs/mount/src/context.c +++ b/shlibs/mount/src/context.c @@ -1440,8 +1440,10 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt) } /* fstab is not required if source and target are specified */ - if (src && tgt && !(cxt->optsmode == MNT_OMODE_FORCE)) + if (src && tgt && !(cxt->optsmode & MNT_OMODE_FORCE)) { + DBG(CXT, mnt_debug_h(cxt, "fstab not required -- skip")); return 0; + } DBG(CXT, mnt_debug_h(cxt, "trying to apply fstab (src=%s, target=%s)", src, tgt)); diff --git a/shlibs/mount/src/context_mount.c b/shlibs/mount/src/context_mount.c index 0b6c3d86..8c764078 100644 --- a/shlibs/mount/src/context_mount.c +++ b/shlibs/mount/src/context_mount.c @@ -107,11 +107,11 @@ static int fix_optstr(struct libmnt_context *cxt) } if (!rc && cxt->user_mountflags && MNT_MS_USER) - rc = mnt_optstr_fix_user(&fs->fs_optstr); + rc = mnt_optstr_fix_user(&fs->user_optstr); done: DBG(CXT, mnt_debug_h(cxt, "fixed options [rc=%d]: " - "vfs='%s' fs='%s' user='%s'", rc, + "vfs: '%s' fs: '%s' user: '%s'", rc, fs->vfs_optstr, fs->fs_optstr, fs->user_optstr)); return rc; } diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c index 9c8aa62e..fd4a8610 100644 --- a/shlibs/mount/src/optstr.c +++ b/shlibs/mount/src/optstr.c @@ -945,12 +945,13 @@ int mnt_optstr_fix_user(char **optstr) if (!username) return -ENOMEM; - if (!ol.valsz || strncmp(ol.value, username, ol.valsz)) { + if (!ol.valsz || (ol.value && strncmp(ol.value, username, ol.valsz))) { if (ol.valsz) /* remove old value */ mnt_optstr_remove_option_at(optstr, ol.value, ol.end); - rc = insert_value(optstr, ol.value, username, NULL); + rc = insert_value(optstr, ol.value ? ol.value : ol.end, + username, NULL); } free(username);