core: set $CREDENTIALS_DIRECTORY only when we set up credentials

It is not necessary to set the environment variable on an execution step
we do not support credentials.
This commit is contained in:
Yu Watanabe 2023-08-12 15:25:03 +09:00
parent 7d202fb35d
commit fbaf3b23ae

View file

@ -2041,7 +2041,9 @@ static int build_environment(
our_env[n_env++] = x;
}
if (exec_context_has_credentials(c) && p->prefix[EXEC_DIRECTORY_RUNTIME]) {
if (exec_context_has_credentials(c) &&
p->prefix[EXEC_DIRECTORY_RUNTIME] &&
FLAGS_SET(p->flags, EXEC_WRITE_CREDENTIALS)) {
x = strjoin("CREDENTIALS_DIRECTORY=", p->prefix[EXEC_DIRECTORY_RUNTIME], "/credentials/", u->id);
if (!x)
return -ENOMEM;