/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2010-09-25 20:09:10 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100925200910-8bxnasqkol93sj89
* mandos: Do not write pid file if --debug is passed.
* mandos.xml (FILES): Pid file only records pid of latest server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1763
1763
                              gnutls_priority=
1764
1764
                              server_settings[u"priority"],
1765
1765
                              use_dbus=use_dbus)
1766
 
    pidfilename = u"/var/run/mandos.pid"
1767
 
    try:
1768
 
        pidfile = open(pidfilename, u"w")
1769
 
    except IOError:
1770
 
        logger.error(u"Could not open file %r", pidfilename)
 
1766
    if not debug:
 
1767
        pidfilename = u"/var/run/mandos.pid"
 
1768
        try:
 
1769
            pidfile = open(pidfilename, u"w")
 
1770
        except IOError:
 
1771
            logger.error(u"Could not open file %r", pidfilename)
1771
1772
    
1772
1773
    try:
1773
1774
        uid = pwd.getpwnam(u"_mandos").pw_uid
1875
1876
    if not tcp_server.clients:
1876
1877
        logger.warning(u"No clients defined")
1877
1878
        
1878
 
    try:
1879
 
        with pidfile:
1880
 
            pid = os.getpid()
1881
 
            pidfile.write(str(pid) + "\n")
1882
 
        del pidfile
1883
 
    except IOError:
1884
 
        logger.error(u"Could not write to file %r with PID %d",
1885
 
                     pidfilename, pid)
1886
 
    except NameError:
1887
 
        # "pidfile" was never created
1888
 
        pass
1889
 
    del pidfilename
1890
 
    
1891
1879
    if not debug:
 
1880
        try:
 
1881
            with pidfile:
 
1882
                pid = os.getpid()
 
1883
                pidfile.write(str(pid) + "\n")
 
1884
            del pidfile
 
1885
        except IOError:
 
1886
            logger.error(u"Could not write to file %r with PID %d",
 
1887
                         pidfilename, pid)
 
1888
        except NameError:
 
1889
            # "pidfile" was never created
 
1890
            pass
 
1891
        del pidfilename
 
1892
        
1892
1893
        signal.signal(signal.SIGINT, signal.SIG_IGN)
 
1894
 
1893
1895
    signal.signal(signal.SIGHUP, lambda signum, frame: sys.exit())
1894
1896
    signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit())
1895
1897