Re: Directory ACL's?
Re: Directory ACL's?
- Subject: Re: Directory ACL's?
- From: Dominic Giampaolo <email@hidden>
- Date: Wed, 23 Aug 2006 11:24:01 -0700
What is the proper method for retrieving an ACL from a directory? I
tried using
acl_get_fd() which works fine on an open file descriptor, but if the
file descriptor points to a directory instead errno gets set to
ENOENT.
So I just tried the following tidbit of code and it
works fine for me under Tiger and Leopard for files
and directories. The code tries both acl_get_file()
and acl_get_fd(). Perhaps you're opening the fd of
the directory is different? I just pass O_RDONLY for
the flags.
--dominic
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/acl.h>
int
main(int argc, char **argv)
{
acl_t acl;
int fd, i;
for(i=1; i < argc; i++) {
acl = acl_get_file(argv[i], ACL_TYPE_EXTENDED);
if (acl == NULL) {
printf("acl_get_file(%s) failed (errno: %s)\n", argv[i],
strerror(errno));
} else {
printf("got the acl for %s (%p)\n", argv[i], acl);
acl_free(acl);
}
fd = open(argv[i], O_RDONLY);
if (fd < 0) {
printf("could not open the file %s (%s)\n", argv[i],
strerror(errno));
continue;
}
acl = acl_get_fd(fd);
if (acl == NULL) {
printf("acl_get_fd() for %s failed (errno: %s)\n", argv
[i], strerror(errno));
} else {
printf("got the acl through the fd for %s (%p)\n", argv
[i], acl);
acl_free(acl);
}
close(fd);
}
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden