File libacl-make-sure-that-acl_from_text-always-sets-errno-when-it-fails.patch of Package acl
From: Andreas Gruenbacher <agruen@linbit.com>
Date: Wed, 23 Oct 2013 19:40:57 +0200
Subject: libacl: Make sure that acl_from_text() always sets errno when it fails
Git-repo: git://git.savannah.nongnu.org/acl.git
Git-commit: 3f079d4e0512c9a241fb23c56a0421441c83621e
References: bsc#945899
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.
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
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;
}