compile: recurse through keydir/ for pubkeys

This commit is contained in:
Sitaram Chamarty 2010-04-10 08:58:17 +05:30
parent 67607760e5
commit e0fe73ac18

View file

@ -509,10 +509,12 @@ 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);
for my $pubkey (glob("*")) for my $pubkey (`find . -type f`)
{ {
chomp($pubkey); $pubkey =~ s(^\./)();
# security check (thanks to divVerent for catching this) # security check (thanks to divVerent for catching this)
unless ($pubkey =~ $USERNAME_PATT) { unless ($pubkey =~ $REPONAME_PATT) {
print STDERR "$pubkey contains some unsavoury characters; ignored...\n"; print STDERR "$pubkey contains some unsavoury characters; ignored...\n";
next; next;
} }
@ -523,7 +525,11 @@ for my $pubkey (glob("*"))
print STDERR "WARNING: pubkey files should end with \".pub\", ignoring $pubkey\n"; print STDERR "WARNING: pubkey files should end with \".pub\", ignoring $pubkey\n";
next; next;
} }
my $user = $pubkey; $user =~ s/(\@[^.]+)?\.pub$//;
my $user = $pubkey;
$user =~ s(.*/)(); # foo/bar/baz.pub -> baz.pub
$user =~ s/(\@[^.]+)?\.pub$//; # baz.pub, baz@home.pub -> baz
# lint check 2 # lint check 2
print STDERR "WARNING: pubkey $pubkey exists but user $user not in config\n" print STDERR "WARNING: pubkey $pubkey exists but user $user not in config\n"
unless $user_list{$user}; unless $user_list{$user};