mirror of https://github.com/fail2ban/fail2ban
amend to 91eca4fdeb
(#2634): server creates a RTM-directory for socket/pid file automatically (don't check its existence in client)
parent
253d47d33c
commit
a7ad3e00dd
|
@ -168,19 +168,6 @@ class Fail2banClient(Fail2banCmdLine, Thread):
|
||||||
if not ret:
|
if not ret:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# verify that directory for the socket file exists
|
|
||||||
socket_dir = os.path.dirname(self._conf["socket"])
|
|
||||||
if not os.path.exists(socket_dir):
|
|
||||||
logSys.error(
|
|
||||||
"There is no directory %s to contain the socket file %s."
|
|
||||||
% (socket_dir, self._conf["socket"]))
|
|
||||||
return None
|
|
||||||
if not os.access(socket_dir, os.W_OK | os.X_OK): # pragma: no cover
|
|
||||||
logSys.error(
|
|
||||||
"Directory %s exists but not accessible for writing"
|
|
||||||
% (socket_dir,))
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Check already running
|
# Check already running
|
||||||
if not self._conf["force"] and os.path.exists(self._conf["socket"]):
|
if not self._conf["force"] and os.path.exists(self._conf["socket"]):
|
||||||
logSys.error("Fail2ban seems to be in unexpected state (not running but the socket exists)")
|
logSys.error("Fail2ban seems to be in unexpected state (not running but the socket exists)")
|
||||||
|
|
|
@ -623,12 +623,6 @@ class Fail2banClientTest(Fail2banClientServerBase):
|
||||||
self.assertLogged("Base configuration directory " + pjoin(tmp, "miss") + " does not exist")
|
self.assertLogged("Base configuration directory " + pjoin(tmp, "miss") + " does not exist")
|
||||||
self.pruneLog()
|
self.pruneLog()
|
||||||
|
|
||||||
## wrong socket
|
|
||||||
self.execCmd(FAILED, (),
|
|
||||||
"--async", "-c", pjoin(tmp, "config"), "-s", pjoin(tmp, "miss/f2b.sock"), "start")
|
|
||||||
self.assertLogged("There is no directory " + pjoin(tmp, "miss") + " to contain the socket file")
|
|
||||||
self.pruneLog()
|
|
||||||
|
|
||||||
## not running
|
## not running
|
||||||
self.execCmd(FAILED, (),
|
self.execCmd(FAILED, (),
|
||||||
"-c", pjoin(tmp, "config"), "-s", pjoin(tmp, "f2b.sock"), "reload")
|
"-c", pjoin(tmp, "config"), "-s", pjoin(tmp, "f2b.sock"), "reload")
|
||||||
|
@ -724,12 +718,6 @@ class Fail2banServerTest(Fail2banClientServerBase):
|
||||||
self.assertLogged("Base configuration directory " + pjoin(tmp, "miss") + " does not exist")
|
self.assertLogged("Base configuration directory " + pjoin(tmp, "miss") + " does not exist")
|
||||||
self.pruneLog()
|
self.pruneLog()
|
||||||
|
|
||||||
## wrong socket
|
|
||||||
self.execCmd(FAILED, (),
|
|
||||||
"-c", pjoin(tmp, "config"), "-x", "-s", pjoin(tmp, "miss/f2b.sock"))
|
|
||||||
self.assertLogged("There is no directory " + pjoin(tmp, "miss") + " to contain the socket file")
|
|
||||||
self.pruneLog()
|
|
||||||
|
|
||||||
## already exists:
|
## already exists:
|
||||||
open(pjoin(tmp, "f2b.sock"), 'a').close()
|
open(pjoin(tmp, "f2b.sock"), 'a').close()
|
||||||
self.execCmd(FAILED, (),
|
self.execCmd(FAILED, (),
|
||||||
|
|
Loading…
Reference in New Issue