indigo-dc / oidc-agent

oidc-agent for managing OpenID Connect tokens on the command line
MIT License
111 stars 30 forks source link

Default `AGENTSERVICEDIR` is cleaned by default on systems with `systemd-tmpfilesd` #519

Closed olifre closed 1 year ago

olifre commented 1 year ago

The default AGENTSERVICEDIR is ${TMPDIR}/oidc-agent-service/${UID}.

This yields the following example directory structure:

/tmp/oidc-agent-service/1000/oidc-agent.pid
/tmp/oidc-agent-service/1000/oidc-agent.sock -> /tmp/oidc-LOrOAk/oidc-agent.7317
/tmp/oidc-LOrOAk/oidc-agent.7317

Current Linux systems usually ship with the default systemd-tmpfilesd configuration file /usr/lib/tmpfiles.d/tmp.conf which contains:

# Clear tmp directories separately, to make them easier to override
q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d

With this, the directory containing the PID file and symlinks will be purged by default after 10 days if the root FS is mounted with noatime. The actual agent directory will remain, since that file remains being "in access".

The cleanest possible workaround is probably to ship a tmpfiles.d exclusion file which prevents the AGENTSERVICEDIR from being cleaned up?

olifre commented 1 year ago

I am right now going with the following file in /usr/lib/tmpfiles.d/oidc-agent.conf:

# /tmp/oidc-agent-service/* is used for symlinks to the actual agent instance
# which may run for many days. This following line prevents systemd from removing this content.
x /tmp/oidc-agent-service/*

I believe this should do the trick.

marcvs commented 1 year ago

Many thanks; I'll include a fix and push it to the next release, likely by end of next week.

marcvs commented 1 year ago

Preivew of the fix is available for a subset of distributed linux distributions at https://repo.data.kit.edu/devel

olifre commented 1 year ago

@marcvs Many thanks! I have deployed the very same file manually on Gentoo Linux for now and can confirm things still work as expected after a week :+1: .