summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-14 17:27:05 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:15 -0400
commit7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac (patch)
treeabc9f4bfcc276834c922463120b35c66ee3bd033 /src/tools
parent0a7a138cd47dcff3f4d53da2db4fa155708b8aeb (diff)
downloadsssd_unused-7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac.tar.gz
sssd_unused-7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac.tar.xz
sssd_unused-7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac.zip
sysdb: convert sysdb_getpwnam
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/sss_sync_ops.c152
-rw-r--r--src/tools/sss_sync_ops.h2
-rw-r--r--src/tools/sss_useradd.c2
-rw-r--r--src/tools/sss_userdel.c2
-rw-r--r--src/tools/sss_usermod.c2
5 files changed, 57 insertions, 103 deletions
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index f9230a38..70203cf2 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -591,125 +591,79 @@ int groupdel(TALLOC_CTX *mem_ctx,
/*
* getpwnam, getgrnam and friends
*/
-static void sss_getpwnam_done(void *ptr, int status,
- struct ldb_result *lrs);
-
int sysdb_getpwnam_sync(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct sysdb_ctx *sysdb,
const char *name,
struct sss_domain_info *domain,
- struct ops_ctx **out)
-{
- int ret;
- struct sync_op_res *res = NULL;
-
- res = talloc_zero(mem_ctx, struct sync_op_res);
- if (!res) {
- return ENOMEM;
- }
-
- if (out == NULL) {
- DEBUG(1, ("NULL passed for storage pointer\n"));
- return EINVAL;
- }
- res->data = *out;
-
- ret = sysdb_getpwnam(mem_ctx,
- sysdb,
- domain,
- name,
- sss_getpwnam_done,
- res);
-
- SYNC_LOOP(res, ret);
-
- return ret;
-}
-
-static void sss_getpwnam_done(void *ptr, int status,
- struct ldb_result *lrs)
+ struct ops_ctx *out)
{
- struct sync_op_res *res = talloc_get_type(ptr, struct sync_op_res );
+ struct ldb_result *res;
const char *str;
+ int ret;
- res->done = true;
-
- if (status != LDB_SUCCESS) {
- res->error = status;
- return;
+ ret = sysdb_getpwnam(mem_ctx, sysdb, domain, name, &res);
+ if (ret) {
+ return ret;
}
- switch (lrs->count) {
- case 0:
- DEBUG(1, ("No result for sysdb_getpwnam call\n"));
- res->error = ENOENT;
- break;
+ switch (res->count) {
+ case 0:
+ DEBUG(1, ("No result for sysdb_getpwnam call\n"));
+ return ENOENT;
- case 1:
- res->error = EOK;
- /* fill ops_ctx */
- res->data->uid = ldb_msg_find_attr_as_uint64(lrs->msgs[0],
- SYSDB_UIDNUM, 0);
+ case 1:
+ /* fill ops_ctx */
+ out->uid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_UIDNUM, 0);
- res->data->gid = ldb_msg_find_attr_as_uint64(lrs->msgs[0],
- SYSDB_GIDNUM, 0);
+ out->gid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_GIDNUM, 0);
- str = ldb_msg_find_attr_as_string(lrs->msgs[0],
- SYSDB_NAME, NULL);
- res->data->name = talloc_strdup(res, str);
- if (res->data->name == NULL) {
- res->error = ENOMEM;
- return;
- }
+ str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_NAME, NULL);
+ out->name = talloc_strdup(out, str);
+ if (out->name == NULL) {
+ return ENOMEM;
+ }
- str = ldb_msg_find_attr_as_string(lrs->msgs[0],
- SYSDB_GECOS, NULL);
- res->data->gecos = talloc_strdup(res, str);
- if (res->data->gecos == NULL) {
- res->error = ENOMEM;
- return;
- }
+ str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_GECOS, NULL);
+ out->gecos = talloc_strdup(out, str);
+ if (out->gecos == NULL) {
+ return ENOMEM;
+ }
- str = ldb_msg_find_attr_as_string(lrs->msgs[0],
- SYSDB_HOMEDIR, NULL);
- res->data->home = talloc_strdup(res, str);
- if (res->data->home == NULL) {
- res->error = ENOMEM;
- return;
- }
+ str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_HOMEDIR, NULL);
+ out->home = talloc_strdup(out, str);
+ if (out->home == NULL) {
+ return ENOMEM;
+ }
- str = ldb_msg_find_attr_as_string(lrs->msgs[0],
- SYSDB_SHELL, NULL);
- res->data->shell = talloc_strdup(res, str);
- if (res->data->shell == NULL) {
- res->error = ENOMEM;
- return;
- }
+ str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_SHELL, NULL);
+ out->shell = talloc_strdup(out, str);
+ if (out->shell == NULL) {
+ return ENOMEM;
+ }
- str = ldb_msg_find_attr_as_string(lrs->msgs[0],
- SYSDB_DISABLED, NULL);
- if (str == NULL) {
- res->data->lock = DO_UNLOCK;
- } else {
- if (strcasecmp(str, "true") == 0) {
- res->data->lock = DO_LOCK;
- } else if (strcasecmp(str, "false") == 0) {
- res->data->lock = DO_UNLOCK;
- } else { /* Invalid value */
- DEBUG(2, ("Invalid value for %s attribute: %s\n",
- SYSDB_DISABLED, str ? str : "NULL"));
- res->error = EIO;
- return;
- }
+ str = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_DISABLED, NULL);
+ if (str == NULL) {
+ out->lock = DO_UNLOCK;
+ } else {
+ if (strcasecmp(str, "true") == 0) {
+ out->lock = DO_LOCK;
+ } else if (strcasecmp(str, "false") == 0) {
+ out->lock = DO_UNLOCK;
+ } else { /* Invalid value */
+ DEBUG(2, ("Invalid value for %s attribute: %s\n",
+ SYSDB_DISABLED, str ? str : "NULL"));
+ return EIO;
}
- break;
+ }
+ break;
- default:
- DEBUG(1, ("More than one result for sysdb_getpwnam call\n"));
- res->error = EIO;
- break;
+ default:
+ DEBUG(1, ("More than one result for sysdb_getpwnam call\n"));
+ return EIO;
}
+
+ return EOK;
}
static void sss_getgrnam_done(void *ptr, int status,
diff --git a/src/tools/sss_sync_ops.h b/src/tools/sss_sync_ops.h
index b2bb51c5..98fbc47f 100644
--- a/src/tools/sss_sync_ops.h
+++ b/src/tools/sss_sync_ops.h
@@ -97,7 +97,7 @@ int sysdb_getpwnam_sync(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
const char *name,
struct sss_domain_info *domain,
- struct ops_ctx **out);
+ struct ops_ctx *out);
int sysdb_getgrnam_sync(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c
index 6198dcae..0dc1993e 100644
--- a/src/tools/sss_useradd.c
+++ b/src/tools/sss_useradd.c
@@ -292,7 +292,7 @@ int main(int argc, const char **argv)
tctx->sysdb,
tctx->octx->name,
tctx->local,
- &tctx->octx);
+ tctx->octx);
if (ret != EOK) {
ERROR("Cannot get info about the user\n");
ret = EXIT_FAILURE;
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 890b4fec..55c41c24 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -236,7 +236,7 @@ int main(int argc, const char **argv)
tctx->sysdb,
tctx->octx->name,
tctx->local,
- &tctx->octx);
+ tctx->octx);
if (ret != EOK) {
/* Error message will be printed in the switch */
goto done;
diff --git a/src/tools/sss_usermod.c b/src/tools/sss_usermod.c
index 88e3fda3..43e685c5 100644
--- a/src/tools/sss_usermod.c
+++ b/src/tools/sss_usermod.c
@@ -143,7 +143,7 @@ int main(int argc, const char **argv)
/* check the username to be able to give sensible error message */
ret = sysdb_getpwnam_sync(tctx, tctx->ev, tctx->sysdb,
tctx->octx->name, tctx->local,
- &tctx->octx);
+ tctx->octx);
if (ret != EOK) {
ERROR("Cannot find user in local domain, "
"modifying users is allowed only in local domain\n");