| IPC-ShellCmd documentation | Contained in the IPC-ShellCmd distribution. |
IPC::ShellCmd::Sudo - Chain sudo-ing to a different user before running the command
$cmd_obj->chain_prog(
IPC::ShellCmd::Sudo->new(
User => 'cpanbuild',
SetHome => 1,
)
);
The only external method for this is the constructor. This sets up the various arguments that are going to be used to generate the command-line.
Other methods on this are used by IPC::ShellCmd, but it should only ever be used inside of the chain_prog method on a IPC::ShellCmd object.
Specifies the username to sudo to
If true, this will cause sudo to set up $ENV{HOME} for the new user, otherwise it will be that of the current user.
I don't know of any, but that doesn't mean they're not there.
See IPC::ShellCmd for authors.
See IPC::ShellCmd for the license.
| IPC-ShellCmd documentation | Contained in the IPC-ShellCmd distribution. |
package IPC::ShellCmd::Sudo; use strict; use Carp qw(croak); use base qw(IPC::ShellCmd::ShBase);
sub chain { my $self = shift; my $cmd = shift; my $args = shift; my $cmd_string = $self->generate_sh_cmd($cmd, $args); my @sudo_args = ('sudo'); push (@sudo_args, "-u", $self->{args}->{User}) if(defined $self->{args}->{User}); push (@sudo_args, "-H") if(defined $self->{args}->{SetHome} && $self->{args}->{SetHome}); push (@sudo_args, "sh", "-c", $cmd_string); return @sudo_args; }
1;