Blame SOURCES/0196-libmount-fix-uid-and-gid-translation.patch

dd89d8
From 791381a715bac0f2910101bf0d6cceac9e569452 Mon Sep 17 00:00:00 2001
dd89d8
From: Karel Zak <kzak@redhat.com>
dd89d8
Date: Mon, 12 Oct 2015 11:42:13 +0200
dd89d8
Subject: [PATCH 196/197] libmount: fix uid= and gid= translation
dd89d8
dd89d8
The current libmount version returns error when no able to convert
dd89d8
username/groupname to uid/git.
dd89d8
dd89d8
 # mount mount /dev/sda1 /mnt/test -o uid=ignore
dd89d8
 # mount: failed to parse mount options
dd89d8
dd89d8
This is regression, the original mount(8) has ignored possible unknown
dd89d8
user/group names and the option has been used unconverted (with the
dd89d8
original value). For example UDF kernel driver depends on this behavior
dd89d8
and "uid=ignore" (or "forgot") is a valid mount option.
dd89d8
dd89d8
Fixed version (unit test):
dd89d8
dd89d8
./test_mount_optstr  --fix uid=kzak,gid=forgot,aaa,bbb
dd89d8
optstr: uid=kzak,gid=forgot,aaa,bbb
dd89d8
fixed:  uid=1000,gid=forgot,aaa,bbb
dd89d8
dd89d8
Reported-By: Anthony DeRobertis <anthony@derobert.net>
dd89d8
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801527
dd89d8
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1747710
dd89d8
Upstream: http://github.com/karelzak/util-linux/commit/440a355a3d3934d99f7ef82adf02342e6f2f7983
dd89d8
Signed-off-by: Karel Zak <kzak@redhat.com>
dd89d8
---
dd89d8
 libmount/src/optstr.c | 25 ++++++++++++++-----------
dd89d8
 1 file changed, 14 insertions(+), 11 deletions(-)
dd89d8
dd89d8
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
dd89d8
index 7bd9bbdb5..63b98c754 100644
dd89d8
--- a/libmount/src/optstr.c
dd89d8
+++ b/libmount/src/optstr.c
dd89d8
@@ -962,7 +962,6 @@ static int set_uint_value(char **optstr, unsigned int num,
dd89d8
  */
dd89d8
 int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
 {
dd89d8
-	int rc = 0;
dd89d8
 	char *end;
dd89d8
 
dd89d8
 	if (!optstr || !*optstr || !value || !valsz)
dd89d8
@@ -974,10 +973,11 @@ int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
 
dd89d8
 	if (valsz == 7 && !strncmp(value, "useruid", 7) &&
dd89d8
 	    (*(value + 7) == ',' || !*(value + 7)))
dd89d8
-		rc = set_uint_value(optstr, getuid(), value, end, next);
dd89d8
+		return set_uint_value(optstr, getuid(), value, end, next);
dd89d8
 
dd89d8
 	else if (!isdigit(*value)) {
dd89d8
 		uid_t id;
dd89d8
+		int rc;
dd89d8
 		char *p = strndup(value, valsz);
dd89d8
 		if (!p)
dd89d8
 			return -ENOMEM;
dd89d8
@@ -985,16 +985,17 @@ int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
 		free(p);
dd89d8
 
dd89d8
 		if (!rc)
dd89d8
-			rc = set_uint_value(optstr, id, value, end, next);
dd89d8
+			return set_uint_value(optstr, id, value, end, next);
dd89d8
+	}
dd89d8
 
dd89d8
-	} else if (next) {
dd89d8
-		/* nothing */
dd89d8
+	if (next) {
dd89d8
+		/* no change, let's keep the original value */
dd89d8
 		*next = value + valsz;
dd89d8
 		if (**next == ',')
dd89d8
 			(*next)++;
dd89d8
 	}
dd89d8
 
dd89d8
-	return rc;
dd89d8
+	return 0;
dd89d8
 }
dd89d8
 
dd89d8
 /*
dd89d8
@@ -1009,7 +1010,6 @@ int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
  */
dd89d8
 int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
 {
dd89d8
-	int rc = 0;
dd89d8
 	char *end;
dd89d8
 
dd89d8
 	if (!optstr || !*optstr || !value || !valsz)
dd89d8
@@ -1021,9 +1021,10 @@ int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
 
dd89d8
 	if (valsz == 7 && !strncmp(value, "usergid", 7) &&
dd89d8
 	    (*(value + 7) == ',' || !*(value + 7)))
dd89d8
-		rc = set_uint_value(optstr, getgid(), value, end, next);
dd89d8
+		return set_uint_value(optstr, getgid(), value, end, next);
dd89d8
 
dd89d8
 	else if (!isdigit(*value)) {
dd89d8
+		int rc;
dd89d8
 		gid_t id;
dd89d8
 		char *p = strndup(value, valsz);
dd89d8
 		if (!p)
dd89d8
@@ -1032,15 +1033,17 @@ int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next)
dd89d8
 		free(p);
dd89d8
 
dd89d8
 		if (!rc)
dd89d8
-			rc = set_uint_value(optstr, id, value, end, next);
dd89d8
+			return set_uint_value(optstr, id, value, end, next);
dd89d8
+
dd89d8
+	}
dd89d8
 
dd89d8
-	} else if (next) {
dd89d8
+	if (next) {
dd89d8
 		/* nothing */
dd89d8
 		*next = value + valsz;
dd89d8
 		if (**next == ',')
dd89d8
 			(*next)++;
dd89d8
 	}
dd89d8
-	return rc;
dd89d8
+	return 0;
dd89d8
 }
dd89d8
 
dd89d8
 /*
dd89d8
-- 
dd89d8
2.25.2
dd89d8