gocryptfs: clean session mount/unmount via systemd service #29

Merged
obel1x merged 7 commits from unbrot/fedora-OEMDRV:main into main 2026-05-07 18:07:11 +02:00
Contributor

Summary

  • mount_ecrypt_home: switch from --scope to a transient systemd user service so ExecStop can run fusermount -u on logout, cleanly unmounting gocryptfs
  • mount_ecrypt_home: add -fg flag to keep gocryptfs in foreground so the service stays active (without it, gocryptfs forks to background, the tracked process exits, and systemd immediately calls ExecStop)
  • mount_ecrypt_home: poll /proc/mounts before removing passfile, since service mode starts asynchronously and gocryptfs may not have read the file yet
  • logon_script: gate kwriteconfig5 calls on XDG_CURRENT_DESKTOP=KDE; also set loginMode=2 (empty session) so previous apps are not restored on login

Test plan

  • Login: gocryptfs mounts ~/data and gocryptfs-home.service stays active
  • Logout: fusermount -u is called via ExecStop, directory is unmounted cleanly
  • On Cinnamon: kwriteconfig5 calls are skipped
  • On KDE: new sessions start empty (no app restore)

🤖 Generated with Claude Code

## Summary - `mount_ecrypt_home`: switch from `--scope` to a transient systemd user service so `ExecStop` can run `fusermount -u` on logout, cleanly unmounting gocryptfs - `mount_ecrypt_home`: add `-fg` flag to keep gocryptfs in foreground so the service stays active (without it, gocryptfs forks to background, the tracked process exits, and systemd immediately calls `ExecStop`) - `mount_ecrypt_home`: poll `/proc/mounts` before removing passfile, since service mode starts asynchronously and gocryptfs may not have read the file yet - `logon_script`: gate `kwriteconfig5` calls on `XDG_CURRENT_DESKTOP=KDE`; also set `loginMode=2` (empty session) so previous apps are not restored on login ## Test plan - [x] Login: gocryptfs mounts `~/data` and `gocryptfs-home.service` stays active - [x] Logout: `fusermount -u` is called via `ExecStop`, directory is unmounted cleanly - [x] On Cinnamon: `kwriteconfig5` calls are skipped - [x] On KDE: new sessions start empty (no app restore) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
unbrot added 7 commits 2026-05-07 18:05:41 +02:00
Switch from --scope to a transient service so systemd can run
fusermount -u via ExecStop before terminating the process.
With KillMode=none, gocryptfs exits on its own once the FUSE
filesystem is detached.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap kwriteconfig5 calls in a KDE check so they are skipped on
Cinnamon and other desktops. Also add empty-session setting so
previous apps are not restored on login.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
systemd-run service mode returns as soon as the start request is
accepted, before gocryptfs has read the passfile. Poll /proc/mounts
for up to 10 seconds so the passfile is only removed after the mount
is confirmed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without -fg, gocryptfs forks to background and the parent exits,
causing systemd to consider the service done and immediately call
ExecStop (fusermount -u). With -fg, gocryptfs stays as the tracked
service process so ExecStop only fires on explicit service stop at
logout.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
obel1x merged commit ef5d6cbf7f into main 2026-05-07 18:07:11 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: obel1x/fedora-OEMDRV#29