Skip to content

core/service: set up credentials for all start-post commands too - #31197

Merged
YHNdnzj merged 7 commits into
systemd:mainfrom
YHNdnzj:protect-system-cred
Feb 5, 2024
Merged

YHNdnzj merged 7 commits into
systemd:mainfrom
YHNdnzj:protect-system-cred

Conversation

@YHNdnzj

@YHNdnzj YHNdnzj commented Feb 3, 2024 •

Copy link
Copy Markdown
Member

Fixes #31194

@YHNdnzj YHNdnzj added the pid1 label Feb 3, 2024
@github-actions github-actions Bot added the please-review PR is ready for (re-)review by a maintainer label Feb 3, 2024

@yuwata yuwata left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think, we should introduce, something like the following.

static ExecFlags service_exec_flags(ServiceState state, ServiceExecCommand command_id) {
        ...
}

Otherwise, we can easily introduce similar bug in the future.

Comment thread src/core/service.c Resolved
Comment thread src/core/service.c Resolved
@yuwata yuwata added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Feb 4, 2024
@YHNdnzj

YHNdnzj commented Feb 4, 2024

Copy link
Copy Markdown
Member Author

I'll introduce a helper like that. But I think ExecCondition= and -Reload= by design should not be accessing credentials.

@YHNdnzj
YHNdnzj marked this pull request as draft February 4, 2024 10:02
@YHNdnzj
YHNdnzj force-pushed the protect-system-cred branch from f80ca1a to f06c5cd Compare February 4, 2024 11:44
@YHNdnzj YHNdnzj removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Feb 4, 2024
@YHNdnzj
YHNdnzj force-pushed the protect-system-cred branch 2 times, most recently from 7ec4148 to e6c6249 Compare February 4, 2024 11:52
@YHNdnzj
YHNdnzj marked this pull request as ready for review February 4, 2024 12:06
@github-actions github-actions Bot added the please-review PR is ready for (re-)review by a maintainer label Feb 4, 2024
Comment thread src/core/execute.c Resolved
Comment thread src/core/service.c Resolved
Comment thread src/core/service.c Resolved
YHNdnzj added a commit to YHNdnzj/systemd that referenced this pull request Feb 4, 2024
As suggested in
systemd#31197 (review)

Note that this slightly changes the behavior for
ExecCondition= and ExecStartPost=. Will be corrected
later.
@YHNdnzj
YHNdnzj force-pushed the protect-system-cred branch 2 times, most recently from 11d0738 to 9df4f91 Compare February 4, 2024 16:42
As suggested in
systemd#31197 (review)

Note that this slightly changes the behavior for
ExecReload=, ExecCondition= and ExecStartPost=. Will
be explained/corrected in later commits.
All tasks spawned later than ExecStart= (e.g. ExecReload=, ExecStop=, ...)
don't get tty access. ExecStopPost= is the odd one out. Fix that.
@yuwata yuwata added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed please-review PR is ready for (re-)review by a maintainer labels Feb 4, 2024
This seems to be a mistake in systemd#27279. I believe credentials should
not be made available to condition or reload tasks. In most cases
they're irrelevant from the actual job of the service. Also, currently
the first ExecCondition= or ExecReload= cannot access creds anyway,
making the incompatibility introduced negligible.

If people actually come up with valid use cases, we can always
revisit this.
@YHNdnzj
YHNdnzj force-pushed the protect-system-cred branch from 9df4f91 to 39f4504 Compare February 4, 2024 16:59
@YHNdnzj

YHNdnzj commented Feb 4, 2024

Copy link
Copy Markdown
Member Author

(Pushed to update commit messages)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

systemd credentials: $CREDENTIALS_DIRECTORY empty with given service, no error in logs

2 participants