summaryrefslogtreecommitdiff
path: root/src/providers/ldap
diff options
context:
space:
mode:
Diffstat (limited to 'src/providers/ldap')
-rw-r--r--src/providers/ldap/ldap_id.c11
-rw-r--r--src/providers/ldap/sdap_async_accounts.c29
2 files changed, 17 insertions, 23 deletions
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
index 135e3708..91b6c8ad 100644
--- a/src/providers/ldap/ldap_id.c
+++ b/src/providers/ldap/ldap_id.c
@@ -27,6 +27,7 @@
#include <sys/time.h>
#include "util/util.h"
+#include "util/strtonum.h"
#include "db/sysdb.h"
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_async.h"
@@ -219,10 +220,9 @@ static void users_get_done(struct tevent_req *subreq)
break;
case BE_FILTER_IDNUM:
- errno = 0;
- uid = (uid_t) strtoul(state->name, &endptr, 0);
+ uid = (uid_t) strtouint32(state->name, &endptr, 0);
if (errno || *endptr || (state->name == endptr)) {
- tevent_req_error(req, errno);
+ tevent_req_error(req, errno ? errno : EINVAL);
return;
}
@@ -445,10 +445,9 @@ static void groups_get_done(struct tevent_req *subreq)
break;
case BE_FILTER_IDNUM:
- errno = 0;
- gid = (gid_t) strtoul(state->name, &endptr, 0);
+ gid = (gid_t) strtouint32(state->name, &endptr, 0);
if (errno || *endptr || (state->name == endptr)) {
- tevent_req_error(req, errno);
+ tevent_req_error(req, errno ? errno : EINVAL);
return;
}
diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c
index 62bafed4..6b14161c 100644
--- a/src/providers/ldap/sdap_async_accounts.c
+++ b/src/providers/ldap/sdap_async_accounts.c
@@ -43,7 +43,6 @@ static int sdap_save_user(TALLOC_CTX *memctx,
const char *gecos;
const char *homedir;
const char *shell;
- unsigned long l;
uid_t uid;
gid_t gid;
struct sysdb_attrs *user_attrs;
@@ -90,16 +89,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_ulong(attrs,
- opts->user_map[SDAP_AT_USER_UID].sys_name,
- &l);
+ ret = sysdb_attrs_get_uint32_t(attrs,
+ opts->user_map[SDAP_AT_USER_UID].sys_name,
+ &uid);
if (ret != EOK) {
DEBUG(1, ("no uid provided for [%s] in domain [%s].\n",
name, dom->name));
ret = EINVAL;
goto fail;
}
- uid = l;
/* check that the uid is valid for this domain */
if (OUT_OF_ID_RANGE(uid, dom->id_min, dom->id_max)) {
@@ -109,16 +107,15 @@ static int sdap_save_user(TALLOC_CTX *memctx,
goto fail;
}
- ret = sysdb_attrs_get_ulong(attrs,
- opts->user_map[SDAP_AT_USER_GID].sys_name,
- &l);
+ ret = sysdb_attrs_get_uint32_t(attrs,
+ opts->user_map[SDAP_AT_USER_GID].sys_name,
+ &gid);
if (ret != EOK) {
DEBUG(1, ("no gid provided for [%s] in domain [%s].\n",
name, dom->name));
ret = EINVAL;
goto fail;
}
- gid = l;
/* check that the gid is valid for this domain */
if (OUT_OF_ID_RANGE(gid, dom->id_min, dom->id_max)) {
@@ -609,7 +606,6 @@ static int sdap_save_group(TALLOC_CTX *memctx,
struct ldb_message_element *el;
struct sysdb_attrs *group_attrs;
const char *name = NULL;
- unsigned long l;
gid_t gid;
int ret;
char *timestamp = NULL;
@@ -623,16 +619,15 @@ static int sdap_save_group(TALLOC_CTX *memctx,
}
name = (const char *)el->values[0].data;
- ret = sysdb_attrs_get_ulong(attrs,
- opts->group_map[SDAP_AT_GROUP_GID].sys_name,
- &l);
+ ret = sysdb_attrs_get_uint32_t(attrs,
+ opts->group_map[SDAP_AT_GROUP_GID].sys_name,
+ &gid);
if (ret != EOK) {
DEBUG(1, ("no gid provided for [%s] in domain [%s].\n",
name, dom->name));
ret = EINVAL;
goto fail;
}
- gid = l;
/* check that the gid is valid for this domain */
if (OUT_OF_ID_RANGE(gid, dom->id_min, dom->id_max)) {
@@ -1792,9 +1787,9 @@ static errno_t sdap_add_incomplete_groups(struct sysdb_ctx *sysdb,
}
if (strcmp(name, missing[i]) == 0) {
- ret = sysdb_attrs_get_ulong(ldap_groups[ai],
- SYSDB_GIDNUM,
- (unsigned long *) &gid);
+ ret = sysdb_attrs_get_uint32_t(ldap_groups[ai],
+ SYSDB_GIDNUM,
+ &gid);
if (ret) {
DEBUG(1, ("The GID attribute is missing or malformed\n"));
goto fail;