summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-02 13:23:10 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-02 22:23:56 +0200
commit59fccd82117cf9a84454f41867a882f872916dc5 (patch)
tree85962a6a42407add9d074e4750d6830fe83416dc /src
parent7074fecf6747c9a6ad872cc87701481e8bece8b0 (diff)
execute.c: always set $SHELL
In e6dca81 $SHELL was added to user@.service. Let's instead provide it to all units which have a user.
Diffstat (limited to 'src')
-rw-r--r--src/core/execute.c56
1 files changed, 19 insertions, 37 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index a53ef48ef8..3979f35988 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1094,7 +1094,7 @@ int exec_spawn(ExecCommand *command,
if (pid == 0) {
int i, err;
sigset_t ss;
- const char *username = NULL, *home = NULL;
+ const char *username = NULL, *home = NULL, *shell = NULL;
uid_t uid = (uid_t) -1;
gid_t gid = (gid_t) -1;
_cleanup_strv_free_ char **our_env = NULL, **pam_env = NULL,
@@ -1277,7 +1277,7 @@ int exec_spawn(ExecCommand *command,
if (context->user) {
username = context->user;
- err = get_user_creds(&username, &uid, &gid, &home, NULL);
+ err = get_user_creds(&username, &uid, &gid, &home, &shell);
if (err < 0) {
r = EXIT_USER;
goto fail_child;
@@ -1462,46 +1462,28 @@ int exec_spawn(ExecCommand *command,
}
}
- our_env = new0(char*, 7);
- if (!our_env) {
+ our_env = new(char*, 8);
+ if (!our_env ||
+ (n_fds > 0 && (
+ asprintf(our_env + n_env++, "LISTEN_PID=%lu", (unsigned long) getpid()) < 0 ||
+ asprintf(our_env + n_env++, "LISTEN_FDS=%u", n_fds) < 0)) ||
+ (home && asprintf(our_env + n_env++, "HOME=%s", home) < 0) ||
+ (username && (
+ asprintf(our_env + n_env++, "LOGNAME=%s", username) < 0 ||
+ asprintf(our_env + n_env++, "USER=%s", username) < 0)) ||
+ (shell && asprintf(our_env + n_env++, "SHELL=%s", shell) < 0) ||
+ ((is_terminal_input(context->std_input) ||
+ context->std_output == EXEC_OUTPUT_TTY ||
+ context->std_error == EXEC_OUTPUT_TTY) && (
+ !(our_env[n_env++] = strdup(default_term_for_tty(tty_path(context))))))) {
+
err = -ENOMEM;
r = EXIT_MEMORY;
goto fail_child;
}
- if (n_fds > 0)
- if (asprintf(our_env + n_env++, "LISTEN_PID=%lu", (unsigned long) getpid()) < 0 ||
- asprintf(our_env + n_env++, "LISTEN_FDS=%u", n_fds) < 0) {
- err = -ENOMEM;
- r = EXIT_MEMORY;
- goto fail_child;
- }
-
- if (home)
- if (asprintf(our_env + n_env++, "HOME=%s", home) < 0) {
- err = -ENOMEM;
- r = EXIT_MEMORY;
- goto fail_child;
- }
-
- if (username)
- if (asprintf(our_env + n_env++, "LOGNAME=%s", username) < 0 ||
- asprintf(our_env + n_env++, "USER=%s", username) < 0) {
- err = -ENOMEM;
- r = EXIT_MEMORY;
- goto fail_child;
- }
-
- if (is_terminal_input(context->std_input) ||
- context->std_output == EXEC_OUTPUT_TTY ||
- context->std_error == EXEC_OUTPUT_TTY)
- if (!(our_env[n_env++] = strdup(default_term_for_tty(tty_path(context))))) {
- err = -ENOMEM;
- r = EXIT_MEMORY;
- goto fail_child;
- }
-
- assert(n_env <= 7);
+ our_env[n_env++] = NULL;
+ assert(n_env <= 8);
final_env = strv_env_merge(5,
environment,