def testNoSubst(self): "Test that we can disable string substitutions." si = StringIO("a: ipmax 0 : faillog %(ip)s\n") aroot = actions.fromfile(si, "<t>") actions.dosubstitutions(0) r = aroot.genaction(makehi(), genrules(("a,"))) self.assertEqual(r.logmsgs, ["%(ip)s"]) # We'd BETTER restore that default! actions.dosubstitutions(1)
(p, h, str(e))) # Renounce privledges if told to. if cfg.has_key('user'): try: proc.changetouser(cfg['user']) except proc.Kaboom, e: log.die("Could not drop privledges to %s: %s" % \ (cfg['user'], str(e))) # Initialize global parameters. if cfg.has_key('dropipafter'): hinfo.setiptimesdur(cfg['dropipafter']) if cfg.has_key('substitutions'): if cfg['substitutions'] == 'off': actions.dosubstitutions(0) else: actions.dosubstitutions(1) proc.initsignals(kickme, repstate) serve(cfg, sockl, threadmax) def usage(): log.die("usage: portnanny2 [-v|-V NUM] [-M MAXTHREADS] [-S STACK] [-C] [-l] conffile") def main(sargs): usesyslog = 0 checkonly = 0 threadmax = None stacklim = None try: opts, args = getopt.getopt(sargs, "vV:p:lCM:S:", [])