There is always a possible hack. For instance you can:
open(my $shell, "|-", "sudo perl") or die "Can't pipe to bash: $!";
print $shell "$password\n";
sleep(1); # Make sure that Perl has started. This is likely unneeded.
print $shell $some_perl_script;
close($shell) or die $! ? "Error closing pipe: $!"
: "Exit status $? from perl child";
And now you can execute an arbitrary Perl script, as root, without installing anything. (Assuming that you have the password.) You can do the same thing over ssh.
Of course this is very much the wrong way to do it. Your root password is now available to anyone who can read the script. A much, much better approach is to find standard, more secure, ways to get a passwordless escalation. For instance locally use setuid. Remotely you can follow the advice at http://www.debian-administration.org/articles/152 and set up secure passwordless logins that use secure public keys. (If you're doing this from a shared box, you may want to set those up from some privileged account, and then have setuid scripts that can run as that account.) |