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