Re: Root User
Re: Root User
- Subject: Re: Root User
- From: Ron Hunsinger <email@hidden>
- Date: Wed, 26 Mar 2014 14:40:03 -0700
On Mar 26, 2014, at 2:20 PM, Luther Fuller < email@hidden> wrote: I need to determine if the current user is 'root'. Perhaps I could use something as simple as ...
tell application "System Events" name of current user --> "root" end tell
But ... Can there be a root user with a name other than "root" ?
If so, then perhaps I should use this handler ...
on rootUser() tell application "System Events" to home directory of current user as alias tell application "Finder" to container of the result as alias as text return (the result ends with ":private:var:") end rootUser ---------------
Although it would be bizarre, the name of the root user can be changed to something other than 'root'. Once that's done, another user's name can be changed to 'root'. That is, you are correct that the name alone is not necessarily conclusive.
But checking the home directory is even less useful. Many users can share the same home directory. (They'd probably step on each other toes, but it's doable.)
The thing that definitively identifies the superuser is that it is the unique user whose numeric userid is zero. If you're paranoid, that's what you should check.
on rootUser() (do shell script "/usr/bin/id -u") = "0" end rootUser
-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
References: | |
| >Root User (From: Luther Fuller <email@hidden>) |