From cd3e036e25a07a24eddc0aa53f1a13bc9299ddd9 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Sun, 30 Jun 2002 20:53:41 +0000 Subject: [PATCH] Modified processz3950queue to create a pid file in /var/run (if it exists) and then drop root privileges to the apache user before doing anything else. Still needs a good init script to start/stop/restart. --- acqui.simple/processz3950queue | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/acqui.simple/processz3950queue b/acqui.simple/processz3950queue index 3077f1263a..68cc91bd89 100755 --- a/acqui.simple/processz3950queue +++ b/acqui.simple/processz3950queue @@ -6,6 +6,26 @@ use C4::Acquisitions; use C4::Biblio; use C4::Output; use Net::Z3950; + + +if ($< == 0) { + # Running as root, switch privs + if (-d "/var/run") { + open PID, ">/var/run/processz3950queue.pid"; + print PID $$."\n"; + close PID; + } + # Get real apacheuser from koha.conf or reparsing httpd.conf + my $apacheuser='www-data'; + my $uid=0; + unless ($uid = (getpwnam($apacheuser))[2]) { + die "Attempt to run daemon as non-existent or superuser\n"; + } + $>=$uid; + $<=$uid; +} + + my $dbh=C4Connect; my $sth=$dbh->prepare("update z3950results set active=0"); @@ -20,6 +40,7 @@ my $logdir=$ARGV[0]; open PID, ">$logdir/processz3950queue.pid"; print PID $$."\n"; close PID; + my $reapcounter=0; my $forkcounter=0; my $checkqueue=1; -- 2.39.5