338
338
logger.info(u"Starting checker %r for %s",
339
339
command, self.name)
340
# We don't need to redirect stdout and stderr, since
341
# in normal mode, that is already done by daemon(),
342
# and in debug mode we don't want to. (Stdin is
343
# always replaced by /dev/null.)
344
340
self.checker = subprocess.Popen(command,
346
342
shell=True, cwd="/")
347
343
self.checker_callback_tag = gobject.child_watch_add\
348
344
(self.checker.pid,
349
345
self.checker_callback)
350
except OSError, error:
346
except subprocess.OSError, error:
351
347
logger.error(u"Failed to start subprocess: %s",
353
349
# Re-run this periodically if run by gobject.timeout_add
410
406
gnutls.library.functions.gnutls_openpgp_crt_import\
411
407
(crt, ctypes.byref(datum),
412
408
gnutls.library.constants.GNUTLS_OPENPGP_FMT_RAW)
413
# Verify the self signature in the key
414
crtverify = ctypes.c_uint();
415
gnutls.library.functions.gnutls_openpgp_crt_verify_self\
416
(crt, ctypes.c_uint(0), ctypes.byref(crtverify))
417
if crtverify.value != 0:
418
gnutls.library.functions.gnutls_openpgp_crt_deinit(crt)
419
raise gnutls.errors.CertificateSecurityError("Verify failed")
420
409
# New buffer for the fingerprint
421
410
buffer = ctypes.create_string_buffer(20)
422
411
buffer_length = ctypes.c_size_t()
574
563
datetime.timedelta(1)
575
564
>>> string_to_delta(u'1w')
576
565
datetime.timedelta(7)
577
>>> string_to_delta('5m 30s')
578
datetime.timedelta(0, 330)
580
timevalue = datetime.timedelta(0)
581
for s in interval.split():
583
suffix=unicode(s[-1])
586
delta = datetime.timedelta(value)
588
delta = datetime.timedelta(0, value)
590
delta = datetime.timedelta(0, 0, 0, 0, value)
592
delta = datetime.timedelta(0, 0, 0, 0, 0, value)
594
delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value)
597
except (ValueError, IndexError):
568
suffix=unicode(interval[-1])
569
value=int(interval[:-1])
571
delta = datetime.timedelta(value)
573
delta = datetime.timedelta(0, value)
575
delta = datetime.timedelta(0, 0, 0, 0, value)
577
delta = datetime.timedelta(0, 0, 0, 0, 0, value)
579
delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value)
582
except (ValueError, IndexError):
603
587
def server_state_changed(state):
716
700
server_config = ConfigParser.SafeConfigParser(server_defaults)
717
701
del server_defaults
718
702
server_config.read(os.path.join(options.configdir, "mandos.conf"))
703
server_section = "server"
719
704
# Convert the SafeConfigParser object to a dict
720
server_settings = server_config.defaults()
705
server_settings = dict(server_config.items(server_section))
721
706
# Use getboolean on the boolean config option
722
707
server_settings["debug"] = server_config.getboolean\
708
(server_section, "debug")
724
709
del server_config
726
711
# Override the settings from the config file with command line
748
733
# Parse config file with clients
749
734
client_defaults = { "timeout": "1h",
750
735
"interval": "5m",
751
"checker": "fping -q -- %(host)s",
736
"checker": "fping -q -- %%(host)s",
754
738
client_config = ConfigParser.SafeConfigParser(client_defaults)
755
739
client_config.read(os.path.join(server_settings["configdir"],
789
773
logger.critical(u"No clients defined")
793
# Redirect stdin so all checkers get /dev/null
794
null = os.open(os.path.devnull, os.O_NOCTTY | os.O_RDWR)
795
os.dup2(null, sys.stdin.fileno())
800
777
logger.removeHandler(console)
801
# Close all input and output, do double fork, etc.
804
780
pidfilename = "/var/run/mandos/mandos.pid"