summaryrefslogtreecommitdiffstats
path: root/server/responder/nss/nsssrv_cmd.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-02-27 13:35:33 -0500
committerSimo Sorce <ssorce@redhat.com>2009-02-27 17:11:23 -0500
commit24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8 (patch)
tree735441471a4e8c5fcc2dd9b9311b000f44584e29 /server/responder/nss/nsssrv_cmd.c
parent60bbc5034e546b7df7a6f782e3353b863f49618b (diff)
downloadsssd-24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8.tar.gz
sssd-24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8.tar.xz
sssd-24480f7fa3bf3f40bd9fb7c865f9e3b329bf3ed8.zip
Refactor creation of domain_map into confdb
The NSS provider, the Data Provider backends and the InfoPipe all need access to the domain map provided by the confdb. Instead of reimplimenting it in multiple places, it is now provided in a pair of helper functions from the confdb. confdb_get_domains() returns a domain map by reference. Always returns the most up-to-date set of domains from the confdb. confdb_get_domains_list() returns an array of strings of all the domain names. Always returns the most up-to-date set of domains from the confdb. This patch also modifies the btreemap_get_keys() function to better handle memory and report allocation failures.
Diffstat (limited to 'server/responder/nss/nsssrv_cmd.c')
-rw-r--r--server/responder/nss/nsssrv_cmd.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c
index 16146585f..76da6e063 100644
--- a/server/responder/nss/nsssrv_cmd.c
+++ b/server/responder/nss/nsssrv_cmd.c
@@ -25,6 +25,7 @@
#include "responder/nss/nsssrv.h"
#include "db/sysdb.h"
#include <time.h>
+#include "confdb/confdb.h"
struct nss_cmd_ctx {
struct cli_ctx *cctx;
@@ -92,7 +93,7 @@ static int nss_parse_name(struct nss_dom_ctx *dctx, const char *fullname)
{
struct nss_cmd_ctx *cmdctx = dctx->cmdctx;
struct nss_ctx *nctx = cmdctx->cctx->nctx;
- struct nss_domain_info *info;
+ struct sss_domain_info *info;
struct btreemap *domain_map;
char *delim;
char *domain;
@@ -617,7 +618,7 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx)
{
struct nss_cmd_ctx *cmdctx;
struct nss_dom_ctx *dctx;
- struct nss_domain_info *info;
+ struct sss_domain_info *info;
const char **domains;
uint8_t *body;
size_t blen;
@@ -643,8 +644,10 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx)
domains = NULL;
num = 0;
/* get domains list */
- btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
- (const void ***)&domains, &num);
+ ret = btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
+ (const void ***)&domains, &num);
+ if (ret != EOK)
+ return ret;
cmdctx->nr = num;
@@ -797,7 +800,7 @@ static void nss_cmd_setpw_dp_callback(uint16_t err_maj, uint32_t err_min,
static int nss_cmd_setpwent_ext(struct cli_ctx *cctx, bool immediate)
{
- struct nss_domain_info *info;
+ struct sss_domain_info *info;
struct nss_cmd_ctx *cmdctx;
struct nss_dom_ctx *dctx;
struct getent_ctx *gctx;
@@ -832,8 +835,11 @@ static int nss_cmd_setpwent_ext(struct cli_ctx *cctx, bool immediate)
domains = NULL;
num = 0;
/* get domains list */
- btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
+ ret = btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
(const void ***)&domains, &num);
+ if (ret != EOK) {
+ return ret;
+ }
/* check if enumeration is enabled in any domain */
for (i = 0; i < num; i++) {
@@ -1515,7 +1521,7 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx)
{
struct nss_cmd_ctx *cmdctx;
struct nss_dom_ctx *dctx;
- struct nss_domain_info *info;
+ struct sss_domain_info *info;
const char **domains;
uint8_t *body;
size_t blen;
@@ -1541,8 +1547,11 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx)
domains = NULL;
num = 0;
/* get domains list */
- btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
- (const void ***)&domains, &num);
+ ret = btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
+ (const void ***)&domains, &num);
+ if (ret != EOK) {
+ return ret;
+ }
cmdctx->nr = num;
@@ -1693,7 +1702,7 @@ static void nss_cmd_setgr_dp_callback(uint16_t err_maj, uint32_t err_min,
static int nss_cmd_setgrent_ext(struct cli_ctx *cctx, bool immediate)
{
- struct nss_domain_info *info;
+ struct sss_domain_info *info;
struct nss_cmd_ctx *cmdctx;
struct nss_dom_ctx *dctx;
struct getent_ctx *gctx;
@@ -1728,8 +1737,11 @@ static int nss_cmd_setgrent_ext(struct cli_ctx *cctx, bool immediate)
domains = NULL;
num = 0;
/* get domains list */
- btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
- (const void ***)&domains, &num);
+ ret = btreemap_get_keys(cmdctx, cctx->nctx->domain_map,
+ (const void ***)&domains, &num);
+ if(ret != EOK) {
+ return ret;
+ }
/* check if enumeration is enabled in any domain */
for (i = 0; i < num; i++) {