本文整理汇总了Python中Milter.set_flags方法的典型用法代码示例。如果您正苦于以下问题:Python Milter.set_flags方法的具体用法?Python Milter.set_flags怎么用?Python Milter.set_flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Milter
的用法示例。
在下文中一共展示了Milter.set_flags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
# Run as a specific user
if run_as_user != None:
run_as_uid = getpwnam(run_as_user).pw_uid
run_as_gid = getpwnam(run_as_user).pw_gid
print "%s running as %s (uid=%s,gid=%s)" % (time.strftime('%Y%b%d %H:%M:%S'), run_as_user, run_as_uid, run_as_gid)
# always set gid first, because once we've set uid, we can't set gid anymore
os.setgid(run_as_gid)
os.setuid(run_as_uid)
# Log startup
print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
sys.stdout.flush()
# Handle log printing in the background
bt = Thread(target=background)
bt.start()
# Register to have the Milter factory create instances of your class:
Milter.factory = MilterSysUser
#Milter.set_flags(Milter.ADDHDRS) # we only need to add a header
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
Milter.runmilter("pythonfilter", socketname, timeout)
# Wait for logger to complete
logq.put(None)
bt.join()
print "%s milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
示例2: macromilterSUT
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def macromilterSUT(request):
macromilter.LOG_DIR = 'test_output/'
macromilter.MATCHED_FILE_LOG_DIR = 'test_output/matched_files/'
macromilter.initialize_async_process_queues(20)
macromilter.cleanup_queues()
Milter.factory = macromilter.MacroMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags)
Milter.factory._ctx = TestBase()
sut = macromilter.MacroMilter()
sut.messageToParse = StringIO.StringIO()
def tear_down():
# clear queues
macromilter.cleanup_queues()
macromilter.WhiteList = ()
request.addfinalizer(tear_down)
return sut
示例3: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
# banner
print('mraptor_milter v%s - http://decalage.info/python/oletools' % __version__)
print('logging to file %s' % LOGFILE_PATH)
print('Press Ctrl+C to stop.')
# make sure the log directory exists:
try:
os.makedirs(LOGFILE_DIR)
except:
pass
# Add the log message handler to the logger
# log to files rotating once a day:
handler = logging.handlers.TimedRotatingFileHandler(LOGFILE_PATH, when='D', encoding='utf8')
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(levelname)8s: %(message)s')
handler.setFormatter(formatter)
log.addHandler(handler)
# enable logging:
log.setLevel(logging.DEBUG)
log.info('Starting mraptor_milter v%s - listening on %s' % (__version__, SOCKET))
log.debug('Python version: %s' % sys.version)
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroRaptorMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("mraptor_milter", SOCKET, TIMEOUT)
log.info('Stopping mraptor_milter.')
示例4: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
# Load the whitelist into memory
WhiteListLoad()
HashTableLoad()
thread_pool = create_and_start_worker_threads()
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# start milter processing
print "%s Macro milter startup - Version %s" % (time.strftime('%d.%b.%Y %H:%M:%S'), __version__)
sys.stdout.flush()
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("MacroMilter", SOCKET, TIMEOUT)
shutdown_worker_threads(thread_pool)
cleanup_queues()
print "%s Macro milter shutdown" % time.strftime('%d.%b.%Y %H:%M:%S')
示例5: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
bt = Thread()
bt.start()
timeout = 60
# Register with Milter factory
Milter.factory = pgpMilter
# we don't modify mails, so no flags
Milter.set_flags(0)
Milter.runmilter("pgpmilter",socket,timeout)
bt.join()
示例6: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
os.umask(007)
Milter.set_flags( Milter.QUARANTINE
+ Milter.CHGHDRS
+ Milter.DELRCPT
+ Milter.ADDRCPT
+ Milter.CHGFROM)
config = getConfig()
def instantiate():
return DMARCMilter(config)
Milter.factory = instantiate
Milter.runmilter("dmarc_milter", config.socket, config.timeout)
示例7: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
bt = Thread(target=background)
bt.start()
socketname = "/home/stuart/pythonsock"
timeout = 600
Milter.factory = myMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags)
print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,timeout)
logq.put(None)
bt.join()
print "%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
示例8: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
# Load the whitelist into memory
WhiteListLoad()
HashTableLoad()
# create helper threads
bt = Thread(target=background)
perft = Thread(target=writeperformacedata)
ha = Thread(target=writehashtofile)
ex = Thread(target=writeExData)
# start helper threads
ex.start()
perft.start()
bt.start()
ha.start()
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# start milter processing
print "%s Macro milter startup - Version %s" % (time.strftime('%d.%b.%Y %H:%M:%S'), __version__)
sys.stdout.flush()
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("MacroMilter",SOCKET,TIMEOUT)
# wait for helper threads
bt.join() # stop logging thread
perft.join() # stop performance data thread
ha.join() # stop hash data thread
ex.join() # stop filename thread - obsolete - delete in next version
# cleanup the queues
logq.put(None)
extension_data.put(None)
hash_to_write.put(None)
performace_data.put(None)
print "%s Macro milter shutdown" % time.strftime('%d.%b.%Y %H:%M:%S')
示例9: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
bt = Thread(target=background)
bt.start()
socketname = "/home/stuart/pythonsock"
timeout = 600
# Register to have the Milter factory create instances of your class:
Milter.factory = myMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,timeout)
logq.put(None)
bt.join()
print("%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
示例10: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
# TODO: log to file with rotation
logging.basicConfig(format='%(levelname)8s: %(message)s', level=logging.DEBUG)
logging.info('Starting MacroRaptorMilter - listening on %s' % SOCKET)
logging.info('Press Ctrl+C to stop.')
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroRaptorMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("MacroRaptorMilter", SOCKET, TIMEOUT)
logging.info('Stopping MacroRaptorMilter.')
示例11: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
#TODO parse command line
# read configuration
cfgfile = "/etc/gnupg-milter.conf"
conf = gpgmilter.config.Config(cfgfile)
conf.init_config(cfgfile)
# Register to have the Milter factory create instances of your class:
Milter.factory = gpgmilter.GnupgMilter.gpgm_get_factory(conf=conf)
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags)
print("%s gnupg-milter startup" % time.strftime('%Y-%m-%d %H:%M:%S'))
sys.stdout.flush()
Milter.runmilter("gnupg-milter", config.socket, config.timeout)
print("%s gnupg-milter shutdown" % time.strftime('%Y-%m-%d %H:%M:%S'))
示例12: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def main():
syslog('Starting daemon')
try:
args = parseArgs()
with PidFile(args.pidfile) as pidfile:
def createMilter():
return EncryptionMilter(args.keyring)
Milter.factory = createMilter
flags = Milter.CHGBODY
Milter.set_flags(flags)
Milter.runmilter('encryption-milter', args.socket, 600)
except Exception as e:
syslog('An error occured')
syslog(str(e))
syslog('Shutting down daemon')
示例13: execute
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
def execute():
log_manager = LogManager(log_queue)
log_manager.start()
postgre_manager = PostgreManager(postgresql_creds, postgre_queue, log_queue)
postgre_manager.start()
Milter.factory = QueuedS3Milter
Milter.set_flags(Milter.MODBODY)
log_queue.put({
'type': 'info',
'message': log_config.log_success(module_name=__name__, function_name='execute',
msg='S3 Milter service launched.')
})
Milter.runmilter('S3Milter', milter_params['socket_name'], milter_params['timeout'])
log_queue.put({
'type': 'info',
'message': log_config.log_success(module_name=__name__, function_name='execute',
msg='S3 Milter service shutdown.')
})
postgre_queue.put(None)
postgre_manager.join()
log_queue.put(None)
log_manager.join()
示例14: print
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
if (__name__ == "__main__"):
os.umask(0o002)
if (len(sys.argv) != 2):
print('Usage: %s MODE' % sys.argv[0])
print('Where MODE is smtpd or nonsmtpd')
exit(1)
if (sys.argv[1] not in ['smtpd', 'nonsmtpd']):
print('%s is not a valid mode' % sys.argv[1])
exit(1)
mode = sys.argv[1]
Milter.factory = SandboxMilter
Milter.set_flags(Milter.ADDRCPT + Milter.DELRCPT)
config = ConfigParser.SafeConfigParser()
config.read('/etc/sandbox_milter/sandbox_milter.cfg')
milter_section = mode + "_milter"
socket = config.get(milter_section, 'socket')
name = config.get(milter_section, 'socket')
# Initialize logging
logger = logging.getLogger('')
if (config.getboolean('sandbox', 'log_debug')):
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
示例15: close
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_flags [as 别名]
return Milter.TEMPFAIL
def close(self):
sys.stdout.flush() # make log messages visible
if self.tempname:
os.remove(self.tempname) # remove in case session aborted
if self.fp:
self.fp.close()
return Milter.CONTINUE
def abort(self):
self.log("abort after %d body chars" % self.bodysize)
return Milter.CONTINUE
if __name__ == "__main__":
#tempfile.tempdir = "/var/log/milter"
#socketname = "/var/log/milter/pythonsock"
socketname = os.getenv("HOME") + "/pythonsock"
Milter.factory = sampleMilter
Milter.set_flags(Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS)
print("""To use this with sendmail, add the following to sendmail.cf:
O InputMailFilters=pythonfilter
Xpythonfilter, S=local:%s
See the sendmail README for libmilter.
sample milter startup""" % socketname)
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,240)
print("sample milter shutdown")