diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-23 19:55:43 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-27 09:02:02 -0500 |
commit | 1e7c355a2d36eb7b942b5111c96eb2a2285d49cc (patch) | |
tree | d2930595d4779d2565eacf491d99ab3d475e2a70 /src | |
parent | cff6bb5f8ee424b0e3aff74247e103e44075b16a (diff) | |
download | sssd-1e7c355a2d36eb7b942b5111c96eb2a2285d49cc.tar.gz sssd-1e7c355a2d36eb7b942b5111c96eb2a2285d49cc.tar.bz2 sssd-1e7c355a2d36eb7b942b5111c96eb2a2285d49cc.zip |
SYSDB: add support for enumerating services
Diffstat (limited to 'src')
-rw-r--r-- | src/db/sysdb_services.c | 50 | ||||
-rw-r--r-- | src/db/sysdb_services.h | 5 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/db/sysdb_services.c b/src/db/sysdb_services.c index efdf7f11..55a0c438 100644 --- a/src/db/sysdb_services.c +++ b/src/db/sysdb_services.c @@ -690,3 +690,53 @@ done: talloc_zfree(tmp_ctx); return ret; } + + +errno_t +sysdb_enumservent(TALLOC_CTX *mem_ctx, + struct sysdb_ctx *sysdb, + struct ldb_result **_res) +{ + errno_t ret; + int lret; + TALLOC_CTX *tmp_ctx; + static const char *attrs[] = SYSDB_SVC_ATTRS; + struct ldb_dn *base_dn; + struct ldb_result *res; + + *_res = NULL; + + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) { + return ENOMEM; + } + + base_dn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, + SYSDB_TMPL_SVC_BASE, + sysdb->domain->name); + if (!base_dn) { + ret = ENOMEM; + goto done; + } + + lret = ldb_search(sysdb->ldb, tmp_ctx, &res, base_dn, + LDB_SCOPE_SUBTREE, attrs, + SYSDB_SC); + if (lret != LDB_SUCCESS) { + ret = sysdb_error_to_errno(lret); + goto done; + } + + if (res->count == 0) { + ret = ENOENT; + goto done; + } + + *_res = talloc_steal(mem_ctx, res); + + ret = EOK; + +done: + talloc_free(tmp_ctx); + return ret; +} diff --git a/src/db/sysdb_services.h b/src/db/sysdb_services.h index 40612355..c4ad1d34 100644 --- a/src/db/sysdb_services.h +++ b/src/db/sysdb_services.h @@ -60,6 +60,11 @@ sysdb_getservbyport(TALLOC_CTX *mem_ctx, struct ldb_result **_res); errno_t +sysdb_enumservent(TALLOC_CTX *mem_ctx, + struct sysdb_ctx *sysdb, + struct ldb_result **_res); + +errno_t sysdb_store_service(struct sysdb_ctx *sysdb, const char *primary_name, int port, |