From: Robert 'phaylon' Sedlacek Date: Mon, 11 Jun 2012 18:13:13 +0000 (+0000) Subject: return authorized_keys stub structure if the file doesn't exist instead of turning... X-Git-Tag: v0.001_001~52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82d8f33c8cbb7188f1975fac31e957328d84502c;p=scpubgit%2FSystem-Introspector.git return authorized_keys stub structure if the file doesn't exist instead of turning it into an error structure --- diff --git a/lib/System/Introspector/Probe/Users.pm b/lib/System/Introspector/Probe/Users.pm index 34886e6..1260120 100644 --- a/lib/System/Introspector/Probe/Users.pm +++ b/lib/System/Introspector/Probe/Users.pm @@ -51,9 +51,10 @@ sub _gather_crontab { sub _gather_ssh_keys { my ($self, $user, $home) = @_; my $ssh_dir = "$home/.ssh"; + my $ssh_authkeys = "$ssh_dir/authorized_keys"; return { files => {}, - authorized => { file_name => "$ssh_dir/authorized_keys", body => '' } + authorized => { file_name => $ssh_authkeys, body => '' } } unless -d $ssh_dir; my %key; for my $item (files_from_dir $ssh_dir) { @@ -65,12 +66,12 @@ sub _gather_ssh_keys { }; }; } - my $auth_keys = transform_exceptions { + my $auth_keys = (-e $ssh_authkeys) ? (transform_exceptions { return { - file_name => "$ssh_dir/authorized_keys", - body => scalar output_from_file "$ssh_dir/authorized_keys", + file_name => $ssh_authkeys, + body => scalar output_from_file $ssh_authkeys, }; - }; + }) : { file_name => $ssh_authkeys, body => '' }; return { files => \%key, authorized => $auth_keys }; }