diff options
Diffstat (limited to 'src/providers/ldap')
-rw-r--r-- | src/providers/ldap/ldap_id.c | 4 | ||||
-rw-r--r-- | src/providers/ldap/sdap_async_accounts.c | 46 |
2 files changed, 16 insertions, 34 deletions
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index be4642aab..135e37084 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -220,7 +220,7 @@ static void users_get_done(struct tevent_req *subreq) case BE_FILTER_IDNUM: errno = 0; - uid = (uid_t)strtol(state->name, &endptr, 0); + uid = (uid_t) strtoul(state->name, &endptr, 0); if (errno || *endptr || (state->name == endptr)) { tevent_req_error(req, errno); return; @@ -446,7 +446,7 @@ static void groups_get_done(struct tevent_req *subreq) case BE_FILTER_IDNUM: errno = 0; - gid = (gid_t)strtol(state->name, &endptr, 0); + gid = (gid_t) strtoul(state->name, &endptr, 0); if (errno || *endptr || (state->name == endptr)) { tevent_req_error(req, errno); return; diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c index 96de9738d..8547dae18 100644 --- a/src/providers/ldap/sdap_async_accounts.c +++ b/src/providers/ldap/sdap_async_accounts.c @@ -43,7 +43,7 @@ static int sdap_save_user(TALLOC_CTX *memctx, const char *gecos; const char *homedir; const char *shell; - long int l; + unsigned long l; uid_t uid; gid_t gid; struct sysdb_attrs *user_attrs; @@ -90,21 +90,15 @@ static int sdap_save_user(TALLOC_CTX *memctx, if (el->num_values == 0) shell = NULL; else shell = (const char *)el->values[0].data; - ret = sysdb_attrs_get_el(attrs, - opts->user_map[SDAP_AT_USER_UID].sys_name, &el); - if (ret) goto fail; - if (el->num_values == 0) { + ret = sysdb_attrs_get_ulong(attrs, + opts->user_map[SDAP_AT_USER_UID].sys_name, + &l); + if (ret != EOK) { DEBUG(1, ("no uid provided for [%s] in domain [%s].\n", name, dom->name)); ret = EINVAL; goto fail; } - errno = 0; - l = strtol((const char *)el->values[0].data, NULL, 0); - if (errno) { - ret = EINVAL; - goto fail; - } uid = l; /* check that the uid is valid for this domain */ @@ -115,21 +109,15 @@ static int sdap_save_user(TALLOC_CTX *memctx, goto fail; } - ret = sysdb_attrs_get_el(attrs, - opts->user_map[SDAP_AT_USER_GID].sys_name, &el); - if (ret) goto fail; - if (el->num_values == 0) { + ret = sysdb_attrs_get_ulong(attrs, + opts->user_map[SDAP_AT_USER_GID].sys_name, + &l); + if (ret != EOK) { DEBUG(1, ("no gid provided for [%s] in domain [%s].\n", name, dom->name)); ret = EINVAL; goto fail; } - errno = 0; - l = strtol((const char *)el->values[0].data, NULL, 0); - if (errno) { - ret = EINVAL; - goto fail; - } gid = l; /* check that the gid is valid for this domain */ @@ -621,7 +609,7 @@ static int sdap_save_group(TALLOC_CTX *memctx, struct ldb_message_element *el; struct sysdb_attrs *group_attrs; const char *name = NULL; - long int l; + unsigned long l; gid_t gid; int ret; char *timestamp = NULL; @@ -635,21 +623,15 @@ static int sdap_save_group(TALLOC_CTX *memctx, } name = (const char *)el->values[0].data; - ret = sysdb_attrs_get_el(attrs, - opts->group_map[SDAP_AT_GROUP_GID].sys_name, &el); - if (ret) goto fail; - if (el->num_values == 0) { + ret = sysdb_attrs_get_ulong(attrs, + opts->group_map[SDAP_AT_GROUP_GID].sys_name, + &l); + if (ret != EOK) { DEBUG(1, ("no gid provided for [%s] in domain [%s].\n", name, dom->name)); ret = EINVAL; goto fail; } - errno = 0; - l = strtol((const char *)el->values[0].data, NULL, 0); - if (errno) { - ret = EINVAL; - goto fail; - } gid = l; /* check that the gid is valid for this domain */ |