From: Pádraig Brady Date: Sat, 25 Apr 2015 20:49:43 +0000 (+0100) Subject: file-has-acl: always return false when ACLs aren't supported X-Git-Tag: v1.0~7086 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=496c2cf0347839dc189891d7f158fcdd7f5c2e7c;p=gnulib.git file-has-acl: always return false when ACLs aren't supported * lib/file-has-acl.c (file_has_acl): Consistent with other paths, change the GNU/Linux getxattr path, to transform "not supported" errors to a false return rather than an error. This is handled within file_has_acl() due to the platform specific tests to determine if ACLs are not supported. --- diff --git a/ChangeLog b/ChangeLog index ec5cd549ba..eb1110be8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-04-26 Pádraig Brady + + file-has-acl: always return false when ACLs aren't supported + * lib/file-has-acl.c (file_has_acl): Consistent with other paths, + change the GNU/Linux getxattr path, to transform "not supported" + errors to a false return rather than an error. This is handled + within file_has_acl() due to the platform specific tests to + determine if ACLs are not supported. + 2015-04-25 Paul Eggert gettext: propagate po/Makefile.in.in too diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 5dfe9a8510..d2b6a146fa 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -37,10 +37,12 @@ # include #endif -/* Return 1 if NAME has a nontrivial access control list, 0 if NAME - only has no or a base access control list, and -1 (setting errno) - on error. SB must be set to the stat buffer of NAME, obtained - through stat() or lstat(). */ +/* Return 1 if NAME has a nontrivial access control list, + 0 if ACLs are not supported, or if NAME has no or only a base ACL, + and -1 (setting errno) on error. Note callers can determine + if ACLs are not supported as errno is set in that case also. + SB must be set to the stat buffer of NAME, + obtained through stat() or lstat(). */ int file_has_acl (char const *name, struct stat const *sb) @@ -54,25 +56,23 @@ file_has_acl (char const *name, struct stat const *sb) ssize_t ret; ret = getxattr (name, XATTR_NAME_POSIX_ACL_ACCESS, NULL, 0); - if (ret < 0) - { - if (errno != ENODATA) - return -1; - } + if (ret < 0 && errno == ENODATA) + ret = 0; else if (ret > 0) - return 1; - if (S_ISDIR (sb->st_mode)) - { - ret = getxattr (name, XATTR_NAME_POSIX_ACL_DEFAULT, NULL, 0); - if (ret < 0) - { - if (errno != ENODATA) - return -1; - } - else if (ret > 0) - return 1; - } - return 0; + return 1; + + if (ret == 0 && S_ISDIR (sb->st_mode)) + { + ret = getxattr (name, XATTR_NAME_POSIX_ACL_DEFAULT, NULL, 0); + if (ret < 0 && errno == ENODATA) + ret = 0; + else if (ret > 0) + return 1; + } + + if (ret < 0) + return - acl_errno_valid (errno); + return ret; # elif HAVE_ACL_GET_FILE