From 60c6c6b6f471606908a0f862cef8eab15d42972b Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 26 Jun 2009 23:12:45 +0000 Subject: [PATCH] add -s and -n flags to freeside-daily to specify the kinds of jobs to be run, RT#5572 --- FS/bin/freeside-queued | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued index 22fd7bb5e..008616fb0 100644 --- a/FS/bin/freeside-queued +++ b/FS/bin/freeside-queued @@ -4,6 +4,7 @@ use strict; 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 @@ $DEBUG = 0; $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 @@ while (1) { ? " 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 @@ while (1) { } } +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 @@ freeside-queued - Job queue daemon =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 -- 2.11.0