--- loncom/build/check-rpms 2002/04/13 19:13:06 1.3 +++ loncom/build/check-rpms 2002/11/04 02:52:39 1.6 @@ -3,6 +3,9 @@ # check-rpms, version 2.1.1 # Martin Siegert, SFU, siegert@sfu.ca, Feb 02 # +# documentation and minor patches, +# Scott Harrison sharrison@users.sourceforge.net 2002 + =pod =head1 NAME @@ -87,7 +90,7 @@ use Getopt::Long; my $retval = &GetOptions("verbose|v","lm|list-missing","lq|list-questionable", "dir|d=s","ftp:s","noftp","download|dl","recheck|r", - "nk|no-kernel","update","c=s"); + "nk|no-kernel","update","c=s","rpmuser=s"); =pod @@ -200,6 +203,10 @@ example configuration file is given belo is omitted, I will use the default configuration file I, if it exists. +=item B<--rpmuser> I + +Specifying $RPMUSER on the command line. + =back =head1 EXAMPLES @@ -294,7 +301,7 @@ Example configuration file: # $RPMUSER is the user name that check-rpms switches to for most of # the script when run as root - $RPMUSER = "joe"; + $RPMUSER = "adminjoe"; # $FTPSERVER and $FTPUPDATES are the hostname of a ftp server and the # directory where RPM updates can be found without the directory. @@ -315,6 +322,10 @@ if ( -f $CONF) { $FTPUPDATES = $DEFFTPUPDATES; } +if ($opt_rpmuser) { + $DEFRPMUSER = $opt_rpmuser; +} + # check whether we are running as root if ($< == 0){ if (! $RPMUSER) { @@ -384,6 +395,9 @@ if (defined $opt_ftp || $FTP) { die "Either $RPMDIR does not exist or it does not contain any packages.\n"; } +my $FTPSERVER_auth = $FTPSERVER; +$FTPSERVER_auth =~ s/^(\w+)\:(\w+)\@/-u $1 -p $2 /; + if ($recheck) { $questionable=1; } @@ -392,7 +406,7 @@ if (defined $opt_update || defined $opt_ $no_kernel=1; } -$PROC = `grep -i athlon /proc/cpuinfo`; +$PROC = `grep -i "athlon\|amd" /proc/cpuinfo`; if ( ! "$PROC" ) { $PROC = `uname -m`; chomp($PROC); @@ -553,6 +567,7 @@ for (@local_rpm_list) { } } + if ($recheck && @q_updates) { if ($ftp) { for (@q_updates) { @@ -562,10 +577,11 @@ if ($recheck && @q_updates) { if ($verbose) { print "Getting questionable packages form $FTPSERVER ...\n"; } - my $status = system("$FTPGET $FTPSERVER $RPMDIR @ftp_files"); + my $status = system("$FTPGET $FTPSERVER_auth $RPMDIR @ftp_files"); if ($status) { if ($< == 0) { # if we are running as root exit to avoid symlink attacks, etc. +print("DEBUG DEBUG $FTPGET $FTPSERVER_auth $RPMDIR @ftp_files"); die "$FTPGET failed with status ", $status/256, ".\n"; } else { print STDERR "warning: $FTPGET failed with status ", $status/256, ".\n"; @@ -607,7 +623,7 @@ if (@updates) { if ($verbose) { print "starting downloads ... \n"; } - my $status = system("$FTPGET $FTPSERVER $RPMDIR @ftp_files"); + my $status = system("$FTPGET $FTPSERVER_auth $RPMDIR @ftp_files"); if ($status) { if ($< == 0) { # if we are running as root exit to avoid symlink attacks, etc. @@ -644,10 +660,10 @@ if (@q_updates && $questionable) { } if ($verbose) { print "starting downloads ... \n"; - system("$FTPGET $FTPSERVER $$RPMDIR @ftp_files"); + system("$FTPGET $FTPSERVER_auth $$RPMDIR @ftp_files"); print "... done.\n"; } else { - system("$FTPGET $FTPSERVER $$RPMDIR @ftp_files"); + system("$FTPGET $FTPSERVER_auth $$RPMDIR @ftp_files"); } } } @@ -678,7 +694,7 @@ sub ftp_download { my ($arch) = m/[^ ]*-[^-]+-[^-]*\.(\w+)\.rpm$/; push(@ftp_packages,"$FTPDIR/$arch/$_"); } - my $status = system("$FTPGET $FTPSERVER $downloaddir @ftp_packages"); + my $status = system("$FTPGET $FTPSERVER_auth $downloaddir @ftp_packages"); return $status; }