3604 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
8ba444990b
backups: Set proper permissions for backups-data directory
Fixes: #2554

- Update permissions on the backups-data directory so that files are only
accessible by root users.

- Ensure that the directory is created by the 'backups' app and not by each of
the apps that take the backup.

Tests:

- Run functional tests for miniflux, dynamicdns, wordpress, zoph, and nextlcoud.
There was an unrelated functional test case failure in nextcloud.

- On a fresh installation, apply patch. Service is restarted. The directory is
created with proper permissions and ownership.

- On a fresh installation, without the patch. Backup the dynamicdns app. The
directory is created with incorrect permissions. Apply the patch. Service is
restarted. Proper permissions are set on the directory.

- On a setup with incorrect permissions, re-run backups app's setup. The
permissions are updated correctly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-15 20:16:36 -05:00
Sunil Mohan Adapa
54bebd7269
transmission: Deal with changes in latest forky package
Fixes: #2555

- '-' in configuration keys changed to '_'. Write both old and new keys to the
configuration file so that same code works for both versions of transmission.
Extra keys are ignored and removed from the configuration by the transmission
daemon.

- When reading the configuration for download directory account for both old and
new keys.

- Update functional tests for change in ID for delete torrent button.

Tests:

- Run functional tests on trixie and forky VM.

- On trixie and forky VM, after the app is installed, the configuration values
are set as expected in the configuration file.  Transmission does not show its
own authentication dialog. FreedomBox SSO works as expected.

- On trixie and forky, updating the download dir in FreedomBox app changes the
values in the web UI.

- On forky, install transmission using old code and sources.list updated to
trixie. Change the download directory. Stop service. Then update the
sources.list to forky, apply patches and start service. Run unattended-upgrades.
Notice that the earlier set download directory persists. Two configuration
values for rpc also are as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-15 20:12:20 -05:00
Sunil Mohan Adapa
0c6335b9df
minetest: Remove legacy code, use new name, conf, etc.
- Update link in copyright file to the logo.

- Update paths to configuration file. Drop hack to load old configuration path.
Migrate old configuration file to new path.

- Use newer package name instead of transitional package name.

- Use newer systemd unit name instead of aliased one.

- Update backup/restore paths.

- Drop code to handle configuration file update. This upgrade was done during
Bookworm cycle. It is not needed for upgrade from Bookworm to Trixie.

- Fix understanding of default values for keys not present in the configuration
file. These values are picked up from source code as the documentation does not
mention them.

Tests:

- Run unit and minetest functional tests.

- After the app is freshly installed. Max users is 15. PvP is enabled. Create
mode is disabled. Damaged is enabled.

- Changes in configuration are reflected.

- Play a game and make some changes. Update configuration. Backup. Uninstall and
restore. The player data is restored. Configuration is restored.

- Install without the changes. Make configuration changes. Apply changes and
remove obsolete files. Restart service. App is updated. Notice that
configuration file is migrated to new path. Configuration options are retained.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-15 19:43:08 -05:00
Benedek Nagy
044d99e367
minetest: Rename Minetest to Luanti
This is to follow up with the upstream change:
https://blog.luanti.org/2024/10/13/Introducing-Our-New-Name/.

Rename Minetest to Luanti in:
- App name
- App description
- Clients' name
- Docstrings

- Also update the donation and client download links to point to the new
  domain.
- Make the app button point to /apps/luanti while continuing to serve
  /apps/minetest in case somebody has it bookmarked.

Closes: #2521

Signed-off-by: Benedek Nagy <contact@nbenedek.me>
[sunil: Rename the old URL to index-old to avoid duplicates]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-12-12 11:16:37 +05:30
Benedek Nagy
959d1e2554
transmission: remove obsolete apache redirects
Tests:
- Install Transmission, apply the patch and confirm that the 409 conflict error,
  that the redirects were originally meant for, is not reproducible anymore.

Fixes: #2502

Signed-off-by: Benedek Nagy <contact@nbenedek.me>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-12-12 06:28:55 +05:30
Sunil Mohan Adapa
6c930a9f24
upgrades: Use bootstrap spinner button instead of custom styling
- This simplifies the implementation and gets it ready for dark/light mode.

Tests:

- In the upgrades main view, set is_busy = True and disable setting
refresh_page_sec. Load the upgrades app and notice that the 'Updating...' button
is showing proper styling in light anddark modes.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-12-02 20:17:11 -05:00
James Valleroy
7e9070e418
homeassistant: Fix spelling in tests
Tests:

- pytest runs the expected tests for Home Assistant.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-11-30 04:43:50 +05:30
Sunil Mohan Adapa
ffecd1411b
jsxc: Update content security policy to prevent style errors
- Without the CSP, during loading there are no errors in the console. However,
during chatting, some styling related error show up.

Tests:

- Ensure that there are no CSP related errors in the browser console.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-21 22:31:27 -05:00
Sunil Mohan Adapa
a66c011f0b
jsxc: Fix missing dependencies
Fixes: #2547.

- Earlier, FreedomBox itself depended on Bootstrap 4 as needed by the room we
built for JSXC. Since FreedomBox moved to Bootstrap 5 this library is no longer
available for JSXC. libjs-jsxc itself depends on libjs-bootstrap which is of
version 3.

- Also fix the path for jquery-slimscroll. This is was likely updated for Trixie
cycle.

Tests:

- Connect to JSXC with two different browsers. Add contacts. Initiate chat and
send messages.

- Re-run app setup and it succeeds.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-21 22:31:14 -05:00
Sunil Mohan Adapa
a10ba40001
dynamicdns: Use only IPv4 for GnuDIP protocol
- The following messages was seen on the ddns.freedombox.org server:
"Unserviceable IP address from <ipv6_address>: user <username>.fbx.one - IP:
<ipv6_address>". This is due to code that checks for validity of incoming IP
address and fails. The current configuration only handles IPv4 address. Even if
this restriction is lifted, GnuDIP code does not contain code to add/remove AAAA
records.

- Fix this by forcing GnuDIP HTTP update requests to go on IPv4.

Tests:

- Copy the code for _request_get_ipv4() into a python3 console and run
_request_get_ipv4('https://ddns.freedombox.org/ip'). Do this on a dual stack
machine with both public IPv4 and IPv6 addresses. Only IPv4 address returned.
Changing the AF to AF_INET6 returns only the IPv6 address.

- Take a test DDNS account offline. Configure it in FreedomBox stable VM. The IP
address is properly updated.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-21 22:03:10 -05:00
Sunil Mohan Adapa
b6bade7d06
janus: Update the video room code from latest upstream
- Bootswatch is a theme library for bootstrap. In Debian, only 3.x version of
the package is available. It is compatible with bootstrap 3.x but not bootstrap
5. Drop the theming altogether and use the basic bootstrap style (which is
already very close to the theme).

- Updated copyright year, mention the video room files in debian/copyright.

- Drop libjs-spin.js which is no longer used by the updated code.

- Change bootstrap version to 5.x from the earlier 4.x. Also add node-popper2
library (needed by bootstrap5 and video room code) as explicit dependency.

- Add missing style for btn-default class dropped in bootstrap 5.

- .simulcast-button CSS style is not longer needed as updated code used flex box
with .d-flex bootstrap class.

Tests:

- Compare the files in janus source code around Mar 2022 with the files in
FreedomBox source code before this patch. Compare latest janus source code with
the files after this patch. Both sets of changes are very similar.

- Connect to video room using two browser windows. Connection is successful and
2 video streams are shown in each of the browser windows.

- Styling looks close to the demo on janus website and is acceptable.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-17 13:03:02 -05:00
Sunil Mohan Adapa
94c344573b
janus: Relax content security policy for the video room
- Needed for the new video room code to run without CSP errors in the browser
console. JS error happens immediately after loading the page before Janus
initialization. Styling related errors happen after joining the room despite
eliminating use of'style=' attributes from JS code.

Tests:

- The video room works for a conference without showing any
Content-Security-Policy header related errors in the Firefox developer console.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-17 13:02:59 -05:00
Sunil Mohan Adapa
32520c7c89
janus: Allow app to be installed from Debian unstable
- Janus is currently not installable in Trixie because Janus was temporarily
removed during the release process of Trixie.

- Installing it from unstable, despite the instability is better than keeping
the app unavailable. Users have reported using the app.

Tests:

- Restarting the service after applying the patch leads to setup for upgrades
app to run. Apt preferences for janus packages are set. App is shown as
available. It can be installed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-17 13:02:56 -05:00
Sunil Mohan Adapa
743b7bd163
ttrss: Remove app not available in Trixie
Tests:

- Running 'make build install' remove the module loading include file for ttrss.

- TT-RSS is no longer available in apps page.

- Installing Tor works. Onion header is set correctly. Re-running app setup
works.

- RSS Bridge's description is updated as expected. Links work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-10 19:20:33 -05:00
Sunil Mohan Adapa
76b360bb68
matrixsynapse: Explicitly set the trusted key server to matrix.org
The following message is shown when Matrix Synapse server is started.

"""
This server is configured to use 'matrix.org' as its trusted key server via the
'trusted_key_servers' config option. 'matrix.org' is a good choice for a key
server since it is long-lived, stable and trusted. However, some admins may
wish to use another server for this purpose.

To suppress this warning and continue using 'matrix.org', admins should set
'suppress_key_server_warning' to 'true' in homeserver.yaml.
"""

Explicitly configure the server to use matrix.org as the trusted key server to
avoid the warning. The value can be set to empty list of servers, however, our
users are served best by this default.

Tests:

- On a testing container, when patch is applied after Matrix app installation,
the configuration file is updated.

- After the configuration is updated the warning is removed during Matrix
Synapse startup.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-10 18:54:46 -05:00
Sunil Mohan Adapa
084c9c5a47
matrixsynapse: Explain federation and link to testing tool
- Create a separate section for federation as it is so important.

Tests:

- Federation description and TLS warning are shown in a separate section on the
app's post-setup page.

- Clicking on the testing tool link takes the user to the testing tool and the
current server's domain is automatically tested.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-10 18:54:41 -05:00
Sunil Mohan Adapa
35cedd7923
matrixsynapse: Clarify how to change domain name in status section
- This has already been update in the pre-setup page.

Tests:

- View the post-setup page and notice that the message was updated.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-11-10 18:54:38 -05:00
Sunil Mohan Adapa
a74028a73f
help: Fix serving images from help pages
Tests:

- Images are shown in the pages /plinth/help/manual/en/bepasty and
/plinth/help/manual/en/. Before the patch, images are not shown and 404 errors
are raised.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-11-06 20:03:04 +05:30
Sunil Mohan Adapa
623604649e
views: Implement an API to retrieve the readiness status in JSON
- This can have may uses such as:

  - Waiting properly on the reboot page until the system has been restarted
  while showing the status.

  - Or, waiting for first setup to complete before running functional tests.

  - Or, monitoring for the health status of FreedomBox in general.

- The page is public as all the information conveyed there is also already
public. Should we introduce any sensitive information there such as
'operations_in_progress', we can provide that information only to
administrators.

Tests:

- Visiting /plinth/status/ shows the status in JSON. Using curl to retrieve the
information is also possible.

- During the first setup 'is_first_setup_running' is 'true'. After it has
completed, it is 'false'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-11-03 13:53:59 +02:00
Sunil Mohan Adapa
43ff0b57ce
zoph: Additional dbconfig configuration keys
Tests:

- Install, uninstall and re-run setup work.

- Functional tests work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-10-05 10:39:22 -04:00
Sunil Mohan Adapa
60c57b6707
miniflux: Fix DB connection issues during install/uninstall
Fixes: #2536.

Multiple fixes:

- When miniflux and postgresql are install simultaneously, miniflux setup may be
installed before postgresql is started.

- When postgresql is already installed and disabled (due to a previous
uninstall), then postgresql may not be running during miniflux package
installation (and fail initial DB setup).

- When app is being installed while it is disabled, the database may not running
and may lead to failure in removing the app database.

Tests:

- Run functional tests on stable/testing twice in a row.

- Install the app without postgresql or miniflux installed.

- Disable the app and uninstall it. DB is purged.

- Uninstall and re-install (with postgresql is disabled during installed).

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-10-05 10:39:18 -04:00
Veiko Aasa
dc837bd6b8
gitweb: Use Git credential helper when cloning URLs with credentials
This prevents logging usernames and passwords to the journal logs and to the
Git repo configuration. Also, avoids usernames and passwords appear in the
process list when cloning a repository.

Tests performed:
- Create a new repository by cloning an existing repository URL with basic
auth credentials. Check that:
  - Cloning succeeds.
  - Journal logs don't contain URLs with credential info.
  - The configuration of the cloned repository doesn't contain credential info.
- Try to clone a non-existing repository URL that contains credential
info. Cloning fails and there are no credential info in the journal logs.
- Cloning a public git repository without credential info succeeds.
- All the gitweb module tests pass.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Add/fix some more type hints]
[sunil: Add tests for URL parsing]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-09-29 16:42:17 -07:00
Sunil Mohan Adapa
f2bceb48cf
backups: Don't show enable/disable button as app can't be disabled
Fixes: #2472.

Tests:

- On backups page, the enable/disable toggle button is not visible anymore.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 17:17:58 +03:00
Sunil Mohan Adapa
7f608cd570
*: Collect output for all privileged sub-processes
- Now that we have a mechanism for properly collecting, transmitting, and display
the stdout and stderr. There is no reason not to collect all of the stdin and
stderr.

- Also, the stdin/stderr=subprocess.PIPE is redundant and prevents the output
from getting collected for debugging. So, remove it.

Tests:

- Ran functional tests on backups, calibre, ejabberd, email, gitweb, ikiwiki,
infinoted, kiwix, mediawiki, mumble, nextcloud,, openvpn, samba, wireguard,
zoph. 2-3 issues were found but did not seem like new errors.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:57 +03:00
Sunil Mohan Adapa
b253166f6d
*: Use action_utils.run instead of subprocess.check_output
- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:56 +03:00
Sunil Mohan Adapa
bf9005ac48
*: Use action_utils.run instead of subprocess.call
- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:55 +03:00
Sunil Mohan Adapa
80e6d940a4
*: Use action_utils.run instead of subprocess.check_call
- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

- systemd daemon-reload is performed during infinoted setup.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:54 +03:00
Sunil Mohan Adapa
61ff15a04f
*: Use action_utils.run instead of subprocess.run
- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:53 +03:00
Sunil Mohan Adapa
5566f05cad
config: Set home page to FreedomBox for invalid values
- When attempting to set an invalid shortcut ID or invalid user's directory as
home page, set FreedomBox UI as home page.

- Simplify the tests somewhat and avoid failure first time and skipping the test
next time.

Tests:

- Run unit tests as 'root' and 'fbx' users.

- Set home page to apache default, FreedomBox, user home page and a shortcut.
The set value is retained. The change works when visiting / with browser. The
value is as expected in Apache configuration.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:47 +03:00
Sunil Mohan Adapa
647e72516c
backups: Fix robust handling of known errors
During functional tests, it was noticed that getattr() failed at the following
line. The original intent of the code is to ensure that there are no failures
when 'stdout'/'stderr' attribute are not present or when they return None.

    stdout = (getattr(err, 'stdout') or b'').decode()

Tests:

- Make the UI raise incorrect password error. Notice that the error is shown
properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:47 +03:00
Sunil Mohan Adapa
288b58e0b5
storage: Fix disk usage checking with disconnected SSH mounts
- When disconnected sshfs mounts are present, then df command prints the disk
usage for the remaining disks but prints a warning to the stderr and return a
non-zero return code. Accommodate this case and parse the information for all
the available disks.

Tests:

- Create a remote backup location and mount it. When the SSH process is killed,
it leaves a mount point that is not properly connected. View the storage page to
see that disk usage for other partitions is shown properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:42 +03:00
Sunil Mohan Adapa
904e5935cb
backups: Ignore a typing error with mypy
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:39 +03:00
Sunil Mohan Adapa
d512a8b645
diagnostics: In development mode, run diagnostics more rarely
Due the frequency and length of execution of diagnostics, the service does not
restart when files are modified. The operation also makes other testing tasks
wait until completed. It also makes functional tests slower. So, reduce the
frequency of execution. It can always be temporarily changed when debugging
diagnostics operations is necessary.

Tests:

- Change the development interval to 18 seconds and notice that new interval is
effective in development mode but not in production mode.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-29 16:58:39 +03:00
Sunil Mohan Adapa
2862862161
api: Fix showing icons for custom shortcuts
Tests:

- Add a custom shortcut and provide a custom icon for it in
/var/www/plinth/custom/static/icons/. Visit the page /plinth/api/1/shortcuts/.
The icon path for the custom shortcut is correct and accessible from browser.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-22 19:43:06 -04:00
Sunil Mohan Adapa
ced83a31e9
zoph: Fix cases when CLI user is set to "autodetect"
Closes: #2538

Tests:

- Without the patch, set the Zoph CLI User to "autodetect" and notice the
failure to load Zoph page.

- With the patch, set user to "autodetect" and access the app page. It is
updated to the first admin user in Zoph DB.

- Try with updating Zoph configuration.

- Try with re-running Zoph setup.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-21 13:25:58 -04:00
Sunil Mohan Adapa
5758bdba2a
upgrades: Overwrite apt sources lens with bug fixes
Fixes: #2251
Fixes: #2426

- Temporarily add a bug fix for the one-line style apt sources format. Upstream
submission: https://github.com/hercules-team/augeas/pull/865 .

- Currently, only two options with keys arch= or trusted= are allowed. However,
as documented in apt manual page[1], there are many different options possible.
Apt itself parses these options in a much more generic way[2][3].

- Fixes allow parsing all the different options allowed by apt. A practical
example (accepted by apt) is also provided as a test case.

Tests:

- Add the following line to one of the apt sources file in
/etc/apt/sources.list.d: "deb
[signed-by=/usr/share/keyrings/debian-archive-trixie-stable.gpg]
https://deb.debian.org/debian trixie main". In augtool, print
/augeas/files/etc/apt/sources.list.d//error.

- With the patch, run 'make build install' and errors in augtool disappear.

- In tor proxy app, enabling/disabling apt through tor works. The files in
/etc/apt/ are updated as expected.

Link: https://manpages.debian.org/trixie/apt/sources.list.5.en.html
Link: 3c9399e643/apt-pkg/sourcelist.cc (L215)
Link: 3c9399e643/apt-pkg/contrib/strutl.cc (L245)
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-21 08:11:50 -04:00
Sunil Mohan Adapa
a98e6f7563
upgrades: Multiple fixes for parsing Apt's Deb822 style sources
- Allow DOS style line endings

- Allow preceding, trailing, and repeating empty lines

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-21 08:11:48 -04:00
Sunil Mohan Adapa
795bd1fd9e
torproxy: When disabling apt over tor fails, report error properly
- It is not possible to disable apt over tor for as many files as possible with
the current code because even an error in a single file will result in entire
process failing. Instead, implement a way to disable the exception.

Tests:

- Add an unparsable line into the one of the apt sources files. Disabling apt
over tor works and all file but the error file are modified.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-21 08:11:44 -04:00
Sunil Mohan Adapa
567e34d467
bepasty: tests: Fix functional test failure to missing / in URL
Helps: #2517.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-09-19 11:13:12 -07:00
Sunil Mohan Adapa
5a55b59939
diagnostics, help: Link to diagnostics page logs in 500 error page
Closes: #2414.

- Remove separate implementation for showing logs in help page.

- Add link to the page in diagnostics app so that FreedomBox logs can more
easily be discovered by users.

Tests:

- Raise an exception in the common error middleware to cause a 500 internal
server error. Run FreedomBox service with the --develop option and notice that
500 error page is served. There, the link to logs page works. It shows the logs
for Diagnostics app.

- Diagnostics page description is update. Link to logs page works.

- Diagnostics page shows logs for plinth.service and freedombox-develop.service.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2025-09-18 16:35:23 +03:00
Sunil Mohan Adapa
c95ee766aa
bepasty: tests: Override backup/restore test properly
- The current name does not the match the base class method it intends to
override.

Tests:

- Run functional tests for bepasty -v option and notice that only one backup and
restore test runs.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-09-12 11:24:19 -07:00
Sunil Mohan Adapa
b7df34d175
matrixsynapse, upgrades: Install select packages from unstable
Tests:

- On stable, testing distributions applying the patches and restarting the
services causes two files to be created on the system.
/etc/apt/sources.list.d/freedombox-unstable.list and
/etc/apt/preferences.d/50freedombox-dist.pref. In unstable distributions the
files are not created.

- Installing Matrix Synapse on all three distributions works. Initial domain
configuration works. All diagnostic tests pass.

- On stable and testing distributions, running 'apt policy matrix-synapse' shows
that priority for package from unstable is 200 higher than installed package
priority of 100. Same for the package python3-pympler. Running 'apt policy
freedombox' shows that package from -backports has a priority of 500 that is
same as the priority of non-backports package.

Tests:

- During re-run of setup, unstable sources are setup.

- Matrix synapse app shows updated description.

- Upgrades app shows updated description about frequent feature updates.

- On oldstable, stable, and testing distributions unstable sources are setup.
But not on unstable.

- On stable, testing distributions applying the patches and restarting the
services causes two files to be created on the system.
/etc/apt/sources.list.d/freedombox-unstable.list and
/etc/apt/preferences.d/50freedombox-unstable.pref. In unstable distributions the
files are not created.

- Installing Matrix Synapse on all four distributions works. Initial domain
configuration works. All diagnostic tests pass.

- On oldstable, stable, and testing distributions, running 'apt policy
python3-pympler matrix-synapse python3-python-multipart' shows that priority for
package from unstable is 200 higher than installed package priority of 100.
Running 'apt policy freedombox' shows that package from -backports has a
priority of 500 that is same as the priority of non-backports package.

- When frequent feature updates is not enabled, the app can't be installed.
"This application is currently not available in your distribution." message is
shown. After enabling frequent feature updates, the apps can be installed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-08 19:33:56 -04:00
Sunil Mohan Adapa
fecd6a3577
upgrades: Overhaul detection of distribution
- Move some utilities to utils.py from distupgrade.py and __init__.py.

- This fixes issues with apt preferences being set on unstable
distribution (despite code that tries to prevent it).

- There is no way to distinguish between 'testing' and 'unstable' distributions
in Debian using commands like lsb_release (powered by /etc/os-release). See:
https://lwn.net/Articles/984635/ . So, use the value set in
/etc/apt/sources.list.

Tests: (tested entire patchset)

- Deluge can be installed in trixie.

- Auto-distribution upgrade button is checked during setup on stable and
oldstable but not on testing and unstable.

- Auto-distribution upgrade button is enabled in the form on stable and
oldstable but not on testing and unstable.

- Backports wizard step is skipped on unstable (non-develop mode), but not on
oldstable, stable, testing, and unstable (develop mode).

- If backports are not activated during first wizard, then backports can be
activated on upgrades app page if distribution is oldstable, stable, testing, or
unstable (non-develop mode) but not unstable (develop mode).

- During re-run of setup, setting up backport sources is skipped if already
setup.

- Backports sources files are not added in testing (non-develop) and
unstable (non-develop) distributions. Backports sources are added to oldstable,
stable, testing (develop) and unstable (develop). Unstable sources sources are
not added to unstable but added to oldstable, stable, and testing.

- Backports sources file is added with correct code name bookworm/trixie for
oldstable, stable, and testing distributions.

- When backports sources is set to 'bookworm-backports' on Trixie distribution,
re-running setup updates them to 'trixie-backports'.

- Preferences files are added in oldstable, stable, and testing distributions
but not unstable.

- If unstable and another distro is present in apt sources, then it is treated
as unstable as shown in the distribution upgrade page.

- Current codename is shown properly from sources.list in oldstable, stable,
testing, and unstable in distribution upgrade page.

- NOT TESTED: If distribution upgrade is interrupted, then continue page is
shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-09-08 19:33:33 -04:00
Sunil Mohan Adapa
4a0e35f806
dynamicdns: Handle showing errors from GnuDIP
- Recently we have changed to using HTTP protocol for GnuDIP updates. These
involve using requests library. For exceptions raised by this library the
arguments may not all be JSON serializable. So, explicitly convert them into
strings.

Tests:

- Turn of network connection to the machine. Trigger a Dynamic DNS update by
re-submitting configuration form. This will results in an error message shown
in status table instead of an unhandled exception.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 22:00:04 +05:30
Sunil Mohan Adapa
0c6f04b55f
actions, backups: Fix tests depending on sudo based actions
Tests:

- Mounting/unmounting of remote SSH repositories works.

- Creating repo, creating/deleting/list archives work.

- If a privileged method raises an exception after outputting to stdout (using
action_utils.run) then stdout is shown in the HTML UI message.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:24:10 +05:30
Sunil Mohan Adapa
a580437de2
privileged_daemon: Introduce a command line client for the API
- Similar call signature as actions/actions.

Tests:

- Running make install places a binary file in /usr/bin/freedombox-cmd

- Running 'freedombox-cmd upgrades get_log --no-args' works.

- Running 'freedombox-cmd upgrades activate_backports --no-args' works.

- Running 'freedombox-cmd storage usage_info --no-args' works.

- Running 'freedombox-cmd sshfs is_mounted --no-args' works.

- echo '{"args": ["USERNAME", "AUTH_USER", "AUTH_PASSWORD"], "kwargs": {}}' |
sudo freedombox-cmd users remove_user.

- Distribution upgrade from Bookworm to Trixie works.

  - Snapshots are disabled and re-enabled during upgrade.

  - /etc/apt/sources.list changes are completed on completion.

- If a command fails, the return code is not 0.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:23:36 +05:30
Sunil Mohan Adapa
143e4a00bd
actions, backup: Implement raw output for privileged daemon
- Regression: downloading does not work with sudo based action anymore. However,
sudo based actions are to be removed in later patches.

Tests:

- Downloading tar backup archive works. Untar works. Downloading gives upto
10MiB/s speed.

- If API is not called with _raw_output=True, then special exception is raised.

- Downloading tar file from command line using nc also works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:23:25 +05:30
Sunil Mohan Adapa
0aa3ee5a70
actions: Simplify raw output code in privileged methods
Tests:

- Downloading tar backup archive works. Untar works. Downloading gives upto
10MiB/s speed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:23:16 +05:30
Sunil Mohan Adapa
773460dde9
storage: Don't use privileged action feature to run as different user
- Instead implement running specific commands inside the privileged action as a
specific user.

Tests:

- In transmission, setting the download directory is valid if

  - A parent level directory is writable by transmission daemon and child does
  not exist.

  - A leaf level directory is writable by transmission daemon when leaf exists.

  - A leaf level exists and is not a directory.

- In MiniDLNA, setting the directory works only if it exists and is readable.
Work when write permission is not available.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:22:54 +05:30
Sunil Mohan Adapa
87331e7c97
gitweb: Don't use privileged action feature to run as different user
- Instead implement running specific commands inside the privileged action as a
specific user.

Tests:

- Gitweb functional tests and unit tests work.

- Running various operations such as clone, create, set branch, rename, etc. all
result in repositories (and all their contents) owned by www-data:www-data.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-09-05 20:22:40 +05:30