From michael at highpoweredhelp.com Thu Jun 22 18:15:16 2017 From: michael at highpoweredhelp.com (Michael Munger) Date: Thu, 22 Jun 2017 18:15:16 -0400 Subject: [Pymilter] Milter as a daemon? Message-ID: I have written a milter that works when run from the command line (directly). I was refactoring it to be a python-daemon compatible daemon for this mail server, but I have hit a snag: When the daemon starts, the script loads into the daemon context and runs; however, when it gets to Milter.runmilter("pythonfilter",socketname,timeout), execution seems to stop. The service is still running, and the process is alive, but it doesn't process mail. Additionally, syslog and mail.log shows this error, which tells me the socket is not listening /reading / writing correctly: syslog: Jun 22 18:13:10 d8 mcdb_mailcache.py: pythonfilter: st_optionneg[0]: xxfi_negotiate returned 1 (protocol options=0x1fffff, actions=0x1ff) mail.log: Jun 22 18:13:10 d8 postfix/smtpd[22936]: warning: milter local:/var/run/mcdbcache/mcdb.sock: can't read SMFIC_OPTNEG reply packet header: Success Jun 22 18:13:10 d8 postfix/smtpd[22936]: warning: milter local:/var/run/mcdbcache/mcdb.sock: read error in initial handshake My suspicion is that it's because the socket is dead and the milter code is not actually running. I cannot figure out where the next path in the code execution is. I think we just hand it off to libmilter, but not sure. I am 99.9% done with this little project, and if I can just get this thing to run as a daemon, there will be much rejoicing. ...as it is, there is only gnashing of teeth. Thanks in advance... -- Michael Munger, dCAP, MCPS, MCNPS, MBSS High Powered Help, Inc. Microsoft Certified Professional Microsoft Certified Small Business Specialist Digium Certified Asterisk Professional michael at highpoweredhelp.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart at gathman.org Thu Jun 22 18:51:26 2017 From: stuart at gathman.org (Stuart Gathman) Date: Thu, 22 Jun 2017 18:51:26 -0400 Subject: [Pymilter] Milter as a daemon? In-Reply-To: References: Message-ID: On 06/22/2017 06:15 PM, Michael Munger wrote: > I have written a milter that works when run from the command line > (directly). I was refactoring it to be a python-daemon compatible > daemon for this mail server, but I have hit a snag: > .... > > I cannot figure out where the next path in the code execution is. I > think we just hand it off to libmilter, but not sure. I am 99.9% done > with this little project, and if I can just get this thing to run as a > daemon, there will be much rejoicing. Milter.runmilter() does indeed hand off to libmilter, and will not return until shutdown. I'm not sure what python-daemon does, but it may be incompatible with libmilter. If your milter runs started by hand, then just use daemon to start it: daemon --check ${prog} --pidfile "${piddir}/${prog}.pid" --user mail \ daemonize -a -e "${logdir}/${prog}.log" -o "${logdir}/${prog}.log" \ -c "${workdir}" -p "${piddir}/${prog}.pid" \ /usr/bin/${python} ${script}.py Is this for systemd or sysvinit ?