1 |
jpp |
1.1 |
diff -up ./common/fmt_string.c.rmwhitespaces ./common/fmt_string.c |
2 |
|
|
--- ./common/fmt_string.c.rmwhitespaces 2012-09-18 15:56:28.000000000 +0200 |
3 |
|
|
+++ ./common/fmt_string.c 2015-12-08 14:52:36.929941509 +0100 |
4 |
|
|
@@ -38,6 +38,8 @@ |
5 |
|
|
# include <strings.h> |
6 |
|
|
#endif /* HAVE_STRINGS_H */ |
7 |
|
|
|
8 |
|
|
+#include <ctype.h> |
9 |
|
|
+ |
10 |
|
|
#include "missing.h" |
11 |
|
|
#include "sudo_debug.h" |
12 |
|
|
|
13 |
|
|
@@ -64,3 +66,17 @@ fmt_string(const char *var, const char * |
14 |
|
|
|
15 |
|
|
debug_return_str(str); |
16 |
|
|
} |
17 |
|
|
+ |
18 |
|
|
+char * rm_whitespaces(char * str){ |
19 |
|
|
+ int state = 1; |
20 |
|
|
+ char * c; |
21 |
|
|
+ for (c = str ; *c != '\0' ; c++){ |
22 |
|
|
+ if (state && isspace(*c))str++; |
23 |
|
|
+ else if (!isspace(*c))state = 0; |
24 |
|
|
+ else if (!state && isspace(*c)){ |
25 |
|
|
+ *c = '\0'; |
26 |
|
|
+ break; |
27 |
|
|
+ } |
28 |
|
|
+ } |
29 |
|
|
+ return str; |
30 |
|
|
+} |
31 |
|
|
diff -up ./plugins/sudoers/ldap.c.rmwhitespaces ./plugins/sudoers/ldap.c |
32 |
|
|
--- ./plugins/sudoers/ldap.c.rmwhitespaces 2015-12-08 14:48:28.331720437 +0100 |
33 |
|
|
+++ ./plugins/sudoers/ldap.c 2015-12-08 14:48:28.334720416 +0100 |
34 |
|
|
@@ -943,17 +943,17 @@ sudo_ldap_parse_options(LDAP *ld, LDAPMe |
35 |
|
|
if (op == '+' || op == '-') { |
36 |
|
|
*(val - 2) = '\0'; /* found, remove extra char */ |
37 |
|
|
/* case var+=val or var-=val */ |
38 |
|
|
- set_default(var, strunquote(val), (int) op); |
39 |
|
|
+ set_default(rm_whitespaces(var), strunquote(val), (int) op); |
40 |
|
|
} else { |
41 |
|
|
/* case var=val */ |
42 |
|
|
- set_default(var, strunquote(val), true); |
43 |
|
|
+ set_default(rm_whitespaces(var), strunquote(val), true); |
44 |
|
|
} |
45 |
|
|
} else if (*var == '!') { |
46 |
|
|
/* case !var Boolean False */ |
47 |
|
|
- set_default(var + 1, NULL, false); |
48 |
|
|
+ set_default(rm_whitespaces(var + 1), NULL, false); |
49 |
|
|
} else { |
50 |
|
|
/* case var Boolean True */ |
51 |
|
|
- set_default(var, NULL, true); |
52 |
|
|
+ set_default(rm_whitespaces(var), NULL, true); |
53 |
|
|
} |
54 |
|
|
efree(var); |
55 |
|
|
} |
56 |
|
|
diff -up ./plugins/sudoers/sssd.c.rmwhitespaces ./plugins/sudoers/sssd.c |
57 |
|
|
--- ./plugins/sudoers/sssd.c.rmwhitespaces 2015-12-08 14:48:28.331720437 +0100 |
58 |
|
|
+++ ./plugins/sudoers/sssd.c 2015-12-08 14:48:28.334720416 +0100 |
59 |
|
|
@@ -1001,17 +1001,17 @@ sudo_sss_parse_options(struct sudo_sss_h |
60 |
|
|
if (op == '+' || op == '-') { |
61 |
|
|
*(val - 2) = '\0'; /* found, remove extra char */ |
62 |
|
|
/* case var+=val or var-=val */ |
63 |
|
|
- set_default(v, strunquote(val), (int) op); |
64 |
|
|
+ set_default(rm_whitespaces(v), strunquote(val), (int) op); |
65 |
|
|
} else { |
66 |
|
|
/* case var=val */ |
67 |
|
|
- set_default(v, strunquote(val), true); |
68 |
|
|
+ set_default(rm_whitespaces(v), strunquote(val), true); |
69 |
|
|
} |
70 |
|
|
} else if (*v == '!') { |
71 |
|
|
/* case !var Boolean False */ |
72 |
|
|
- set_default(v + 1, NULL, false); |
73 |
|
|
+ set_default(rm_whitespaces(v + 1), NULL, false); |
74 |
|
|
} else { |
75 |
|
|
/* case var Boolean True */ |
76 |
|
|
- set_default(v, NULL, true); |
77 |
|
|
+ set_default(rm_whitespaces(v), NULL, true); |
78 |
|
|
} |
79 |
|
|
efree(v); |
80 |
|
|
} |
81 |
|
|
diff -up ./plugins/sudoers/sudoers.h.rmwhitespaces ./plugins/sudoers/sudoers.h |
82 |
|
|
--- ./plugins/sudoers/sudoers.h.rmwhitespaces 2015-12-08 14:48:28.315720552 +0100 |
83 |
|
|
+++ ./plugins/sudoers/sudoers.h 2015-12-08 14:48:28.334720416 +0100 |
84 |
|
|
@@ -346,6 +346,7 @@ int sudoers_hook_unsetenv(const char *na |
85 |
|
|
|
86 |
|
|
/* fmt_string.c */ |
87 |
|
|
char *fmt_string(const char *, const char *); |
88 |
|
|
+char *rm_whitespaces(char * str); |
89 |
|
|
|
90 |
|
|
/* sudoers.c */ |
91 |
|
|
void plugin_cleanup(int); |