logging die and warn messages
- change a few important die()s to _die()s - setup SIGs for both die and warn so any others will get caught
This commit is contained in:
parent
67327ebfb4
commit
581e79d745
|
@ -25,9 +25,9 @@ my $repo = shift;
|
||||||
my $on = ( shift eq 'on' );
|
my $on = ( shift eq 'on' );
|
||||||
|
|
||||||
if ( $repo eq '@all' ) {
|
if ( $repo eq '@all' ) {
|
||||||
die "you are not authorized\n" if $ENV{GL_USER} and not is_admin();
|
_die "you are not authorized" if $ENV{GL_USER} and not is_admin();
|
||||||
} else {
|
} else {
|
||||||
die "you are not authorized\n" if $ENV{GL_USER} and not owns($repo);
|
_die "you are not authorized" if $ENV{GL_USER} and not owns($repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $msg = join( " ", @ARGV );
|
my $msg = join( " ", @ARGV );
|
||||||
|
|
|
@ -64,6 +64,7 @@ sub dbg {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _warn {
|
sub _warn {
|
||||||
|
gl_log( 'warn', @_ );
|
||||||
if ( $ENV{D} and $ENV{D} >= 3 ) {
|
if ( $ENV{D} and $ENV{D} >= 3 ) {
|
||||||
cluck "WARNING: ", @_, "\n";
|
cluck "WARNING: ", @_, "\n";
|
||||||
} elsif ( defined( $ENV{D} ) ) {
|
} elsif ( defined( $ENV{D} ) ) {
|
||||||
|
@ -72,6 +73,7 @@ sub _warn {
|
||||||
warn "WARNING: ", @_, "\n";
|
warn "WARNING: ", @_, "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$SIG{__WARN__} = \&_warn;
|
||||||
|
|
||||||
sub _die {
|
sub _die {
|
||||||
gl_log( 'die', @_ );
|
gl_log( 'die', @_ );
|
||||||
|
@ -83,6 +85,7 @@ sub _die {
|
||||||
die "FATAL: " . join( ",", @_ ) . "\n";
|
die "FATAL: " . join( ",", @_ ) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$SIG{__DIE__} = \&_die;
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
_warn(shift) if @_;
|
_warn(shift) if @_;
|
||||||
|
|
|
@ -25,6 +25,8 @@ package Gitolite::Easy;
|
||||||
%rc
|
%rc
|
||||||
say
|
say
|
||||||
say2
|
say2
|
||||||
|
_die
|
||||||
|
_warn
|
||||||
_print
|
_print
|
||||||
usage
|
usage
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,14 +62,14 @@ sub check_vrefs {
|
||||||
} else {
|
} else {
|
||||||
my ( $dummy, $pgm, @args ) = split '/', $vref;
|
my ( $dummy, $pgm, @args ) = split '/', $vref;
|
||||||
$pgm = "$ENV{GL_BINDIR}/VREF/$pgm";
|
$pgm = "$ENV{GL_BINDIR}/VREF/$pgm";
|
||||||
-x $pgm or die "$vref: helper program missing or unexecutable\n";
|
-x $pgm or _die "$vref: helper program missing or unexecutable";
|
||||||
|
|
||||||
open( my $fh, "-|", $pgm, @_, $vref, @args ) or die "$vref: can't spawn helper program: $!\n";
|
open( my $fh, "-|", $pgm, @_, $vref, @args ) or _die "$vref: can't spawn helper program: $!";
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
my ( $ref, $deny_message ) = split( ' ', $_, 2 );
|
my ( $ref, $deny_message ) = split( ' ', $_, 2 );
|
||||||
check_vref( $aa, $ref, $deny_message );
|
check_vref( $aa, $ref, $deny_message );
|
||||||
}
|
}
|
||||||
close($fh) or die $!
|
close($fh) or _die $!
|
||||||
? "Error closing sort pipe: $!"
|
? "Error closing sort pipe: $!"
|
||||||
: "$vref: helper program exit status $?";
|
: "$vref: helper program exit status $?";
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ sub setup_gladmin {
|
||||||
tsh_try("git config --get user.name") or tsh_run( "git config user.name '$ENV{USER} on '" . `hostname` );
|
tsh_try("git config --get user.name") or tsh_run( "git config user.name '$ENV{USER} on '" . `hostname` );
|
||||||
tsh_try("git diff --cached --quiet")
|
tsh_try("git diff --cached --quiet")
|
||||||
or tsh_try("git commit -am 'gl-setup $argv'")
|
or tsh_try("git commit -am 'gl-setup $argv'")
|
||||||
or die "setup failed to commit to the admin repo";
|
or _die "setup failed to commit to the admin repo";
|
||||||
delete $ENV{GIT_WORK_TREE};
|
delete $ENV{GIT_WORK_TREE};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ my $old_ak = slurp($akfile);
|
||||||
my @non_gl = grep { not /^# gito.*start/ .. /^# gito.*end/ } slurp($akfile);
|
my @non_gl = grep { not /^# gito.*start/ .. /^# gito.*end/ } slurp($akfile);
|
||||||
chomp(@non_gl);
|
chomp(@non_gl);
|
||||||
my %seen = map { $_ => 'a non-gitolite key' } ( fp(@non_gl) );
|
my %seen = map { $_ => 'a non-gitolite key' } ( fp(@non_gl) );
|
||||||
# die 1;
|
|
||||||
|
|
||||||
# pubkey files
|
# pubkey files
|
||||||
chomp( my @pubkeys = `find keydir -type f -name "*.pub" | sort` );
|
chomp( my @pubkeys = `find keydir -type f -name "*.pub" | sort` );
|
||||||
|
|
Loading…
Reference in a new issue