(minor) be less noisy about pubkeys present but not used in config

The main use case is for people who give most people access via @all,
which is somewhat unusual but in some situations it probably makes
sense.

See also a related commit made a month or so ago (aa8da93).

Actually these two lint checks were made to help people spot typos in
the config, which sorta becomes meaningless if you have more than a few
such cases anyway, so for most people it should not matter that I am now
merely summarising the number of such cases if there are more then 10.
This commit is contained in:
Sitaram Chamarty 2010-06-18 16:22:17 +05:30
parent 0f5f82e4f5
commit bf1a9720af

View file

@ -553,6 +553,7 @@ while (<$authkeys_fh>)
# options, in the standard ssh authorized_keys format), then the "end" line. # options, in the standard ssh authorized_keys format), then the "end" line.
print $newkeys_fh "# gitolite start\n"; print $newkeys_fh "# gitolite start\n";
wrap_chdir($GL_KEYDIR); wrap_chdir($GL_KEYDIR);
my @not_in_config; # pubkeys exist but users don't appear in the config file
for my $pubkey (`find . -type f`) for my $pubkey (`find . -type f`)
{ {
chomp($pubkey); $pubkey =~ s(^\./)(); chomp($pubkey); $pubkey =~ s(^\./)();
@ -574,9 +575,8 @@ for my $pubkey (`find . -type f`)
$user =~ s(.*/)(); # foo/bar/baz.pub -> baz.pub $user =~ s(.*/)(); # foo/bar/baz.pub -> baz.pub
$user =~ s/(\@[^.]+)?\.pub$//; # baz.pub, baz@home.pub -> baz $user =~ s/(\@[^.]+)?\.pub$//; # baz.pub, baz@home.pub -> baz
# lint check 2 # lint check 2 -- don't print right now; just collect the messages
print STDERR "WARNING: pubkey $pubkey exists but user $user not in config\n" push @not_in_config, "$user($pubkey)" unless $user_list{$user};
unless $user_list{$user};
$user_list{$user} = 'has pubkey'; $user_list{$user} = 'has pubkey';
# apparently some pubkeys don't end in a newline... # apparently some pubkeys don't end in a newline...
my $pubkey_content = `cat $pubkey`; my $pubkey_content = `cat $pubkey`;
@ -590,6 +590,14 @@ for my $pubkey (`find . -type f`)
print $newkeys_fh "command=\"$AUTH_COMMAND $user\",$AUTH_OPTIONS "; print $newkeys_fh "command=\"$AUTH_COMMAND $user\",$AUTH_OPTIONS ";
print $newkeys_fh $pubkey_content; print $newkeys_fh $pubkey_content;
} }
# lint check 2 -- print less noisily
if (@not_in_config > 10) {
print STDERR "$WARN You have " . scalar(@not_in_config) . " pubkeys that do not appear to be used in the config\n";
} elsif (@not_in_config) {
print STDERR "$WARN the following users (pubkey files in parens) do not appear in the config file:\n", join(",", sort @not_in_config), "\n";
}
# lint check 3; a little more severe than the first two I guess... # lint check 3; a little more severe than the first two I guess...
{ {
my @no_pubkey = my @no_pubkey =