Re: Privileged shutdown
Re: Privileged shutdown
- Subject: Re: Privileged shutdown
- From: Axel Luttgens <email@hidden>
- Date: Sat, 24 Jul 2004 15:46:42 +0200
Bernard Azancot wrote:
This shutdown dialog snippet is OK when the user is the administrator,
but not with another user.
When I replace the administrator password by the other user one,
nothing happens (the shudown does not occur).
--
if button returned of result is "OK" then
do shell script "/sbin/shutdown -h now" password
"xxxx" with administrator privileges
end if
--
Well, there are two facets here.
First,
do shell script "<some command>" with administrator privileges
in fact results in executing:
sudo <some command>
By default, only users in the 'admin' group are allowed to do a 'sudo'.
And by default, a 'sudo' performed by those users will execute <some
command> as user 'root'.
So, yes, the current user (the one who is logged in and executing the
script) as to be an administrator.
Second, shutdown is a shell command that must be run by user 'root'.
So, for the same reasons as above, the current user must be an
administrator.
Any suggestion ?
You could change the defaults for 'sudo' by modifying the sudoers file.
See the man pages for visudo(8) and sudo(8).
For example, this could be done so as to allow some users,
authenticating as themselves, to execute "/sbin/shutdown -h now" as root.
But you could first have a look at System Events' dictionary, especially
its 'shut down' command.
This one should be executable by any user (as if the corresponding item
in the Apple menu was selected), and even without the "with
administrator privileges" part.
Would be nicer, if it works, than messing with sudoers or possibly
by-passing some system calls.
HTH,
Axel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.