1 |
diff -up cpu-1.4.3/src/include/plugins/ldap/ldap.h.mod-delete cpu-1.4.3/src/include/plugins/ldap/ldap.h |
2 |
--- cpu-1.4.3/src/include/plugins/ldap/ldap.h.mod-delete 2003-12-30 20:22:20.000000000 -0700 |
3 |
+++ cpu-1.4.3/src/include/plugins/ldap/ldap.h 2010-11-05 23:54:19.000000000 -0600 |
4 |
@@ -127,8 +127,8 @@ int ldapCat(LDAP *ld); |
5 |
uid_t getNextUid(LDAP * ld); |
6 |
gid_t getNextGid(LDAP * ld, ldapop_t op); |
7 |
int ldapUserCheck(int mod_op, LDAP * ld); |
8 |
-int ldapGroupCheck(int mod_op); |
9 |
-LDAPMod ** ldapBuildListStr(int mod_op, char * mod_type, char * value, |
10 |
+int ldapGroupCheck(int mod_op, LDAP * ld); |
11 |
+LDAPMod ** ldapBuildListStr(LDAP * ld, int mod_op, char * mod_type, char * value, |
12 |
LDAPMod ** mods); |
13 |
LDAPMod ** ldapBuildList(int mod_op, char * mod_type, char ** value, |
14 |
LDAPMod ** mods); |
15 |
diff -up cpu-1.4.3/src/plugins/ldap/group.c.mod-delete cpu-1.4.3/src/plugins/ldap/group.c |
16 |
--- cpu-1.4.3/src/plugins/ldap/group.c.mod-delete 2003-10-12 17:34:59.000000000 -0600 |
17 |
+++ cpu-1.4.3/src/plugins/ldap/group.c 2010-11-05 23:54:19.000000000 -0600 |
18 |
@@ -31,7 +31,7 @@ LDAPMod **groupMod = NULL; |
19 |
int |
20 |
ldapGroupAdd (LDAP * ld) |
21 |
{ |
22 |
- if (ldapGroupCheck (LDAP_MOD_ADD) < 0) |
23 |
+ if (ldapGroupCheck (LDAP_MOD_ADD, ld) < 0) |
24 |
{ |
25 |
fprintf (stderr, "ldap: ldapGroupAdd: error in ldapGroupCheck\n"); |
26 |
return -1; |
27 |
@@ -50,7 +50,7 @@ int |
28 |
ldapGroupMod (LDAP * ld) |
29 |
{ |
30 |
char *newdn = NULL; |
31 |
- if (ldapGroupCheck (LDAP_MOD_REPLACE) < 0) |
32 |
+ if (ldapGroupCheck (LDAP_MOD_REPLACE, ld) < 0) |
33 |
{ |
34 |
fprintf (stderr, "ldap: ldapGroupMod: error in ldapGroupCheck\n"); |
35 |
return -1; |
36 |
@@ -105,7 +105,7 @@ ldapGroupDel (LDAP * ld) |
37 |
} |
38 |
|
39 |
int |
40 |
-ldapGroupCheck (int mod_op) |
41 |
+ldapGroupCheck (int mod_op, LDAP * ld) |
42 |
{ |
43 |
int op = 0; |
44 |
if (mod_op == LDAP_MOD_ADD) |
45 |
@@ -126,11 +126,11 @@ ldapGroupCheck (int mod_op) |
46 |
groupMod = ldapBuildList (op, "objectClass", |
47 |
globalLdap->group_object_class, groupMod); |
48 |
groupMod = |
49 |
- ldapBuildListStr (LDAP_MOD_ADD, "cn", ldapGetCn (), groupMod); |
50 |
+ ldapBuildListStr (ld, LDAP_MOD_ADD, "cn", ldapGetCn (), groupMod); |
51 |
} |
52 |
|
53 |
if (globalLdap->passent->pw_passwd) |
54 |
- groupMod = ldapBuildListStr (op, "userPassword", |
55 |
+ groupMod = ldapBuildListStr (ld, op, "userPassword", |
56 |
globalLdap->passent->pw_passwd, groupMod); |
57 |
|
58 |
if ((int) globalLdap->passent->pw_gid > -1) |
59 |
@@ -143,7 +143,7 @@ ldapGroupCheck (int mod_op) |
60 |
pos = globalLdap->parse; |
61 |
while (pos != NULL) |
62 |
{ |
63 |
- groupMod = ldapBuildListStr (op, pos->attr, pos->attrval, groupMod); |
64 |
+ groupMod = ldapBuildListStr (ld, op, pos->attr, pos->attrval, groupMod); |
65 |
pos = pos->next; |
66 |
} |
67 |
} |
68 |
diff -up cpu-1.4.3/src/plugins/ldap/ld.c.mod-delete cpu-1.4.3/src/plugins/ldap/ld.c |
69 |
--- cpu-1.4.3/src/plugins/ldap/ld.c.mod-delete 2010-11-05 23:53:41.000000000 -0600 |
70 |
+++ cpu-1.4.3/src/plugins/ldap/ld.c 2010-11-06 00:03:17.000000000 -0600 |
71 |
@@ -278,7 +278,7 @@ ldapAddList (LDAPMod ** mods) |
72 |
} |
73 |
|
74 |
LDAPMod ** |
75 |
-ldapBuildListStr (int mod_op, char *mod_type, char *value, LDAPMod ** mods) |
76 |
+ldapBuildListStr (LDAP * ld, int mod_op, char *mod_type, char *value, LDAPMod ** mods) |
77 |
{ |
78 |
char **temp; |
79 |
|
80 |
@@ -286,19 +286,65 @@ ldapBuildListStr (int mod_op, char *mod_ |
81 |
return mods; |
82 |
|
83 |
if (value == NULL || strlen(value) == strspn(value, " ")) |
84 |
- return mods; |
85 |
- |
86 |
- mods = ldapAddList (mods); |
87 |
+ { |
88 |
+ int strsize = 1; |
89 |
+ char *filter = NULL; |
90 |
+ int ldapres = 0; |
91 |
+ int err = 0; |
92 |
+ |
93 |
+ LDAPMessage *res[2]; |
94 |
+ res[1] = NULL; |
95 |
+ |
96 |
+ strsize = strlen (mod_type) + 5; |
97 |
+ filter = (char *) malloc (sizeof (char) * strsize); |
98 |
+ if (filter == NULL) |
99 |
+ return -1; |
100 |
+ bzero (filter, strsize); |
101 |
+ snprintf (filter, strsize, "(%s=*)", mod_type); |
102 |
+ if (ldap_search_st (ld, globalLdap->dn, LDAP_SCOPE_BASE, filter, NULL, 0, |
103 |
+ &globalLdap->timeout, res) != LDAP_SUCCESS) |
104 |
+ { |
105 |
+ if (ldap_get_option (ld, LDAP_OPT_ERROR_NUMBER, &err) < 0) |
106 |
+ { |
107 |
+ fprintf (stderr, "Error in ldap_get_option\n"); |
108 |
+ return -1; |
109 |
+ } |
110 |
+ if (err != LDAP_NO_SUCH_OBJECT) |
111 |
+ { |
112 |
+ CPU_ldapPerror (ld, globalLdap, |
113 |
+ "ldapBuildListStr: ldap_search_st"); |
114 |
+ return -1; |
115 |
+ } |
116 |
+ } |
117 |
+ else |
118 |
+ { |
119 |
+ ldapres = ldap_count_entries (ld, res[0]); |
120 |
+ if (ldapres > 0) |
121 |
+ { |
122 |
+ mods = ldapAddList (mods); |
123 |
+ |
124 |
+ mods[list_size]->mod_op = LDAP_MOD_DELETE; |
125 |
+ mods[list_size]->mod_type = strdup (mod_type); |
126 |
+ mods[list_size]->mod_values = NULL; |
127 |
+ list_size++; |
128 |
+ } |
129 |
+ } |
130 |
+ } |
131 |
+ else |
132 |
+ { |
133 |
+ mods = ldapAddList (mods); |
134 |
|
135 |
- temp = (char **) malloc (sizeof (char *) * 2); |
136 |
- bzero (temp, sizeof (char *) * 2); |
137 |
- temp[0] = value; |
138 |
- temp[1] = NULL; |
139 |
+ temp = (char **) malloc (sizeof (char *) * 2); |
140 |
+ bzero (temp, sizeof (char *) * 2); |
141 |
+ temp[0] = value; |
142 |
+ temp[1] = NULL; |
143 |
+ |
144 |
+ mods[list_size]->mod_op = mod_op; |
145 |
+ mods[list_size]->mod_type = strdup (mod_type); |
146 |
+ mods[list_size]->mod_values = temp; |
147 |
+ list_size++; |
148 |
+ } |
149 |
|
150 |
- mods[list_size]->mod_op = mod_op; |
151 |
- mods[list_size]->mod_type = strdup (mod_type); |
152 |
- mods[list_size]->mod_values = temp; |
153 |
- list_size++; |
154 |
return mods; |
155 |
} |
156 |
|
157 |
diff -up cpu-1.4.3/src/plugins/ldap/user.c.mod-delete cpu-1.4.3/src/plugins/ldap/user.c |
158 |
--- cpu-1.4.3/src/plugins/ldap/user.c.mod-delete 2010-11-05 23:53:41.000000000 -0600 |
159 |
+++ cpu-1.4.3/src/plugins/ldap/user.c 2010-11-05 23:54:19.000000000 -0600 |
160 |
@@ -251,16 +251,16 @@ ldapUserCheck (int mod_op, LDAP * ld) |
161 |
*/ |
162 |
if (op == LDAP_MOD_ADD) |
163 |
{ |
164 |
- userMod = ldapBuildListStr (LDAP_MOD_ADD, "cn", ldapGetCn (), userMod); |
165 |
+ userMod = ldapBuildListStr (ld, LDAP_MOD_ADD, "cn", ldapGetCn (), userMod); |
166 |
userMod = |
167 |
ldapBuildList (op, "objectClass", globalLdap->user_object_class, |
168 |
userMod); |
169 |
} |
170 |
else if (globalLdap->passent->pw_gecos || (globalLdap->first_name && globalLdap->last_name)) |
171 |
- userMod = ldapBuildListStr (op, "cn", ldapGetCn (), userMod); |
172 |
+ userMod = ldapBuildListStr (ld, op, "cn", ldapGetCn (), userMod); |
173 |
|
174 |
userMod = |
175 |
- ldapBuildListStr (op, "uid", globalLdap->passent->pw_name, userMod); |
176 |
+ ldapBuildListStr (ld, op, "uid", globalLdap->passent->pw_name, userMod); |
177 |
|
178 |
/* do we allow duplicates ? */ |
179 |
if ((int) globalLdap->passent->pw_uid > -1) |
180 |
@@ -433,35 +433,35 @@ ldapUserCheck (int mod_op, LDAP * ld) |
181 |
} |
182 |
if (globalLdap->first_name) |
183 |
userMod = |
184 |
- ldapBuildListStr (op, "givenName", globalLdap->first_name, userMod); |
185 |
+ ldapBuildListStr (ld, op, "givenName", globalLdap->first_name, userMod); |
186 |
|
187 |
if (globalLdap->last_name) |
188 |
- userMod = ldapBuildListStr (op, "sn", globalLdap->last_name, userMod); |
189 |
+ userMod = ldapBuildListStr (ld, op, "sn", globalLdap->last_name, userMod); |
190 |
|
191 |
if (globalLdap->new_username) |
192 |
- userMod = ldapBuildListStr (op, "uid", globalLdap->new_username, userMod); |
193 |
+ userMod = ldapBuildListStr (ld, op, "uid", globalLdap->new_username, userMod); |
194 |
|
195 |
if (globalLdap->email_address) |
196 |
userMod = |
197 |
- ldapBuildListStr (op, "mail", globalLdap->email_address, userMod); |
198 |
+ ldapBuildListStr (ld, op, "mail", globalLdap->email_address, userMod); |
199 |
|
200 |
if (globalLdap->passent->pw_passwd) |
201 |
userMod = |
202 |
- ldapBuildListStr (op, "userPassword", globalLdap->passent->pw_passwd, |
203 |
+ ldapBuildListStr (ld, op, "userPassword", globalLdap->passent->pw_passwd, |
204 |
userMod); |
205 |
|
206 |
if (globalLdap->passent->pw_gecos) |
207 |
- userMod = ldapBuildListStr (op, "gecos", globalLdap->passent->pw_gecos, |
208 |
+ userMod = ldapBuildListStr (ld, op, "gecos", globalLdap->passent->pw_gecos, |
209 |
userMod); |
210 |
|
211 |
if (globalLdap->passent->pw_dir) |
212 |
userMod = |
213 |
- ldapBuildListStr (op, "homeDirectory", globalLdap->passent->pw_dir, |
214 |
+ ldapBuildListStr (ld, op, "homeDirectory", globalLdap->passent->pw_dir, |
215 |
userMod); |
216 |
|
217 |
if (globalLdap->passent->pw_shell) |
218 |
userMod = |
219 |
- ldapBuildListStr (op, "loginShell", globalLdap->passent->pw_shell, |
220 |
+ ldapBuildListStr (ld, op, "loginShell", globalLdap->passent->pw_shell, |
221 |
userMod); |
222 |
if ((int) globalLdap->passent->sp_lstchg != -10) |
223 |
userMod = ldapBuildListInt (op, "shadowLastChange", |
224 |
@@ -501,7 +501,7 @@ ldapUserCheck (int mod_op, LDAP * ld) |
225 |
pos = globalLdap->parse; |
226 |
while (pos != NULL) |
227 |
{ |
228 |
- userMod = ldapBuildListStr (op, pos->attr, pos->attrval, userMod); |
229 |
+ userMod = ldapBuildListStr (ld, op, pos->attr, pos->attrval, userMod); |
230 |
pos = pos->next; |
231 |
} |
232 |
} |
233 |
diff -up cpu-1.4.3/src/util/parser.c.mod-delete cpu-1.4.3/src/util/parser.c |
234 |
--- cpu-1.4.3/src/util/parser.c.mod-delete 2010-11-07 16:05:19.000000000 -0700 |
235 |
+++ cpu-1.4.3/src/util/parser.c 2010-11-07 16:13:07.000000000 -0700 |
236 |
@@ -290,11 +290,7 @@ |
237 |
p->cont = true; |
238 |
token = getToken(&cart[i], delim); |
239 |
if ( token == NULL ) |
240 |
- { |
241 |
- printf("%d: Malformed file, cannot continue parsing.\n", |
242 |
- __LINE__); |
243 |
- return NULL; |
244 |
- } |
245 |
+ token = strdup (""); |
246 |
} |
247 |
p->attrval = delWhite(&token); |
248 |
pos = parse; |