250 lines
8.7 KiB
Diff
250 lines
8.7 KiB
Diff
|
diff -up cpu-1.4.3/src/include/plugins/ldap/ldap.h.mod-delete cpu-1.4.3/src/include/plugins/ldap/ldap.h
|
||
|
--- cpu-1.4.3/src/include/plugins/ldap/ldap.h.mod-delete 2003-12-30 20:22:20.000000000 -0700
|
||
|
+++ cpu-1.4.3/src/include/plugins/ldap/ldap.h 2010-11-05 23:54:19.000000000 -0600
|
||
|
@@ -127,8 +127,8 @@ int ldapCat(LDAP *ld);
|
||
|
uid_t getNextUid(LDAP * ld);
|
||
|
gid_t getNextGid(LDAP * ld, ldapop_t op);
|
||
|
int ldapUserCheck(int mod_op, LDAP * ld);
|
||
|
-int ldapGroupCheck(int mod_op);
|
||
|
-LDAPMod ** ldapBuildListStr(int mod_op, char * mod_type, char * value,
|
||
|
+int ldapGroupCheck(int mod_op, LDAP * ld);
|
||
|
+LDAPMod ** ldapBuildListStr(LDAP * ld, int mod_op, char * mod_type, char * value,
|
||
|
LDAPMod ** mods);
|
||
|
LDAPMod ** ldapBuildList(int mod_op, char * mod_type, char ** value,
|
||
|
LDAPMod ** mods);
|
||
|
diff -up cpu-1.4.3/src/plugins/ldap/group.c.mod-delete cpu-1.4.3/src/plugins/ldap/group.c
|
||
|
--- cpu-1.4.3/src/plugins/ldap/group.c.mod-delete 2003-10-12 17:34:59.000000000 -0600
|
||
|
+++ cpu-1.4.3/src/plugins/ldap/group.c 2010-11-05 23:54:19.000000000 -0600
|
||
|
@@ -31,7 +31,7 @@ LDAPMod **groupMod = NULL;
|
||
|
int
|
||
|
ldapGroupAdd (LDAP * ld)
|
||
|
{
|
||
|
- if (ldapGroupCheck (LDAP_MOD_ADD) < 0)
|
||
|
+ if (ldapGroupCheck (LDAP_MOD_ADD, ld) < 0)
|
||
|
{
|
||
|
fprintf (stderr, "ldap: ldapGroupAdd: error in ldapGroupCheck\n");
|
||
|
return -1;
|
||
|
@@ -50,7 +50,7 @@ int
|
||
|
ldapGroupMod (LDAP * ld)
|
||
|
{
|
||
|
char *newdn = NULL;
|
||
|
- if (ldapGroupCheck (LDAP_MOD_REPLACE) < 0)
|
||
|
+ if (ldapGroupCheck (LDAP_MOD_REPLACE, ld) < 0)
|
||
|
{
|
||
|
fprintf (stderr, "ldap: ldapGroupMod: error in ldapGroupCheck\n");
|
||
|
return -1;
|
||
|
@@ -105,7 +105,7 @@ ldapGroupDel (LDAP * ld)
|
||
|
}
|
||
|
|
||
|
int
|
||
|
-ldapGroupCheck (int mod_op)
|
||
|
+ldapGroupCheck (int mod_op, LDAP * ld)
|
||
|
{
|
||
|
int op = 0;
|
||
|
if (mod_op == LDAP_MOD_ADD)
|
||
|
@@ -126,11 +126,11 @@ ldapGroupCheck (int mod_op)
|
||
|
groupMod = ldapBuildList (op, "objectClass",
|
||
|
globalLdap->group_object_class, groupMod);
|
||
|
groupMod =
|
||
|
- ldapBuildListStr (LDAP_MOD_ADD, "cn", ldapGetCn (), groupMod);
|
||
|
+ ldapBuildListStr (ld, LDAP_MOD_ADD, "cn", ldapGetCn (), groupMod);
|
||
|
}
|
||
|
|
||
|
if (globalLdap->passent->pw_passwd)
|
||
|
- groupMod = ldapBuildListStr (op, "userPassword",
|
||
|
+ groupMod = ldapBuildListStr (ld, op, "userPassword",
|
||
|
globalLdap->passent->pw_passwd, groupMod);
|
||
|
|
||
|
if ((int) globalLdap->passent->pw_gid > -1)
|
||
|
@@ -143,7 +143,7 @@ ldapGroupCheck (int mod_op)
|
||
|
pos = globalLdap->parse;
|
||
|
while (pos != NULL)
|
||
|
{
|
||
|
- groupMod = ldapBuildListStr (op, pos->attr, pos->attrval, groupMod);
|
||
|
+ groupMod = ldapBuildListStr (ld, op, pos->attr, pos->attrval, groupMod);
|
||
|
pos = pos->next;
|
||
|
}
|
||
|
}
|
||
|
diff -up cpu-1.4.3/src/plugins/ldap/ld.c.mod-delete cpu-1.4.3/src/plugins/ldap/ld.c
|
||
|
--- cpu-1.4.3/src/plugins/ldap/ld.c.mod-delete 2010-11-05 23:53:41.000000000 -0600
|
||
|
+++ cpu-1.4.3/src/plugins/ldap/ld.c 2010-11-06 00:03:17.000000000 -0600
|
||
|
@@ -278,7 +278,7 @@ ldapAddList (LDAPMod ** mods)
|
||
|
}
|
||
|
|
||
|
LDAPMod **
|
||
|
-ldapBuildListStr (int mod_op, char *mod_type, char *value, LDAPMod ** mods)
|
||
|
+ldapBuildListStr (LDAP * ld, int mod_op, char *mod_type, char *value, LDAPMod ** mods)
|
||
|
{
|
||
|
char **temp;
|
||
|
|
||
|
@@ -286,19 +286,66 @@ ldapBuildListStr (int mod_op, char *mod_
|
||
|
return mods;
|
||
|
|
||
|
if (value == NULL || strlen(value) == strspn(value, " "))
|
||
|
- return mods;
|
||
|
-
|
||
|
- mods = ldapAddList (mods);
|
||
|
+ {
|
||
|
+ int strsize = 1;
|
||
|
+ char *filter = NULL;
|
||
|
+ int ldapres = 0;
|
||
|
+ int err = 0;
|
||
|
+
|
||
|
+ LDAPMessage *res[2];
|
||
|
+ res[1] = NULL;
|
||
|
+
|
||
|
+ strsize = strlen (mod_type) + 5;
|
||
|
+ filter = (char *) malloc (sizeof (char) * strsize);
|
||
|
+ if (filter == NULL)
|
||
|
+ return -1;
|
||
|
+ bzero (filter, strsize);
|
||
|
+ snprintf (filter, strsize, "(%s=*)", mod_type);
|
||
|
+ if (ldap_search_st (ld, globalLdap->dn, LDAP_SCOPE_BASE, filter, NULL, 0,
|
||
|
+ &globalLdap->timeout, res) != LDAP_SUCCESS)
|
||
|
+ {
|
||
|
+ if (ldap_get_option (ld, LDAP_OPT_ERROR_NUMBER, &err) < 0)
|
||
|
+ {
|
||
|
+ fprintf (stderr, "Error in ldap_get_option\n");
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+ if (err != LDAP_NO_SUCH_OBJECT)
|
||
|
+ {
|
||
|
+ CPU_ldapPerror (ld, globalLdap,
|
||
|
+ "ldapBuildListStr: ldap_search_st");
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ ldapres = ldap_count_entries (ld, res[0]);
|
||
|
+ if (ldapres > 0)
|
||
|
+ {
|
||
|
+ mods = ldapAddList (mods);
|
||
|
+
|
||
|
+ mods[list_size]->mod_op = LDAP_MOD_DELETE;
|
||
|
+ mods[list_size]->mod_type = strdup (mod_type);
|
||
|
+ mods[list_size]->mod_values = NULL;
|
||
|
+ list_size++;
|
||
|
+ }
|
||
|
+ }
|
||
|
+ free(filter);
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ mods = ldapAddList (mods);
|
||
|
|
||
|
- temp = (char **) malloc (sizeof (char *) * 2);
|
||
|
- bzero (temp, sizeof (char *) * 2);
|
||
|
- temp[0] = value;
|
||
|
- temp[1] = NULL;
|
||
|
+ temp = (char **) malloc (sizeof (char *) * 2);
|
||
|
+ bzero (temp, sizeof (char *) * 2);
|
||
|
+ temp[0] = value;
|
||
|
+ temp[1] = NULL;
|
||
|
+
|
||
|
+ mods[list_size]->mod_op = mod_op;
|
||
|
+ mods[list_size]->mod_type = strdup (mod_type);
|
||
|
+ mods[list_size]->mod_values = temp;
|
||
|
+ list_size++;
|
||
|
+ }
|
||
|
|
||
|
- mods[list_size]->mod_op = mod_op;
|
||
|
- mods[list_size]->mod_type = strdup (mod_type);
|
||
|
- mods[list_size]->mod_values = temp;
|
||
|
- list_size++;
|
||
|
return mods;
|
||
|
}
|
||
|
|
||
|
diff -up cpu-1.4.3/src/plugins/ldap/user.c.mod-delete cpu-1.4.3/src/plugins/ldap/user.c
|
||
|
--- cpu-1.4.3/src/plugins/ldap/user.c.mod-delete 2010-11-05 23:53:41.000000000 -0600
|
||
|
+++ cpu-1.4.3/src/plugins/ldap/user.c 2010-11-05 23:54:19.000000000 -0600
|
||
|
@@ -251,16 +251,16 @@ ldapUserCheck (int mod_op, LDAP * ld)
|
||
|
*/
|
||
|
if (op == LDAP_MOD_ADD)
|
||
|
{
|
||
|
- userMod = ldapBuildListStr (LDAP_MOD_ADD, "cn", ldapGetCn (), userMod);
|
||
|
+ userMod = ldapBuildListStr (ld, LDAP_MOD_ADD, "cn", ldapGetCn (), userMod);
|
||
|
userMod =
|
||
|
ldapBuildList (op, "objectClass", globalLdap->user_object_class,
|
||
|
userMod);
|
||
|
}
|
||
|
else if (globalLdap->passent->pw_gecos || (globalLdap->first_name && globalLdap->last_name))
|
||
|
- userMod = ldapBuildListStr (op, "cn", ldapGetCn (), userMod);
|
||
|
+ userMod = ldapBuildListStr (ld, op, "cn", ldapGetCn (), userMod);
|
||
|
|
||
|
userMod =
|
||
|
- ldapBuildListStr (op, "uid", globalLdap->passent->pw_name, userMod);
|
||
|
+ ldapBuildListStr (ld, op, "uid", globalLdap->passent->pw_name, userMod);
|
||
|
|
||
|
/* do we allow duplicates ? */
|
||
|
if ((int) globalLdap->passent->pw_uid > -1)
|
||
|
@@ -433,35 +433,35 @@ ldapUserCheck (int mod_op, LDAP * ld)
|
||
|
}
|
||
|
if (globalLdap->first_name)
|
||
|
userMod =
|
||
|
- ldapBuildListStr (op, "givenName", globalLdap->first_name, userMod);
|
||
|
+ ldapBuildListStr (ld, op, "givenName", globalLdap->first_name, userMod);
|
||
|
|
||
|
if (globalLdap->last_name)
|
||
|
- userMod = ldapBuildListStr (op, "sn", globalLdap->last_name, userMod);
|
||
|
+ userMod = ldapBuildListStr (ld, op, "sn", globalLdap->last_name, userMod);
|
||
|
|
||
|
if (globalLdap->new_username)
|
||
|
- userMod = ldapBuildListStr (op, "uid", globalLdap->new_username, userMod);
|
||
|
+ userMod = ldapBuildListStr (ld, op, "uid", globalLdap->new_username, userMod);
|
||
|
|
||
|
if (globalLdap->email_address)
|
||
|
userMod =
|
||
|
- ldapBuildListStr (op, "mail", globalLdap->email_address, userMod);
|
||
|
+ ldapBuildListStr (ld, op, "mail", globalLdap->email_address, userMod);
|
||
|
|
||
|
if (globalLdap->passent->pw_passwd)
|
||
|
userMod =
|
||
|
- ldapBuildListStr (op, "userPassword", globalLdap->passent->pw_passwd,
|
||
|
+ ldapBuildListStr (ld, op, "userPassword", globalLdap->passent->pw_passwd,
|
||
|
userMod);
|
||
|
|
||
|
if (globalLdap->passent->pw_gecos)
|
||
|
- userMod = ldapBuildListStr (op, "gecos", globalLdap->passent->pw_gecos,
|
||
|
+ userMod = ldapBuildListStr (ld, op, "gecos", globalLdap->passent->pw_gecos,
|
||
|
userMod);
|
||
|
|
||
|
if (globalLdap->passent->pw_dir)
|
||
|
userMod =
|
||
|
- ldapBuildListStr (op, "homeDirectory", globalLdap->passent->pw_dir,
|
||
|
+ ldapBuildListStr (ld, op, "homeDirectory", globalLdap->passent->pw_dir,
|
||
|
userMod);
|
||
|
|
||
|
if (globalLdap->passent->pw_shell)
|
||
|
userMod =
|
||
|
- ldapBuildListStr (op, "loginShell", globalLdap->passent->pw_shell,
|
||
|
+ ldapBuildListStr (ld, op, "loginShell", globalLdap->passent->pw_shell,
|
||
|
userMod);
|
||
|
if ((int) globalLdap->passent->sp_lstchg != -10)
|
||
|
userMod = ldapBuildListInt (op, "shadowLastChange",
|
||
|
@@ -501,7 +501,7 @@ ldapUserCheck (int mod_op, LDAP * ld)
|
||
|
pos = globalLdap->parse;
|
||
|
while (pos != NULL)
|
||
|
{
|
||
|
- userMod = ldapBuildListStr (op, pos->attr, pos->attrval, userMod);
|
||
|
+ userMod = ldapBuildListStr (ld, op, pos->attr, pos->attrval, userMod);
|
||
|
pos = pos->next;
|
||
|
}
|
||
|
}
|
||
|
diff -up cpu-1.4.3/src/util/parser.c.mod-delete cpu-1.4.3/src/util/parser.c
|
||
|
--- cpu-1.4.3/src/util/parser.c.mod-delete 2010-11-07 16:05:19.000000000 -0700
|
||
|
+++ cpu-1.4.3/src/util/parser.c 2010-11-07 16:13:07.000000000 -0700
|
||
|
@@ -290,11 +290,7 @@
|
||
|
p->cont = true;
|
||
|
token = getToken(&cart[i], delim);
|
||
|
if ( token == NULL )
|
||
|
- {
|
||
|
- printf("%d: Malformed file, cannot continue parsing.\n",
|
||
|
- __LINE__);
|
||
|
- return NULL;
|
||
|
- }
|
||
|
+ token = strdup ("");
|
||
|
}
|
||
|
p->attrval = delWhite(&token);
|
||
|
pos = parse;
|