59 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
222563a482
*: Use privileged decorator for service actions
Tests:

- DONE: Unit tests work
- DONE: Transmission
  - DONE: Enabling/disabling an app with a daemon works: transmission
  - DONE: Showing the status of whether the app is enabled with daemon
    is-enabled works.
  - DONE: A message is shown if app is enabled and service is not running
  - DONE: Service is stopped and re-started during backup
  - DONE: Adding user to share group during initial setup restarts the service
- Not tested: Enabling/disabling a service with alias works (no such apps)
- DONE: Restarting/try-restarting a service works
- DONE: Masking/unmasking works
  - DONE: rsyslog is masked after initial setup
  - DONE: systemd-journald is try-restarted during initial setup
- DONE: Avahi, email, security initial setup works
  - DONE: Fail2ban is unmasked and enabled
- DONE: Enabling/disabling fail2ban is security app works
- DONE: Enabling/disabling password authentication in SSH works
- ?? Let's encrypt
  - Services are try-restarted during certificate setup, obtain, renew
- Not tested: upgrade pagekite from version 1

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:53:55 -04:00
Sunil Mohan Adapa
5389303e98
email: Use privileged decorator for actions
Tests:

- Functional tests work (uninstall test does not work)
- Initial setup works
  - Domains are setup
  - Home is setup (others don't have permission for /var/mail)
  - Aliases configuration is setup
  - Postfix is setup
  - rspamd is setup
- Changing primary domain works
- Adding/removing domains works
- Error during operations is handle properly: getting dkim key
- Setting up DKIM key when changing, adding/removing domain works
  - Showing DKIM key in app page works

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:51:57 -04:00
Sunil Mohan Adapa
585092ca63
actions: Allow nested and top-level actions
- Currently, privileged actions are not allowed under top-level plinth module.
They are only allowed under each app module. Allow privileged actions under
plinth module.

- Currently, privileged actions are not allowed under a sub-module of
'privileged' package. They are allowed only in 'privileged' module. Allow
sub-modules under 'privileged' package.

Tests:

- Email app functional tests pass
- Functional tests for apps using package and service privileged methods pass

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:50:34 -04:00
Sunil Mohan Adapa
1908bd5366
package: Implement low-level methods for uninstalling
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-29 08:28:35 -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
75f6abac1e
*: Make setup method part of App class for all apps
- Primary purpose is to complete the App API and allow for multiple apps to be
present in a module without a single clashing setup() method. Secondary
objective is to get rid of SetupHelper instance simple use App instance instead.

- This brings us closer to not needing to implement setup() method for some of
the typical apps.

- Remove default value None for old_version parameter.

  - A valid integer value is always passed to this call.

  - The value of None is undefined.

  - Simplifies the App API slightly.

- Drop setting 'pre', 'post' values to indicate the stage of setup for the App.

  - Simplifies the setup methods significantly. Eliminates a class of
  bugs (some of them seen earlier).

  - The UI can show a simple 'installing...' or progress spinner instead of
  individual stages.

  - There are currently many inconsistencies where many operations are not
  wrapped in helper.call() calls.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-15 10:36:16 -04:00
Sunil Mohan Adapa
3c7bc4a192
*: pylint: Explicitly specify encoding when open a file
This is recommended by PEP-0597: https://peps.python.org/pep-0597/

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-07-04 19:45:57 -04:00
Sunil Mohan Adapa
086b805c2b
email: Make app available for all users (even without advanced flag)
- Discussed during progress call.

- More testing has happened on the app since making it available.

- Will document difficulties with setting up domain name and ISP outgoing
traffic on port 25.

Tests:

- App is available without the advance flag.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-06-06 20:55:06 -04:00
Sunil Mohan Adapa
8e5d126b67
email: Add description about ISP and domain limitations
As discussed during progress calls, this is a pre-condition for making the app
generally available (without advanced flag).

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-06-06 20:54:57 -04:00
Sunil Mohan Adapa
74a6042ed8
*: Show Learn More... links in frontpage with description
Closes: #1797.

Tests:

- For each affected app, install the app, visit frontpage. Select the shortcut.
Notice that Learn More... link is shown and clicking on the link takes us to the
manual page of the app.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-05-22 05:44:22 -04:00
Sunil Mohan Adapa
7e761c91ea
email: Fix userdb lookups with LDAP
Without the base attribute set, LDAP search returns no results and because of
the lookup failure LMTP will not be able to deliver message even though postfix
has successfully received the messages.

Tests:

- On a fresh container, send a message to a local user using roundcube. The user
should receive the message successfully.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-05-09 21:06:56 -04:00
Sunil Mohan Adapa
354985f97c
email: Fix issue with certs not being available
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:10 -05:00
Sunil Mohan Adapa
9d4ae972e9
email: Revert to LDAP auth as pam does not allow non-admin users
Since FreedomBox does not allow any users but those belonging to 'admin' group
to login, using passwd driver for auth means that only admin can login to
postfix/dovecot. Fix this by reverting to using LDAP driver.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:08 -05:00
Sunil Mohan Adapa
56f95ddf97
email: rspamd: Log to journald via syslog
Unified querying, reduce random writes for SD cards, eliminate need for separate
log rotation.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:06 -05:00
Sunil Mohan Adapa
265534a6bf
email: postfix: use inline map for TLS SNI maps
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:04 -05:00
Sunil Mohan Adapa
64d0411d6b
email: Allow re-running setup
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:02 -05:00
Sunil Mohan Adapa
e52aae3acd
email: clients: Make Thunderbird URLs language independent
The site will then redirect to a language specific URL.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:39:00 -05:00
Sunil Mohan Adapa
a5a3500630
email: aliases: Minor refactoring to form validation
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:57 -05:00
Sunil Mohan Adapa
3d15ebd436
email: postfix: Fix priority for authentication directives
Otherwise, the default directives in 10-auth.conf take higher priority.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:55 -05:00
Sunil Mohan Adapa
828cc73320
email: Add various documentation links for future readability
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:53 -05:00
Sunil Mohan Adapa
6bdd62b643
email: Implement adding common aliases for first admin user
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:51 -05:00
Sunil Mohan Adapa
25da081ea2
email: Don't start disabled daemons when setup is re-run
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:48 -05:00
Sunil Mohan Adapa
ef6619d8d6
email: Use the term 'setup' rather than 'repair' for consistency
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:46 -05:00
Sunil Mohan Adapa
55bd428bd7
email: Update module docstrings
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:44 -05:00
Sunil Mohan Adapa
6cfa0589a7
email: Drop atomic writing to a file
Not very critical. Reduce complexity. Re-implement later at framework level.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:42 -05:00
Sunil Mohan Adapa
48f17c4eeb
email: Drop postfix and dovecot LDAP packages
They are unused. postfix-ldap is needed for LDAP based maps. In dovecot,
authentication happens using PAM.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:40 -05:00
Sunil Mohan Adapa
e08988507e
email: Name module ldap to postfix
There is nothing related to LDAP in the module. It actually configures postfix.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:38 -05:00
Sunil Mohan Adapa
59e51faf2e
email: Drop unused utility method for logging
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:36 -05:00
Sunil Mohan Adapa
8a53957b1e
email: Simplify and rename postfix configuration module
- Remove unnecessary complex crash handler needed due to setting the service
configuration in two steps. Merge the two step into one after which crash
handler is not needed.

- Drop '_unsafe' API and verify all keys and values for sanity.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:33 -05:00
Sunil Mohan Adapa
5bc5191ea7
email: Drop use of mutex for postfix configuration operations
This is not critically needed in FreedomBox. Implementation is complex. This may
be recreated at framework level to benefit all applications.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:30 -05:00
Sunil Mohan Adapa
1b5e99c56e
email: Rename audit module to privileged
The module does not interact with kernel audit system or is not related to
security logging. The 'privileged' makes us pay more attension.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:28 -05:00
Sunil Mohan Adapa
37b28e05d7
email: Drop mentions of clamav as it is too memory intensive
A fresh install of clamav-daemon takes up about 1GiB or RAM. Most of this is the
virus signature database and is used regularly for a scan. This makes ClamAV
unsuitable for FreedomBox running on many single board computers. Drop ClamAV
until we start recommending/requiring at least 2GiB of RAM.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:26 -05:00
Sunil Mohan Adapa
ad702e1a91
email: Add shortcut for non-admin users to manage their aliases
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:24 -05:00
Sunil Mohan Adapa
9d0d7e586c
email: aliases: Drop ability to enable/disable aliases
- There is no use case for keeping an alias disabled.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:22 -05:00
Sunil Mohan Adapa
60822f7198
email: Enable as an advanced app
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:19 -05:00
Sunil Mohan Adapa
bc5de46eb2
email: dns: Show table for desired DNS entries
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:17 -05:00
Sunil Mohan Adapa
1af9a6b114
email: dkim: Implement setting up DKIM signing keys
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:15 -05:00
Sunil Mohan Adapa
10606bfc69
email: Set an icon from Tango project
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:13 -05:00
Sunil Mohan Adapa
1bc576387e
email: Minor indentation and docstring changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:10 -05:00
Sunil Mohan Adapa
11b4b8fa93
email: Drop unused diagnosis module
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:08 -05:00
Sunil Mohan Adapa
c8d1f614da
email: Simplify setting up postfix
- Reduce complexity by removing the diagnosis approach.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:05 -05:00
Sunil Mohan Adapa
bbd0b629f3
email: Add backup/restore component
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:03 -05:00
Sunil Mohan Adapa
851644574d
email: Add basic functional tests
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:38:01 -05:00
Sunil Mohan Adapa
96c587c13c
email: Setup rspamd configuration to include FreedomBox config
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:58 -05:00
Sunil Mohan Adapa
60d137a537
email: Remove override for local addresses
- The default, which is to trust local LAN IPs is good enough for FreedomBox use
case.

- This allows skipping some checks like DKIM for mails originating from local
networks which are not expected to have proper signatures.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:56 -05:00
Sunil Mohan Adapa
0d5366a356
email: Drop special handling for outbound filtering
- Reduces a lot of complexity and avoids running a couple of more postfix
daemons (one on 10025 port and other on socket fbxcleanup).

- Cleaning outbound headers for privacy can be done in a simpler way. This may
be re-implemented later.

- Masquerading domains is not very important for FreedomBox use case. Users are
expected to send all mail using MUA using properly configured email addresses.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:53 -05:00
Sunil Mohan Adapa
84f7b60bc5
email: Drop special handling for reserved TLDs
There is no special reason to handle them separately instead of letting DNS
resolution to them fail. No documentation on what caret addresses are or what
.fm.localhost TLD is.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:50 -05:00
Sunil Mohan Adapa
4b741e9192
email: Simplify setting milter configuration and running sievec
- Drop diagnosis.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:48 -05:00
Sunil Mohan Adapa
75ec7c5a5a
email: Add more special-use IMAP folders, set autoexpunge to 60days
A mail client should not create these special folders if they see existing
folders with the special-use flag set on them. However, if a mail clients does
create a folder and does not set special-use folder, the server will set the
flag so that all other mail clients can see the flag.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:45 -05:00
Sunil Mohan Adapa
9710369949
email: Narrowly match just rspamd's spam header
There is no need to match generically for flags that are possibly generated by
other spam software. Allow other rules to run after filing into Junk folder.
Allow other sieve filter to be present in the FreedomBox configuration directory.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-03-02 07:37:42 -05:00