Просмотр исходного кода

libdpkg: Only use the SHELL environment variable for interactive shells

SHELL is the user preferred shell, but it does not guarantee a POSIX
shell. Use it only for interactive shells, and use «sh» otherwise.

Closes: #788819
Stable-Candidate: 1.16.x 1.17.x
Guillem Jover лет назад: 11
Родитель
Сommit
8d09898b4f
3 измененных файлов с 13 добавлено и 8 удалено
  1. 2 0
      debian/changelog
  2. 8 6
      lib/dpkg/command.c
  3. 3 2
      man/dpkg.1

+ 2 - 0
debian/changelog

@@ -20,6 +20,8 @@ dpkg (1.18.2) UNRELEASED; urgency=low
   * Switch libdpkg xz compressor to use CRC64 for integrity checks, to match
     the default on the command-line tool, which should provide slightly better
     detection against damaged data, at a negligible speed difference.
+  * Only use the SHELL environment variable for interactive shells.
+    Closes: #788819
   * Perl modules:
     - Remove non-functional timezone name support from
       Dpkg::Changelog::Entry::Debian.

+ 8 - 6
lib/dpkg/command.c

@@ -216,14 +216,16 @@ command_shell(const char *cmd, const char *name)
 	const char *shell;
 	const char *mode;
 
-	shell = getenv("SHELL");
-	if (str_is_unset(shell))
-		shell = DEFAULTSHELL;
-
-	if (cmd == NULL)
+	if (cmd == NULL) {
 		mode = "-i";
-	else
+		shell = getenv("SHELL");
+	} else {
 		mode = "-c";
+		shell = NULL;
+	}
+
+	if (str_is_unset(shell))
+		shell = DEFAULTSHELL;
 
 	execlp(shell, shell, mode, cmd, NULL);
 	ohshite(_("unable to execute %s (%s)"), name, cmd);

+ 3 - 2
man/dpkg.1

@@ -751,7 +751,8 @@ Sent just before a processing stage starts. \fIstage\fR is one of
 .TP
 \fB\-\-status\-logger\fR=\fIcommand\fR
 Send machine-readable package status and progress information to the
-shell \fIcommand\fR's standard input (since dpkg 1.16.0).
+shell \fIcommand\fR's standard input, to be run via \*(lqsh \-c\*(rq
+(since dpkg 1.16.0).
 This option can be specified multiple times.
 The output format used is the same as in \fB\-\-status\-fd\fP.
 .RE
@@ -808,7 +809,7 @@ temporary files and directories.
 The program \fBdpkg\fP will execute when displaying the conffiles.
 .TP
 .B SHELL
-The program \fBdpkg\fP will execute when starting a new shell.
+The program \fBdpkg\fP will execute when starting a new interactive shell.
 .TP
 .B COLUMNS
 Sets the number of columns \fBdpkg\fP should use when displaying formatted