the penguin has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I'm trying to execute perl script from php code;some commands in the script need root user to be executed(connection to gsm) , i’m 'www' user (because of apache); can i su from my perl script? thank you in advance

Replies are listed 'Best First'.
Re: change user in perl
by Corion (Patriarch) on Feb 24, 2010 at 12:45 UTC

    The best approach to separating user privileges is to have one part running as a daemon, under the root user, and to send commands from the web part to the other part, for example by creating a file in a special directory or by connecting to a pipe or (domain) socket.

Re: change user in perl
by cdarke (Prior) on Feb 24, 2010 at 12:23 UTC
    Do you want to? Sounds a tad dangerous. The problem with su(1) is that it prompts for a password, you might try sudo(1) instead - but it takes a bit of setting up.

      ... and having www-data as a sudoer is dangerous, too. I would go with Corion's option.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."