Package: shadow / 1:4.2-3+deb8u4

523_su_arguments_are_no_more_concatenated_by_default Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Goal: Do not concatenate the additional arguments, and support an
      environment variable to revert to the old Debian's su behavior.

This patch needs the su_arguments_are_concatenated patch.

This patch, and su_arguments_are_concatenated should be dropped after
Etch.

Status wrt upstream: This patch is Debian specific.

--- a/src/su.c
+++ b/src/su.c
@@ -104,6 +104,19 @@
 /* If nonzero, change some environment vars to indicate the user su'd to. */
 static bool change_environment = true;
 
+/*
+ * If nonzero, keep the old Debian behavior:
+ *   * concatenate all the arguments and provide them to the -c option of
+ *     the shell
+ *   * If there are some additional arguments, but no -c, add a -c
+ *     argument anyway
+ * Drawbacks:
+ *   * you can't provide options to the shell (other than -c)
+ *   * you can't rely on the argument count
+ * See http://bugs.debian.org/276419
+ */
+static int old_debian_behavior;
+
 #ifdef USE_PAM
 static pam_handle_t *pamh = NULL;
 static int caught = 0;
@@ -964,6 +977,8 @@
 	int ret;
 #endif				/* USE_PAM */
 
+	old_debian_behavior = (getenv("SU_NO_SHELL_ARGS") != NULL);
+
 	(void) setlocale (LC_ALL, "");
 	(void) bindtextdomain (PACKAGE, LOCALEDIR);
 	(void) textdomain (PACKAGE);
@@ -1171,7 +1186,7 @@
 		 * resulting string is always given to the shell with its
 		 * -c option.
 		 */
-		{
+		if (old_debian_behavior) {
 			char **parg;
 			unsigned int cmd_len = 0;
 			char *cmd = NULL;