[Pkg-shadow-commits] r404 - branches/experimental/debian/patches

Nicolas FRANCOIS nekral-guest at costa.debian.org
Sun Jul 24 20:46:01 UTC 2005


Author: nekral-guest
Date: 2005-07-24 20:46:00 +0000 (Sun, 24 Jul 2005)
New Revision: 404

Added:
   branches/experimental/debian/patches/423_su_arguments_are_concatenated
Log:
Lets flame!
Do concatenate. Keep the old behavior for now.


Added: branches/experimental/debian/patches/423_su_arguments_are_concatenated
===================================================================
--- branches/experimental/debian/patches/423_su_arguments_are_concatenated	2005-07-24 20:44:46 UTC (rev 403)
+++ branches/experimental/debian/patches/423_su_arguments_are_concatenated	2005-07-24 20:46:00 UTC (rev 404)
@@ -0,0 +1,60 @@
+Index: shadow-4.0.10/src/su.c
+===================================================================
+--- shadow-4.0.10.orig/src/su.c	2005-07-24 10:50:14.000000000 +0200
++++ shadow-4.0.10/src/su.c	2005-07-24 10:51:11.000000000 +0200
+@@ -218,6 +218,8 @@
+ 	int status;
+ 	int ret;
+ 	int argno = 0;
++	int cmd_len = 0;
++	char *cmd = NULL;
+ 
+ 	/* There is at most 4 arguments (arg0, '-c', <command>, NULL) + the
+ 	 * number of arguments in the additional_args array. */
+@@ -243,6 +245,16 @@
+ 	if (command) {
+ 		args[argno++] = "-c";
+ 		args[argno++] = command;
++	} else if (additional_args) {
++		/* even if -c was not specified, there are some additional arguments
++		 * and they will be passed to the shell in the command provided
++		 * with the -c shell option.
++		 * This differ from others su implementations (FreeBSD, SUN).
++		 *
++		 * If you want to supply arguments to the shell, you will need to
++		 * put the shell with its arguments in the command.
++		 */
++		args[argno++] = "-c";
+ 	}
+ 
+ 	if (additional_args) {
+@@ -253,6 +265,29 @@
+ 
+ 	args[argno] = NULL;
+ 
++	/* Arguments are concatenated because the shell requires the command to
++	 * be specified in one argument (which must follow -c).
++	 * This differ from others su implementations (FreeBSD, SUN).
++	 *
++	 * If you need to supply separated arguments to the shell, then put
++	 * the shell and its arguments in the command line.
++	 */
++	if (args[1]) {
++		const char **parg;
++		cmd_len = 1; /* final \0 */
++		for (parg = &args[2]; *parg; parg++) {
++			cmd_len += strlen(*parg) + 1;
++		}
++		cmd = (char *) xmalloc(sizeof(char) * cmd_len);
++		for (parg = &args[2]; *parg; parg++) {
++			strcat (cmd, " ");
++			strcat (cmd, *parg);
++		}
++		cmd[cmd_len-1] = '\0';
++		args[2] = &cmd[1]; /* do not take first space */
++		args[3] = NULL;
++	}
++
+ #ifndef USE_PAM
+ 	(void) execv (shellstr, args);
+ 	fprintf (stderr, _("No shell\n"));




More information about the Pkg-shadow-commits mailing list