summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/sdap_async_accounts.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-10-15 15:57:10 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-10-18 13:12:04 -0400
commit27c67307976a60088ca301e07404bdb52740c3af (patch)
tree698c9331ad91cd71687055f3cf4951dbc5a755b3 /src/providers/ldap/sdap_async_accounts.c
parentd80a670c94e5a0e21702b8cd8ac5a66fbba81178 (diff)
downloadsssd-27c67307976a60088ca301e07404bdb52740c3af.tar.gz
sssd-27c67307976a60088ca301e07404bdb52740c3af.tar.xz
sssd-27c67307976a60088ca301e07404bdb52740c3af.zip
Use unsigned long for conversion to id_t
We used strtol() on a number of places to convert into uid_t or gid_t from a string representation such as LDAP attribute, but on some platforms, unsigned long might be necessary to store big id_t values. This patch converts to using strtoul() instead.
Diffstat (limited to 'src/providers/ldap/sdap_async_accounts.c')
-rw-r--r--src/providers/ldap/sdap_async_accounts.c46
1 files changed, 14 insertions, 32 deletions
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 */