This is an intermediate step towards collecting reporting at top-level.
This commit also enables the cleanup processing that has long been present,
but was skipped due to fatal calling exit instead of throwing an exception.
The testsuite is adjusted accordingly.
my $directive_file_contents = shift;
my $exit_code = shift;
- $directive_file_contents ||= '';
- if (($directive_file_contents ne '') && DEBUG) {
- mail ($directive_file_contents,0,"debug: directive file contents");
- }
-
ftp_syslog('err', "$tainted_msg");
# Don't let them do perl or shell quoting tricks, but show everything
$tainted_msg =~ m=^([-.:,/@\w\s]+)$=;
my $msg = $1;
- mail ($msg,$send_to_user);
-
- my $pid = open(PWD, "-|");
- my $cwd;
-
- if ($pid) { # parent
- while (<PWD>) {
- chomp ($cwd = $_);
- }
- close (PWD) or warn "pwd exited $?";
- } else { # child
- exec ("/bin/pwd") or ftp_abort("can't exec pwd: $!");
- }
- ftp_abort("(in $cwd) $msg",$exit_code);
+ our $Phase;
+ die {Phase => $Phase,
+ message => $msg,
+ send_to_user => $send_to_user};
}
\f
my $directive_file = $packet->[0];
my $upload_file = ''; my $sig_file = '';
+ unless ($directive_only) {
+ foreach (@{$packet}[1..$#$packet]) {
+ if (m/[.]sig$/) { $sig_file =$_ } else { $upload_file = $_ }
+ }
+ }
+
eval { # trap exceptions encountered while processing a packet
local $Phase = 'PV';
$directive_text = slurp_clearsigned_message($packet->[0]);
fatal("directive file $directive_file has no signature",0)
if $directive_text eq '';
- unless ($directive_only) {
- foreach (@{$packet}[1..$#$packet]) {
- if (m/[.]sig$/) { $sig_file =$_ } else { $upload_file = $_ }
- }
- }
-
# this function just updates $info{email}
guess_email_address_from_signature($directive_text);
# do the work
execute_commands($oplist);
- $Phase = 'RP'; # temporary; TODO: move to after eval {}
+ $complete = 1;
+ };
+
+ if ($complete) {
+ local $Phase = 'RP';
+
# report success
if (!$directive_only) {
success_upload($sig_file, $upload_file, $directive_file);
} else {
success_directive($directive_file);
}
+ } else {
+ local $Phase = 'RP';
- $complete = 1;
- };
+ if (ref $@) {
+ # Processing explicitly threw an exception
+ my $E = $@; # preserve the exception, since many functions use eval
+
+ unless ($oplist) {
+ # The directive text is emailed immediately after $oplist is set,
+ # so if $oplist is not set, then we still need to send it. Do so now.
+ mail($directive_text,0,'debug: directive file contents')
+ if $directive_text && DEBUG;
+ }
- unless ($complete) {
- warn "eval failed: $@";
+ # If a send_to_user key is set, then this came from a call to fatal().
+ if (defined $E->{send_to_user}) {
+ mail($E->{message},$E->{send_to_user});
+ }
+ } else {
+ # Exceptions thrown by perl itself come out as strings
+ warn "error during processing: $@";
+ }
# clean up files if we abort while processing a triplet
cleanup ($sig_file, $upload_file, $directive_file)
}
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
unsigned-directive,foo.directive.asc "unsigned directive"
} email-to {
}
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
unsigned-directive,foo.directive.asc "unsigned directive"
} email-to {
}
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
unsigned-directive,foo.directive.asc "unsigned directive"
} email-to {
}
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
unsigned-directive,foo.directive.asc "unsigned directive"
} email-to {
} dsig { good 00 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
validate,no-directory-given "directive rejected: no directory specified"
} email-to {
} dsig { good 01 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
gpgv,directive-verify-failed "incorrect signature rejected"
} email-to {
} dsig { good 01 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
validate,bad-directory-repeat "duplicate directory rejected"
} email-to {
} dsig { good 01 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
validate,bad-directory-repeat "ambiguous directory rejected"
} email-to {
} dsig { good 01 1001 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
validate,bad-directory-depth "excessively deep directory rejected"
} email-to {
} dsig { good 02 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
unknown-package "unknown package from directive"
} email-to {
} dsig { good 04 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
validate,no-op "null directive rejected"
} email-to {
} dsig { good 05 1000 }
} file-tree {
{ incoming stage pub archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
} log {
validate,no-op "null directive rejected"
} email-to {
}
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin foo/bar/README }
} log {
validate,bad-parameter,symlink \
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink \
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink "bogus symlink name rejected"
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink "bogus symlink target rejected"
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink "absolute symlink name rejected"
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink "absolute symlink target rejected"
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink "bogus symlink command rejected"
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,symlink "bogus symlink command rejected"
pub { foo-1.2.bin foo/foo-latest.bin }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.2.bin foo/foo-latest.bin }
{ pub } symlink-targets { foo-1.2.bin foo/foo-latest.bin }
} log {
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,rmsymlink \
pub { foo-1.0.bin foo/foo-latest.bin }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin foo/foo-latest.bin }
{ pub } symlink-targets { foo-1.0.bin foo/foo-latest.bin }
} log {
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
validate,bad-parameter,rmsymlink \
pub { foo/foo-1.0.bin { good 05 1000 } }
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin }
} log {
action,rm-symlink-failure,not-link \
}
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin foo/foo-1.2.bin }
} log {
action,make-symlink-failure "overwrite with symlink fails"
}
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.2.bin }
} log {
action,archive-failure,not-found "cannot archive nonexistent file"
}
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin foo/foo-1.2.bin }
} log {
validate,bad-parameter,archive \
}
} file-tree {
{ incoming stage archive } empty {}
- { in-stage } files { foo.directive.asc }
+ { in-stage } files { .foo.directive.asc }
{ pub } files { foo/foo-1.0.bin foo/foo-1.2.bin }
} log {
validate,bad-parameter,archive \
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.tar.gz.directive.asc foo.tar.gz.sig foo.tar.gz
+ .foo.tar.gz.directive.asc .foo.tar.gz.sig .foo.tar.gz
}
} log {
found,foo.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.tar.gz.directive.asc foo.tar.gz.sig foo.tar.gz
+ .foo.tar.gz.directive.asc .foo.tar.gz.sig .foo.tar.gz
}
} log {
found,foo.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.tar.gz.directive.asc foo.tar.gz.sig foo.tar.gz
+ .foo.tar.gz.directive.asc .foo.tar.gz.sig .foo.tar.gz
}
} log {
found,foo.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.tar.gz.directive.asc foo.tar.gz.sig foo.tar.gz
+ .foo.tar.gz.directive.asc .foo.tar.gz.sig .foo.tar.gz
}
} log {
found,foo.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin foo.bin.sig foo.bin.directive.asc
+ .foo.bin .foo.bin.sig .foo.bin.directive.asc
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin foo.bin.sig foo.bin.directive.asc
+ .foo.bin .foo.bin.sig .foo.bin.directive.asc
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- bar.tar.gz.directive.asc bar.tar.gz.sig bar.tar.gz
+ .bar.tar.gz.directive.asc .bar.tar.gz.sig .bar.tar.gz
}
} log {
found,bar.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- bar.tar.gz.directive.asc bar.tar.gz.sig bar.tar.gz
+ .bar.tar.gz.directive.asc .bar.tar.gz.sig .bar.tar.gz
}
} log {
found,bar.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- bar.tar.gz.directive.asc bar.tar.gz.sig bar.tar.gz
+ .bar.tar.gz.directive.asc .bar.tar.gz.sig .bar.tar.gz
}
} log {
found,bar.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- bar.tar.gz.directive.asc bar.tar.gz.sig bar.tar.gz
+ .bar.tar.gz.directive.asc .bar.tar.gz.sig .bar.tar.gz
}
} log {
found,bar.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- bar.tar.gz.directive.asc bar.tar.gz.sig bar.tar.gz
+ .bar.tar.gz.directive.asc .bar.tar.gz.sig .bar.tar.gz
}
} log {
found,bar.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- bar.tar.gz.directive.asc bar.tar.gz.sig bar.tar.gz
+ .bar.tar.gz.directive.asc .bar.tar.gz.sig .bar.tar.gz
}
} log {
found,bar.tar.gz.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage pub archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
} log {
found,foo.bin.directive.asc "found directive in triplet"
file-tree {
{ incoming stage archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
{ pub } files {
foo/foo.bin foo/foo.bin.sig
file-tree {
{ incoming stage archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
{ pub } files {
foo/foo.bin
file-tree {
{ incoming stage archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
{ pub } files {
foo/foo.bin foo/foo.bin.sig
file-tree {
{ incoming stage archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
{ pub } files {
foo/foo.bin foo/foo.bin.sig
{ incoming stage pub archive } empty {}
analyze_file_tree $tenv "am_cve: $desc" \
{ in-stage } files {
- foo.tar.gz.directive.asc foo.tar.gz.sig foo.tar.gz
+ .foo.tar.gz.directive.asc .foo.tar.gz.sig .foo.tar.gz
}
close_test_environment $tenv
file-tree {
{ incoming stage archive } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
{ pub } files {
foo/foo.bin.sig foo/foo.bin
file-tree {
{ incoming stage } empty {}
{ in-stage } files {
- foo.bin.directive.asc foo.bin.sig foo.bin
+ .foo.bin.directive.asc .foo.bin.sig .foo.bin
}
{ archive } archived-files {
foo/foo.bin