Re: C API for ACLs

2022-02-05 Thread raf
On Sat, Feb 05, 2022 at 11:05:11PM -0500, Andrew Udvare  
wrote:

> > On 2022-02-05, at 22:29, raf  wrote:
> > 
> > Hi,
> > 
> > Does anyone know how to get at macOS's ACLs from C?
> > I just need to access them in text form. I'm using
> > the "POSIX" ACL API, and it compiles and runs, but
> > it doesn't find anything. The ACL entries that I can
> > create with chmod +a, and view with ls -e, don't
> > show up because they're not "POSIX" ACL compatible
> > (or some similar sensible reason). Searching the net
> > has only turned up the "POSIX" ACL API so far.
> > 
> > cheers,
> > raf
> 
> Apple uses acl_get_link_np() with ACL_TYPE_EXTENDED as the acl_type_t 
> argument.
> 
> https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-321.100.11/ls/ls.c#L847

Thanks. I just found ACL_TYPE_EXTENDED. It also works with
acl_get_file(). The format is wierd but that's fine for my
purposes. It is what it is. Thanks again.

cheers,
raf



Re: C API for ACLs

2022-02-05 Thread Andrew Udvare


> On 2022-02-05, at 22:29, raf  wrote:
> 
> Hi,
> 
> Does anyone know how to get at macOS's ACLs from C?
> I just need to access them in text form. I'm using
> the "POSIX" ACL API, and it compiles and runs, but
> it doesn't find anything. The ACL entries that I can
> create with chmod +a, and view with ls -e, don't
> show up because they're not "POSIX" ACL compatible
> (or some similar sensible reason). Searching the net
> has only turned up the "POSIX" ACL API so far.
> 
> cheers,
> raf
> 

Apple uses acl_get_link_np() with ACL_TYPE_EXTENDED as the acl_type_t argument.

https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-321.100.11/ls/ls.c#L847

Re: C API for ACLs

2022-02-05 Thread Richard L. Hamilton
Use the source, Luke.

How "ls" does it:

https://github.com/apple-oss-distributions/file_cmds/tree/file_cmds-321.100.11/ls

Looks like the presence of an ACL and getting a handle for it is done in ls.c, 
and actually retrieving and printing all the entries (ls.c retrieves the 1st 
entry just to make sure it's really there) is done in print.c.

I gather that getattrlist(2) and setattrlist(2) are what, for the filesystems 
that support those calls (not all do!) underlie the various section 3 acl*() 
routines, but if in doubt, you could even look at the source for those library 
routines. But beware: acl(3) says:
 The syscalls between the internal interfaces and the public library 
routines may change over time, and as such are not documented.  They are not 
intended to be called directly without going through the library.

> On Feb 5, 2022, at 22:29, raf  wrote:
> 
> Hi,
> 
> Does anyone know how to get at macOS's ACLs from C?
> I just need to access them in text form. I'm using
> the "POSIX" ACL API, and it compiles and runs, but
> it doesn't find anything. The ACL entries that I can
> create with chmod +a, and view with ls -e, don't
> show up because they're not "POSIX" ACL compatible
> (or some similar sensible reason). Searching the net
> has only turned up the "POSIX" ACL API so far.
> 
> cheers,
> raf
> 

-- 
eMail:  mailto:rlha...@smart.net






smime.p7s
Description: S/MIME cryptographic signature


C API for ACLs

2022-02-05 Thread raf
Hi,

Does anyone know how to get at macOS's ACLs from C?
I just need to access them in text form. I'm using
the "POSIX" ACL API, and it compiles and runs, but
it doesn't find anything. The ACL entries that I can
create with chmod +a, and view with ls -e, don't
show up because they're not "POSIX" ACL compatible
(or some similar sensible reason). Searching the net
has only turned up the "POSIX" ACL API so far.

cheers,
raf