91 Commits

Author SHA1 Message Date
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
b494f8a993
names: Add information about adding static domains/subdomains
Tests:

- Visit the add static domain page. Notice that additional form description is
visible.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-05-30 15:14:04 -04:00
Sunil Mohan Adapa
5a9d5730a7
names: Store domains in kvstore instead of /etc/hosts
As reported in discussion forum[1], when clients connected via 'shared' network
connection try to resolve the a static domain name configured in FreedomBox,
they resolve to 127.0.1.1. Since this refers to client's own IP address, they
fail to connect.

In the previous version, this was not a problem because the entry was stored as
<hostname>.<domainname>. To resolve this, store domain names in kvstore instead
of /etc/hosts.

Links:

1)
https://discuss.freedombox.org/t/freedombox-resolves-its-own-external-name-as-127-0-1-1/3660

Tests:

- Adding/removing static domains from Names app works. The order of added
domains is preserved in the stored configuration. When adding a existing domain,
a proper error message is shown.

- Without the patch, configure multiple domains. They show up in /etc/hosts.
Apply the patches and restart the service. Names app setup will run. Entries
from /etc/hosts are removed and will be added to kvstore. The list of domains
shows properly in Names app. After restarting the services, domains are show
properly.

- Without the patch on a version of FreedomBox without support for multiple
static domains, configure a static domain. Switch to latest version FreedomBox
with the patches. Restart the service. Names app setup will run. Entry from
/etc/hosts will be removed and will be added to kvstore. The list of domains
shows properly in Names app. After restarting the services, domains are show
properly.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-03-21 16:01:41 -04:00
Sunil Mohan Adapa
84bf20e1b8
names: Handle addition of duplicate static domains
Tests:

- Adding an new unique domain works.

- Adding an existing domain results in an error.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-24 17:30:42 -05:00
Sunil Mohan Adapa
85a694f20f
names: Retrieve the most important domain in a more generic way
- The get_domain_name() has some problem. It returns only static domain names
but not a dynamic domain name. It may not always return the same domain when
multiple static domains are configured. It may return return an empty string.

Tests:

- JSXC page shows the alphabetically first static domain. If no static domain is
configured, first dynamic domain is shown, next pagekite domain, next pagekite
domain, next tor onion domain, and finally .local domain.

- Downloading profile from OpenVPN will set the first domain in it.

- When ejabberd is installed, the first domain is configured by default.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:45:05 -05:00
Sunil Mohan Adapa
aac12f4391
names: Sort domains by priority of their domain types
- First of the list is the most important one and may be used as "primary"
domain in apps.

- Change the return type of DomainName.list() from set to list so that order can
be preserved. Update all users of the API accordingly. Add type hints to all the
methods using this API to catch any errors.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:45:01 -05:00
Sunil Mohan Adapa
045b336a9b
names: Specify priority order among domain types
- This can be used to ensure that apps that can deal with only a single domain
auto-configure the best domain by default.

Tests:

- Unit tests run.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:58 -05:00
Sunil Mohan Adapa
49d16412f8
names: Simplify/clarify domain names types for static/dynamic
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:56 -05:00
Sunil Mohan Adapa
863d170219
names: Allow adding multiple static domain names
- Change the mechanism for storing domain names in /etc/hosts. Don't write
hostname to /etc/hosts. Don't prepend hostname to domain name. This means that
when hostname changes, set_domain_name need not be called.

- This means that domain names such as example.fbx.one were not resolvable using
/etc/hosts but these will now resolve to 127.0.1.1. This is a minor concern to
becoming a breaking change.

- Don't use socket.getfqdn() for finding the domain name of the machine. Instead
read from /etc/hosts. There does not seem to a glibc/python API for querying
domain names from /etc/hosts with all variations it allows. Forward resolution
properly works no matter the library.

- Drop a pre-Python 3 conversion from unicode to ascii string for hostname. This
is no longer relevant.

- Domain name form is now domain add form. Passing domain name is mandatory.
Domain delete form and view have been introduced.

- Use augeas to edit hosts file. Add privileged methods to add/delete/get
domains. Add method to migration from old format to new. Support reading old
format too in get_domains.

Tests:

- Without hostname written in /etc/hosts, 'resolvectl query <hostname>' and
'ping <hostname>' work.

- With old /etc/hosts format apply patches and restart service. It will be
converted to new format.

- Adding a domain adds a new line to /etc/hosts file. The domain is shown in
domains list in Names app. Applications get reconfigured with the new domain
name.

- Deleting a domain adds a new line to /etc/hosts file. The domain is shown in
domains list in Names app. Applications get reconfigured with the new domain
name.

- Restarting app triggers domain added signal for all domains and all the
domains are shown in the Names app.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:50 -05:00
Sunil Mohan Adapa
889453daff
names: Simplify showing current and available domains
- In the main domains list, only show currently configured domains. Allow
operations such as edit/delete/configure on them. Actions are determined by the
domain type.

- Show domain types that can be added in a separate table. If an domain is
present and only of that type can exist, it will not be shown in this table.
Show add/configure action based on whether multiple domains can exist.

Tests:

- Configuring a singleton domain type puts it in the domains tables and removes
it from the add domains table. De-configuring it or disabling it does the
opposite.

- For domain types with multiple domains (static/dynamic), entries are shown in
domains if such domains exist. Entry in add domains tables always shows up.

- All action buttons for all five domain types work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:47 -05:00
Sunil Mohan Adapa
e8d2faecab
names: Add more URLs to the domain type component
- To be used to present better interface for domain types that have multiple
domains.

Tests:

- Unit tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:43 -05:00
Sunil Mohan Adapa
ca5f547c02
names: domain type: Minor refactor
- In preparation for changes to domain type component.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:19 -05:00
Sunil Mohan Adapa
d9f9168c76
names: Use hostnamectl instead of socket API get the current hostname
- This would mean consistent interfacing with systemd instead of a split
approach.

Tests:

- Edit hostname page shows the current value of hostname correctly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2025-02-16 10:44:16 -05:00
Sunil Mohan Adapa
89bce7a344
app: Add tags to menu and frontpage components
- Add typing information for init methods Info, Shortcut, and Menu to easily
  identify problems.

- Update docstrings for these components.

- Updates test cases to deal with tags instead of short description.

- Update custom shortcuts code to read tags and ignore short description.

- Update API to send tags instead of custom shortcuts.

- OpenVPN special treatment of info.description in Shortcut

Tests:

- All unit tests pass and type checking succeeds.

- All apps show icons with tags in apps and system section.

- In help section cards don't show tags.

- In front page, enabled apps show shortcuts with tags.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2025-01-09 21:08:10 +05:30
Sunil Mohan Adapa
3a0db947b2
system: Add tags to all remaining apps
Tests:

- Visit the system page and notice that tags appear as expected for all items on
the page.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-12-29 22:58:23 -08:00
Sunil Mohan Adapa
62dad9336b
ui: Use Bootstrap 5 styling for all alerts
- Ensure that .sr-only is replaced with newer classes.

- Ensure that icons are present for all alerts.

- Use flex-box for display of icons on the left center of the alert.

- .close has been renamed to .btn-close.

- &times; is no longer required for close buttons.

Tests:

- Visually verify all the changes by triggering them with code changes.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-12 12:38:01 +02:00
Sunil Mohan Adapa
db92640f3c
names: Don't hard depend on systemd-resolved
Fixes: #2453

- It will be installed later.

Tests:

- Build the Debian package with all the changes and notice that it neither has
dependency on resolvconf nor on systemd-resolved.

- Version 24.18 can upgrade to this package using unattended-upgrade. For this
place the package in a folder repository and add this repository to apt
sources.list and tweak unattened-upgrades settings to accept the new repository.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:35:04 +03:00
Sunil Mohan Adapa
5611585790
names: Schedule a task to install systemd-resolved when possible
- Don't schedule if the package is already installed.

Tests:

- With systemd-resolved installed and without internet connectivity start a
fresh instance (without first setup). Setup succeeds but systemd-resolved is not
installed.

- Wait in develop mode for 180 seconds. Setup for names app is re-run. Ensure
that internet connectivity is not available and systemd-package is not
installed. Setup still succeeds.

- On next run, ensure that internet connectivity is available, systemd-resolved
is installed. Setup succeeds.

- On next run, setup is not re-run for names app.

- When service is restarted, the task is not even scheduled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:34:54 +03:00
Sunil Mohan Adapa
7e8819d7d5
names: Try to install systemd-resolved during app setup
- If installing systemd-resolved for the first time, set fallback DNS setting to
True irrespective of the app version.

Tests:

- Ensure that systemd-resolved is not installed. On a fresh systemd without
first setup done, run service.

- Names app setup is run and systemd-resolved is installed if internet
connection is available. Setup succeeds. Fallback DNS setting is true in privacy
app. systemd-resolved has been restarted and current DNS known to Network
Manager has been populated in it. Name resolution works.

- If Internet connection is not available, setup still succeeds but
systemd-resolved package is not installed.

- Rerun setup without internet connectivity. Setup succeeds without installing
systemd-resolved.

- Rerun setup with internet connectivity. Setup succeeds and installs
systemd-resolved. Fallback DNS setting is true in privacy app. systemd-resolved
has been restarted and current DNS known to Network Manager has been populated
in it. Name resolution works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:34:37 +03:00
Sunil Mohan Adapa
70c37f309e
names: Don't control resolved daemon when package is not installed
Tests:

- Ensure that systemd-resolved is not installed.

- There is no warning showing that systemd-resolved daemon is not running.

- When re-running setup, systemd-resolved is not enabled.

- Diagnostic shows a warning that systemd-resolved is not installed.

- Ensure that systemd-resolved is installed.

- If daemon is not running, warning shown that it is not running.

- If daemon is running, warning is not shown.

- When re-running setup, systemd-resolved is enabled.

- Diagnostic shows that the daemon is running when running and not running when
it is not.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:34:21 +03:00
Sunil Mohan Adapa
5c06b6c31a
names: Don't show resolver status if package is not installed
Tests:

- Ensure that systemd-resolved package is not installed.

- Resolver status table is now shown.

- Instead a message is shown with button to re-run setup. Clicking the button
re-runs setup of the names app.

- Configuration form is also now shown.

- If systemd-resolved package is installed during re-run of setup, then status
table is shown.

- Message to install systemd-resolved is not shown.

- Configuration form is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:34:01 +03:00
Sunil Mohan Adapa
0a10ced950
names: Perform resolve diagnostics only if resolved is installed
Tests:

- Ensure that systemd-resolved is not installed. Run diagnostics on names app.
There should be no diagnostic related to resolving address for deb.debian.org.

- Ensure that systemd-resolved is installed. Run diagnostics on names app. There
should be diagnostic related to resolving address for deb.debian.org.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:33:49 +03:00
Sunil Mohan Adapa
dd16034e3c
names: Introduce method to check if resolved is installed
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-10-07 01:32:02 +03:00
Sunil Mohan Adapa
9009cdafd6
config, names: Move domain name configuration to names app
Tests:

- Config app description is as expected.
- Config form does not show domain name field anymore.
  - Submitting the form with changes works.
- Names app has correct link for configuring static domain name. Clicking it
  takes to page for setting domain name.
- On startup, static domian name signal is sent properly if set. Otherwise no
  signal is send.
- Change domain name form shows correct value for current domain name.
- Change domain name form sets the value for domain name properly.
  - Page title is correct.
  - Validations works.
  - Add/remove domain name signals are sent properly.
  - Success message as shown expected
  - /etc/hosts is updated as expected.
- Unit tests work.
- Functional tests on ejabberd, letsencrypt, matrix, email, jsxc, openvpn
- After freshly starting the service. Visiting names app shows correct list of
  domains.
- ejabberd:
  - Installs works as expected. Currently set domain_name is setup properly.
    Copy certificate happens on proper domain.
  - Changing the domain sets the domain properly in ejabberd configuration.
  - Ejabberd app page shows link to name services instead of config app.
    Clicking works as expected.
- letsencrypt:
  - When no domains are configured, the link to 'Configure domains' is to the
    names app.
- matrix-synapse:
  - Domain name is properly shown in the status.
- email:
  - Primary domain name is shows properly in the app page.
  - Setting new primary domain works.
  - When installing, domain set as static domain name is prioritized as primary
    domain.
- jsxc:
  - Show the current static domain name in the domain field. BOSH server is
    available.
- openvpn:
  - Show the current static domain in profile is set otherwise show the current
    hostname.
  - If domain name is not set, downloaded OpenVPN profile shows hostname.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-19 13:43:32 +03:00
Sunil Mohan Adapa
8c69858d43
config, names: Move setting hostname from config to names
Tests:

- Config app description is as expected.
- Config form does not show hostname anymore.
  - Submitting the form with changes works.
- Names app has correct link for configuring Local Domain Name. Clicking it
  takes to page for setting hostname.
- Avahi shows the current .local domain correctly in Names app.
- Change hostname form shows correct value for current hostname.
- Change hostname form sets the value for hostname properly.
  - Page title is correct.
  - Validations works.
  - Pre/post hostname change signals are sent properly
  - Success message as shown expected
  - hostnamectl shows the set domain
- If domain name is not set, downloaded OpenVPN profile shows hostname.
- Unit tests work.
- Functional tests on names/config/avahi apps work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-19 13:42:47 +03:00
Sunil Mohan Adapa
a1070bf319
names: Show systemd-resolved status in the names page
This improves the user experience in many ways:

- Help user understand if DNSSEC is being used on the current DNS server in case
'allow-fallback' is supported.

- Nudges the user to explore enabling DNS-over-TLS and DNSSEC.

- Help user understand how global vs. link specific configuration works. Help
user understand if a global DNS is being used.

- Show the list of fallback DNS servers being used (as this poses privacy
concerns).

Also helps with debugging in problematic situations:

- Find out which DNS server is being used (and leading to problems) and show the
cycling mechanism.

Tests:

- Enable/disable fallback DNS server in privacy app. See that fallback servers
line is only shown when enabled.

- Set various global values of DNS-over-TLS and DNSSEC and see the status
changes.

- Set various values of DNS-over-TLS in the network connection settings and see
the changes in status.

- Set DNSSEC to allow-fallback. Perform a query and see that the value of
supported/unsupported changes.

- Set DNS servers with special configuration file in
/etc/systemd/resolved.conf.d/test.conf and restart systemd-resolved. See change
in status page. Notice that if connection specific DNS server is set to an
invalid server, global section has a current DNS server.

- Set SNI domain name and port for the an IPv4 DNS and an IPv6 DNS. See that the
display is as expected.

- Raise an exception in get_status() and notice that an error alert is show
properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewd-by: Veiko Aasa <veiko17@disroot.org>
2024-09-07 22:58:48 +03:00
Sunil Mohan Adapa
ffa628c4e4
names: Add option for setting global DNSSEC preference
Closes: #603.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-07 12:25:03 +03:00
Sunil Mohan Adapa
6062b9ef85
names: Restart instead of reload for systemd-resolved changes
- Reloading systemd-resolved does not seem to apply the DNS-over-TLS changes
fully. Although resolvectl shows the new status after a reload, systemd-resolved
seems to be using incorrect DNS-over-TLS setting.

Tests:

- Without the patch, set DNS server that does not support DNS-over-TLS such as
dnsmasq in Network Manager's 'shared' connection. Then enable DNS-over-TLS.
resolvectl shows that DNSOverTLS flag correctly. But name resolutions still
work.

- With the patch, repeat the above and notice that resolution does not work.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-07 12:24:41 +03:00
Sunil Mohan Adapa
1eb578fdb5
names: Implement a diagnostic check for checking name resolution
- Use deb.debian.org because it is already contacted regularly for
checking/downloading packages and updates.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-07 12:24:21 +03:00
Sunil Mohan Adapa
a124681083
names: Add option for setting global DNS-over-TLS preference
Tests:

- Visit the names app. New 'Domains' heading and configuration section appear.

- DNS-over-TLS configuration option is as expected.

- When the configuration file does not exist, the option selected is 'no'.

- When the configuration option is changed, 'resolvectl' shows the newly set
configuration. Using 'resolvectl query {domain}' does not work when DoT is on
and server does not support DoT. 'opportunistic' and 'no' work on those cases.

- When a DNS server supporting DoT (such as 1.1.1.1) is manually set, resolution
with all three settings works.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-07 12:23:52 +03:00
Sunil Mohan Adapa
28886b56cf
names, network: Re-feed DNS known to network-manager to resolved
- This avoids using fallback DNS servers in systemd-resolved soon after
systemd-resolved takes over /etc/resolv.conf and if network-manager knows some
DNS servers from the connections it has established.

- Version for the names app has already been incremented in this patch series.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-04 10:30:00 +03:00
Sunil Mohan Adapa
0817e7af45
names: Use systemd-resolved for DNS resolution
- Disable mDNS resolution. While we can migrate our DNS-SD service definition
files to systemd-resolved and switch from using avahi to systemd-resolved, many
programs still solely depend on avahi-daemon. Examples include cups and GNOME.
It is not clear if they will work any mDNS daemon or if they interact with
avahi-daemon in other ways that the mDNS protocol. So, for now, disable mDNS in
systemd-resolved and continue to use avahi-daemon for it. This is also Fedora's
default.

- Re-introduce Fallback DNS servers with the value same as the upstream systemd
project. Debian removes the default fallback DNS servers likely because they
could be considered a privacy violation. However, when systemd-resolved package
is first installed, the post install script recommends a reboot instead of
feeding the currently configured nameservers from /etc/resolve.conf into
systemd-resolved. Immediately, this causes the system not be able to connect to
any external servers. While this may be acceptable solution for interactive
systems and pre-built images, FreedomBox has to a) be available for remote
access b) perform upgrades without user intervention (and without reboot until a
day). To mitigate privacy concerns, an option to disable these fallback servers
will be provided in the UI.

- systemd-resolved's stub resolver runs on 127.0.0.53%lo:53 and 127.0.0.54. This
does not conflict either with shared connections which listen on 10.42.x.1 or
with bind which listens on 127.0.0.1 (and other IP addresses). This MR does not
address the existing conflict between bind and shared network connections.
However, it does not cause any further conflicts.

Tests:

* mDNS

- Avahi diagnostics works. daemon is running. mdns port is exposed in the
firewall.

- systemd-resolved does not listen on mDNS ports.

- Running avahi-browse shows freedombox on local network.

- Running avahi-browse shows the services ssh, sftp-ssh, http and ejabberd.

- Machine can be discovered in Gnome Files.

* NetworkManager shared connections

- After install/upgrade to systemd-resolved, 'shared' connections can be
created.

- With a 'shared' connection configured and active, it is possible to upgrade to
using systemd-resolved.

- Resolving domains from a machine on shared network goes via systemd-resolved
on FreedomBox.

* Bind

- Installing, running tests on bind works.

- Programs connecting from outside network can connect to bind as expected.

- Programs connecting from local machine can connect to bind as expected.

* Upgrading works

- Upgrading to new FreedomBox package works

- systemd-resolved is installed and running. 'resolvectl' shows a proper name
server (or fallback nameserver like 1.1.1.1).

- libnss-resolve is installed and configured in /etc/nsswitch.conf

- /etc/resolv.conf has proper link to /run/systemd/resolve/stub-resolv.conf.

- Programs using /etc/resolv.conf directly work. Install python3-pycares.
python3 -m pycares freedombox.org.

- NetworkManager has passed on proper DNS entries. In logs dns=systemd-resolved,
rc-manager=unmanaged, plugin=systemd-resolved

- DNS resolution works after first setup. Installing packages works.

- 'resolvectl query' resolution works.

- Programs using glibc API resolution such as 'ping' work.

* Fresh image

- Building an image with new freedombox package works without error.

- Booting from fresh images works.

- systemd-resolved is installed and running. 'resolvectl' show proper name
server.

- libnss-resolve is installed and configured in /etc/nsswitch.conf

- /etc/resolv.conf has proper link to /run/systemd/resolve/stub-resolv.conf

- Programs using /etc/resolv.conf directly work. Install python3-pycares.
python3 -m pycares wikipedia.org

- NetworkManager has passed on proper DNS entries. In logs dns=systemd-resolved,
rc-manager=unmanaged, plugin=systemd-resolved

- DNS resolution works after first setup. Installing packages works.

* Installing package on Debian

- Installing new freedombox package in Debian machine works.

- systemd-resolved is installed and running.

- libnss-resolve is installed and configured.

- /etc/resolv.conf has proper link to /run

- NetworkManager has passed on proper DNS entries to systemd-resolved using
'nmcli reload dns-rc'.

- Resolution works with fallback DNS servers when network interfaces are
configured with /etc/network/interfaces

* OpenVPNs works

- As a server, we don't push DNS servers to the client. So, a client continues
to use its old DNS servers. With systemd-resolved running on server, the client
is able to connect to OpenVPN server, route traffic to the internet, and resolve
DNS queries.

* WireGuard works

- As a server, we can't push DNS servers to the client. So, a client continues
to use its old DNS servers. With systemd-resolved running on server, the client
is able to connect to WireGuard server, route traffic to the internet, and
resolve DNS queries.

- As a client, server does not push DNS servers to the client. So, a client
continues to use its old DNS servers. With systemd-resolved running on the
client, the client is able to connect to WireGuard server, route traffic to the
internet, and resolve DNS queries.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-04 10:28:47 +03: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
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
2dd00a8f08
*: Fix all typing hint related errors
- Try to mark class variables in component classes.

- Leave typing hints generic, such as 'list' and 'dict' where content is usually
not filled, too complex, or context is unimportant.

- backups: Handle failure for tarfile extraction so that methods are not called
on potentially None valued variables.

- backups: Prevent potentially passing a keyword argument twice.

- dynamicdns: Deal properly with outcome of urlparsing.

- ejabberd: Deal with failed regex match

- email: Fix a mypy compliant when iterating a filtered list.

- tor: Don't reuse variables for different typed values.

- tor: Don't reuse variables for different typed values.

- operation: Return None explicitly.

- operation: Ensure that keyword argument is not repeated.

Tests:

- Where only typing hints were modified and no syntax error came up, additional
testing was not done.

- `mypy --ignore-missing-imports .` run successfully.

- Generate developer documentation.

- Service runs without errors upon start up.

- backups: Listing and restoring specific apps from a backup works.

- backups: Mounting a remote backup repository works.

- NOT TESTED: dynamicdns: Migrating from old style configuration works.

- ejabberd: Verify that setting coturn configuration works.

- email: Test that showing configuration from postfix works.

- tor: Orport value is properly shown.

- transmission: Configuration values are properly set.

- users: Running unit tests as root works.

- operation: Operation status messages are show properly during app install.

- ./setup.py install runs

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-09-25 20:03:24 -04:00
Sunil Mohan Adapa
40eecb6446
*: Move modules-enabled files to /usr/share
- This will leave /etc/{plinth,freedombox} empty by default making service more
robust to run across various environments and situations. See systemd's
explanation for more details.

- Use Debian maintainer scripts remove all the existing files in
/etc/plinth/modules-enabled.

- Read from /usr/share/freedombox/modules-enabled then from
/etc/plinth/modules-enabled and finally from /etc/freedombox/modules-enabled.
Later read ones override previously read files. Any file pointing to /dev/null
will mean the module must be ignored.

Tests:

- Clean up /etc/plinth, /etc/freedombox and
/usr/share/freedombox/modules-enabled. Run service and notice that files are
getting loaded from development folder using a debug message.

- Run setup.py and notice that files get installed in
/usr/share/freedombox/modules-enabled/ and in the next run they get loaded from
there.

- Create a override file in /etc/plinth/modules-enabled/transmission and notice
that overriden file gets priority over the one in
/usr/share/freedombox/modules-enabled.

- Link the file /etc/plinth/modules-enabled/transmission to /dev/null and notice
that is not loaded.

- Create another file in /etc/freedombox/modules-enabled/transmission and notice
that it overrides the previous two files.

- All affected modules are loaded.

- Build a new Debian package and ensure that upgrading 23.8 to new version
removes are all configuration files.

- Build developer documentation and test that Tutorial -> Full Code and Tutorial
-> Skeleton sections have been updated with references to
-.../modules-enabled/... paths.

- Install quassel and notice that certificates were copied to /var/lib/quassel
directory. Change domain to another domain and notice that certificates were
copied again to that directory.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-05-13 07:08:43 -04:00
Sunil Mohan Adapa
6bd9211791
names: Use AppView for app page
Tests:

- App page shows properly. Status of the current domains is shown properly.

- App page does not show enable/disable button.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-29 08:29:03 -04:00
Sunil Mohan Adapa
900c0d30b9
*: Drop module level app property
module.app property usage is greatly reduced because setup() and force_upgrade()
method are now part of App class instead of at the module level. Remove the
remaining minor cases of usage and drop the property altogether.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-15 10:36:29 -04:00
Sunil Mohan Adapa
f6ef0135d2
*: Add setup method on all apps that don't have it
This is needed for the apps to get enabled soon after installation. In case of
'sharing' app, a shortcut will appear on the apps page. This also brings
uniformity to help later refactoring.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-15 10:36:19 -04:00
Sunil Mohan Adapa
a3d4d99b33
*: Drop use of module level version
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-12-04 16:38:08 -05:00
Sunil Mohan Adapa
cf36a9d385
*: Drop use of module level is_essential flag
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-12-04 16:37:59 -05:00
Joseph Nuthalapati
a912c867c8
names: Create a generic TLS domain selection form
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-11-21 19:04:35 -05:00
Sunil Mohan Adapa
1d17ba2134
names: Split app initialization
Tests:

- When domain name is changed in config module. The updated names shows up in
the names module.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-11-15 10:13:25 -05:00
Sunil Mohan Adapa
cd2b2f5f2c
*: Use django.urls.re_path() instead of its alias url()
- In Django 2.2 django.conf.urls.url() is an alias to django.urls.re_path().

- In Django 4.0, url() function will be removed. On Django 3.2, it throws a
warning that this function will be removed in future.

Tests:

- Run unit tests with Django 3.2 and Django 2.2.

- With Django 3.2 there are no warnings when running unit tests and when running
FreedomBox Service.

- Visit a few affected apps with both Django versions.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:47 -04:00
Sunil Mohan Adapa
74214c18ae
*: Use Django gettext functions instead of ugettext
- ugettext functions will be removed in Django 4.0. Each use emits a warning
when running with Django 3.2. Since we have warnings enabled in developer mode,
we see quite a few messages because of this.

- ugettext is already a simple alias of gettext. So, no regressions are
expected.

Tests:

- Accessing an affected app in UI with Django 3.2 and Django 2.2 works fine.

- Using Django 3.2 there are no warnings related to removal of ugettext
functions.

- Ran regular unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:16 -04:00
Sunil Mohan Adapa
fb1898befc
backups: Use the backup component in all apps
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-01-04 13:47:38 +02:00
Sunil Mohan Adapa
83dcafac55
ui: Make all tables responsive
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-12-19 11:26:34 +02:00
Sunil Mohan Adapa
fef8da230f
ui: Adopt a consistent and new table style
Rows in bootstrap 4 tables are taller by default. This is better suited for
mobile layouts and look prettier on desktops too. Adopting this approach instead
of condensed tables eliminates the need for striping, bordering and narrower
tables.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-12-19 11:26:33 +02:00
achalaramu
00bc55f762
Migrate bootstrap 4 from bootstrap 3
Closes: #1818. The new navbar collapse handles items better without a scrollbar.

- Switch dependency to newer bootstrap4 library.

- Bootstrap 4 has 5 grid levels instead of 4. Adjust all classes accordingly to
retain current semantics.

- Update for newer markup for dropdowns.

- Replace use for labels with badges. Labels have been removed. Use
badge-secondary instead of label-default.

- Replace use of btn-xs with btn-sm. Size is roughly the same.

- Accommodate removal of form-horizontal.

- .hidden* and .visible* classes have been removed. Use alternate utilities.

- Replace use of table-condensed with table-sm.

- Update progress bar background styling. .progress-bar-* have been replaced
with bg-*.

- Drop support for IE9 and below. Bootstrap 4 does not support those browsers.

- Use the new simplified markup for navs, navbar and navbar-toggler. Accommodate
removal of .navbar-fixed-top.

- Update the JSXC page too.

- Update all values that are using rem units. The base font size is now 1rem =
16px instead of 1rem = 10px. This the default for bootstrap 4.

- A button inside a dropdown menu is natively supported by bootstrap 4. Remove
custom styling done earlier.

- Drop use of removed class thumbnail.

- Override colors for buttons and warnings to keep the old style.

- Use new markup for close buttons inside alerts.

- Use .collapse.show instead of .collapse.in as per bootstrap 4 styling.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-12-19 11:26:32 +02:00
Fioddor Superconcentrado
43ab6db456
i18n: Mark strings missed for translation
Helps: #1938.

    backups/forms.py:
	- ChoiceField labeled to allow translation.
	- Translation applied to hard coded literals.

    config/forms.py:
	Lazy translation applied to literals that were translated but still
	displayed in english to non-english users.

    diagnostics_results.html:
	Apply translation to results. Use gettext_noop to mark for translation.

    dynamicdns/forms.py:
	Apply translation to choice literals.

    i2p/views.py:
	Lazy translation applied to literals that were translated but still
	displayed in english to non-english users.

    names.html:
	Apply translation to table headers.

    performance/__init__.py:
	Apply translation to description literals.

    radicale/forms.py:
	ChoiceField labeled to allow translation.

    users/forms.py:
	CharField labeled to allow translation.

    QA:
	- Literals visually verified.
	- No errors in py.test-3.
	- Yapf applied (only) to changed files.
	- No remarks by flake8 to changed file.

Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
[sunil: Separate out the translations]
[sunil: Fix i18n for diagnostics]
[sunil: dynamicdns: Also do i18n for string GnuDIP]
[sunil: searx: Revert an incorrect removal of import]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-09-14 15:39:19 -07:00