Blame SOURCES/sudo-1.8.6p7-strunquote.patch

72fdaf
diff -up sudo-1.8.6p7/common/Makefile.in.strunquote sudo-1.8.6p7/common/Makefile.in
72fdaf
--- sudo-1.8.6p7/common/Makefile.in.strunquote	2013-02-25 20:46:09.000000000 +0100
72fdaf
+++ sudo-1.8.6p7/common/Makefile.in	2015-07-07 14:30:09.267181200 +0200
72fdaf
@@ -63,7 +63,7 @@ SHELL = @SHELL@
72fdaf
 
72fdaf
 LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo lbuf.lo list.lo \
72fdaf
 	 secure_path.lo setgroups.lo sudo_conf.lo sudo_debug.lo term.lo \
72fdaf
-	 ttysize.lo zero_bytes.lo @COMMON_OBJS@
72fdaf
+	 ttysize.lo zero_bytes.lo strunquote.lo @COMMON_OBJS@
72fdaf
 
72fdaf
 all: libcommon.la
72fdaf
 
72fdaf
@@ -164,3 +164,6 @@ ttysize.lo: $(srcdir)/ttysize.c $(top_bu
72fdaf
 zero_bytes.lo: $(srcdir)/zero_bytes.c $(top_builddir)/config.h \
72fdaf
                $(incdir)/missing.h
72fdaf
 	$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/zero_bytes.c
72fdaf
+strunquote.lo: $(srcdir)/strunquote.c $(top_builddir)/config.h \
72fdaf
+               $(incdir)/missing.h
72fdaf
+	$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/strunquote.c
72fdaf
diff -up sudo-1.8.6p7/common/strunquote.c.strunquote sudo-1.8.6p7/common/strunquote.c
72fdaf
--- sudo-1.8.6p7/common/strunquote.c.strunquote	2015-07-07 14:30:09.267181200 +0200
72fdaf
+++ sudo-1.8.6p7/common/strunquote.c	2015-07-07 14:31:05.403649285 +0200
72fdaf
@@ -0,0 +1,45 @@
72fdaf
+/*
72fdaf
+ * Copyright (c) 2015 Daniel Kopecek <dkopecek@redhat.com>
72fdaf
+ *
72fdaf
+ * Permission to use, copy, modify, and distribute this software for any
72fdaf
+ * purpose with or without fee is hereby granted, provided that the above
72fdaf
+ * copyright notice and this permission notice appear in all copies.
72fdaf
+ *
72fdaf
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
72fdaf
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
72fdaf
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
72fdaf
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
72fdaf
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
72fdaf
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
72fdaf
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
72fdaf
+ */
72fdaf
+#include <string.h>
72fdaf
+#include <ctype.h>
72fdaf
+
72fdaf
+char *strunquote(char *arg)
72fdaf
+{
72fdaf
+  char *str = arg;
72fdaf
+  if (str == NULL) {
72fdaf
+    return NULL;
72fdaf
+  }
72fdaf
+  const size_t len = strlen(str);
72fdaf
+  char *strend = str + len - 1;
72fdaf
+
72fdaf
+  /* Remove blanks */
72fdaf
+  for (; isblank((unsigned char)*str); str++);
72fdaf
+  for (; isblank((unsigned char)*strend) && strend > str; strend--);
72fdaf
+  /*
72fdaf
+   * Check that the string is double-quoted.
72fdaf
+   * If not, we are done.
72fdaf
+   */
72fdaf
+  if (*str != '"' || *strend != '"' || str == strend) {
72fdaf
+    /* Return the original argument if we didn't touch it */
72fdaf
+    return arg;
72fdaf
+  }
72fdaf
+
72fdaf
+  /* Remove the double-quotes */
72fdaf
+  *strend = '\0';
72fdaf
+  ++str;
72fdaf
+
72fdaf
+  return str;
72fdaf
+}
72fdaf
diff -up sudo-1.8.6p7/include/strunquote.h.strunquote sudo-1.8.6p7/include/strunquote.h
72fdaf
--- sudo-1.8.6p7/include/strunquote.h.strunquote	2015-07-07 14:30:09.267181200 +0200
72fdaf
+++ sudo-1.8.6p7/include/strunquote.h	2015-07-07 14:30:09.267181200 +0200
72fdaf
@@ -0,0 +1,17 @@
72fdaf
+/*
72fdaf
+ * Copyright (c) 2015 Daniel Kopecek <dkopecek@redhat.com>
72fdaf
+ *
72fdaf
+ * Permission to use, copy, modify, and distribute this software for any
72fdaf
+ * purpose with or without fee is hereby granted, provided that the above
72fdaf
+ * copyright notice and this permission notice appear in all copies.
72fdaf
+ *
72fdaf
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
72fdaf
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
72fdaf
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
72fdaf
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
72fdaf
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
72fdaf
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
72fdaf
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
72fdaf
+ */
72fdaf
+
72fdaf
+char *strunquote(char *arg);
72fdaf
diff -up sudo-1.8.6p7/plugins/sudoers/ldap.c.strunquote sudo-1.8.6p7/plugins/sudoers/ldap.c
72fdaf
--- sudo-1.8.6p7/plugins/sudoers/ldap.c.strunquote	2015-07-07 14:30:09.259181276 +0200
72fdaf
+++ sudo-1.8.6p7/plugins/sudoers/ldap.c	2015-07-07 14:30:09.267181200 +0200
72fdaf
@@ -79,6 +79,7 @@
72fdaf
 #include "sudoers.h"
72fdaf
 #include "parse.h"
72fdaf
 #include "lbuf.h"
72fdaf
+#include "strunquote.h"
72fdaf
 
72fdaf
 /* Older Netscape LDAP SDKs don't prototype ldapssl_set_strength() */
72fdaf
 #if defined(HAVE_LDAPSSL_SET_STRENGTH) && !defined(HAVE_LDAP_SSL_H) && !defined(HAVE_MPS_LDAP_SSL_H)
72fdaf
@@ -1004,10 +1005,10 @@ sudo_ldap_parse_options(LDAP *ld, LDAPMe
72fdaf
 	    if (op == '+' || op == '-') {
72fdaf
 		*(val - 2) = '\0';	/* found, remove extra char */
72fdaf
 		/* case var+=val or var-=val */
72fdaf
-		set_default(var, val, (int) op);
72fdaf
+		set_default(var, strunquote(val), (int) op);
72fdaf
 	    } else {
72fdaf
 		/* case var=val */
72fdaf
-		set_default(var, val, true);
72fdaf
+		set_default(var, strunquote(val), true);
72fdaf
 	    }
72fdaf
 	} else if (*var == '!') {
72fdaf
 	    /* case !var Boolean False */
72fdaf
diff -up sudo-1.8.6p7/plugins/sudoers/sssd.c.strunquote sudo-1.8.6p7/plugins/sudoers/sssd.c
72fdaf
--- sudo-1.8.6p7/plugins/sudoers/sssd.c.strunquote	2015-07-07 14:30:09.260181267 +0200
72fdaf
+++ sudo-1.8.6p7/plugins/sudoers/sssd.c	2015-07-07 14:30:09.268181191 +0200
72fdaf
@@ -61,6 +61,7 @@
72fdaf
 #include "lbuf.h"
72fdaf
 #include "sudo_debug.h"
72fdaf
 #include "ipa_hostname.h"
72fdaf
+#include "strunquote.h"
72fdaf
 
72fdaf
 /* SSSD <--> SUDO interface - do not change */
72fdaf
 struct sss_sudo_attr {
72fdaf
@@ -996,10 +997,10 @@ sudo_sss_parse_options(struct sudo_sss_h
72fdaf
 	    if (op == '+' || op == '-') {
72fdaf
 		*(val - 2) = '\0';	/* found, remove extra char */
72fdaf
 		/* case var+=val or var-=val */
72fdaf
-		set_default(v, val, (int) op);
72fdaf
+		set_default(v, strunquote(val), (int) op);
72fdaf
 	    } else {
72fdaf
 		/* case var=val */
72fdaf
-		set_default(v, val, true);
72fdaf
+		set_default(v, strunquote(val), true);
72fdaf
 	    }
72fdaf
 	} else if (*v == '!') {
72fdaf
 	    /* case !var Boolean False */