running perl script as sudo
running perl script as sudo
- Subject: running perl script as sudo
- From: Cory Forsyth <email@hidden>
- Date: Sat, 15 Nov 2003 15:12:19 -0500
Hi,
I'm trying to make a Cocoa Wrapper of a perl script that needs to be
run with root privileges. I found some examples of how to use Apple's
Security framework and was able to successfully authenticate and run a
command with root privileges (the command was "touch /etc/xxx.xxx"),
though I'm frankly still mystified by the authentication system.
And I also figured out how to use NSTask to run a perl script that was
bundled in the resources. (There are some small problems with this,
though, most notable being that it fails to set the locale...this
doesn't really seem to hinder the perl script from running correctly,
however, so I'm not as concerned. I've included the output at the end
of this message, though.)
But I can't figure out how to run a perl script as sudo. I tried
changing the pathname for the task to "sudo /usr/bin/perl", but no
luck. And I tried
using the command
AuthorizationExecuteWithPrivileges(authorizationRef,
"/usr/bin/perl",
0, args, NULL);
But, in addition to giving me the "locale" warnings, it also says:
"Insecure $ENV{PATH} while running setuid at
/Users/blah/authPerlTest/build/authTest.app/Contents/Resources/
perltest.pl line 5."
Anyone have any suggestions? A good example of what I'm trying to do
is Sendmail Enabler...it seems to just have a bunch of (shell) scripts
in its resources folder that it runs after authenticating the user.
cheers,
Cory
email: cforsyth [at] singingtree [dot] com
Here's the locale warnings;
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = (unset),
LANG = "en_US"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.