fixed self-test

This commit is contained in:
Roland Gruber 2004-03-11 21:02:55 +00:00
parent 4e9fd1c9ff
commit 13e9b1ec8e
1 changed files with 14 additions and 14 deletions

View File

@ -71,11 +71,10 @@ if ($( == 0 ) { # we are root
if ($ARGV[0] eq "*test") { if ($ARGV[0] eq "*test") {
use Quota; # Needed to get and set quotas use Quota; # Needed to get and set quotas
print "Perl quota module successfully installed.\n"; print "Perl quota module successfully installed.\n";
print "IF you haven't seen any errors lamdaemon.pl was set up successfully.\n"; print "If you haven't seen any errors lamdaemon.pl was set up successfully.\n";
} }
else { else {
# loop for every transmitted user # loop for every transmitted user
# XXX fixme change code to read stdin at once and then loop
my $string = do {local $/;<STDIN>}; my $string = do {local $/;<STDIN>};
@input = split ("\n", $string ); @input = split ("\n", $string );
for ($i=0; $i<=$#input; $i++) { for ($i=0; $i<=$#input; $i++) {
@ -198,21 +197,22 @@ else {
@username = split (',', $ARGV[0]); @username = split (',', $ARGV[0]);
$username[0] =~ s/uid=//; $username[0] =~ s/uid=//;
$password = $ARGV[1]; $password = $ARGV[1];
# Put all transfered lines in one string
if ($ARGV[2] ne "*test") {
$string = do {local $/;<STDIN>};
}
else { $argv = "*test\n"; }
my $ssh = Net::SSH::Perl->new($hostname, options=>[ my $ssh = Net::SSH::Perl->new($hostname, options=>[
"UserKnownHostsFile /dev/null"], "UserKnownHostsFile /dev/null"],
protocol => "2,1" ); protocol => "2,1" );
$ssh->login($username[0], $password); $ssh->login($username[0], $password);
# Change needed to prevent buffer overrun # Put all transfered lines in one string
@string2 = split ("\n", $string); if ($ARGV[2] ne "*test") {
for ($i=0; $i<=$#string2; $i++) { $string = do {local $/;<STDIN>};
($stdout2, $stderr, $exit) = $ssh->cmd("sudo $remotepath $argv", $string2[$i]); @string2 = split ("\n", $string);
$stdout .= $stdout2; for ($i=0; $i<=$#string2; $i++) {
($stdout2, $stderr, $exit) = $ssh->cmd("sudo $remotepath $argv", $string2[$i]);
$stdout .= $stdout2;
} }
#($stdout, $stderr, $exit) = $ssh->cmd("sudo $remotepath $argv", $string); print $stdout;
print $stdout;
} }
else {
($stdout, $stderr, $exit) = $ssh->cmd("sudo $remotepath *test");
print $stdout;
}
}