File 0008-libacl-Make-sure-that-acl_from_text-always-sets-errn.patch of Package acl

From 3f079d4e0512c9a241fb23c56a0421441c83621e Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruen@linbit.com>
Date: Wed, 23 Oct 2013 19:40:57 +0200
Subject: [PATCH 08/34] libacl: Make sure that acl_from_text() always sets
 errno when it fails

The getpwnam() and getgrnam() functions may or may not set errno when
they fail.  If they don't, set it to EINVAL so that errno is always set
when acl_from_text() fails.
---
 libacl/acl_from_text.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libacl/acl_from_text.c b/libacl/acl_from_text.c
index 1e05322..c08bd3b 100644
--- a/libacl/acl_from_text.c
+++ b/libacl/acl_from_text.c
@@ -152,11 +152,14 @@ get_uid(const char *token, uid_t *uid_p)
 
 	if (get_id(token, uid_p) == 0)
 		return 0;
+	errno = 0;
 	passwd = getpwnam(token);
 	if (passwd) {
 		*uid_p = passwd->pw_uid;
 		return 0;
 	}
+	if (errno == 0)
+		errno = EINVAL;
 	return -1;
 }
 
@@ -168,11 +171,14 @@ get_gid(const char *token, gid_t *gid_p)
 
 	if (get_id(token, (uid_t *)gid_p) == 0)
 		return 0;
+	errno = 0;
 	group = getgrnam(token);
 	if (group) {
 		*gid_p = group->gr_gid;
 		return 0;
 	}
+	if (errno == 0)
+		errno = EINVAL;
 	return -1;
 }
 
-- 
2.5.2
openSUSE Build Service is sponsored by