kov changed gksu/trunk/ChangeLog, gksu/trunk/gksu/gksu.c

Gustavo Noronha kov at alioth.debian.org
Sun Mar 4 16:03:26 CET 2007


Mensagem de log: 
accepted patch by Michael Vogt to correctly quote
strings which have \ or ', when in sudo mode


-----


Modified: gksu/trunk/ChangeLog
===================================================================
--- gksu/trunk/ChangeLog	2007-03-04 14:57:06 UTC (rev 781)
+++ gksu/trunk/ChangeLog	2007-03-04 15:03:26 UTC (rev 782)
@@ -1,3 +1,9 @@
+2007-03-04  Gustavo Noronha Silva  <kov at debian.org>
+
+	* gksu/gksu.c:
+	- accepted patch by Michael Vogt to correctly quote
+	  strings which have \ or ', when in sudo mode
+
 2007-02-04  Gustavo Noronha Silva  <kov at debian.org>
 
 	* configure.ac:

Modified: gksu/trunk/gksu/gksu.c
===================================================================
--- gksu/trunk/gksu/gksu.c	2007-03-04 14:57:06 UTC (rev 781)
+++ gksu/trunk/gksu/gksu.c	2007-03-04 15:03:26 UTC (rev 782)
@@ -670,6 +670,24 @@
 
       for (i = optind + 1; i < newargc; i++)
 	{
+	   // in sudo mode, check for ' and \ in string and escape it
+	  if(run_mode == SUDO_MODE && 
+	     (strchr(newargv[i],'\'') || strchr(newargv[i],'\\'))) 
+	       {
+		  const gchar *p = newargv[i];
+		  gchar *q,*dest;
+		  dest = q = g_malloc(strlen(newargv[i])*2+1);
+		  while(*p) {
+		     if (*p == '\'')
+			*q++ = '\\';
+		     else if (*p == '\\')
+			*q++ = '\\';
+		     *q++ = *p++;
+		  }
+		  *q = 0;
+		  g_free(newargv[i]);
+		  newargv[i] = dest;
+	       }
 	  tmp = g_strconcat (command, " '", newargv[i], "'", NULL);
 	  g_free (command);
 	  command = tmp;




More information about the gksu-commits mailing list