#!/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;
}
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;
}