Re: User Privileges
Re: User Privileges
- Subject: Re: User Privileges
- From: Ron Hunsinger <email@hidden>
- Date: Fri, 06 Jan 2012 15:51:23 -0800
On Jan 6, 2012, at 7:05 AM, Luther Fuller wrote:
> User "B" is logged in and, via an AppleScript, wants to get the privileges assigned to him by user "A".
If all "B" wants to do is see whether he has specific privileges, it might be simpler to just test for those specific privileges. Let the underlying security system do all the parsing of ACLs and what-not, and just give you the answer(s) to your specific question(s).
set fyl to ... -- Posix path of the file of interest
set whatIcanDo to do shell script "fyl=" & quoted form of fyl & "; perms=''; for att in d f r w x; do if [ -$att \"$fyl\" ]; then perms=$perms$att; fi; done; echo $perms"
In the example, the "specific questions" are "d f r w x" (is it a directory, is it a file, can I read it, can I write it, can I execute it). Check the man page for the test command (man test) to see what questions you can ask. The result is a string containing the questions for which the answer is yes. For example, a file you have read/write access to might return "frw" (file+read+write), and user "A"'s Drop Box folder might return "dwx" (directory+write+execute). A non-existent file would return an empty string.
-Ron Hunsinger _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden