#!/usr/bin/env python2.4 #Copyright 2004,2006 Sebastian Hagen # This file is part of eucharis. # eucharis is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation # eucharis is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with eucharis; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #This file initializes iptrack_core. import os import sys if (os.getuid() == 0): sys.exit('Eucharis will not run as root; it just causes problems.') fork_result = os.fork() #fork if (fork_result != 0): print 'Started as %s.' % (fork_result,) sys.exit(0) os.setsid() #(eval('026') == 22) which is -rw-r----- os.umask(22) import time import pid_filing import eucharis_core import socket_management import data_pickling import daemon_init #close stdin,stdout,stderr, and replace the latter two. #for std* to be closed correctly, os.close() has to be called #on their file descriptors. pid_file = pid_filing.file_pid() pid_filing.release_pid_file(pidfile=pid_file) daemon_init.daemon_init(stdout_filename='stdout_iptrack.log', stderr_filename='stderr_iptrack.log') pid_file = pid_filing.file_pid() sys.stdout.write('%s: Starting eucharis.\n' % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),)) sys.stderr.write('%s: Starting eucharis.\n' % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),)) daemon_init.warnings_redirect_logging() version_info = eucharis_core.version_info eucharis_core.init() socket_management.select_loop() data_pickling.save_variables()