aboutsummaryrefslogtreecommitdiffstats
path: root/main/fail2ban/0001-amend-to-f3dbc9dda10e52610e3de26f538b5581fd905505-ch.patch
blob: 831d7a48c538e89f4265a04ccff84b97957a8322 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From ef7aeba83a6fb936c4dca847a69140c5b22c8000 Mon Sep 17 00:00:00 2001
From: sebres <serg.brester@sebres.de>
Date: Fri, 7 Feb 2020 11:08:01 +0100
Subject: [PATCH] amend to f3dbc9dda10e52610e3de26f538b5581fd905505: change
 main thread-name back to `fail2ban-server`; implements new command line
 option `--pname` to specify it by start of server (default
 `fail2ban-server`); closes gh-2623 (revert change of main thread-name,
 because it can affect process-name too, so `pgrep` & co. may be confused)

(cherry picked from commit 3f489070646b363aa0374681fe910f05521cd247)
---
 fail2ban/client/fail2bancmdline.py | 3 ++-
 fail2ban/server/server.py          | 5 +++--
 man/fail2ban-client.1              | 3 +++
 man/fail2ban-server.1              | 3 +++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fail2ban/client/fail2bancmdline.py b/fail2ban/client/fail2bancmdline.py
index 1268ee9f..3c6bd0bf 100644
--- a/fail2ban/client/fail2bancmdline.py
+++ b/fail2ban/client/fail2bancmdline.py
@@ -97,6 +97,7 @@ class Fail2banCmdLine():
 		output("    -c <DIR>                configuration directory")
 		output("    -s <FILE>               socket path")
 		output("    -p <FILE>               pidfile path")
+		output("    --pname <NAME>          name of the process (main thread) to identify instance (default fail2ban-server)")
 		output("    --loglevel <LEVEL>      logging level")
 		output("    --logtarget <TARGET>    logging target, use file-name or stdout, stderr, syslog or sysout.")
 		output("    --syslogsocket auto|<FILE>")
@@ -185,7 +186,7 @@ class Fail2banCmdLine():
 			try:
 				cmdOpts = 'hc:s:p:xfbdtviqV'
 				cmdLongOpts = ['loglevel=', 'logtarget=', 'syslogsocket=', 'test', 'async',
-					'timeout=', 'str2sec=', 'help', 'version', 'dp', '--dump-pretty']
+					'pname=', 'timeout=', 'str2sec=', 'help', 'version', 'dp', '--dump-pretty']
 				optList, self._args = getopt.getopt(self._argv[1:], cmdOpts, cmdLongOpts)
 			except getopt.GetoptError:
 				self.dispUsage()
diff --git a/fail2ban/server/server.py b/fail2ban/server/server.py
index 15265822..417f4514 100644
--- a/fail2ban/server/server.py
+++ b/fail2ban/server/server.py
@@ -81,8 +81,6 @@ class Server:
 			'Linux': '/dev/log',
 		}
 		self.__prev_signals = {}
-		# replace real thread name with short process name (for top/ps/pstree or diagnostic):
-		prctl_set_th_name('f2b/server')
 
 	def __sigTERMhandler(self, signum, frame): # pragma: no cover - indirect tested
 		logSys.debug("Caught signal %d. Exiting", signum)
@@ -113,6 +111,9 @@ class Server:
 				logSys.error(err)
 				raise ServerInitializationError(err)
 			# We are daemon.
+
+		# replace main thread (and process) name to identify server (for top/ps/pstree or diagnostic):
+		prctl_set_th_name(conf.get("pname", "fail2ban-server"))
 		
 		# Set all logging parameters (or use default if not specified):
 		self.__verbose = conf.get("verbose", None)
diff --git a/man/fail2ban-client.1 b/man/fail2ban-client.1
index 745c080a..5727caf0 100644
--- a/man/fail2ban-client.1
+++ b/man/fail2ban-client.1
@@ -19,6 +19,9 @@ socket path
 \fB\-p\fR <FILE>
 pidfile path
 .TP
+\fB\-\-pname\fR <NAME>
+name of the process (main thread) to identify instance (default fail2ban\-server)
+.TP
 \fB\-\-loglevel\fR <LEVEL>
 logging level
 .TP
diff --git a/man/fail2ban-server.1 b/man/fail2ban-server.1
index 418b46dd..25c5ec96 100644
--- a/man/fail2ban-server.1
+++ b/man/fail2ban-server.1
@@ -19,6 +19,9 @@ socket path
 \fB\-p\fR <FILE>
 pidfile path
 .TP
+\fB\-\-pname\fR <NAME>
+name of the process (main thread) to identify instance (default fail2ban\-server)
+.TP
 \fB\-\-loglevel\fR <LEVEL>
 logging level
 .TP
-- 
2.20.1