From 27c67307976a60088ca301e07404bdb52740c3af Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 15 Oct 2010 15:57:10 +0200 Subject: 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. --- src/providers/ldap/sdap_async_accounts.c | 46 ++++++++++---------------------- 1 file changed, 14 insertions(+), 32 deletions(-) (limited to 'src/providers/ldap/sdap_async_accounts.c') 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 */ -- cgit