diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-10-15 15:57:10 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-10-18 13:12:04 -0400 |
commit | 27c67307976a60088ca301e07404bdb52740c3af (patch) | |
tree | 698c9331ad91cd71687055f3cf4951dbc5a755b3 /src/providers/ldap | |
parent | d80a670c94e5a0e21702b8cd8ac5a66fbba81178 (diff) | |
download | sssd-27c67307976a60088ca301e07404bdb52740c3af.tar.gz sssd-27c67307976a60088ca301e07404bdb52740c3af.tar.bz2 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')
-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 be4642aa..135e3708 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 96de9738..8547dae1 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 */ |