3155 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
8d0455aa45
matrixsynapse: Prevent setup page from being shown during uninstall
Fixes: #2381.

When app is being uninstalled, it is disabled. Use that to not show the setup
page.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-25 18:27:30 -04:00
Veiko Aasa
709f58ac90
samba: Disable nmbd NetBIOS service
NetBIOS was used with now deprecated SMB1 protocol.

Tests performed:
- Windows 10 can access shares when the nmbd service is disabled.
- In stable and testing containers, all the samba module tests pass.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-22 14:26:02 -07:00
Veiko Aasa
9bc07f60ed
samba: Fix Samba not accessible from IPv6 localhost ::1 address
Also:
 - Remove addressses [fc00::]/7 and [fe80::] from `allow hosts`, as
those had no effect as described in #2334.
 - Remove unknown parameter `access control = yes` from Samba
configuration.

Tests performed in a stable container:

- After Samba app upgrade was performed, enabled Samba Home share.

- Using the `testparm` command, checked that the share is accessible
from ::1 IPv6 address:
```
> sudo testparm -s /etc/samba/smb-freedombox.conf  host-ip ::1
Allow connection from host-ip (::1) to disk_home

> sudo testparm -s /etc/samba/smb-freedombox.conf  host-ip ::2
Denied connection from host-ip (::2)
Deny connection from host-ip (::2) to disk_home
```

- Checked that when `ping localhost` returns ::1 in the container,
all the Samba tests pass.

Closes #2334.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-19 14:42:07 -07:00
Sunil Mohan Adapa
601b48d5b1
snapshot: Show better error messages
- Simplify success message for easy localization.

Tests:

- Update configuration notice the success message is shown properly.

- Insert errors in set_config() privileged method and notice that HTML error is
shown properly.

- Insert errors in privileged.delete() method, print 'Config is in use.' message
on stderr and notice that HTML error is shown properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:43 -04:00
Sunil Mohan Adapa
f240c4203c
upgrades: Show better error messages
- Reduce the number of specialized messages to ease localization and clear way
for generalized configuration change handler.

Tests:

- Update the one or two configuration setting at the same time and notice that a
single message is shown.

- When no setting is changed and form is submitted, 'settings unchanged' message
is shown.

- Raise error when enabling/disable auto updates and notice a proper HTML error
shown. When other setting is also updated, then one error and one success
message is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:41 -04:00
Sunil Mohan Adapa
64d754701f
storage: Show better error message
Tests:

- In a VM, mount a loopback disk. Insert an error in ejected code and notice
that HTML message is shown properly during eject operation.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:39 -04:00
Sunil Mohan Adapa
598d7570ff
letsencrypt: Remove unnecessary processing of the error messages
- This allows the certbot command output to be shown accurately in the HTML
error message.

Tests:

- Edit the code to show all the action buttons in the UI. Set domain to
mydomain.example. Run all four actions. Notice that HTML error message are shown
and certbot output is shown properly in stdout/stderr sections.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:37 -04:00
Sunil Mohan Adapa
969d9311ab
storage: Adjust to changes in privileged errors
Tests:

- Edit auto-mounting to try mounting an already mounted device. In a VM, during
service startup, notice the warning about failure to auto-mount as device is
already mounted.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:34 -04:00
Sunil Mohan Adapa
cf4f29e848
letsencrypt: Show better error messages
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:32 -04:00
Sunil Mohan Adapa
8d5ba3d67a
letsencrypt: Simplify error warning when certificate revoke fails
- The privileged call already prints the log message with full error details.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:30 -04:00
Sunil Mohan Adapa
c855640f84
backups: Adjust to changes in privileged errors
Tests:

- Unit tests requiring root succeed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-19 11:46:28 -04:00
Sunil Mohan Adapa
6e557dd1e9
system: Organize items into sections
Closes: #2161.

- Sections are ordered by importance on which administrator must act after
setting up the system.

- Consistent order across all the languages.

- Update the styling for the section hearers.

  - For system section, make them compact.

  - Make them look like a header text (with underline) rather than a
    divider (like in a menu).

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-03-16 09:17:35 +02:00
Sunil Mohan Adapa
1b09d01575
users: Add email address field during first boot
- Mostly because administrators won't discover the email address field for the
user later on.

- This field is important to be able to run 'reset password' operation.

Tests:

- In stable and testing containers, run first boot wizard. Enter the email
address during the first boot and see that it was saved as part of user account.
Leave the email address blank and it is possible to proceed. User account show
blank email address.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-03-14 21:58:04 +02:00
Sunil Mohan Adapa
9d2a11b874
users: Add email address field when creating/updating user accounts
Closes: #1826.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-03-14 18:07:16 +02:00
Sunil Mohan Adapa
f9c624562a
wordpress: Fix minor issue in restoring database
- Overlooked in !2454.

Tests:

- Take a backup of wordpress app and disable it. Restore from the backup
succeeds after that.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-11 15:24:21 -07:00
Sunil Mohan Adapa
5dbf890881
tests: functional: Refactor install/setup fixture for apps
- Fixes an issue with zoph not being setup after uninstall+install setup and
makes a test pass.

- Some failures exist but don't seem related to this change.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:56 -04:00
Sunil Mohan Adapa
8096c14b14
wordpress: tests: Uninstall app after backup and before restore
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:53 -04:00
Sunil Mohan Adapa
7d4c5650f4
zoph: Restore database password to old value after restore op.
Fixes: #2346.

Tests:

- Without the patch, install zoph, take a backup. Note the db password in
/etc/zoph.ini. Uninstall zoph. Install it. Note that db password changed.
Restore from previous backup. Note that password has been restored to old value
and zoph is unable to connect to database.

- With the patch, repeat the test and notice zoph works after restore.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:49 -04:00
Sunil Mohan Adapa
f0ff0c181b
wordpress: Drop database user when app is uninstalled
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:45 -04:00
Sunil Mohan Adapa
d615ff107e
wordpress: Fix backup, restore and uninstall when db is not running
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:42 -04:00
Sunil Mohan Adapa
c341a531dd
zoph: Ensure that database server is running when setting up app
When mysql server is not running, app installation fails. Similarly the setup
process will fail when app is being upgrade and database upgrade needs to be
performed. So, ensure that database server is running before attempting
install/upgrade of app.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:40 -04:00
Sunil Mohan Adapa
74fc8e08da
zoph: Uninstall fully so that reinstall works
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:35 -04:00
Sunil Mohan Adapa
17e84419b8
zoph: Don't fail with backup/restore if app is disabled
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:32 -04:00
Sunil Mohan Adapa
6646512a0a
zoph: Don't redirect to setup page when app is disabled
- When app is disabled, it can't be setup as it requires database server and
connecting to the database.

- If app is disabled, we don't show configuration any more, so redirection to
setup page is also not needed. This results in neither setup nor configuration
being shown when app is disabled.

- During uninstall process, app is disable for first. So, the workaround
implemented in is_configured() is no longer needed.

Tests:

- Install zoph. Setup page is shown. Disable the app by disabling the apache
configuration for it and restart service. Setup is no longer shown.

- Uninstall zoph. During the uninstall setup, when page is refreshing, setup
page is not shown.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:21 -04:00
Sunil Mohan Adapa
0edb6a1219
zoph: Hide configuration form when app is disabled
- MySQL server may be disabled when zoph is disabled. Trying to retrieve
configuration or trying to set the configuration at the time will result in
failures. So, disable the configuration form so that get/set of configuration
does not happen.

Tests:

- Disable zoph. Configuration form will disappear. Re-enable zoph, configuration
form will reappear.

- Functional tests for zoph pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:16 -04:00
Sunil Mohan Adapa
717e8cd7f5
wordpress: Don't fail setup if mysql installed but not running
Tests:

- Install zoph and disable it. This will install mysql and disable it. Then
install wordpress. Installation should succeed.

- Disable wordpress and re-run setup. Setup should succeed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:12 -04:00
Sunil Mohan Adapa
d79ba1cede
zoph: Don't fail setup if mysql installed but not running
Tests:

- Install wordpress and disable it. This will install mysql and disable it. Then
install zoph installation should succeed.

- Disable zoph and re-run setup. Setup should succeed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:09 -04:00
Veiko Aasa
22671510e6
samba: Ignore non-existent users who are in freedombox-share group
Fixes error 500 when trying to open Samba app page when at least
one of the users in freedombox-share group doesn't exist.

Tests performed in both stable and testing containers:
- Installed Samba app.
- Installed Deluge app (Plinth install/setup fails but the Debian
package itself was installed).
- Did `apt remove --purge deluged` from command line.
- Checked that the debian-deluged user doesn't exist (`getent passwd`)
and the user is in the freedombox-share group (`getent group`).
- Checked that the Samba app page opens without errors.
- Checked that all the Samba tests pass.

Fixes #2411.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-10 10:27:38 -07:00
Sunil Mohan Adapa
4b09d91f93
*: Add type hints for diagnose method
Helps: #2410.

- Ensure that diagnostics methods and parameters are type checked so that we can
catch any potential issues.

- Move plinth/modules/diagnostics/check.py to plinth/diagnostic_check.py to
avoid many circular dependencies created. This is due to
plinth.modules.diagnostics automatically imported when
plinth.modules.diagnostics.check is imported. Also app.py is already (type)
dependent on diagnostic_check due to diagnose() method. To make the Check
classes independent of diagnostic module is okay.

Tests:

- Run make check-type.

- Run full diagnostics with following apps installed: torproxy, tor.
  - Test to netcat to 9051 in tor works.
  - Test 'port available for internal/external networks' in firewall works.
  - Test 'Package is latest' works.
  - Test 'Access url with proxy' in privoxy works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
[jvalleroy: Also move tests for diagnostic_check]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-09 14:23:33 -05:00
Sunil Mohan Adapa
f9b186e14f
*: Add type hints for app init methods
- This is so that the methods will be checked by mypy. This should help identify
any incorrect initialization of components.

- Remove unused self.repos in GitwebApp.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-09 14:22:14 -05:00
Veiko Aasa
ca0479aae2
users: tests: Do not remove LDAP user when testing views
Fixes an issue where the LDAP user 'tester' was removed after testing
test_views.py. It happened when there were two admin users present.

Tested with both stable and testing containers that all the users
module tests pass and a user 'tester' is not removed when
two admin users exists.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-08 15:09:40 -08:00
Sunil Mohan Adapa
b36d4419c4
users: Minor refactor when creating django groups
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-03-08 11:28:54 +02:00
Sunil Mohan Adapa
526a3018e4
users: Fix creating users with initial set of groups
Fixes: #2409.

When creating a user if one or more groups is selected, creation fails. This
is because the fields contains group choices as (name, label) tuples instead
of (group_id, label) tuples as expected by the many-to-many field mapping
mechanism in ModelField class. Fix this by using the same mechanism used in
UserUpdateForm, which is to reuse the base class form field (but adjust some
properties).

Tests:

- During first boot
  - Django groups are fully created when form is accessed with blank database
- In user creation/modify form:
  - Label appears are 'Permissions'
  - Choices appear fully and as 'Description (Group name)'
  - Help text is correct.
  - Choices are sorted on group name.
  - Django groups are fully created when form is accessed when a new group is
    added to code.
  - User can have no groups
  - Widget is multiple checkbox widget. Multiple groups can be selected.
  - User is added to proper ldap groups after submission
- In user modify form:
  - If the user is last admin user, admin checkbox is checked and disabled.
  - Current list of groups is accurate shown when form is displayed.
  - Add remove of groups works as expected
- Functional tests for gitweb and users apps pass

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-03-08 11:28:54 +02:00
James Valleroy
d512e4268c
diagnostics: Handle TypeError when copying results
Display and log an error, including contents of current_results.

Clear the contents of current_results.

Tests:

- View the diagnostics results as normal.

- Introduce a TypeError before the results are copied. See the error message
  shown in the interface. (The error details are cleared when the page is
  refreshed.)

Helps: #2410

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Fix a mypy error]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-05 10:44:21 -08:00
James Valleroy
dfaeadee6b
diagnostics: Add tests for get_results
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-03-05 10:44:16 -08:00
Veiko Aasa
1268898176
gitweb: Fix modifying git repositories when gitweb app is disabled
Fixes #2408.

- When app is disabled, continue to update the app shortcut's login required
property. Otherwise, the value is current after the app is re-enabled.

- When public access is enabled, the gitweb-freedombox-auth.conf configuration
must be disabled. This can be done even if the configuration is already disabled
or does not exist. So, continue doing this.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Perform enable public access even if app is disabled]
[sunil: Perform shortcut update in all cases even if app is disabled]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-02-27 15:06:27 -08:00
Sunil Mohan Adapa
dbdac3b001
zoph: Add shared daemon component for mariadb/mysql
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-21 20:54:54 -05:00
Sunil Mohan Adapa
2fc354ea7f
wordpress: Add shared daemon component for mariadb/mysql
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-21 20:54:52 -05:00
Sunil Mohan Adapa
d32d02ecb5
gitweb, users: Minor fixes for newer pycodestyle
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-21 20:54:47 -05:00
Sunil Mohan Adapa
3aae4b39d6
tor: tests: Convert to pytest style tests from class based tests
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-18 18:21:33 -05:00
Sunil Mohan Adapa
37b9e21e30
tor: tests: Fix issue with pytest 8.x versions
Closes: https://bugs.debian.org/1063968.

- Due to a changed behavior in pytest 8.x, any imports with 'setup_module' name
will be treated as a method to setup the module in the style of unittest/nose.
pytest tries to call this as a method and will fail.

- Rename the import to 'setup_module_' instead of 'setup_module' to fix this issue.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-18 18:21:31 -05:00
Sunil Mohan Adapa
71a10bfd31
backups: tests: Don't use pytest marks on fixtures
- It removes this warning. plinth/modules/backups/tests/test_ssh_remotes.py:62: PytestRemovedIn9Warning: Marks applied to fixtures have no effect.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-18 18:21:28 -05:00
Sunil Mohan Adapa
5e10b2d4ae
firewalld: Implement force upgrading to any 2.x versions
Closes: #2396.

New configuration options were introduced from 1.3.x to 2.1.x. This cause
configuration file prompt due to our existing changes to the configuration file.
Changes to the configuration file were investigated in #2396.

Tests:

- Install firewalld 1.3.x. Ensure that firewalld configuration changes are
present as intended by FreedomBox. Change priority of the .deb package to allow
installing 2.1.x. Run apt update and notice that force upgrade has been
performed to 2.1.x.

- firewalld upgrade has also been tested as part of this patch series.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-15 19:47:53 -05:00
Sunil Mohan Adapa
8202b734a6
help: tests: Run tests using doc in current dir instead of /usr
- This prevents the test from failing if install has not run yet.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-12 19:16:59 -05:00
James Valleroy
d7907e0ef3
diagnostics: Add option to toggle daily run
The option is stored in kvstore. If no value is set, it is assumed to be
enabled.

Tests:

- Disable daily run. In development mode, diagnostic are not run after several
  minutes.

- Enable daily run. In development mode, diagnostics are run after several
  minutes.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Minor refactoring and update messages in UI]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-23 11:40:09 -08:00
Benedek Nagy
9c5491de7e
zoph: Fix failing PHP configuration requirements
I tested both fresh install and updating an existing installation.
When updating an existing instance, the app had to be manually enabled,
so I added:

```
elif old_version < 2:
            self.enable()
```

Fixes: #2345

Signed-off-by: Benedek Nagy <contact@nbenedek.me>
[sunil: Change the config name to zoph-freedombox.php]
[sunil: Enable the config during update only if app is already enabled]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-19 12:37:57 -08:00
Sunil Mohan Adapa
acc498cb90
diagnostics: Fix a potential iteration of None value in error cases
- Prompted by pylint.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-18 22:19:28 -08:00
Sunil Mohan Adapa
ba145b3194
diagnostics: Safely access results when showing notification
It is best to have obtained the results lock when counting the severe failures
in diagnostic results.

Tests:

- When some packages are outdated, notification is shown with warning severity.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-18 22:19:24 -08:00
Sunil Mohan Adapa
5f08752058
diagnostics: Simplify getting translated description in results
Tests:

- Unit tests pass.

- Run full diagnostics tests and see that results and app name are translated
when language preference is not English.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-18 22:19:21 -08:00
James Valleroy
27284fe888
diagnostics: Store results of full run in database
Tests:

- Run diagnostics. Restart plinth, and check that the diagnostics results are
  still available to view.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-18 22:19:14 -08:00