summaryrefslogtreecommitdiff
path: root/libacl
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2002-06-25 07:45:27 +0000
committerNathan Scott <nathans@sgi.com>2002-06-25 07:45:27 +0000
commit9f09cb39086002d9f5d3f69916e15809064a92df (patch)
treeb065a7ccf5d075014ed7cf7af94c320ee126df00 /libacl
parent3b2d7db59a5e41948b4bd87e281b2a7f8f7b500d (diff)
downloadacl-9f09cb39086002d9f5d3f69916e15809064a92df.tar.gz
patch from AndreasG - acl_get_file/acl_set_file have been made to follow
the draft standard to the letter. bump version.
Diffstat (limited to 'libacl')
-rw-r--r--libacl/Makefile2
-rw-r--r--libacl/acl_get_file.c17
-rw-r--r--libacl/acl_set_file.c16
3 files changed, 28 insertions, 7 deletions
diff --git a/libacl/Makefile b/libacl/Makefile
index 1d214be..a1df30e 100644
--- a/libacl/Makefile
+++ b/libacl/Makefile
@@ -37,7 +37,7 @@ include $(TOPDIR)/include/builddefs
LTLIBRARY = libacl.la
LTLIBS = -lattr
LT_CURRENT = 1
-LT_REVISION = 1
+LT_REVISION = 2
LT_AGE = 0
CFILES = $(POSIX_CFILES) $(LIBACL_CFILES) $(INTERNAL_CFILES)
diff --git a/libacl/acl_get_file.c b/libacl/acl_get_file.c
index 42f05ac..693ddf1 100644
--- a/libacl/acl_get_file.c
+++ b/libacl/acl_get_file.c
@@ -69,15 +69,20 @@ acl_get_file(const char *path_p, acl_type_t type)
acl_t acl = __acl_from_xattr(ext_acl_p, retval);
return acl;
} else if (retval == 0 || errno == ENOATTR) {
- if (type == ACL_TYPE_ACCESS) {
- struct stat st;
+ struct stat st;
- if (stat(path_p, &st) == 0)
- return acl_from_mode(st.st_mode);
- else
+ if (stat(path_p, &st) != 0)
+ return NULL;
+
+ if (type == ACL_TYPE_DEFAULT) {
+ if (S_ISDIR(st.st_mode))
+ return acl_init(0);
+ else {
+ errno = EACCES;
return NULL;
+ }
} else
- return acl_init(0);
+ return acl_from_mode(st.st_mode);
} else
return NULL;
}
diff --git a/libacl/acl_set_file.c b/libacl/acl_set_file.c
index 38d8a6d..5def084 100644
--- a/libacl/acl_set_file.c
+++ b/libacl/acl_set_file.c
@@ -19,6 +19,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <attr/xattr.h>
#include "libacl.h"
@@ -51,6 +53,20 @@ acl_set_file(const char *path_p, acl_type_t type, acl_t acl)
errno = EINVAL;
return -1;
}
+
+ if (type == ACL_TYPE_DEFAULT) {
+ struct stat st;
+
+ if (stat(path_p, &st) != 0)
+ return -1;
+
+ /* Only directories may have default ACLs. */
+ if (!S_ISDIR(st.st_mode)) {
+ errno = EACCES;
+ return -1;
+ }
+ }
+
ext_acl_p = __acl_to_xattr(acl_obj_p, &size);
if (!ext_acl_p)
return -1;