Explorar o código

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 %!s(int64=11) %!d(string=hai) anos
pai
achega
8d09898b4f
Modificáronse 3 ficheiros con 13 adicións e 8 borrados
  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
   * Switch libdpkg xz compressor to use CRC64 for integrity checks, to match
     the default on the command-line tool, which should provide slightly better
     the default on the command-line tool, which should provide slightly better
     detection against damaged data, at a negligible speed difference.
     detection against damaged data, at a negligible speed difference.
+  * Only use the SHELL environment variable for interactive shells.
+    Closes: #788819
   * Perl modules:
   * Perl modules:
     - Remove non-functional timezone name support from
     - Remove non-functional timezone name support from
       Dpkg::Changelog::Entry::Debian.
       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 *shell;
 	const char *mode;
 	const char *mode;
 
 
-	shell = getenv("SHELL");
-	if (str_is_unset(shell))
-		shell = DEFAULTSHELL;
-
-	if (cmd == NULL)
+	if (cmd == NULL) {
 		mode = "-i";
 		mode = "-i";
-	else
+		shell = getenv("SHELL");
+	} else {
 		mode = "-c";
 		mode = "-c";
+		shell = NULL;
+	}
+
+	if (str_is_unset(shell))
+		shell = DEFAULTSHELL;
 
 
 	execlp(shell, shell, mode, cmd, NULL);
 	execlp(shell, shell, mode, cmd, NULL);
 	ohshite(_("unable to execute %s (%s)"), name, cmd);
 	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
 .TP
 \fB\-\-status\-logger\fR=\fIcommand\fR
 \fB\-\-status\-logger\fR=\fIcommand\fR
 Send machine-readable package status and progress information to the
 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.
 This option can be specified multiple times.
 The output format used is the same as in \fB\-\-status\-fd\fP.
 The output format used is the same as in \fB\-\-status\-fd\fP.
 .RE
 .RE
@@ -808,7 +809,7 @@ temporary files and directories.
 The program \fBdpkg\fP will execute when displaying the conffiles.
 The program \fBdpkg\fP will execute when displaying the conffiles.
 .TP
 .TP
 .B SHELL
 .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
 .TP
 .B COLUMNS
 .B COLUMNS
 Sets the number of columns \fBdpkg\fP should use when displaying formatted
 Sets the number of columns \fBdpkg\fP should use when displaying formatted