Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl setuid and fork

Status
Not open for further replies.

bdw238

MIS
Dec 15, 2005
52
0
0
GB
#!/usr/bin/perl -w

Can someone advise me please I am writing a script (run as root) that forks many child process's, which need to run as different user (ftppub).


I need the main code of script to stay as root, whereas the forked processes have a uid of ftppub. Can this been done?

Regards

Brian



e.g.


sub test {

my $pid;
unless ($pid = fork()) {
my ($login,$pass,$uid,$gid) = getpwname('ftppub');
$) = $gid;
$) = $gid;
$< = $uid;
$> = $uid;
print "E and R UID $< $>"; ## uid of ftppub
Do Something //
}
return $pid
}

for (my $i=0;$i<10;$i++) {
test();
print "E and R UID $< $>"; // Should show root ID.
}
exit 1;



}
 
Ignore, sent to wrong forum

Regards


Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top