Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure environment-specific services in dom0 via systemd #1038

Merged
merged 4 commits into from
May 31, 2024
Merged

Conversation

rocodes
Copy link
Contributor

@rocodes rocodes commented May 22, 2024

Status

Ready for review

Description of Changes

Refs #1004 (comment)
Supersedes #1031

Changes proposed in this pull request:

  • Configure systemd-logind changes via logind.conf.d directory rather than editing logind.conf file directly
  • Install logind powersetting changes via workstation RPM
  • Disable logind powersetting changes on dev setups [note: this means that during the time between installing the rpm and sdw-admin --apply, the power settings are in effect. But I think devs can handle that; usually those things follow pretty closely one after the other.]
  • Write build flavour/environment flag (dev, staging, prod) to /var/lib/securedrop-workstation/ during Saltstack orchestration.
  • use above mentioned flag file to conditionally disable logind changes in dev environments.
  • Convert xfce power settings to be handled the same way: service enabled during rpm installation, disabled conditionally at orchestration on dev machines, reverted fully if dom0 RPM is uninstalled.

Testing

  • CI passes
  • Uninstall SDW via sdw-admin --uninstall (or skip if fresh install scenario)
  • Create a desktop icon or shortcut on dom0 desktop.
  • Install rpm built from the tip of this branch: RPM installs successfully
  • systemctl --user list-unit-files | grep enabled shows user-xfce-settings.service and user-xfce-icon-size.service
  • systemctl list-unit-files | grep logind shows logind-override-disable.service as enabled
  • Reboot laptop. Upon login, desktop icon is enlarged and power settings are adjusted (no suspend/hibernate options available)
  • Closing laptop lid shuts off laptop
  • Power on and run sdw-admin --apply [dev]. Provisioning completes successfully, and after reboot or restarting systemd (systemctl daemon-reexec), power setting changes are reverted
  • sdw-admin --apply [staging or prod] completes successfully and power settings changes are in place after reboot
    • as discussed below, going from dev -> staging/prod does not reinstate power settings.
  • Uninstalling rpm reverts icon size and power settings changes.

Deployment

Any special considerations for deployment? Consider both:

  1. Upgrading existing pilot instances
  2. New installs

Checklist

If you have made changes to the provisioning logic

  • All tests (make test) pass in dom0

If you have added or removed files

  • I have updated MANIFEST.in and rpm-build/SPECS/securedrop-workstation-dom0-config.spec

If documentation is required

  • I have opened a PR in the docs repo for these changes, or will do so later
  • I would appreciate help with the documentation

@rocodes rocodes force-pushed the logind-conf branch 2 times, most recently from 40a4af5 to 9ec2b0c Compare May 23, 2024 15:31
Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like where this is going :)

dom0/sd-dom0-files.sls Outdated Show resolved Hide resolved
rpm-build/SPECS/securedrop-workstation-dom0-config.spec Outdated Show resolved Hide resolved
@rocodes rocodes force-pushed the logind-conf branch 2 times, most recently from f8c2804 to 300f139 Compare May 23, 2024 21:43
@rocodes rocodes force-pushed the logind-conf branch 4 times, most recently from 1d156d3 to 959600f Compare May 29, 2024 14:37
@rocodes rocodes force-pushed the logind-conf branch 4 times, most recently from 50cc076 to d37d487 Compare May 30, 2024 18:48
@rocodes rocodes marked this pull request as ready for review May 30, 2024 19:07
rocodes added 3 commits May 30, 2024 15:19
… systemd service to conditionally disable this service in dev environments. Write environment flag to /var/lib/securedrop-workstation/ during Saltstack orchestration.
Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, minor notes inline. Will test it now

files/user-xfce-settings.service Outdated Show resolved Hide resolved
files/logind-override-disable.service Outdated Show resolved Hide resolved
@legoktm
Copy link
Member

legoktm commented May 30, 2024

It seems if I switch to a dev install and then back to staging/prod, rpm will not restore the deleted 10-logind_override.conf file. (sudo rpm -V securedrop-workstation-dom0-config reports it as missing). https://serverfault.com/questions/1131250/can-you-force-replacement-of-files-marked-config-in-rpms says it's marked as %config and it's not possible to override that (like we do in Debian with our conffiles hack).

Maybe this is an OK limitation for now? that if you switch to dev you need to do a full provision from scratch to switch to staging/prod.

@rocodes
Copy link
Contributor Author

rocodes commented May 31, 2024

It seems if I switch to a dev install and then back to staging/prod, rpm will not restore the deleted 10-logind_override.conf file.

Ugh, good catch, and I don't love that. I always sdw uninstall if I'm switching between dev, staging, prod, just because unfortunately some of our cleanup logic is still in Salt and requires the uninstall command, but this could bite people.

Another solution could be putting a second, lower-priority configuration file that unsets this option on dev systems, instead of a service that deletes the other override file. (With the eventual goal of moving more logic out of salt and into the rpm so that we can cleanly uninstall and reinstall each time we re-provision, and so that there is symmetry in terms of where the setup/teardown actions happen, instead of them being in two places).

Either way I'm not forcing this through if we're unhappy with it in some way - I'll make your suggested changes (thank you!) and let me know your thoughts re the way to handle the dev configuration.

@legoktm
Copy link
Member

legoktm commented May 31, 2024

Ugh, good catch, and I don't love that. I always sdw uninstall if I'm switching between dev, staging, prod, just because unfortunately some of our cleanup logic is still in Salt and requires the uninstall command, but this could bite people.

I think this is a reasonable limitation for now, I'm okay with documenting it in a bug as something to eventually fix.

(Finishing up the test plan now)

Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM \o/

@legoktm legoktm added this pull request to the merge queue May 31, 2024
Merged via the queue into main with commit 52fb64b May 31, 2024
6 of 7 checks passed
@legoktm legoktm deleted the logind-conf branch May 31, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants