Code

Add function to merge multiple XML files
[nagixsc.git] / nagixsc_conf2http.py
index d296bfff07bd2ca70da64fdd8e5ef3a1bbbccf2b..1c5d28ff137af6c64218c6eb4bfb138d80bbdde0 100755 (executable)
@@ -22,6 +22,8 @@ from nagixsc import *
 parser = optparse.OptionParser()
 
 parser.add_option('-c', '', dest='cfgfile', help='Config file')
+parser.add_option('-d', '--daemon', action='store_true', dest='daemon', help='Daemonize, go to background')
+parser.add_option('', '--nossl', action='store_true', dest='nossl', help='Disable SSL (overwrites config file)')
 
 parser.set_defaults(cfgfile='conf2http.cfg')
 
@@ -100,7 +102,7 @@ class Conf2HTTPHandler(MyHTTPRequestHandler):
                if re.search('\.\.', configfile):
                        self.http_error(500, 'Found ".." in config file name')
                        return
-               if not re.search('^[a-zA-Z0-9-_\.]+$', configfile):
+               if not re.search('^[a-zA-Z0-9-_]+.conf$', configfile):
                        self.http_error(500, 'Config file name contains invalid characters')
                        return
 
@@ -124,10 +126,16 @@ class Conf2HTTPHandler(MyHTTPRequestHandler):
 
 
 def main():
+       if options.nossl:
+               config['ssl'] = False
+
        if config['ssl'] and not os.path.isfile(config['cert']):
                print 'SSL certificate "%s" not found!' % config['cert']
                sys.exit(127)
 
+       if options.daemon:
+               daemonize(pidfile='/var/run/nagixsc_conf2http.pid')
+
        server = MyHTTPServer((config['ip'], config['port']), Conf2HTTPHandler, ssl=config['ssl'], sslpemfile=config['cert'])
        try:
                server.serve_forever()