Commit 77336123 authored by Ad Schellevis's avatar Ad Schellevis

(configd) ignore syslog on startup when not excepting connections, closes...

(configd) ignore syslog on startup when not excepting connections, closes https://github.com/opnsense/core/issues/853
parent 55aea0a6
...@@ -39,6 +39,7 @@ import sys ...@@ -39,6 +39,7 @@ import sys
import logging import logging
import signal import signal
import time import time
import socket
import subprocess import subprocess
import modules.processhandler import modules.processhandler
import modules.csconfigparser import modules.csconfigparser
...@@ -144,14 +145,17 @@ else: ...@@ -144,14 +145,17 @@ else:
# run as daemon, wrap the actual work process to enable automatic restart on sudden death # run as daemon, wrap the actual work process to enable automatic restart on sudden death
syslog_socket = "/var/run/log" syslog_socket = "/var/run/log"
if os.path.exists(syslog_socket): if os.path.exists(syslog_socket):
# bind log handle to syslog to catch messages from Daemonize() try:
# (if syslog facility is active) # bind log handle to syslog to catch messages from Daemonize()
loghandle = logging.getLogger("configd.py") # (if syslog facility is active)
loghandle.setLevel(logging.INFO) loghandle = logging.getLogger("configd.py")
handler = logging.handlers.SysLogHandler(address=syslog_socket, loghandle.setLevel(logging.INFO)
facility=logging.handlers.SysLogHandler.LOG_DAEMON) handler = logging.handlers.SysLogHandler(address=syslog_socket,
handler.setFormatter(logging.Formatter("%(name)s %(message)s")) facility=logging.handlers.SysLogHandler.LOG_DAEMON)
loghandle.addHandler(handler) handler.setFormatter(logging.Formatter("%(name)s %(message)s"))
loghandle.addHandler(handler)
except socket.error:
loghandle = None
else: else:
loghandle = None loghandle = None
# daemonize process # daemonize process
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment