Repository navigation
core/service: support credentials refreshing on reload - #40093
Conversation
|
Will this work with all services, or only with |
Extension refreshing has been reworked in #39376 to work with any service already ;) |
Great! That must have slipped under my radar (and I find no mention in NEWS). Though I guess the man pages are still outdated? Lines 570 to 579 in fd2cdad |
422c94a to
cc72cb9
Compare
2d72a59 to
fb377df
Compare
99b795f to
7886c16
Compare
7886c16 to
289d76d
Compare
289d76d to
8b86c21
Compare
Updated now |
bd8ffe9 to
9f3ee14
Compare
|
CI is passing, yay! PTAL! |
Follow-up for 21eb636 Our sd_notify() protocol uses newline as separator, which is not suitable for direct logging.
We should only fall back to the dir_is_empty() check if it's a plain dir, where we can't reasonably differentiate populated yet empty vs not set up. Otherwise let's stick to the existing mount if we're told to reuse it. Yes, this is a minor compat break, but with the to-be-introduced credential reloading support it should fulfill the goal of keeping the passed set of credentials stable better, while still allowing things to be refreshed when requested.
Starting from cfbf753 we'd always install the credentials dir regardless of whether it's empty, with the correct permissions. Hence the problem stated in the comment should no longer be a concern. Moreover, this ensures later in setup_namespace() the mountpoint would be in-place. This is important for credential reloading as it saves the trouble of remounting the upper tmpfs as rw again and create the mountpoint.
… exec_setup_credentials() No functional change, preparation for credential reloading support, where we'd operate on Unit rather than ExecParameters.
Typically when entering a namespace the userns is handled last, because we assume our process is more privileged than the userns. However, that assumption no longer holds for user managers, which have no privilege over initial userns and all other namespaces are actually owned by the userns unshared first (in executor). Hence, let's add another flavor namespace_enter_delegated() to accommodate that use case.
This allows controlling resources to be refreshed before performing reload, with one extra benefit that in the future we can permit "seemless reload"s, i.e. no active signaling is done to the main process after refreshing get updated. This could come in handy for programs that loads stuff on demand or watches changes via inotify.
Dejavu moment ;)
… even without exec/notify-reload This was originally brought up by @poettering. If the process loads stuff on demand and flushes them out after each use, or actively monitors file changes, they can be reloaded by merely refreshing the resources.
|
|
||
| tunnel_fds[1] = safe_close(tunnel_fds[1]); | ||
|
|
||
| /* Wait for the child to validate the creds tree in the unit namespace is populated. */ |
| if (s->refresh_on_reload_set && s->refresh_on_reload_flags != _SERVICE_REFRESH_ON_RELOAD_ALL) { | ||
| if (FLAGS_SET(s->refresh_on_reload_flags, SERVICE_RELOAD_EXTENSIONS)) | ||
| service_can_reload_extensions(s, /* warn = */ true); | ||
| } |
There was a problem hiding this comment.
This could use a comment, not exactly sure at a glance what this does
| if (!s->refresh_on_reload_set) { | ||
| assert_cc(SERVICE_REFRESH_ON_RELOAD_DEFAULT == SERVICE_RELOAD_EXTENSIONS); | ||
| s->refresh_on_reload_flags = service_can_reload_extensions(s, /* warn = */ false) ? SERVICE_RELOAD_EXTENSIONS : 0; | ||
| } |
There was a problem hiding this comment.
Ditto, could use a comment
| _cleanup_free_ char *v = NULL; | ||
| ServiceRefreshOnReload f; | ||
|
|
||
| r = extract_first_word(&s, &v, NULL, 0); |
There was a problem hiding this comment.
Missing comments for null/0 arguments
| else if (streq(key, "refreshed-mask")) { | ||
| r = service_refresh_on_reload_from_string_many(value, &s->refreshed_mask); | ||
| if (r < 0) | ||
| log_unit_debug_errno(u, r, "Failed to parse refresh-mask value: %s", value); |
| r = service_refresh_on_reload_from_string_many("extensions", &flags); | ||
| ASSERT_OK(r); |
There was a problem hiding this comment.
Why assign to r here?
| r = service_refresh_on_reload_from_string_many("credentials extensions", &flags); | ||
| ASSERT_OK(r); |
| systemctl start "$UNIT_NAME" | ||
| ls -l /run/credentials/"$UNIT_NAME"/ | ||
|
|
||
| echo "neu" >/run/credstore/test.creds.new-refresh-1 |
|
None of my comments actually matter, so merging, feel free to do a follow up commit for yourself if you feel strongly about any of these. |
|
The new test fails:
|
That only failed once and seems to be in qemu infra? The subsequent retry succeeded? |
|
Well sure, but it didn't fail before I don't think, so it's suspicious that a new test is added and it got stuck no? |
Closes #21099
Closes #35227