Skip to content

Commit 8761175

Browse files
committed
disable sudo by default. --sudo option implemented for backwark compatibility
1 parent 274a1e6 commit 8761175

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

clinit

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ sub check_status
419419
$env->log(3, 'checking status of ' . $svc->host_id);
420420
if ($svc->status_command) {
421421
$env->job( sub {
422-
return $env->remote_exec($svc->host, $svc->status_command);
422+
return $env->remote_exec($svc->host, $svc->status_command, $svc);
423423
}, sub {
424424
my $exit_code = shift;
425425
if ($env->dry_run) {
@@ -547,7 +547,7 @@ sub go
547547
$svc->last_status($go->{trn_status});
548548
push(@{$svc->{wait_callbacks_}}, $callback);
549549
$env->job( sub {
550-
return $env->remote_exec($svc->host, $svc->{$cmd."_command_"});
550+
return $env->remote_exec($svc->host, $svc->{$cmd."_command_"}, $svc);
551551
}, sub {
552552
my $exit_code = shift;
553553
if ($exit_code != 0) {
@@ -845,6 +845,7 @@ sub new
845845
probe_delay => 3,
846846
colors => ($term =~ m/^(xterm|screen|cygwin|rxvt)/ ? 1 : 0),
847847
no_remote => [""],
848+
sudo => 0,
848849
help => 0,
849850
};
850851

@@ -866,6 +867,7 @@ sub new
866867
'probe-delay=i' => \$opt->{probe_delay},
867868
'jobs|j=i' => \$opt->{jobs},
868869
'colors!' => \$opt->{colors},
870+
'sudo|U' => \$opt->{sudo},
869871
'help|h' => \$opt->{help},
870872
);
871873
@{$opt->{no_remote}} = split (/ |,/, join(',', @{$opt->{no_remote}}));
@@ -940,7 +942,7 @@ sub new
940942
exit $env->result;
941943
}
942944

943-
if ($priveleged_command && defined($svcs->effective_user) && !$env->dry_run) {
945+
if ($priveleged_command && defined($svcs->effective_user) && !$env->dry_run && $opt->{sudo}) {
944946
my $effective_user = $svcs->effective_user;
945947
my @eui = getpwnam($effective_user);
946948
if (@eui == 0) {
@@ -1242,6 +1244,7 @@ sub remote_exec
12421244
my $env = shift;
12431245
my $host = shift;
12441246
my $command = shift;
1247+
my $svc = shift;
12451248

12461249
if ($env->no_remote($host)) {
12471250
my $res = $env->exec($command);
@@ -1251,7 +1254,12 @@ sub remote_exec
12511254

12521255
return $status;
12531256
}
1254-
my @args = ('/usr/bin/ssh', @{$env->{ssh_opt_}}, $host, $command);
1257+
my @ssh_opt = (@{$env->{ssh_opt_}});
1258+
1259+
if (defined($svc) && defined($svc->user)) {
1260+
push(@ssh_opt, '-l', $svc->user);
1261+
}
1262+
my @args = ('/usr/bin/ssh', @ssh_opt, $host, $command);
12551263
my $res = $env->exec(@args);
12561264
my $status = $res >> 8;
12571265

@@ -1636,6 +1644,10 @@ Sets probe count to N before probe procedure considered to be failed. Defaults t
16361644
16371645
Sets delay to N seconds between probe attempts. Default 3 sec.
16381646
1647+
=item B<-U --sudo>
1648+
1649+
Use sudo to effective user before executing ssh commands.
1650+
16391651
=item B<-n, --dry-run>
16401652
16411653
Do not execute commands

0 commit comments

Comments
 (0)