919 Commits

Author SHA1 Message Date
James Valleroy
39d411be5b
upgrades: Check for held freedombox package daily
Guard against removing a hold while the package manager is busy.

Test:
1. Place hold on freedombox package.
2. Wait 3 minutes in development mode.
   - Package is held.
3. Touch /var/lib/freedombox/package-held.
4. Wait 3 minutes in development mode.
   - Package is not held.
   - Flag is removed.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:47 -04:00
James Valleroy
912d9ec9e0
upgrades: Check for held freedombox package in manual update
This is to recover from a situation where the package is held, and
then plinth process is interrupted so it cannot release the hold.

We check for and recover from this situation when installing new apps,
and when running dist upgrade. This provides another way to recover
from the problem, by running manual update.

Tests:

- (normal) No hold on freedombox package, and flag is not set. Run
  manual update. Afterwards, there is no hold, and flag is not set.

- (admin preference) Place hold on freedombox package, but flag is not
set. Run manual update. Afterwards, there is still a hold, but flag is
not set.

- (recovery) Place hold on freedombox package, but flag is
set. Run manual update. Afterwards, there is no hold, and flag is not
set.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:38 -04:00
James Valleroy
5412bd75d7
action_utils: Separate function to hold freedombox package
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:15 -04:00
James Valleroy
9b446d5dd1
coturn: Validate TURN URIs if provided in form
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>

- Re-use the same validator in Matrix Synapse.
- Avoid importing plinth classes in actions files.
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-04-16 17:52:57 -04:00
Joseph Nuthalapati
7a30470cb5
ejabberd: STUN/TURN configuration
This implementation is very similar to that of Matrix Synapse with a lot
of code duplicated.

One major difference is that ejabberd doesn't have a conf.d/ directory.
So, the managed configuration and overridden configuration cannot be
cleanly separated.

Whether the configuration is managed or not is determined by the
presence of a file under `/etc/ejabberd`. Managed coturn configuration
isn't stored in ejabberd, since only one set of configuration can be
stored at a time. If the admin chooses to use the managed configuration,
the current coturn configuration is fetched and used to configure
ejabberd.

Fixes #1978

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-04-16 17:52:48 -04:00
Sunil Mohan Adapa
ee991dbab8
action_utils: Introduce utility for masking services
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-03-05 18:06:25 -08:00
Joseph Nuthalapati
2ffde1b646
matrix-synapse: Auto configure STUN/TURN using coturn server
- Matrix Synapse will automatically pick up the locally installed coturn server
during its installation. This handles only the case where coturn is installed
and configured with a valid TLS domain name before matrix-synapse is installed.

- Allow overriding STUN/TURN config. Matrix Synapse uses the local coturn
server's configuration by default. However, an administrator can override the
STUN/TURN configuration from FreedomBox web interface. Allow administrator's
overrides to co-exist with FreedomBox's managed STUN/TURN configuration.
Administrator's configuration, if it exists, always overrides FreedomBox's
managed configuration. Any updates to FreedomBox's managed configuration will
have no impact on the administrator's configuration since the latter takes
precedence.

Sunil:

- Collapse multiple turn actions into a single one for simplicity. Sending empty
configuration means removal of the configuration.

- Ensure that when removing configuration file is idempotent.

- Manage TURN configuration even when app setup is not yet completed. This fixes
issue with TURN configuration not getting setup on app installation and setup.

- Fix issue with TURN configuration getting updated on form submission even when
the field is not changed. This is due to mismatch between the browser submitted
\r\n with the internal \n.

- Simplify JavaScript for the form and attach handlers only after DOM is ready.

- Drop the no-JS message since the loss of functionality is trivial and to
reduce translation burden.

- Fix issue with URIs and secret parameters not getting updated unless the
managed checkbox changes.

- Drop specialized success messages for TURN configuration update to reduce
translation burden.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-28 16:28:53 -08:00
James Valleroy
db993ecb16
upgrades: Disable searx during dist-upgrade
Avoid high CPU usage due to uwsgi continuously restarting before searx
config is upgraded.

Helps #1644.

Tests: Ran dist-upgrade for each case:

- Without searx installed -> no log messages related to searx.

- With searx installed but not enabled -> searx config is upgraded.

- With searx installed and enabled -> searx is disabled, later config
  is upgraded, and searx is re-enabled. Searx page can be accessed at
  the end.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-02-24 11:34:25 +02:00
James Valleroy
4db96b17e5
upgrades: Disable apt snapshots during dist upgrade
Take a snapshot before dist upgrade, if supported.

Tests:
- Ran dist upgrade test with apt snapshots enabled. Snapshot is taken
  at beginning. Apt snapshots are enabled at end.
- Ran dist upgrade test with apt snapshots disabled. Snapshot is taken
  at beginning. Apt snapshots are disabled at end.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-10 17:08:38 -05:00
James Valleroy
72716366c1
upgrades: Add 10 minute delay before apt update
Ensure that plinth is fully started so that it can detect the apt
update, and perform force_upgrades.

Test: Perform dist upgrade. At the end, all packages have been
upgraded.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-10 17:08:10 -05:00
James Valleroy
f83c763ab7
upgrades: Only check free space bytes before dist upgrade
Remove the percentage check, which was incorrectly checking used
percent, not free percent.

Closes: #2046.

Tests:

- Fill up disk space so that 4.5G is free. Dist upgrade does not start
  due to not enough free space.

- Fill up disk space so that 5.5G is free. Dist upgrade can be
  started.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-10 07:54:52 -05:00
John Lines
f978d2f0d0
zoph: Add new app to organize photos
- Identify Freedbombox admin who installed the app to be zoph admin.

- Implement backup and restore.

- Photos directory should remain at /var/lib/zoph, for proper operation of
backups.

- There remains an issue that the App is enabled before it is configured but
will not work correctly until configuration.

- OpenStreetMap mapping is enabled. These should be configurable before
installation.

- Add initial forms.py and views.py to Zoph app, however these are currently
unused as urls.py does not invoke the view. When the view is not invoked the
Zoph App installs, with single signon, currently as the first LDAP user, rather
than the plinth user.

- The first user's preferences are not set, and need to be manually set to avoid
other errors.

* Sunil's changes

- Squash commits and re-split them.

- Drop documentation as it will be auto populated from wiki later.

- Remove outdated validation code from manifest.

- Drop some dead code.

- Don't send MySQL password over command line for improved security. Instead
  rely on Unix authentication of root user similar to backup/restore process.

- Use JSON for exchanging configuration dump to avoid encoding errors.

- Add username validation to avoid a potential SQL injection.

- Update description for neural tone and brevity. Add information about how user
  accounts work in FreedomBox

- Fix functional tests.

- Drop all code related to changing photos path until it is ready.

- Update URL from /zoph to /zoph/ to avoid another redirect.

- Fix disabling the app.

- Use icon that Zoph uses for favicon as logo. Update copyright file.

- Fix spelling unzip.

- Minor refactors. Run yapf and isort.

- Use subprocess.run() instead of os.popen() everywhere for better security with
argument parsing.

- Enable OpenStreetMap by default. User have a choice to disable it before using
the app. Add label to explain privacy concerns.

- Fix dropping database by using --force argument.

- Cleanup enabling the app to not enable the app when updating configuration.

- Use AppView's default template instead of overriding.

- Update functional tests to just check if the app is enabled/disabled as
expected. Checking that Zoph site is available will require reliable handling of
admin user.

Signed-off-by: John Lines <john@paladyn.org>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-10 01:13:29 -08:00
James Valleroy
975dfca7ad
roundcube: Allow upgrade to 1.4.*
Hold roundcube during dist upgrade.

Closes: #2035.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-04 17:41:31 -08:00
Joseph Nuthalapati
15f6fb1f61
matrix-synapse: python3-psycopg2 from backports
matrix-synapse 1.26 fails to start on FreedomBox stable if it doesn't
find the right version of python3-psycopg2. Version 2.8 of this library
is currently not available in Debian stable and has to be installed from
the buster-backports repository.

Tested the upgrade on a FreedomBox stable virtual machine.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-02-04 09:51:20 -08:00
James Valleroy
3ada482b90
upgrades: Move start-dist-upgrade result string to app
Separate checking for dist upgrade from other setup. We don't want to
start a dist upgrade during the module's setup.

Tests: Checked logs for the following:
- Up to date.
- Updates not enabled.
- Dist upgrade started.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-01-31 22:34:25 +02:00
James Valleroy
d747f77f80
upgrades: Get result of start-dist-upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-01-31 22:31:39 +02:00
James Valleroy
906816f7cb
upgrades: Return reason when checking for dist upgrade
With default logging settings, only print the result.

Tests: Checked output for following cases:
- Dist upgrade flag exists.
- System is Debian testing.
- Latest stable release without --test.
- Automatic updates not enabled.
- Not enough free space.
- Dist upgrade started.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-01-31 22:31:15 +02:00
James Valleroy
37a38549bf
upgrades: Requires at least 5 GB free space for dist upgrade
With all apps installed, the used space increases by 4.9 GB.

Helps: #1644.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-01-25 14:35:30 +02:00
Sunil Mohan Adapa
01e00cdde4
backups: Allow comments to be added to archives during backup
Tests performed:

- Schedules are able to store and retrieve comments properly. Information about
schedule backups stored in comments is extracted properly.

- Unit tests run.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-01-21 20:33:47 -05:00
Veiko Aasa
77face68b0
syncthing: Hide unnecessary security warning
- Hide the warning 'The Syncthing admin interface is configured to allow
remote access without a password. ... '. This warning is unnecessary because
we are using authentication through Apache.

- Hide the usage reporting notification by declining reporting, if the user
has not made a choice yet.

- Call add_user_to_share_group() in setup() before starting syncthing to
avoid another syncthing daemon restart.

- Add a functional test for hidden notification messages.

- Functional tests: Improve the method to check if the javascript
loading process is complete.

Closes #1581

Tests performed:
- The syncthing app is installed successfully on Debian testing
- All syncthing tests pass on Debian stable and testing

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-21 16:34:51 -08:00
Veiko Aasa
f892843ba5
syncthing: Create LDAP group name different from system group
When installing the syncthing app, create a LDAP group named "syncthing-access"
instead of "syncthing", because the app creates the "syncthing" system group
to run the syncthing daemon. Duplicate group names can cause some ambiguity as
described in #2008.

- Rename the existing "syncthing" LDAP and Django group to "syncthing-access".
- Update existing web shares to be accessible with new group name
- Functional tests: Add tests to check access to the syncthing site with a user
in the syncthing-access group and no group.
- Functional tests: Scroll to the edit button before clicking. Fixes some test
failures on a smaller browser window.

Fixes #2008

Tests performed on Debian stable and testing:

- Check that the existing "syncthing" group is renamed after upgrade:
1) Without patch applied, install syncthing, create a user in group "syncthing".
2) Apply patch, update Apache2 config file /etc/apache2/conf-available/syncthing-plinth.conf,
reload Apache2, restart plinth.
3) Check that the created user is now in the "syncthing-access" group and can
access /syncthing site.

- Check that the app upgrade succeeds when there are no users in the syncthing group.

- Create a web share accessible by the 'syncthing' group. Check that after the upgrade,
the share is accessible to a member of syncthing-access group.

- All the syncthing app tests pass.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-21 15:47:12 -08:00
James Valleroy
566a1bd243
upgrades: Hold tt-rss during dist upgrade, if available
Performs this hold separately from the others, and ignore errors only
for tt-rss.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:44:03 -08:00
James Valleroy
a9914128f3
upgrades: Use full path to searx action script
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:59 -08:00
James Valleroy
8a3603cd5f
upgrades: Restart FreedomBox service at end of dist-upgrade
This was removed in an earlier change, so restore it.

Avoids a transient "IndexError: list index out of range" error caused
by django when visiting a page.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:56 -08:00
James Valleroy
2ae60802a9
upgrades: Write dist-upgrade service file in /run
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:53 -08:00
James Valleroy
2e95077d74
upgrades: Check before starting dist upgrade process
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:50 -08:00
James Valleroy
a66520f3ff
upgrades: Don't allow needrestart to restart freedombox-dist-upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:46 -08:00
James Valleroy
0241b82479
upgrades: Install python3-systemd for unattended-upgrades
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:43 -08:00
James Valleroy
8934c22ef3
upgrades: Add service for dist upgrade
Only restart plinth if needed.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:40 -08:00
James Valleroy
66b0238146
upgrades: Ensure freedombox package is upgraded during dist upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:43:31 -08:00
James Valleroy
30a0e69548
upgrades: Update searx search engines during dist upgrade
Flush stdout after printing debug info.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-12-28 10:48:45 -08:00
James Valleroy
092c7e70d1
upgrades: Allow grub-pc upgrade without reinstalling grub
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-12-28 10:48:38 -08:00
Veiko Aasa
0255058656
users: Remove timeout when creating Samba user
Fixes #2000

Tests performed:
- All the users module tests pass
- Create a user, add the user to the freedombox-share group,
check that the user can connect to the Samba Group share.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-12-26 12:59:08 -05:00
Veiko Aasa
5f3643cc24
apache: Create snake oil certificate if not exists
When FreedomBox package is installed on a fresh Debian machine where a
snakeoil certificate doesn't exist, generate a new one.

Fixes #1923
Fixes #1999

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[Veiko: Made added code comment more precise]
Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-12-26 10:18:14 +02:00
James Valleroy
d7c70b74d7
upgrades: Hold mumble-server during dist upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Minor refactor to reuse list of packages with prompts]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-12-13 15:53:34 -08:00
James Valleroy
d794b575e1
upgrades: Fix sources list for dist upgrade from buster
- Check apt sources list regardless of whether we are upgrading to
stable or testing.

- Replace stable code name with new stable code name.

- When testing, also replace "stable" with code name to be tested.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-28 21:29:14 -08:00
James Valleroy
3455e72cbf
upgrades: Print steps in dist-upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-25 21:32:27 -08:00
James Valleroy
6c801f117f
upgrades: Use apt_hold contextmanager
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-25 21:32:23 -08:00
James Valleroy
5750373ea0
upgrades: Hold freedombox package during dist upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-25 21:32:18 -08:00
James Valleroy
890ab87589
upgrades: Fix flag name in info message
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-25 21:31:45 -08:00
Joseph Nuthalapati
e81104aa86
sso: Fix regression in auth-pubtkt configuration
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-23 17:19:28 -05:00
Matthias Dellweg
4b4f8187ef
Enable dynamicdns module to handle IPv6
Signed-off-by: Matthias Dellweg <2500@gmx.de>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-15 19:17:50 -05:00
Joseph Nuthalapati
a3df0342b7
openvpn: client configuration for RSA and ECC
Provide the correct client configuration based on whether the server is
using RSA or ECC.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-14 18:29:55 -05:00
Joseph Nuthalapati
030e6ce98d
openvpn: Remove opinion on which curve to use
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-14 18:29:49 -05:00
Joseph Nuthalapati
2b33a752d0
openvpn: ECC: Setup and Migration
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-14 18:29:42 -05:00
Joseph Nuthalapati
de6030b46c
openvpn: Cleanup easyrsa 2 to 3 upgrade code
Debian Buster has easyrsa 3. Since we're nearing Bullseye now, it is
safe to asssume that most users are already using easyrsa 3.

The code to do the upgrade is 2 years old already. Removing it.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-11-14 18:29:37 -05:00
Joseph Nuthalapati
9d616cc5e2
pubtkt: Fix Python format language errors
The CI is now using a newer version of Python.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-11-07 18:07:40 +05:30
Joseph Nuthalapati
e5b149baa3
ci: Fix flake8 errors
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-11-07 17:45:26 +05:30
Joseph Nuthalapati
658e260d23
mediawiki: Add action to set domain name
- Set domain name during app setup

- Improve tests for settings. Prefer to call functions in plinth which invoke
actions than test actions directly.

- Also, '$wgServer' is not a domain name since it also includes the protocol.

- Add domain selection form. Make server url a text input field.

- Added a functional test to set the value of server url to the value provided
by FREEDOMBOX_URL before doing running any other tests.

- Make server url setting a pre-requisite.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Squash commits as they were fixing themselves]
[sunil: Simplify configuration reading]
[sunil: Use 'server_url' terminology consistently]
[sunil: cosmetic: Minor styling]
[sunil: Update test_settings.py to use fixture pattern]
[sunil: Remove seemingly incorrectly used aria-describedby attribute]
[sunil: Don't rely solely on env variable value in functional tests]
[sunil: Fix issue with http/https mismatch when checking site availability]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-10-31 22:04:10 -07:00
Joseph Nuthalapati
04617cbf7f
mediawiki: Ensure password file is not empty
The temporary file is sometimes not flushed to disk by the time the PHP
command is called. This makes the password file empty and breaks the
installation.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
2020-10-31 22:04:07 -07:00