[freeside-commits] freeside/FS/bin freeside-queued,1.42,1.43

Ivan,,, ivan at wavetail.420.am
Fri Jun 26 16:12:47 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv8196

Modified Files:
	freeside-queued 
Log Message:
add -s and -n flags to freeside-daily to specify the kinds of jobs to be run, RT#5572

Index: freeside-queued
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-queued,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- freeside-queued	24 Jun 2009 18:36:32 -0000	1.42
+++ freeside-queued	26 Jun 2009 23:12:45 -0000	1.43
@@ -4,6 +4,7 @@
 use vars qw( $DEBUG $kids $max_kids %kids );
 use POSIX qw(:sys_wait_h);
 use IO::File;
+use Getopt::Std;
 use FS::UID qw(adminsuidsetup forksuidsetup driver_name dbh myconnect);
 use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
 use FS::Conf;
@@ -18,6 +19,10 @@
 
 $kids = 0;
 
+&untaint_argv;  #what it sounds like  (eww)
+use vars qw(%opt);
+getopts('sn', \%opt );
+
 my $user = shift or die &usage;
 
 warn "starting daemonization (forking)\n" if $DEBUG;
@@ -95,9 +100,16 @@
                    ? " LIMIT $limit FOR UPDATE "
                    : " FOR UPDATE LIMIT $limit " );
 
+  my $hashref = { 'status' => 'new' };
+  if ( $opt{'s'} ) {
+    $hashref->{'status'} = 'Y';
+  } elsif ( $opt{'n'} ) {
+    $hashref->{'status'} = '';
+  }
+
   my @jobs = qsearch({
     'table'     => 'queue',
-    'hashref'   => { 'status' => 'new' },
+    'hashref'   => $hashref,
     'extra_sql' => $nodepend,
     'order_by'  => $order_by,
   });
@@ -217,6 +229,15 @@
   }
 }
 
+sub untaint_argv {
+  foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
+    #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
+    # Date::Parse
+    $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
+    $ARGV[$_]=$1;
+  }
+}
+
 sub usage {
   die "Usage:\n\n  freeside-queued user\n";
 }
@@ -237,12 +258,16 @@
 
 =head1 SYNOPSIS
 
-  freeside-queued user
+  freeside-queued [ -s | -n ] user
 
 =head1 DESCRIPTION
 
 Job queue daemon.  Should be running at all times.
 
+-s: "secure" jobs only (queued billing jobs)
+
+-n: non-"secure" jobs only (other jobs)
+
 user: from the mapsecrets file - see config.html from the base documentation
 
 =head1 VERSION



More information about the freeside-commits mailing list