8567 Commits

Author SHA1 Message Date
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
ec52d9bed9
daemon: Added method to ensure a daemon is running in component
This will help apps like zoph that need to have database server running to
install or upgrade a package.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:38 -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
8f5dc14183
app: views: Expose method to get enabled/disabled state and cache it
- So that it can be used by derived classes.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:19 -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
524fdf6049
app: Add ability to hide configuration form when app is disabled
- Some apps store their configuration in database. The database server may not
be running when app is disabled. Configuration changes may then not be
possible for such apps. Provide the ability to disable configuration for apps
that don't support configuration changes when disabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:14 -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
Sunil Mohan Adapa
a488ee4d43
action_utils: Implement method for starting a service temporarily
Used when a service is needed for an operation but we don't wish to keep it
running after the operation.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-11 16:50:05 -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
Sunil Mohan Adapa
3a7dd4e812
actions: When action errors out, log a better message
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-09 11:22:05 -05:00
Sunil Mohan Adapa
1274ffdf87
actions: Fix log message when action return can't be decoded
return_value is not available during exception handling.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-09 11:22:03 -05:00
Sunil Mohan Adapa
15b537ccb7
log: Don't log with in color inside actions scripts
This would be better for collecting the stderr of the action and logging it
again.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-03-09 11:22:00 -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
ikmaak
903059501f
Translated using Weblate (Dutch)
Currently translated at 99.5% (1550 of 1557 strings)
2024-02-28 11:02:08 +01: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
James Valleroy
c217fdb5c6
Release v24.5 to unstable
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
v24.5
2024-02-26 20:59:13 -05:00
James Valleroy
169eb9854f
doc: Fetch latest manual
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-26 20:58:28 -05:00
Olaf Schaf
a9b77bbec8
Translated using Weblate (German)
Currently translated at 100.0% (1557 of 1557 strings)
2024-02-22 15:02:04 +01: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
02e409a3a1
daemon: Add new component for daemons shared across apps
- This is useful for managing redis service needed by the upcoming Nextcloud
app.

- Disable the daemon only if all the apps using it are disabled. Enable it when
even one of the them is enabled.

- The component is not a 'leader' component as it does not decide the
enabled/disabled status of the app.

Tests:

- Unit tests pass.

- Install zoph and wordpress with full patch series. If one of the apps is
disabled, mysql service is still enabled and running. If both apps are disabled,
then mysql service is disabled and not running. Enabled/disabled status of apps
are accurate after they are enabled/disabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-21 20:54:49 -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
5399efde73
pyproject.toml: Exclude the build directory from mypy checks
- build/ directory is generated after the 'make build install' step and contains
files that are duplicates of the main source leading to a failure.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-21 20:54:44 -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
James Valleroy
6c5fbf6523
tests: Patch apps_init for enable/disable daemon test
Otherwise, apps_init calls _sort_apps, which randomly fails in functional tests
CI job. The failure may be due to the tests running in parallel, since I could
not reproduce it locally.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-02-18 10:13:46 -08: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
bd4ddcf158
setup: Ensure that apt is updated before checking force upgrade
If the package cache is outdated and a check is performed for whether force
upgrade is needed, it might return negative. After the operation proceeds to run
setup, we perform 'apt update' before 'apt install' at this point the
configuration file prompt will cause failure.

Tests:

- Re-run firewalld upgrade from 1.3.x to 2.1.x with a re-run setup.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-15 19:47:51 -05:00
Sunil Mohan Adapa
e208bdbbca
setup: Ensure that force upgrade won't run when app is not installed
- This keep the initial setup of the app simple and efficient. Setup will be
less prone to any issues in force upgrade code. There are also fewer chances for
immediate regressions.

Tests:

- Tested as part of the patch series.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-15 19:47:48 -05:00
Sunil Mohan Adapa
56b58174b3
setup: Minor refactoring of force upgrader class instantiation
- It is okay to instantiate before shutdown to mark shutdown initiation.

- Still keep the instantiating lazy.

Tests:

- Tested as part of patch series.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-15 19:47:45 -05:00
James Valleroy
29d48e86b7
setup: Try force upgrade before running app setup
Avoid running setup if it would bypass a needed force upgrade.

Fixes: #2397

Tests:

- Rerun setup on an app and see that there are no errors.

- Install modified freedombox on bookworm and perform dist-upgrade to
  testing. Then rerun setup on Firewall app. It fails with the message "App
  firewall failed to force upgrade." firewalld package is not upgraded.

- Modify Firewall app to allow force upgrade to latest version. Then rerun
  setup on Firewall app. firewalld is successfully force upgraded.

  NOTE: In this case, Firewall setup is run twice, once by force upgrade, and
  again by rerun setup.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-02-15 19:47:41 -05:00
Sunil Mohan Adapa
7b2a65d449
container: Fix issue with missing make command on stable image
Fixes: #2402.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-15 19:42:33 -05:00
James Valleroy
b09f2cd74e
Release v24.4 to unstable
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
v24.4
2024-02-12 21:24:48 -05:00
James Valleroy
13793fee1f
doc: Fetch latest manual
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-12 21:23:44 -05:00
James Valleroy
b355faf59a
locale: Update translation strings
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-12 20:40:56 -05:00
Besnik Bleta
510daf3d43
Translated using Weblate (Albanian)
Currently translated at 99.6% (1552 of 1558 strings)
2024-02-13 02:32:56 +01:00
James Valleroy
2d3c610f3a
debian: Remove lintian override for init script
The lintian tag was removed. See:
579d080bff

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-12 20:18:52 -05:00
Sunil Mohan Adapa
2788d6810d
Makefile: Move various tests into build system
- This allows those tests to be invoked on console and not just in CI pipelines.

Tests:

- Running make check works.

- CI pipeline succeeds.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[jvalleroy: Remove phony test target]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-02-12 19:17:16 -05:00