diff options
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, |