mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
pam_systemd: split out setting of shell env vars from credentials and move it later
Let's shorten the code of pam_sm_open_session() a bit, and also make sure the importing of the env vars from the creds also happens if the session registration with logind is skipped.
This commit is contained in:
parent
5e782e4de3
commit
166a678fea
@ -948,6 +948,27 @@ static int create_session_message(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int import_shell_credentials(pam_handle_t *handle) {
|
||||
|
||||
static const char *const propagate[] = {
|
||||
"shell.prompt.prefix", "SHELL_PROMPT_PREFIX",
|
||||
"shell.prompt.suffix", "SHELL_PROMPT_SUFFIX",
|
||||
"shell.welcome", "SHELL_WELCOME",
|
||||
NULL
|
||||
};
|
||||
int r;
|
||||
|
||||
assert(handle);
|
||||
|
||||
STRV_FOREACH_PAIR(k, v, propagate) {
|
||||
r = propagate_credential_to_environment(handle, *k, *v);
|
||||
if (r != PAM_SUCCESS)
|
||||
return r;
|
||||
}
|
||||
|
||||
return PAM_SUCCESS;
|
||||
}
|
||||
|
||||
_public_ PAM_EXTERN int pam_sm_open_session(
|
||||
pam_handle_t *handle,
|
||||
int flags,
|
||||
@ -1234,19 +1255,6 @@ _public_ PAM_EXTERN int pam_sm_open_session(
|
||||
if (r != PAM_SUCCESS)
|
||||
return r;
|
||||
|
||||
static const char *const propagate[] = {
|
||||
"shell.prompt.prefix", "SHELL_PROMPT_PREFIX",
|
||||
"shell.prompt.suffix", "SHELL_PROMPT_SUFFIX",
|
||||
"shell.welcome", "SHELL_WELCOME",
|
||||
NULL
|
||||
};
|
||||
|
||||
STRV_FOREACH_PAIR(k, v, propagate) {
|
||||
r = propagate_credential_to_environment(handle, *k, *v);
|
||||
if (r != PAM_SUCCESS)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (vtnr > 0) {
|
||||
char buf[DECIMAL_STR_MAX(vtnr)];
|
||||
sprintf(buf, "%u", vtnr);
|
||||
@ -1272,6 +1280,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
|
||||
}
|
||||
|
||||
success:
|
||||
r = import_shell_credentials(handle);
|
||||
if (r != PAM_SUCCESS)
|
||||
return r;
|
||||
|
||||
if (default_capability_ambient_set == UINT64_MAX)
|
||||
default_capability_ambient_set = pick_default_capability_ambient_set(ur, service, seat);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user