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
51
52
|
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.
Index: shadow-4.4/src/su.c
===================================================================
--- shadow-4.4.orig/src/su.c
+++ shadow-4.4/src/su.c
@@ -104,6 +104,19 @@ static char caller_name[BUFSIZ];
/* 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 char kill_msg[256];
static char wait_msg[256];
@@ -952,6 +965,8 @@ int main (int argc, char **argv)
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);
@@ -1159,7 +1174,7 @@ int main (int argc, char **argv)
* 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;
|