/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: 2009-02-07 04:50:39 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090207045039-xkr6b80vtqwqrq8l
* Makefile (install-client-nokey): Move "initramfs-tools-script" from
                                   "/scripts/local-top/mandos" to
                                   "/scripts/init-premount/mandos".
  (uninstall-client): - '' -
* debian/mandos-client.dirs: - '' -
* initramfs-tools-script (PREREQ): Added "udev".

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
             (facility = logging.handlers.SysLogHandler.LOG_DAEMON,
74
74
              address = "/dev/log"))
75
75
syslogger.setFormatter(logging.Formatter
76
 
                       ('Mandos: %(levelname)s: %(message)s'))
 
76
                       ('Mandos [%(process)d]: %(levelname)s:'
 
77
                        ' %(message)s'))
77
78
logger.addHandler(syslogger)
78
79
 
79
80
console = logging.StreamHandler()
80
 
console.setFormatter(logging.Formatter('%(name)s: %(levelname)s:'
81
 
                                       ' %(message)s'))
 
81
console.setFormatter(logging.Formatter('%(name)s [%(process)d]:'
 
82
                                       ' %(levelname)s: %(message)s'))
82
83
logger.addHandler(console)
83
84
 
84
85
class AvahiError(Exception):
676
677
        # using OpenPGP certificates.
677
678
        
678
679
        #priority = ':'.join(("NONE", "+VERS-TLS1.1", "+AES-256-CBC",
679
 
        #                "+SHA1", "+COMP-NULL", "+CTYPE-OPENPGP",
680
 
        #                "+DHE-DSS"))
 
680
        #                     "+SHA1", "+COMP-NULL", "+CTYPE-OPENPGP",
 
681
        #                     "+DHE-DSS"))
681
682
        # Use a fallback default, since this MUST be set.
682
683
        priority = self.server.settings.get("priority", "NORMAL")
683
684
        (gnutls.library.functions
699
700
            session.bye()
700
701
            return
701
702
        logger.debug(u"Fingerprint: %s", fpr)
 
703
        
702
704
        for c in self.server.clients:
703
705
            if c.fingerprint == fpr:
704
706
                client = c
763
765
                                 u" bind to interface %s",
764
766
                                 self.settings["interface"])
765
767
                else:
766
 
                    raise error
 
768
                    raise
767
769
        # Only bind(2) the socket if we really need to.
768
770
        if self.server_address[0] or self.server_address[1]:
769
771
            if not self.server_address[0]:
790
792
 
791
793
def string_to_delta(interval):
792
794
    """Parse a string and return a datetime.timedelta
793
 
 
 
795
    
794
796
    >>> string_to_delta('7d')
795
797
    datetime.timedelta(7)
796
798
    >>> string_to_delta('60s')
999
1001
    pidfilename = "/var/run/mandos.pid"
1000
1002
    try:
1001
1003
        pidfile = open(pidfilename, "w")
1002
 
    except IOError, error:
 
1004
    except IOError:
1003
1005
        logger.error("Could not open file %r", pidfilename)
1004
1006
    
1005
1007
    try:
1017
1019
                uid = 65534
1018
1020
                gid = 65534
1019
1021
    try:
 
1022
        os.setgid(gid)
1020
1023
        os.setuid(uid)
1021
 
        os.setgid(gid)
1022
1024
    except OSError, error:
1023
1025
        if error[0] != errno.EPERM:
1024
1026
            raise error
1025
1027
    
 
1028
    # Enable all possible GnuTLS debugging
 
1029
    if debug:
 
1030
        # "Use a log level over 10 to enable all debugging options."
 
1031
        # - GnuTLS manual
 
1032
        gnutls.library.functions.gnutls_global_set_log_level(11)
 
1033
        
 
1034
        @gnutls.library.types.gnutls_log_func
 
1035
        def debug_gnutls(level, string):
 
1036
            logger.debug("GnuTLS: %s", string[:-1])
 
1037
        
 
1038
        (gnutls.library.functions
 
1039
         .gnutls_global_set_log_function(debug_gnutls))
 
1040
    
1026
1041
    global service
1027
1042
    service = AvahiService(name = server_settings["servicename"],
1028
1043
                           servicetype = "_mandos._tcp", )
1185
1200
        sys.exit(1)
1186
1201
    except KeyboardInterrupt:
1187
1202
        if debug:
1188
 
            print
 
1203
            print >> sys.stderr
 
1204
        logger.debug("Server received KeyboardInterrupt")
 
1205
    logger.debug("Server exiting")
1189
1206
 
1190
1207
if __name__ == '__main__':
1191
1208
    main()