Commit | Line | Data |
---|---|---|
a9fdb55e | 1 | package Object::Remote::Connector::LocalSudo; |
2 | ||
3 | use Moo; | |
4 | ||
5 | extends 'Object::Remote::Connector::Local'; | |
6 | ||
7 | around _perl_command => sub { | |
8 | my ($orig, $self, $target_user) = @_; | |
9 | return 'sudo', '-u', $target_user, $self->$orig($target_user); | |
10 | }; | |
11 | ||
12 | push @Object::Remote::Connection::Guess, sub { | |
13 | for ($_[0]) { | |
14 | # username followed by @ | |
15 | if (defined and !ref and /^ ([^\@]*?) \@ $/x) { | |
16 | return __PACKAGE__->new->connect($1); | |
17 | } | |
18 | } | |
19 | return; | |
20 | }; | |
21 | ||
22 | 1; |