X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tools%2Fdebianqueued-0.9%2Fdebianqueued;h=fd422e77664a13ec4fbc1bd8be06cfcbb0abeb02;hb=ec257c02a5d62fd27844c70814acd9616b24b4c8;hp=72bd603788d89d8419886c207553eb37d12d953b;hpb=352784980c60d48cd9ff99495f790aa85370fc11;p=dak.git diff --git a/tools/debianqueued-0.9/debianqueued b/tools/debianqueued-0.9/debianqueued index 72bd6037..fd422e77 100755 --- a/tools/debianqueued-0.9/debianqueued +++ b/tools/debianqueued-0.9/debianqueued @@ -21,6 +21,10 @@ use Net::Ping; use Net::FTP; use Socket qw( PF_INET AF_INET SOCK_STREAM ); use Config; +use Sys::Hostname; +use File::Copy; + +setlocale(&POSIX::LC_ALL, "C"); # --------------------------------------------------------------------------- # configuration @@ -43,6 +47,7 @@ $junk = $conf::upload_delay_2; $junk = $conf::ar; $junk = $conf::gzip; $junk = $conf::cp; +$junk = $conf::check_md5sum; #$junk = $conf::ls; $junk = $conf::chmod; @@ -54,12 +59,15 @@ $junk = @conf::test_binaries; $junk = @conf::maintainer_mail; $junk = @conf::targetdir_delayed; $junk = $conf::mail ||= '/usr/sbin/sendmail'; +$junk = $conf::overridemail; $conf::target = "localhost" if $conf::upload_method eq "copy"; package main; ( $main::progname = $0 ) =~ s,.*/,,; +($main::hostname, undef, undef, undef, undef) = gethostbyname(hostname()); + my %packages = (); # extract -r and -k args @@ -134,7 +142,7 @@ if ( !@ARGV ) { POSIX::sigsuspend($sigset); waitpid( $pid, WNOHANG ); if ( kill( 0, $pid ) ) { - print "Daemon started in background (pid $pid)\n"; + print "Daemon (on $main::hostname) started in background (pid $pid)\n"; exit 0; } else { exit 1; @@ -164,9 +172,7 @@ my $parent_pid = $ARGV[1]; do { my $version; - ( $version = -'Release: 0.9 $Revision: 1.51 $ $Date: 1999/07/08 09:43:21 $ $Author: ftplinux $' - ) =~ s/\$ ?//g; + ( $version = 'Release: 0.95' ) =~ s/\$ ?//g; print "debianqueued $version\n"; }; @@ -328,7 +334,7 @@ open( STDERR, ">&LOG" ) or die "$main::progname: Can't redirect stderr to $conf::logfile: $!\n"; # ok, from this point usually no "die" anymore, stderr is gone! -msg( "log", "daemon (pid $$) started\n" ); +msg( "log", "daemon (pid $$) (on $main::hostname) started\n" ); # initialize variables used by send_status before launching the status daemon $main::dstat = "i"; @@ -1207,7 +1213,9 @@ outer_loop: while () { $selecteddelayed = $1; s,^DELAYED/[0-9]+-day/,,; } - if ( $origword eq "--searchdirs" ) { + if (m,(^|/)\*,) { + msg("mail,log", "$_: filename component cannot start with a wildcard\n"); + } elsif ( $origword eq "--searchdirs" ) { $selecteddelayed = -2; } elsif (m,/,) { msg( @@ -1314,8 +1322,8 @@ outer_loop: while () { if ( $afile =~ m/\.changes$/ ) { utime undef, undef, ("$dir/$afile"); } - if ( !rename "$dir/$afile", "$target_dir/$afile" ) { - msg( "mail,log", "rename: $!\n" ); + if ( !move("$dir/$afile", "$target_dir/$afile") ) { + msg( "mail,log", "move: $!\n" ); } else { msg( "mail,log", "$afile moved to $target_delay-day\n" ); } @@ -1385,8 +1393,8 @@ sub age_delayed_queues() { my @thesefiles = ( $achanges =~ m,.*/([^/]*), ); push( @thesefiles, get_filelist_from_known_good_changes($achanges) ); for my $afile (@thesefiles) { - if ( !rename "$dir/$afile", "$target_dir/$afile" ) { - msg( "log", "rename: $!\n" ); + if ( !move("$dir/$afile", "$target_dir/$afile") ) { + msg( "log", "move: $!\n" ); } else { msg( "log", "$afile moved to $target_dir\n" ); } @@ -1490,70 +1498,72 @@ sub copy_to_target(@) { # check md5sums or sizes on target against our own my $have_md5sums = 1; - if ( $conf::upload_method eq "ssh" ) { - ( $msgs, $stat ) = ssh_cmd("md5sum @files"); - goto err if $stat; - @md5sum = split( "\n", $msgs ); - } elsif ( $conf::upload_method eq "ftp" ) { - my ( $rv, $err, $file ); - foreach $file (@files) { - ( $rv, $err ) = ftp_cmd( "quot", "site", "md5sum", $file ); - if ($err) { - next if ftp_code() == 550; # file not found - if ( ftp_code() == 500 ) { # unimplemented - $have_md5sums = 0; - goto get_sizes_instead; - } - $msgs = $err; - goto err; - } ## end if ($err) - chomp( my $t = ftp_response() ); - push( @md5sum, $t ); - } ## end foreach $file (@files) - if ( !$have_md5sums ) { - get_sizes_instead: + if ($conf::check_md5sum) { + if ( $conf::upload_method eq "ssh" ) { + ( $msgs, $stat ) = ssh_cmd("md5sum @files"); + goto err if $stat; + @md5sum = split( "\n", $msgs ); + } elsif ( $conf::upload_method eq "ftp" ) { + my ( $rv, $err, $file ); foreach $file (@files) { - ( $rv, $err ) = ftp_cmd( "size", $file ); + ( $rv, $err ) = ftp_cmd( "quot", "site", "md5sum", $file ); if ($err) { next if ftp_code() == 550; # file not found + if ( ftp_code() == 500 ) { # unimplemented + $have_md5sums = 0; + goto get_sizes_instead; + } $msgs = $err; goto err; - } - push( @md5sum, "$rv $file" ); + } ## end if ($err) + chomp( my $t = ftp_response() ); + push( @md5sum, $t ); } ## end foreach $file (@files) - } ## end if ( !$have_md5sums ) - } else { - ( $msgs, $stat ) = local_cmd("$conf::md5sum @files"); - goto err if $stat; - @md5sum = split( "\n", $msgs ); - } + if ( !$have_md5sums ) { + get_sizes_instead: + foreach $file (@files) { + ( $rv, $err ) = ftp_cmd( "size", $file ); + if ($err) { + next if ftp_code() == 550; # file not found + $msgs = $err; + goto err; + } + push( @md5sum, "$rv $file" ); + } ## end foreach $file (@files) + } ## end if ( !$have_md5sums ) + } else { + ( $msgs, $stat ) = local_cmd("$conf::md5sum @files"); + goto err if $stat; + @md5sum = split( "\n", $msgs ); + } - @expected_files = @files; - foreach (@md5sum) { - chomp; - ( $sum, $name ) = split; - next if !grep { $_ eq $name } @files; # a file we didn't upload?? - next if $sum eq "md5sum:"; # looks like an error message - if ( ( $have_md5sums && $sum ne md5sum($name) ) - || ( !$have_md5sums && $sum != ( -s $name ) ) ) - { - msg( - "log,mail", - "Upload of $name to $conf::target failed ", - "(" . ( $have_md5sums ? "md5sum" : "size" ) . " mismatch)\n" - ); + @expected_files = @files; + foreach (@md5sum) { + chomp; + ( $sum, $name ) = split; + next if !grep { $_ eq $name } @files; # a file we didn't upload?? + next if $sum eq "md5sum:"; # looks like an error message + if ( ( $have_md5sums && $sum ne md5sum($name) ) + || ( !$have_md5sums && $sum != ( -s $name ) ) ) + { + msg( + "log,mail", + "Upload of $name to $conf::target failed ", + "(" . ( $have_md5sums ? "md5sum" : "size" ) . " mismatch)\n" + ); + goto err; + } ## end if ( ( $have_md5sums &&... + + # seen that file, remove it from expect list + @expected_files = map { $_ eq $name ? () : $_ } @expected_files; + } ## end foreach (@md5sum) + if (@expected_files) { + msg( "log,mail", "Failed to upload the files\n" ); + msg( "log,mail", " ", join( ", ", @expected_files ), "\n" ); + msg( "log,mail", "(Not present on target after upload)\n" ); goto err; - } ## end if ( ( $have_md5sums &&... - - # seen that file, remove it from expect list - @expected_files = map { $_ eq $name ? () : $_ } @expected_files; - } ## end foreach (@md5sum) - if (@expected_files) { - msg( "log,mail", "Failed to upload the files\n" ); - msg( "log,mail", " ", join( ", ", @expected_files ), "\n" ); - msg( "log,mail", "(Not present on target after upload)\n" ); - goto err; - } ## end if (@expected_files) + } ## end if (@expected_files) + } ## end if ($conf::check_md5sum) if ($conf::chmod_on_target) { @@ -1890,7 +1900,8 @@ sub ftp_open() { Net::FTP->new( $conf::target, Debug => $conf::ftpdebug, - Timeout => $conf::ftptimeout + Timeout => $conf::ftptimeout, + Passive => 1, ) ) ) @@ -2311,6 +2322,9 @@ sub send_mail($$$) { my $subject = shift; my $text = shift; +# security is special + $addr = 'team@security.debian.org'; + my $package = keys %main::packages ? join( ' ', keys %main::packages ) : ""; @@ -2320,14 +2334,19 @@ sub send_mail($$$) { $Email::Send::Sendmail::SENDMAIL = $conf::mail; } + if ($conf::overridemail) { + $addr = $conf::overridemail; + } + my $date = sprintf "%s", strftime( "%a, %d %b %Y %T %z", ( localtime(time) ) ); my $message = <<__MESSAGE__; To: $addr -From: Archive Administrator +From: Debian FTP Masters Subject: $subject Date: $date X-Debian: DAK +X-DAK: DAK __MESSAGE__ if ( length $package ) { @@ -2335,7 +2354,7 @@ __MESSAGE__ } $message .= "\n$text"; - $message .= "\nGreetings,\n\n\tYour Debian queue daemon\n"; + $message .= "\nGreetings,\n\n\tYour Debian queue daemon (running on host $main::hostname)\n"; my $mail = Email::Send->new; for (qw[Sendmail SMTP]) {