Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: root-owned script needs to "shell out" to bash as a non-privileged user. How?

by aitap (Deacon)
on Jan 16, 2013 at 19:05 UTC ( #1013638=note: print w/ replies, xml ) Need Help??


in reply to root-owned script needs to "shell out" to bash as a non-privileged user. How?

Where do you run your script on, so it doesn't have a tty, but can be run interactively?

A pure-perl approach to this problem looks like this:

if ((my $pid = fork) == 0) { $< = getpwnam "dbuser" || die "getpwnam: $!"; $( = getgrnam "dbuser" || die "getgrnam: $!"; exec "/bin/bash", "-i" or die "exec: $!"; } elsif ($pid > 0) { waitpid $pid, 0; } else { die "fork: $!"; }
Sorry if my advice was wrong.


Comment on Re: root-owned script needs to "shell out" to bash as a non-privileged user. How?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013638]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-09-16 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (157 votes), past polls