2901 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
4769c1c861
ssh: Update existing setups to add sudo group to allowed SSH groups
Tests:

- On a setup with the patch, disable and re-enable the restricted users feature.
sudo is not part of allowed users. Apply the patch and restart the service. SSH
app will be updated and sudo is added to SSH allowed groups.

- Add a fresh unprivileged user to sudo group. SSH using that user to the
system.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2023-01-13 07:52:02 -08:00
James Valleroy
09d8ee1b8e
ssh: Add sudo to allowed groups
This is to allow vagrant user to login, as well as a normal sudo user
that was created before installing FreedomBox.

For most FreedomBoxes, the sudo group is empty, so it will have no
impact.

I do not update the existing file. But if someone needs this update,
they can disable and then re-enable the restrict option.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2023-01-13 07:41:49 -08:00
James Valleroy
695138d4d6 upgrades: Stop quassel during dist upgrade
Fixes: #2098.

Tests:

- Install quassel in bullseye system.

- Start dist upgrade. Check that quassel service is stopped during the
  dist upgrade.

- Finish dist upgrade. Quassel service is running again.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2023-01-13 07:35:05 -08:00
nbenedek
863afa34ce
tor: Add onion location to apache
- When hidden service is enabled create and enable an apache site with the
proper configurations. This will let visitors using the Tor browser that a
hidden version of the website is available.

- Disable apache site when hidden service is disabled

- Create a backup of the apache site

- Hidden service won't be advertised when the user visits mediawiki, wordpress
or tt-rss. These sites don't work (well) with a hidden service when a normal
domain is already set up.

Tests:

- Functional tests pass.

- With fresh install of Tor app, onion location header apache configuration is
enabled and header is served in HTTP requests.

- When Onion services are enabled/disabled, header is enabled/disabled due to
webserver configuration changes.

- When Tor app is enabled/disabled, header is enabled/disabled due to webserver
configuration being enabled/disabled.

- When Tor app is upgraded from earlier version while app is enabled, onion
service is enabled, Tor app remains enabled. Onion location is enabled.

- FAILED: When Tor app is upgraded from earlier version while app is enabled,
onion service is disabled, Tor app remains enabled. Onion location is disabled.

- FAILED: When Tor app is upgraded from earlier version while app is disabled,
onion service is enabled, Tor app remains disabled. Onion location is disabled.

- FAILED: When Tor app is upgraded from earlier version while app is disabled,
onion service is disabled, Tor app remains disabled. Onion location is disabled.

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Ensure that enabling/disabling app enables/disables onion location]
[sunil: Ensure that upgrading from old version does not enable the app]
[sunil: Ensure that upgrading from old version enables/disables onion location]
[sunil: Apache file should be a 'config' and not 'site']
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-01-02 22:11:36 -05:00
Sunil Mohan Adapa
2607fffd47
zoph: Add explicit dependency on default-mysql-server
This is to ensure that mysql server is not uninstalled when wordpress is
uninstalled.

Tests:

- Uninstalling zoph does not remove default-mysql-server when wordpress is
installed.

- Uninstalling wordpress does not remove default-mysql-server when zoph is
installed.

- Uninstalling both wordpress and zoph removes default-mysql-server.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-01-02 21:00:19 -05:00
Sunil Mohan Adapa
82104ccf84
email: Workaround an issue with error on finishing uninstall
Showing the uninstall progress page fails during uninstall of email app.
Workaround that by handling the errors raised. A better approach is to ensure
that the view is not processed when uninstall operation is in progress.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-01-02 21:00:00 -05:00
Veiko Aasa
b94e1ea596
gitweb: Run git commands as a web user
Fixes #2306.

Tested that all the gitweb tests pass in Debian stable and testing
containers.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-12-29 15:20:38 -08:00
James Valleroy
d3d7e233e3
janus: Allow upgrade to 1.1
Closes: #2303.

Tests:

- In testing container, install Janus.

- Downgrade janus package to 1.0.1-1.

- Manually re-run janus setup action.

- Run "apt update".

- janus is upgraded to 1.1.1-1, and rtp_port_range is set in
  /etc/janus/janus.jcfg.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-12-29 11:12:46 -08:00
James Valleroy
9736d426cb
wordpress: Redirect Webfinger queries
Needed by ActivityPub plugin.

Closes: #2257.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-19 11:34:33 -08:00
James Valleroy
331e6f33d8
upgrades: dist-upgrade: Don't change apt security line
This change was only needed for upgrade to bullseye.

Closes: #2302.

Tests:

- Run a dist upgrade in a bullseye vagrant box. Apt sources has
  expected content and apt-get does not produce an error.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-12-19 10:53:48 -08:00
Sunil Mohan Adapa
b056f5829c
zoph, wordpress: Add conflicts on libpam-tmpdir
Closes: #2239.

- Adding Conflicts in freedombox Debian package seems to cause
unattended-upgrade to not upgrade the package to next version. This approach
seems be an alternative.

Tests:

- Install libpam-tmpdir. Go to Zoph page, see that conflicts messages is shown.
Install succeeds. libpam-tmpdir is removed.

- Install libpam-tmpdir. Go to WordPress page, see that conflicts messages is
shown. Install succeeds. libpam-tmpdir is removed.

- Remove libpam-tmpdir. Go to Zoph page, see that conflicts message is not
shown. Install succeeds.

- Remove libpam-tmpdir. Go to WordPress page, see that conflicts message is not
shown. Install succeeds.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-18 17:30:30 -05:00
Sunil Mohan Adapa
0b9d567493
package, email: Move conflicting package removal to framework
- Warning that exim4 will be removed is incorrectly not shown during email app
installation. Fix that.

Tests:

- Unit tests pass.

- On a fresh testing container, trying to install email app shows the warning
message that exim will be removed. Installing the email app succeeds. exim is
removed during installation.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-18 17:30:27 -05:00
Sunil Mohan Adapa
bcb0823e7c
snapshot: Fix showing unsupported message on non-btrfs filesystems
This is a regression from commit 9b6774f279e2c8af588609c2413aa9804fd48cfa. When
change the view to use AppView, the condition to check for non-btrfs filesystems
and show an unsupported message instead of the actual view was accidentally
removed. Restore the check and show a different view when on non-btrfs
filesystems.

Fixes: #2268.

Tests:

- On non-btrfs filesystem, snapshots view is shown as expected.

- On ext4 filesystem, a message that snapshots are not supported is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-18 09:35:58 -05:00
Sunil Mohan Adapa
740609c339
minidlna: Fix incorrect marking for firewall local protection
MiniDLNA's TCP service has been incorrectly marked as needing to be protected
from local users. This leads to service not being accessible from local network.
Fix this by removing local protection.

As reported on https://discuss.freedombox.org/t/minidlna-on-22-26/2386

Tests:

- With MiniDLNA installed, apply the changes and restart service. 'nft list
ruleset ip', 'nft list ruleset ip6' and 'cat /etc/firewalld/direct.xml' confirm
that port 8200 is no longer protected as a local service.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-17 19:57:08 -05:00
Sunil Mohan Adapa
7e0b728498
users: tests: Fix privileged tests
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-16 10:40:01 -05:00
Sunil Mohan Adapa
253540fb3d
security: Remove restricted access setting and configuration
Closes: #2276.

Functionality all over the system keeps failing due this approach. The latest is
changing hostname in ejabberd Mnesia database fails (#2276). Further, users
connecting FreedomBox to a monitor can't use a GUI.

Tests:

- Without patches, enable restricted access. Apply patches and setup.py install.
Security app is updated. Restricted access is disabled and
/etc/security/access.d/{50freedombox.conf, 10freedombox-security.conf,
10freedombox-performance.conf} are removed. It is possible to login into
non-admin account via SSH.

- On a fresh install, the configuration files are not found.

- Security page does not show 'restrict console logins' option.

- Updating security app setting works. Message 'Configuration updated.' is
shown.

- First boot succeeds. Restrict console login is not enabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:47:13 -05:00
Sunil Mohan Adapa
c20f640641
ssh: Add checkbox to remove login group restrictions
Tests:

- Disable the checkbox. Non-admin user who is not part freedombox-ssh group
fails to login. Admin user can login.

- Enable the checkbox and both non-admin user and admin user can login via SSH.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:47:11 -05:00
Sunil Mohan Adapa
21c8a8945f
ssh: Restrict logins to groups root, admin and freedombox-ssh
Tests:

- Remove restricted console logins. Try to login via SSH with non-admin and note
that it fails. sudo into the user succeeds.

- Add a user to freedombox-ssh group from Users & Groups app. Login with SSH
succeeds.

- Login with admin user succeeds with and without adding to freedombox-ssh
group.

- On a fresh install, non-admin users are not restricted.

- On an upgrade from a version with the patch, non-admin users are restricted.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:47:08 -05:00
Sunil Mohan Adapa
7d4283d7b8
email: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- Trying to connect to local daemon from fbx user fails.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:47:06 -05:00
Sunil Mohan Adapa
c4241abfe8
i2p: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- Trying to connect to local daemon from fbx user fails.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:47:04 -05:00
Sunil Mohan Adapa
489c536805
minidlna: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- Trying to connect to local daemon from fbx user fails.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:47:01 -05:00
Sunil Mohan Adapa
f518c75922
syncthing: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- Trying to connect to local daemon from fbx user fails.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:59 -05:00
Sunil Mohan Adapa
6b7556c6d3
transmission: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- Trying to connect to local daemon from fbx user fails.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:57 -05:00
Sunil Mohan Adapa
9198a00038
deluge: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- Trying to connect to local daemon from fbx user fails.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:54 -05:00
Sunil Mohan Adapa
05e5ec4011
calibre: Add protection to local service using firewall
Tests:

- When app is freshly installed, nft rules are inserted.

- When app is upgraded from older version, nft rules are inserted.

- When app is enabled/disabled, nft rules are added/removed.

- When app is uninstalled, rules are removed

- Inserted rules are after the basic setup rules inserted firewall app.

- Trying to connect to local daemon from fbx user fails. Trying to access as
root user or apache succeeds. Test connecting with 'nc localhost <port>'.

- Functional tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:52 -05:00
Sunil Mohan Adapa
4bf347dbe3
firewall: Introduce component for local service protection
- Automatically handle a setup of the component getting added to an existing
app.

Tests:

- Run unit tests

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:49 -05:00
Sunil Mohan Adapa
2240f7a151
firewall: Create a mechanism for protecting local services
Tests:

- On a fresh container, run FreedomBox service. Notice that firewall app setup
succeeds. Base setup rules are inserted into the nftables as checked with 'nft
list ruleset ip' and 'nft list ruleset ipv6'.

- When firewalld is restarted or reloaded, the rules are still present.

- When machine is restarted, the rules are still present.

- Without the patch, setup a container. Then apply patches and restart
FreedomBox service. App setup runs again however, duplicate rules are listed in
nftables as checked with 'nft list ruleset ip' and 'nft list ruleset ipv6'.

- Increment setup version of the firewall app manually and repeat the test.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:46 -05:00
Sunil Mohan Adapa
a8400d07a6
searx: Ensure that socket is only reachable by Apache and root
When the security access restrictions are removed from /etc/security/access.d,
we don't want users to bypass Apache access control and directly access the app.

Tests:

- Without the patch, the uwsgi socket file is with permissions 666 in
/run/uwsgi/apps/searx/socket. nc -U <socket> succeeds as non-admin user on the
system.

- Apply the patch and restart FreedomBox. searx set is run and uwsgi service is
restarted and permissions are 660 on /run/uwsgi/apps/searx/socket. nc -U
<socket> fails as non-admin user on the system.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-05 20:46:43 -05:00
James Valleroy
39aac9228b
ejabberd: Enable mod_http_upload
- Upgrade existing config.

Tests:

- Install ejabberd. Configuration is set as expected and ejabberd is
  running.

- Upgrade from existing ejabberd install. Configuration is set as
  expected and ejabberd is running.

- Send a file between two users in dino-im and Conversations app.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-12-04 10:56:30 -08:00
Sunil Mohan Adapa
ce1347b172
i2p: Remove donation URL that is no longer available
Closes: #2300

https://www.reddit.com/r/i2p/comments/utou95/what_happened_to_the_donate_page_on_geti2pnet/

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-12-03 08:55:24 -05:00
Sunil Mohan Adapa
678ca1a9d1
email: Fix creation of aliases for security@ and usenet@
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-11-21 19:37:50 -05:00
nbenedek
c1129be4e7
email: dovecot: Add fail2ban jail
I tested this patch on a production server. When trying to authenticate with
Thunderbird, the program will try to log in three times, then disconnect from
the server. This means that one failed login attempt will be logged as four
attempts. For this reason, set maxretry to be 30.

The IP block only affects dovecot, other services are still reachable.

Signed-off-by: nbenedek <contact@nbenedek.me>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-11-21 11:04:37 -08:00
Sunil Mohan Adapa
22a58db896
upgrades: Add documentation link upgrades service file
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-11-05 07:20:13 -04:00
James Valleroy
3b69714e58
upgrades: Update list of holds during dist upgrade
Add bind9, minetest-server, minidlna.

This matches the set of apps that implement force_upgrade.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-11-04 16:38:16 -07:00
James Valleroy
e3c623b471
minetest: Handle upgrade from 5.3.0 to 5.6.1
Closes: #2134.

Tests:

1. In testing container, install Minetest and change the
configuration.

2. Manually downgrade minetest-server and minetest-data to a slightly
older version (5.5.0+dfsg+~1.9.0mt4+dfsg-1).

3. In /var/lib/dpkg/status, change the hash for
/etc/minetest/minetest.conf.

4. Run "apt update".
- minetest-server package is upgraded.
- Configuration changes are kept.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-11-04 16:38:01 -07:00
James Valleroy
b1b457a65f
storage: Drop skip_recommends
Originally there was a separate module for udiskie, which later got
merged into storage module. Since storage is an essential module,
skip_recommends has no effect. (Recommends are never installed for
essential modules.)

Closes: #2203.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-11-04 14:41:32 -07:00
Sunil Mohan Adapa
4c5344dfa0
letsencrypt: Fix regression with comparing certificate
Closes: #2295.

_assert_managed_path() expects pathlib.Path. Due to a typo, a string is being
sent instead.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-24 20:11:17 -04:00
Sunil Mohan Adapa
bcbd623f00
upgrades: Fix a minor flake8 pipeline failure
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-24 16:06:38 -07:00
nbenedek
63278f0bcd
rssbridge: add option to allow public access
These modifications are copied after the wordpress
public access configurator.

Signed-off-by: nbenedek <contact@nbenedek.me>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-24 12:02:10 -07:00
James Valleroy
c16d1e51d6
upgrades: Skip unattended-upgrade in dist-upgrade
Skip running unattended-upgrade due to it getting stuck in endless
loop. See #2266.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-24 11:19:43 -07:00
tunebes
c4b17130d4
storage: Handle file systems on non-physical devices
Fixes: #2126.

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-24 11:18:53 -07:00
James Valleroy
f0fd3d9132
upgrades: Allow FreedomBox vendor when adding backports
Fixes: #2294.

Tests:

- In stable container, when frequent feature updates option is
enabled, /etc/apt/sources.list.d/freedombox2.list exists as expected.

- Matrix Synapse can be installed.

- Shaarli can be installed.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-23 17:21:58 -07:00
Sunil Mohan Adapa
bbb6451254
privacy: Remove unused import, fix pipline
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-10 22:55:30 -07:00
Sunil Mohan Adapa
236ad3771a
privacy: Set vendor as FreedomBox for dpkg and popularity-contest
- This changes sets the default dpkg vendor as FreedomBox. 'Debian' is still the
parent of the vendor.

- This results in popcon setting the Vendor as FreedomBox. This allows measuring
the popular of FreedomBox distribution itself as against other Debian
derivatives in the section 'Statistics per distributions reporting to Debian' of
https://popcon.debian.org

Tests:

- Run `sudo ./setup.py install` and freedombox service. Privacy app will be
setup for the first time. In /etc/dpkg/origins/ the file default is a symlink
pointing to /etc/dpkg/origins/fredombox. Running 'sudo sh +x
/etc/cron.daily/popularity' runs successfully. Remove files
/var/lib/popularity-contest/lastsub /var/log/popularity-contest* if necessary.
The file /etc/log/popularity-contest shows VENDOR:FreedomBox in the first line.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-10 21:33:27 -04:00
nbenedek
7e2ebcb743
privacy: Add new system app for popularity-contest
- Keep the description about app generic

- Remove enable/disable option

- Create a booleanfield to turn on/off popcon

- Don't re-enable popcon during an update

Tests:

- When enabling/disabling the option, the `"PARTICIPATE"` value in
`/etc/popularity-contest.conf` is changed to yes/no as expected. For reference
see `/var/lib/dpkg/info/popularity-contest.templates`

- When popcon option is enabled, running sudo sh -x
/etc/cron.daily/popularity-context shows that execution was successful and data
was submitted. Remove files /var/log/popularity-contest* and
/var/lib/popularity-contest/lastsub if necessary. Gpg is used and encrypted data
is what was submitted.

- When popcon option is disabled, running sudo sh -x
/etc/cron.daily/popularity-context shows that execution stopped because the
option is disabled.

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Add a notification to tell users about privacy app]
[sunil: Correct the URL to /sys]
[sunil: Minor code styling changes and updates to description, icon]
[sunil: Ensure that popcon works with encryption]
[sunil: Write configuration to a separate file]
[sunil: Use Shellvars lens instead of Php lns]
[sunil: Add functional tests]
[sunil: Backup/restore the configuration file]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-10 17:35:26 -07:00
nbenedek
95f2d372d8
matrix: Add fail2ban jail
Test:

- Setup Matrix on a VPS with a FQDN and a valid LE certificate, then add these
configs to fail2ban.

- On a production server apply the changes of MR !2296

- Setup the fail2ban filter and jail, then restart fail2ban

- Trying to log in unsuccessfully from FluffyChat leads to a 10 min ban

Result:

`sudo fail2ban-client status matrix-synapse-auth-freedombox` returns the
following output, but the server actually remains accessible in every way.

```
Status for the jail: matrix-synapse-auth-freedombox
|- Filter
|  |- Currently failed: 1
|  |- Total failed:     11
|  `- Journal matches:
`- Actions
   |- Currently banned: 1
   |- Total banned:     1
   `- Banned IP list:   MY IP
```
Signed-off-by: nbenedek <contact@nbenedek.me>
2022-10-10 10:08:06 -07:00
Sunil Mohan Adapa
387874ecfd
fail2ban: Make fail2ban log to journald
- Recommendation to use 'sysout' as log target in order to log to systemd
journal comes from the fail2ban.service file.

Tests:

- Install the changes and restart fail2ban. Notice that journalctl shows new
log lines.

- Logged to /var/log/fail2ban.log has stopped.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-09 08:54:02 -04:00
Sunil Mohan Adapa
9cc91441ff
wordpress: Update fail2ban filter
- Name of the jail has to be less than 29 characters for an iptables/nft chain
to be created.

- Make the regular expressions more specific to avoid matching incorrect fields
for <HOST>.

- Added journalmatch to improve performance by matching the regular expressions
against only specific journal entries.

Tests:

- Run setup.py, remove the old jail and filter files. Restart fail2ban and make
10 incorrect login attempts. The IP address gets banned for 10 minutes.

- Not run: Build new freedombox package and upgrade from older version to see
that old configuration files have been removed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-09 08:53:56 -04:00
Sunil Mohan Adapa
72d7a05ead
apache: Fix logs still going into /var/log files
Closes: #2264.

- Set apache-auth fail2ban jail's backend to read from journal instead of
syslog. Tweak the regex matching to deal with the custom format.

- Adjust the apache error log format to remove unnecessary timestamp. It causes
problems for fail2ban regex matching.

- There was an error in the earlier patch the make apache log into journald.
Configuration for TLS sites still contained ErrorLog and CustomLog directives.
Remove them.

- There is also file with CustomLog directive that logs for other vhosts.

- For some reason, for custom error log format, %T - thread ID did not work and
had to switch to %{g}T global thread ID.

- Added journalmatch to improve performance by matching the regular expressions
against only specific journal entries.

Tests:

- In a container, apply the patch, run setup and start FreedomBox. Apache app is
updated to new version. Apache web server is reloaded. The
other-vhosts-access-log configuration is disabled.

- On a production machine, remove the directives in
freedombox-tls-site-macro.conf and disabling other-vhosts-access-log stopped the
logging into /var/log/apache2/ directory.

- Use TTRSS /tt-rss-app/ URL and type wrong credentials for 10 times. The client
is banned for 10 minutes. Repeat after unban. Client is banned again.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-09 08:53:46 -04:00
Sunil Mohan Adapa
6a0493a752
action_utils: Drop support for non-systemd environments
- There hasn't been a need for this for a long time. non-systemd environments
haven't been worked on or tested for in a long time.

- Keep the is_systemd_running() method for future use.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:54:13 -04:00