/usr/sbin/auth2db-daemon is in auth2db 0.2.5-2+dfsg-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #!/usr/bin/python
import os
import sys
from configobj import ConfigObj
NAME="auth2db"
PIDFILE="/var/run/"+NAME+"/"+NAME+".pid"
default = ConfigObj('/etc/default/auth2db')
def createDaemon():
'''create auth2db daemon...'''
# create - fork 1
try:
if os.fork() > 0: os._exit(0) # exit father...
except OSError, error:
print 'fork #1 failed: %d (%s)' % (error.errno, error.strerror)
os._exit(1)
# it separates the son from the father
os.chdir('/')
os.setsid()
os.umask(0)
# create - fork 2
try:
pid = os.fork()
if pid > 0:
fd = open(PIDFILE, 'w')
fd.write(str(pid))
fd.flush()
#print 'START auth2db daemon PID %d' % pid
os._exit(0)
except OSError, error:
print 'fork #2 failed: %d (%s)' % (error.errno, error.strerror)
os._exit(1)
daemonAuth2db() # function daemon
def daemonAuth2db():
import time
from types import IntType
AlertActivation = default['ACTIVE_ALERTS'].lower()
try:
frequency = int(default['FREQUENCY'])
except ValueError:
print "The frequency defined on /etc/default/auth2db must be an integer"
while True:
os.system("/usr/sbin/auth2db > /dev/null")
if AlertActivation == "yes" or AlertActivation == "y":
os.system("/usr/sbin/auth2db-alert > /dev/null")
if frequency >= 5:
time.sleep(frequency)
elif (frequency > 0) and (frequency < 5):
# Warning message managed on Debian initscript
time.sleep(frequency)
else:
print "FATAL ERROR: Frequency MUST be a value higher than 0. NOT STARTING."
# Full warning info managed on Debian initscript, the above is just a tip :-)
break
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == "start":
existepid = os.path.exists(PIDFILE)
if existepid == 0:
createDaemon()
else:
print "auth2db is already running..."
sys.exit()
elif len(sys.argv) > 1 and sys.argv[1] == "stop":
existepid = os.path.exists(PIDFILE)
if existepid:
fd = open( PIDFILE )
file_pid = fd.readline()
#print 'STOP auth2db daemon PID '+str(file_pid)
os.system("kill "+file_pid)
os.system("rm "+PIDFILE)
else:
print "auth2db is not running..."
else:
print "Usage: auth2db-daemon start|stop"
|