Repository navigation
core: reuse credential dir across start and start-post if populated - #31202
Conversation
ceb8402 to
3f9a1ce
Compare
i have a blurry memory of someone doing exactly this/asking for this, so we supported this. too lazy to do a git log search, but i have a hazy idea, that this has came up before. I agree that creds passed to a unit should be stable which is what my proposal would do – except that it limits that to the time window that starts when we switch from ExecStartPre= to ExecStart=, i.e. when the preparatory steps are over. |
The way I'd assume people us this is by populating /run/credstore/ from ExecStartPre= and then import it via ImportCredential= in a graceful matter? That isn#t weird at all? |
I'd really not make that configurable, but simply say "in preparatory you have flexibility – but once you leave them things are immutable". Or in other words: on ExecStartPre= we reread creds each time, but on ExecStart=/ExecStartPost= we don't anymore, except for the first time. |
343d292 to
6c9fc64
Compare
Also rename EXEC_WRITE_CREDENTIALS to EXEC_SETUP_CREDENTIALS.
fresh otherwise Currently, exec_setup_credential() always rewrite all credentials upon exec_invoke(), i.e. invocation of each ExecCommand, and within a single tmpfs instance. This is problematic though: * When writing each tmp cred file, we essentially double the size of the credential. Therefore, if one cred is bigger than half of CREDENTIALS_TOTAL_SIZE_MAX, confusing ENOSPC occurs (see also systemd#24734 (comment)) * Credential is a unit-wide thing and thus should not change during the whole lifetime of main process. However, if e.g. a on-disk credential or SetCredential= in unit file changes between ExecStart= and ExecStartPost=, the credentials are overwritten when the latter gets to run, and the already-running main process is suddenly seeing completely different creds. So, let's try to reuse final cred dir if the main process has started and the tmpfs has been populated, so that the creds used is stable across all ExecStart= and ExecStartPost=-s. We still want to retain the ability of updating creds through ExecStartPre= though, therefore we forcibly use a fresh cred dir for those. 'Fresh' means to actually unmount the old tmpfs first, so the first problem goes away, too.
Currently, exec_setup_credential() always rewrite all credentials
upon exec_invoke(), i.e. invocation of each ExecCommand, and within
a single tmpfs instance. This is problematic though:
When writing each tmp cred file, we essentially double the size
of the credential. Therefore, if one cred is bigger than half
of CREDENTIALS_TOTAL_SIZE_MAX, confusing ENOSPC occurs (see also
also provide credentials in ExecStartPre #24734 (comment))
Credential is a unit-wide thing and thus should not change
during the whole lifetime of main process. However, if e.g.
a on-disk credential or SetCredential= in unit file
changes between ExecStart= and ExecStartPost=,
the credentials are overwritten when the latter gets to run,
and the already-running main process is suddenly seeing
completely different creds.
So, let's try to reuse final cred dir if the main process has started
and the tmpfs has been populated, so that the creds used is stable
across all ExecStart= and ExecStartPost=-s. We still want to retain
the ability of updating creds through ExecStartPre= though, therefore
we forcibly use a fresh cred dir for those. 'Fresh' means to actually
unmount the old tmpfs first, so the first problem goes away, too.
Replaces #31201