summaryrefslogtreecommitdiff
path: root/server/nss/nsssrv_ldb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-10-09 08:30:10 -0400
committerSimo Sorce <idra@samba.org>2008-10-09 08:30:10 -0400
commitf9e85b312049affb38a180d29c69d36ac0ac4048 (patch)
tree3bc77785e1e4871661cb9d8cb90881ac315f7416 /server/nss/nsssrv_ldb.c
parentfb263dd17c3fc00d9e5e8f366d60adbf5e76edf0 (diff)
downloadsssd-f9e85b312049affb38a180d29c69d36ac0ac4048.tar.gz
sssd-f9e85b312049affb38a180d29c69d36ac0ac4048.tar.bz2
sssd-f9e85b312049affb38a180d29c69d36ac0ac4048.zip
Use classic errno instead of inventing our own, it's broad enough fro atm.
Diffstat (limited to 'server/nss/nsssrv_ldb.c')
-rw-r--r--server/nss/nsssrv_ldb.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/server/nss/nsssrv_ldb.c b/server/nss/nsssrv_ldb.c
index 272ee366..86e03709 100644
--- a/server/nss/nsssrv_ldb.c
+++ b/server/nss/nsssrv_ldb.c
@@ -32,6 +32,12 @@ struct nss_ldb_search_ctx {
struct ldb_result *res;
};
+static int nss_ldb_error_to_errno(int lerr)
+{
+ /* fake it up for now, requires a mapping table */
+ return EIO;
+}
+
static int request_error(struct nss_ldb_search_ctx *sctx, int ldb_error)
{
sctx->callback(sctx->ptr, ldb_error, sctx->res);
@@ -116,20 +122,20 @@ int nss_ldb_getpwnam(TALLOC_CTX *mem_ctx,
sctx = talloc(mem_ctx, struct nss_ldb_search_ctx);
if (!sctx) {
- return RES_NOMEM;
+ return ENOMEM;
}
sctx->callback = fn;
sctx->ptr = ptr;
sctx->res = talloc_zero(sctx, struct ldb_result);
if (!sctx->res) {
talloc_free(sctx);
- return RES_NOMEM;
+ return ENOMEM;
}
expression = talloc_asprintf(sctx, NSS_PWNAM_FILTER, name);
if (!expression) {
talloc_free(sctx);
- return RES_NOMEM;
+ return ENOMEM;
}
ret = ldb_build_search_req(&req, ldb, sctx,
@@ -139,15 +145,15 @@ int nss_ldb_getpwnam(TALLOC_CTX *mem_ctx,
sctx, getpw_callback,
NULL);
if (ret != LDB_SUCCESS) {
- return RES_ERROR;
+ return nss_ldb_error_to_errno(ret);;
}
ret = ldb_request(ldb, req);
if (ret != LDB_SUCCESS) {
- return RES_ERROR;
+ return nss_ldb_error_to_errno(ret);
}
- return RES_SUCCESS;
+ return EOK;
}
int nss_ldb_getpwuid(TALLOC_CTX *mem_ctx,
@@ -165,20 +171,20 @@ int nss_ldb_getpwuid(TALLOC_CTX *mem_ctx,
sctx = talloc(mem_ctx, struct nss_ldb_search_ctx);
if (!sctx) {
- return RES_NOMEM;
+ return ENOMEM;
}
sctx->callback = fn;
sctx->ptr = ptr;
sctx->res = talloc_zero(sctx, struct ldb_result);
if (!sctx->res) {
talloc_free(sctx);
- return RES_NOMEM;
+ return ENOMEM;
}
expression = talloc_asprintf(sctx, NSS_PWUID_FILTER, filter_uid);
if (!expression) {
talloc_free(sctx);
- return RES_NOMEM;
+ return ENOMEM;
}
ret = ldb_build_search_req(&req, ldb, sctx,
@@ -188,15 +194,15 @@ int nss_ldb_getpwuid(TALLOC_CTX *mem_ctx,
sctx, getpw_callback,
NULL);
if (ret != LDB_SUCCESS) {
- return RES_ERROR;
+ return nss_ldb_error_to_errno(ret);
}
ret = ldb_request(ldb, req);
if (ret != LDB_SUCCESS) {
- return RES_ERROR;
+ return nss_ldb_error_to_errno(ret);
}
- return RES_SUCCESS;
+ return EOK;
}
int nss_ldb_init(TALLOC_CTX *mem_ctx,
@@ -208,16 +214,16 @@ int nss_ldb_init(TALLOC_CTX *mem_ctx,
ldb = ldb_init(mem_ctx, ev);
if (!ldb) {
- return RES_ERROR;
+ return EIO;
}
ret = ldb_connect(ldb, NSS_LDB_PATH, 0, NULL);
if (ret != LDB_SUCCESS) {
talloc_free(ldb);
- return RES_ERROR;
+ return EIO;
}
*ldbp = ldb;
- return RES_SUCCESS;
+ return EOK;
}