« Simplicity | Main | Feeling stressed »
February 28, 2007
Need to run as root?
Every now and then, I find myself in a locked down account on a restricted access box where I need to run something as root.
Say, for example, you were running BigBrother (why?) on AIX (why?) and you need to run bootinfo -r
. In this case the AIX partition is a NIM - so no sudo available....
What you need is a little C program:
main()
{
setuid(0);
seteuid(0);
setgid(0);
seteuid(0);
system("/usr/sbin/bootinfo -r");
}
Note the full pathname used in the system call and the lack of externally passed variables - we don't want to make too big a hole here...
Compile this (obviously not on the NIM because there is no installed compiler). Install it somewhere safe - so that root and bigbrother are the only users that can access it and then:
chown 0:0 filename
chmod a+rx filename
chmod ug+s filename
Of course, if you are more security concious, you should have checked the userid in the C program as well....
Posted by Ozguru at February 28, 2007 07:00 AM