c23f2e984e929a8c3ec33e97e3e684db7906d680
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / LocalSudo.pm
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;