diff options
author | Roger Leigh <rleigh@debian.org> | 2005-06-21 12:08:57 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2005-06-21 12:08:57 +0000 |
commit | 311a7de44229955ef12d69c99450b9b005743de4 (patch) | |
tree | 6f15b611ede915d1d1278ab057c9eb4a1991d62d | |
parent | 6b1395490dc622d8b05ed095696f0a720f69fb04 (diff) | |
download | schroot-311a7de44229955ef12d69c99450b9b005743de4.tar.gz |
Summary:
Run a real login shell
Revision:
schroot--mainline--0.1.0--patch-18
- SbuildSession: If no environment has been set, and no command has been
specified, run a real login shell by prefixing - to argv[0].
-rw-r--r-- | schroot/sbuild-session.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/schroot/sbuild-session.c b/schroot/sbuild-session.c index 75c59cce..a41fbefe 100644 --- a/schroot/sbuild-session.c +++ b/schroot/sbuild-session.c @@ -995,13 +995,28 @@ sbuild_session_run_chroot (SbuildSession *session, g_debug("Set environment: %s", env[i]); /* Run login shell */ + char *file = NULL; + + /* Altering session->command is OK since we forked */ if ((session->command == NULL || session->command[0] == NULL)) // No command { g_assert (session->shell != NULL); session->command = g_new(char *, 2); - session->command[0] = g_strdup(session->shell); + file = g_strdup(session->shell); + if (session->environment == NULL) // Not keeping environment; login shell + { + char *shellbase = g_path_get_basename(session->shell); + char *shell = g_strconcat("-", shellbase, NULL); + g_free(shellbase); + session->command[0] = shell; + g_debug("Login shell: %s", session->command[1]); + } + else + { + session->command[0] = g_strdup(session->shell); + } session->command[1] = NULL; g_debug("Running login shell: %s", session->shell); @@ -1014,6 +1029,7 @@ sbuild_session_run_chroot (SbuildSession *session, } else { + file = g_strdup(session->command[0]); char *command = g_strjoinv(" ", session->command); g_debug("Running command: %s", command); syslog(LOG_USER|LOG_NOTICE, "[%s chroot] %s:%s Running command: %s", @@ -1026,7 +1042,7 @@ sbuild_session_run_chroot (SbuildSession *session, } /* Execute */ - if (execve (session->command[0], session->command, env)) + if (execve (file, session->command, env)) { fprintf (stderr, "Could not exec %s: %s\n", session->command[0], g_strerror (errno)); |