Skip to content

Configure tgadmin service account during .deb installation#13

Merged
Al-Muhandis merged 1 commit intodeb-packagingfrom
codex/configure-tgadmin.service-for-non-root-user
Mar 26, 2026
Merged

Configure tgadmin service account during .deb installation#13
Al-Muhandis merged 1 commit intodeb-packagingfrom
codex/configure-tgadmin.service-for-non-root-user

Conversation

@Al-Muhandis
Copy link
Copy Markdown
Owner

@Al-Muhandis Al-Muhandis commented Mar 24, 2026

Motivation

  • Avoid hardcoding a local username in the packaged service so the daemon can run without root on other systems.
  • Make the runtime user/group configurable at package install time so the package is portable between hosts.
  • Ensure the package can create a system account when needed and instruct systemd to run the service under that account.

Description

  • Add a packaged systemd unit debian/lib/systemd/system/tgadmin.service that does not embed User/Group so runtime identity can be provided via a drop-in.
  • Add /etc/default/tgadmin (added as a conffile) with TGADMIN_SERVICE_USER and TGADMIN_SERVICE_GROUP defaulting to tgadmin.
  • Update debian/DEBIAN/postinst to read TGADMIN_SERVICE_USER/GROUP from /etc/default/tgadmin, create the system group and user if missing, and write a systemd drop-in /etc/systemd/system/tgadmin.service.d/10-run-as.conf containing User= and Group= so the service runs as the non-root account.
  • Adjust config ownership in postinst to chown "root:${SERVICE_GROUP}" and update debian/DEBIAN/postrm purge handling to remove the generated drop-in; add /etc/default/tgadmin to DEBIAN/conffiles.

Testing

  • Ran a shell syntax check with bash -n debian/DEBIAN/postinst debian/DEBIAN/postrm which completed successfully.

@Al-Muhandis Al-Muhandis marked this pull request as ready for review March 26, 2026 02:11
@Al-Muhandis Al-Muhandis merged commit dd81a6f into deb-packaging Mar 26, 2026
1 check passed
@Al-Muhandis Al-Muhandis deleted the codex/configure-tgadmin.service-for-non-root-user branch March 26, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant