Browse code

fail2ban: new addition

Introduced following required packages for fail2ban:
- whois
- python3-systemd

Change-Id: Ibb3862d8091bfcb97532948d77b3475fa2ca6c8c
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/19818
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Shreenidhi Shedi <sshedi@vmware.com>

Nitesh Kumar authored on 2023/02/25 00:39:47
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,6 @@
0
+# This file is part of the fail2ban-systemd package to configure the use of
1
+# the systemd journal as the default backend.  You can remove this package
2
+# (along with the empty fail2ban meta-package) if you do not want to use the
3
+# journal backend
4
+[DEFAULT]
5
+backend=systemd
0 6
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+From bfe0ca44db431d20ac2d155b6af1d0b9c431d4ac Mon Sep 17 00:00:00 2001
1
+From: Nitesh Kumar <kunitesh@vmware.com>
2
+Date: Wed, 15 Feb 2023 14:16:54 +0530
3
+Subject: [PATCH] Replace 2to3 binary name with 2to3-3.10
4
+
5
+---
6
+ fail2ban-2to3 | 2 +-
7
+ 1 file changed, 1 insertion(+), 1 deletion(-)
8
+
9
+diff --git a/fail2ban-2to3 b/fail2ban-2to3
10
+index 2015ed5..c8d955d 100755
11
+--- a/fail2ban-2to3
12
+@@ -5,7 +5,7 @@
13
+ 
14
+ set -eu
15
+ 
16
+-if 2to3 -w --no-diffs bin/* fail2ban;then
17
++if 2to3-3.11 -w --no-diffs bin/* fail2ban;then
18
+   echo "Success!" >&2
19
+   exit 0
20
+ else
21
+-- 
22
+2.17.1
23
+
0 24
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+From a71a22c075c306d3ff252bf879ede69cc5e25477 Mon Sep 17 00:00:00 2001
1
+From: Nitesh Kumar <kunitesh@vmware.com>
2
+Date: Mon, 13 Feb 2023 22:51:58 +0530
3
+Subject: [PATCH] Set proper config path in include section
4
+
5
+---
6
+ config/jail.conf | 3 ++-
7
+ 1 file changed, 2 insertions(+), 1 deletion(-)
8
+
9
+diff --git a/config/jail.conf b/config/jail.conf
10
+index fe8db52..ae06348 100644
11
+--- a/config/jail.conf
12
+@@ -33,7 +33,8 @@
13
+ [INCLUDES]
14
+ 
15
+ #before = paths-distro.conf
16
+-before = paths-debian.conf
17
++#before = paths-debian.conf
18
++before = paths-common.conf
19
+ 
20
+ # The DEFAULT allows a global definition of the options. They can be overridden
21
+ # in each jail afterwards.
22
+-- 
23
+2.17.1
24
+
0 25
new file mode 100644
... ...
@@ -0,0 +1,220 @@
0
+Summary:        Daemon to ban hosts that cause multiple authentication errors
1
+Name:           fail2ban
2
+Version:        1.0.2
3
+Release:        1%{?dist}
4
+License:        GPLv2+
5
+Group:          Productivity/Networking/Security
6
+Vendor:         VMware, Inc.
7
+Distribution:   Photon
8
+URL:            http://fail2ban.sourceforge.net
9
+
10
+Source0: https://github.com/%{name}/%{name}/archive/refs/tags/%{name}-%{version}.tar.gz
11
+%define sha512 %{name}=688a84361b5794e1658f53d2d200ce752fe1e3320ddb1742c32c4b4b82a79ace16ae464e7ea3eeb94a0e862bcac73c2d3a0e61dd7b28e179a4c857f950d74dbb
12
+
13
+Source1: 00-fail2ban-systemd.conf
14
+
15
+Patch0: 0001-Set-proper-config-path-in-include-section.patch
16
+Patch1: 0001-Replace-2to3-binary-name-with-2to3-3.11.patch
17
+
18
+BuildArch: noarch
19
+
20
+BuildRequires: python3-devel
21
+BuildRequires: python3-setuptools
22
+BuildRequires: python3-tools
23
+BuildRequires: sqlite-devel
24
+BuildRequires: systemd-devel
25
+
26
+%if 0%{?with_check}
27
+BuildRequires: python3-systemd
28
+%endif
29
+
30
+Requires: systemd
31
+Requires: python3-systemd
32
+Requires: nftables
33
+Requires: perl
34
+Requires: whois
35
+Requires(post): systemd
36
+Requires(preun): systemd
37
+Requires(postun): systemd
38
+
39
+# Default components
40
+Requires: %{name} = %{version}-%{release}
41
+Requires: %{name}-sendmail = %{version}-%{release}
42
+Requires: %{name}-systemd = %{version}-%{release}
43
+
44
+%description
45
+Fail2Ban scans log files and bans IP addresses that makes too many password
46
+failures. It updates firewall rules to reject the IP address. These rules can
47
+be defined by the user. Fail2Ban can read multiple log files such as sshd or
48
+Apache web server ones.
49
+
50
+The main package contains the core server components for Fail2Ban with minimal
51
+dependencies.  You can install this directly if you want to have a small
52
+installation and know what you are doing.
53
+
54
+%package hostsdeny
55
+Summary:  Hostsdeny (tcp_wrappers) support for Fail2Ban
56
+Group:    Productivity/Networking/Security
57
+Requires: %{name} = %{version}-%{release}
58
+Requires: ed
59
+Requires: tcp_wrappers
60
+
61
+%description hostsdeny
62
+This package enables support for manipulating tcp_wrapper's /etc/hosts.deny
63
+files.
64
+
65
+%package devel
66
+Summary:  Fail2Ban testcases
67
+Group:    Productivity/Networking/Security
68
+Requires: %{name} = %{version}-%{release}
69
+
70
+%description devel
71
+This package contains Fail2Ban's testscases and scripts.
72
+
73
+%package mail
74
+Summary:  Mail actions for Fail2Ban
75
+Group:    Productivity/Networking/Security
76
+Requires: %{name} = %{version}-%{release}
77
+Requires: sendmail
78
+
79
+%description mail
80
+This package installs Fail2Ban's mail actions.  These are an alternative
81
+to the default sendmail actions.
82
+
83
+%package sendmail
84
+Summary:  Sendmail actions for Fail2Ban
85
+Group:    Productivity/Networking/Security
86
+Requires: %{name} = %{version}-%{release}
87
+Requires: sendmail
88
+
89
+%description sendmail
90
+This package installs Fail2Ban's sendmail actions.  This is the default
91
+mail actions for Fail2Ban.
92
+
93
+%package systemd
94
+Summary:  Systemd journal configuration for Fail2Ban
95
+Group:    Productivity/Networking/Security
96
+Requires: %{name} = %{version}-%{release}
97
+
98
+%description systemd
99
+This package configures Fail2Ban to use the systemd journal for its log input
100
+by default.
101
+
102
+%prep
103
+%autosetup -p1
104
+
105
+%build
106
+bash ./%{name}-2to3
107
+%{py3_build}
108
+
109
+%install
110
+%{py3_install}
111
+ln -sfv python3 %{buildroot}%{_bindir}/%{name}-python
112
+
113
+mkdir -p %{buildroot}%{_unitdir} \
114
+         %{buildroot}%{_tmpfilesdir} \
115
+         %{buildroot}%{_mandir}/man{1,5} \
116
+         %{buildroot}%{_sysconfdir}/logrotate.d
117
+
118
+cp -p build/%{name}.service %{buildroot}%{_unitdir}
119
+
120
+install -p -m 644 man/*.1 %{buildroot}%{_mandir}/man1
121
+install -p -m 644 man/*.5 %{buildroot}%{_mandir}/man5
122
+install -p -m 644 files/%{name}-logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
123
+install -d -m 0755 %{buildroot}/run/%{name}/
124
+install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name}/
125
+install -p -m 0644 files/%{name}-tmpfiles.conf %{buildroot}%{_tmpfilesdir}/%{name}.conf
126
+
127
+# Remove non-Linux actions, config files for other distros, installed doc
128
+rm -rf %{buildroot}%{_sysconfdir}/%{name}/action.d/*ipfw.conf \
129
+       %{buildroot}%{_sysconfdir}/%{name}/action.d/{ipfilter,pf,ufw}.conf \
130
+       %{buildroot}%{_sysconfdir}/%{name}/action.d/osx-*.conf \
131
+       %{buildroot}%{_sysconfdir}/%{name}/paths-{arch,debian,freebsd,opensuse,osx}.conf \
132
+       %{buildroot}%{_docdir}/%{name}
133
+
134
+# systemd journal configuration
135
+cp -p %{SOURCE1} %{buildroot}%{_sysconfdir}/%{name}/jail.d/
136
+
137
+%if 0%{?with_check}
138
+%check
139
+%{python3} bin/%{name}-testcases --verbosity=2 --no-network
140
+%endif
141
+
142
+%post
143
+%systemd_post %{name}.service
144
+
145
+%preun
146
+%systemd_preun %{name}.service
147
+
148
+%postun
149
+%systemd_postun_with_restart %{name}.service
150
+
151
+%clean
152
+rm -rf %{buildroot}
153
+
154
+%files
155
+%defattr(-,root,root)
156
+%{_bindir}/%{name}-client
157
+%{_bindir}/%{name}-python
158
+%{_bindir}/%{name}-regex
159
+%{_bindir}/%{name}-server
160
+%{python3_sitelib}/*
161
+%exclude %{python3_sitelib}/%{name}/tests
162
+%{_unitdir}/%{name}.service
163
+%{_mandir}/man1/%{name}.1*
164
+%{_mandir}/man1/%{name}-client.1*
165
+%{_mandir}/man1/%{name}-python.1*
166
+%{_mandir}/man1/%{name}-regex.1*
167
+%{_mandir}/man1/%{name}-server.1*
168
+%{_mandir}/man5/*.5*
169
+%config(noreplace) %{_sysconfdir}/%{name}/filter.d/*.conf
170
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/*.conf
171
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/smtp.py
172
+%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
173
+%config(noreplace) %{_sysconfdir}/%{name}/filter.d/ignorecommands/apache-fakegooglebot
174
+%config(noreplace) %{_sysconfdir}/%{name}/jail.conf
175
+%config(noreplace) %{_sysconfdir}/%{name}/paths-*.conf
176
+%exclude %{_sysconfdir}/%{name}/filter.d/sendmail-*.conf
177
+%exclude %{_sysconfdir}/%{name}/action.d/complain.conf
178
+%exclude %{_sysconfdir}/%{name}/action.d/hostsdeny.conf
179
+%exclude %{_sysconfdir}/%{name}/action.d/mail.conf
180
+%exclude %{_sysconfdir}/%{name}/action.d/mail-buffered.conf
181
+%exclude %{_sysconfdir}/%{name}/action.d/mail-whois.conf
182
+%exclude %{_sysconfdir}/%{name}/action.d/mail-whois-lines.conf
183
+%exclude %{_sysconfdir}/%{name}/action.d/sendmail-*.conf
184
+%exclude %{_sysconfdir}/%{name}/jail.d/*.conf
185
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
186
+%{_tmpfilesdir}/%{name}.conf
187
+%dir %{_sharedstatedir}/%{name}
188
+%dir /run/%{name}/
189
+
190
+%files hostsdeny
191
+%defattr(-,root,root)
192
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/hostsdeny.conf
193
+
194
+%files devel
195
+%defattr(-,root,root)
196
+%{_bindir}/%{name}-testcases
197
+%{_mandir}/man1/%{name}-testcases.1*
198
+%{python3_sitelib}/%{name}/tests
199
+
200
+%files mail
201
+%defattr(-,root,root)
202
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/complain.conf
203
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/mail.conf
204
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/mail-buffered.conf
205
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/mail-whois.conf
206
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/mail-whois-lines.conf
207
+
208
+%files sendmail
209
+%defattr(-,root,root)
210
+%config(noreplace) %{_sysconfdir}/%{name}/action.d/sendmail-*.conf
211
+%config(noreplace) %{_sysconfdir}/%{name}/filter.d/sendmail-*.conf
212
+
213
+%files systemd
214
+%defattr(-,root,root)
215
+%config(noreplace) %{_sysconfdir}/%{name}/jail.d/00-%{name}-systemd.conf
216
+
217
+%changelog
218
+* Tue Feb 14 2023 Nitesh Kumar <kunitesh@vmware.com> 1.0.2-1
219
+- Initial version
0 220
new file mode 100644
... ...
@@ -0,0 +1,56 @@
0
+%global srcname  python-systemd
1
+
2
+Summary:       Python module wrapping libsystemd functionality
3
+Name:          python3-systemd
4
+Version:       235
5
+Release:       1%{?dist}
6
+License:       LGPLv2+
7
+URL:           https://github.com/systemd/python-systemd
8
+Group:         Development/Languages/Python
9
+Vendor:        VMware, Inc.
10
+Distribution:  Photon
11
+
12
+Source0: https://github.com/systemd/%{srcname}/archive/refs/tags/%{srcname}-%{version}.tar.gz
13
+%define sha512 %{srcname}=f1286a477200cc7b4d2c44b43452da576e8e660925711466659795775bcee44796688e1ede6cc22e61cb5b03e631c396d22f9a133327ae1147506bce09bab47f
14
+
15
+BuildRequires: systemd-devel
16
+BuildRequires: python3-devel
17
+BuildRequires: python3-setuptools
18
+
19
+%if 0%{?with_check}
20
+BuildRequires: python3-pytest
21
+%endif
22
+
23
+Requires: systemd-libs
24
+
25
+%description
26
+Python module for native access to the libsystemd facilities. Functionality
27
+includes sending of structured messages to the journal and reading journal
28
+files, querying machine and boot identifiers and a lists of message identifiers
29
+provided by systemd. Other functionality provided the library is also wrapped.
30
+
31
+%prep
32
+%autosetup -p1 -n %{srcname}-%{version}
33
+
34
+%build
35
+%{py3_build}
36
+
37
+%install
38
+%{py3_install}
39
+
40
+%if 0%{?with_check}
41
+%check
42
+make %{?_smp_mflags} check
43
+%endif
44
+
45
+%clean
46
+rm -rf %{buildroot}
47
+
48
+%files
49
+%defattr(-,root,root)
50
+%{python3_sitearch}/systemd/
51
+%{python3_sitearch}/systemd_python*.egg-info
52
+
53
+%changelog
54
+* Tue Feb 14 2023 Nitesh Kumar <kunitesh@vmware.com> 235-1
55
+- Initial build
... ...
@@ -4,7 +4,7 @@
4 4
 
5 5
 Name:           toybox
6 6
 Version:        0.8.8
7
-Release:        2%{?dist}
7
+Release:        3%{?dist}
8 8
 License:        BSD
9 9
 Summary:        Common Linux command line utilities in a single executable
10 10
 Url:            http://landley.net/toybox
... ...
@@ -12,13 +12,13 @@ Group:          Applications/System
12 12
 Vendor:         VMware, Inc.
13 13
 Distribution:   Photon
14 14
 
15
-Source0:        http://landley.net/toybox/downloads/%{name}-%{version}.tar.gz
15
+Source0: http://landley.net/toybox/downloads/%{name}-%{version}.tar.gz
16 16
 %define sha512  %{name}=3ffe4de6b17770ad9c43f98f2c69a110f94e5a85da909f8f770bbc9abaff42a524237b4ffaaa8b9800c8d31f0a8b6d3521f03bfdd0d1260fa421ef2525a34290
17 17
 
18
-Patch0:         %{name}-change-toys-path.patch
18
+Patch0: %{name}-change-toys-path.patch
19 19
 
20
-Source1:        config-%{name}
21
-Source2:        %{name}-toys
20
+Source1: config-%{name}
21
+Source2: %{name}-toys
22 22
 
23 23
 BuildRequires:  openssl-devel
24 24
 BuildRequires:  zlib-devel
... ...
@@ -43,7 +43,7 @@ Requires:   %{name} = %{version}-%{release}
43 43
 The package contains %{name} doc files.
44 44
 
45 45
 %prep
46
-%autosetup -p1 -n %{name}-%{version}
46
+%autosetup -p1
47 47
 
48 48
 %build
49 49
 cp %{SOURCE1} .config
... ...
@@ -279,6 +279,11 @@ mktoy %{_bindir}/mix
279 279
 %{_mktoy_}
280 280
 mktoy %{_bindir}/mkpasswd
281 281
 
282
+%triggerpostun -- mkpasswd
283
+[ $2 -eq 0 ] || exit 0
284
+%{_mktoy_}
285
+mktoy /usr/bin/mkpasswd
286
+
282 287
 %triggerpostun -- e2fsprogs
283 288
 [ $2 -eq 0 ] || exit 0
284 289
 %{_mktoy_}
... ...
@@ -543,7 +548,7 @@ mktoy %{_bindir}/which
543 543
 # elixir
544 544
 %ghost %{_bindir}/mix
545 545
 
546
-# expect
546
+# expect & mkpasswd
547 547
 %ghost %{_bindir}/mkpasswd
548 548
 
549 549
 # e2fsprogs
... ...
@@ -702,6 +707,8 @@ mktoy %{_bindir}/which
702 702
 %doc README LICENSE
703 703
 
704 704
 %changelog
705
+* Fri Feb 17 2023 Shreenidhi Shedi <sshedi@vmware.com> 0.8.8-3
706
+- Add rules for mkpasswd
705 707
 * Fri Jan 27 2023 Shreenidhi Shedi <sshedi@vmware.com> 0.8.8-2
706 708
 - Fix triggers
707 709
 * Sun Aug 21 2022 Vamsi Krishna Brahmajosyula <vbrahmajosyula@vmware.com> 0.8.8-1
708 710
new file mode 100644
... ...
@@ -0,0 +1,73 @@
0
+Summary:      Improved WHOIS client
1
+Name:         whois
2
+Version:      5.5.15
3
+Release:      1%{?dist}
4
+License:      GPLv2+
5
+URL:          https://github.com/rfc1036/whois
6
+Group:        Productivity/Networking/Other
7
+Vendor:       VMware, Inc.
8
+Distribution: Photon
9
+
10
+Source0: https://ftp.debian.org/debian/pool/main/w/%{name}/%{name}_%{version}.tar.xz
11
+%define sha512 %{name}=e173927fd3428d27bc8ab34b1a66b82d6a2cfc107245755868bdd33cb7eb1b8159e87774c3a751d9694e65b3d870b9904dc9a3c657dca385950c8a19be1fa61c
12
+
13
+BuildRequires:  pkg-config
14
+BuildRequires:  xz-devel
15
+BuildRequires:  make
16
+BuildRequires:  perl
17
+BuildRequires:  openssl-devel
18
+
19
+%description
20
+Searches for an object in a RFC 3912 database.
21
+
22
+This version of the WHOIS client tries to guess the right server to ask for
23
+the specified object. If no guess can be made it will connect to
24
+whois.networksolutions.com for NIC handles or whois.arin.net for IPv4
25
+addresses and network names.
26
+
27
+%package nls
28
+Summary:    Gettext catalogs for whois tools
29
+BuildArch:  noarch
30
+
31
+%description nls
32
+whois tools messages translated into different natural languages.
33
+
34
+%package -n mkpasswd
35
+Summary:   Encrypt a password with crypt(3) function using a salt
36
+Requires:  openssl
37
+Conflicts: expect
38
+
39
+%description -n mkpasswd
40
+mkpasswd tool encrypts a given password with the crypt(3) libc function
41
+using a given salt.
42
+
43
+%prep
44
+%autosetup -p1 -n %{name}
45
+
46
+%build
47
+%make_build HAVE_LIBIDN2=1 \
48
+            HAVE_ICONV=1 \
49
+            HAVE_CRYPT_GENSALT=1
50
+
51
+%install
52
+%make_install %{?_smp_mflags}
53
+
54
+%find_lang %{name}
55
+
56
+%files
57
+%defattr(-,root,root)
58
+%{_bindir}/whois
59
+%{_mandir}/man1/%{name}.*
60
+%{_mandir}/man5/%{name}.*
61
+
62
+%files nls -f %{name}.lang
63
+%defattr(-,root,root)
64
+
65
+%files -n mkpasswd
66
+%defattr(-,root,root)
67
+%{_bindir}/mkpasswd
68
+%{_mandir}/man1/mkpasswd.*
69
+
70
+%changelog
71
+* Tue Feb 14 2023 Nitesh Kumar <kunitesh@vmware.com> 5.5.15-1
72
+- Initial version, needed by fail2ban.