summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-10-25 15:14:24 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-10-26 08:00:21 -0400
commit580374daba2ab2c6075a7d0de9512abff133e2e9 (patch)
treedfd9abe14efa5f6c79291ef72b1d2ac0b8326334 /src/providers/ldap
parent13147b598a8409c338abb9472e74bbd606f224bd (diff)
downloadsssd-580374daba2ab2c6075a7d0de9512abff133e2e9.tar.gz
sssd-580374daba2ab2c6075a7d0de9512abff133e2e9.tar.xz
sssd-580374daba2ab2c6075a7d0de9512abff133e2e9.zip
Always use uint32_t for UID/GID numbers
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 135e37084..91b6c8add 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 62bafed43..6b14161ce 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;