|No such thing as a small change|
root-owned script needs to "shell out" to bash as a non-privileged user. How?by mrfirmware (Initiate)
|on Jan 16, 2013 at 16:12 UTC||Need Help??|
mrfirmware has asked for the
wisdom of the Perl Monks concerning the following question:
I feel like I've read every search hit I've found so far and no one seems to need to shell out to a proper bash shell from within a Perl program.
We have a Perl program running with root privileges that presents the user with a friendly yet limited CLI. It allows them to do root-y things safely to operate the product.
This works for 95% of the operations that the user needs to do on our product. However, we sometimes need to do some database things as the database user account (regular user, not root). The list of things that users may wish to do as this user (account) are many and not worth trying to encapsulate with our Perl CLI.
So I'd like to change my UID/GID to the database user, e.g. 'dbuser:dbuser', and then system('/bin/bash -i'). When the user is done with this 'mode' they type exit and are returned to the Perl CLI. I can't use 'su' here because I get 'not a tty' errors. I'm also failing to get the $< and $( to work as I had hoped.
Is this possible? If so, how?