From: Robert 'phaylon' Sedlacek Date: Mon, 18 Jun 2012 23:01:38 +0000 (+0000) Subject: cope with optional user prefix to groups list X-Git-Tag: v0.001_001~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b728b79569dbede7f5ad5e9d7cd54d8b8363d863;p=scpubgit%2FSystem-Introspector.git cope with optional user prefix to groups list --- diff --git a/lib/System/Introspector/Probe/Users.pm b/lib/System/Introspector/Probe/Users.pm index 0b4047a..0327bb7 100644 --- a/lib/System/Introspector/Probe/Users.pm +++ b/lib/System/Introspector/Probe/Users.pm @@ -78,6 +78,7 @@ sub _gather_ssh_keys { sub _gather_user_groups { my ($self, $user) = @_; my $groups = output_from_command [groups => $user]; + $groups =~ s{^ \Q$user\E \s* : \s* }{}x; return [split m{\s+}, $groups]; } diff --git a/t/bin/groups b/t/bin/groups index 432a363..db8a7ab 100755 --- a/t/bin/groups +++ b/t/bin/groups @@ -1,4 +1,4 @@ #!/usr/bin/env perl use strictures 1; my $user = shift @ARGV; -printf "%s\n", join ' ', map { "${user}_group_${_}" } qw( A B C ); +printf "$user : %s\n", join ' ', map { "${user}_group_${_}" } qw( A B C );