summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2009-06-26 23:12:45 +0000
committerivan <ivan>2009-06-26 23:12:45 +0000
commit60c6c6b6f471606908a0f862cef8eab15d42972b (patch)
tree3c76c0e192b0f1c03e6958a9a85769806d1c9632 /FS
parent2594c62a8915496a5dde2db46f2f3bcba3f86a43 (diff)
add -s and -n flags to freeside-daily to specify the kinds of jobs to be run, RT#5572
Diffstat (limited to 'FS')
-rw-r--r--FS/bin/freeside-queued29
1 files 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