diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-01-31 22:59:58 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-31 20:30:25 -0500 |
commit | ab68008f87504ace9451c14ba2a7e8dfec435779 (patch) | |
tree | ca43219fe43d1d68d0a543311d596c46c9654b96 /src/responder/nss | |
parent | 25a9a1768d2e3587cc68b76a0a5df1e42a2c89ab (diff) | |
download | sssd-ab68008f87504ace9451c14ba2a7e8dfec435779.tar.gz sssd-ab68008f87504ace9451c14ba2a7e8dfec435779.tar.bz2 sssd-ab68008f87504ace9451c14ba2a7e8dfec435779.zip |
Refactor nss_cmd_send_empty
Diffstat (limited to 'src/responder/nss')
-rw-r--r-- | src/responder/nss/nsssrv_cmd.c | 37 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_netgroup.c | 4 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_private.h | 3 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_services.c | 4 |
4 files changed, 7 insertions, 41 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 579c7602..bbb115c8 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -46,41 +46,10 @@ static int nss_cmd_send_error(struct nss_cmd_ctx *cmdctx, int err) return EOK; } -int fill_empty(struct sss_packet *packet) -{ - uint8_t *body; - size_t blen; - int ret; - - ret = sss_packet_grow(packet, 2*sizeof(uint32_t)); - if (ret != EOK) return ret; - - sss_packet_get_body(packet, &body, &blen); - ((uint32_t *)body)[0] = 0; /* num results */ - ((uint32_t *)body)[1] = 0; /* reserved */ - - return EOK; -} - static int nss_cmd_send_empty(struct nss_cmd_ctx *cmdctx) { struct cli_ctx *cctx = cmdctx->cctx; - int ret; - - /* create response packet */ - ret = sss_packet_new(cctx->creq, 0, - sss_packet_get_cmd(cctx->creq->in), - &cctx->creq->out); - if (ret != EOK) { - return ret; - } - ret = fill_empty(cctx->creq->out); - if (ret != EOK) { - return ret; - } - sss_packet_set_error(cctx->creq->out, EOK); - sss_cmd_done(cctx, cmdctx); - return EOK; + return sss_cmd_send_empty(cctx, cmdctx); } int nss_cmd_done(struct nss_cmd_ctx *cmdctx, int ret) @@ -1674,7 +1643,7 @@ static int nss_cmd_retpwent(struct cli_ctx *cctx, int num) none: if (ret == ENOENT) { - ret = fill_empty(cctx->creq->out); + ret = sss_cmd_empty_packet(cctx->creq->out); } return ret; } @@ -2913,7 +2882,7 @@ static int nss_cmd_retgrent(struct cli_ctx *cctx, int num) none: if (ret == ENOENT) { - ret = fill_empty(cctx->creq->out); + ret = sss_cmd_empty_packet(cctx->creq->out); } return ret; } diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c index bb047d6a..093329fa 100644 --- a/src/responder/nss/nsssrv_netgroup.c +++ b/src/responder/nss/nsssrv_netgroup.c @@ -618,7 +618,7 @@ static void nss_cmd_setnetgrent_done(struct tevent_req *req) if (ret == EOK) { if (reqret == ENOENT) { /* Notify the caller that this entry wasn't found */ - fill_empty(cmdctx->cctx->creq->out); + sss_cmd_empty_packet(cmdctx->cctx->creq->out); } else { packet = cmdctx->cctx->creq->out; ret = sss_packet_grow(packet, 2*sizeof(uint32_t)); @@ -803,7 +803,7 @@ static errno_t nss_cmd_getnetgrent_process(struct nss_cmd_ctx *cmdctx, if (!netgr->entries || netgr->entries[0] == NULL) { /* No entries */ DEBUG(5, ("No entries found\n")); - ret = fill_empty(client->creq->out); + ret = sss_cmd_empty_packet(client->creq->out); if (ret != EOK) { return nss_cmd_done(cmdctx, ret); } diff --git a/src/responder/nss/nsssrv_private.h b/src/responder/nss/nsssrv_private.h index 83936fac..876552fb 100644 --- a/src/responder/nss/nsssrv_private.h +++ b/src/responder/nss/nsssrv_private.h @@ -109,9 +109,6 @@ struct setent_step_ctx { /* Finish the request */ int nss_cmd_done(struct nss_cmd_ctx *cmdctx, int ret); -/* Respond with no entries */ -int fill_empty(struct sss_packet *packet); - int setent_remove_ref(TALLOC_CTX *ctx); errno_t setent_add_ref(TALLOC_CTX *memctx, struct getent_ctx *getent_ctx, diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c index 9013c682..da37708b 100644 --- a/src/responder/nss/nsssrv_services.c +++ b/src/responder/nss/nsssrv_services.c @@ -994,7 +994,7 @@ nss_cmd_getserv_done(struct tevent_req *req) if (ret == EOK) { if (reqret == ENOENT) { /* Notify the caller that this entry wasn't found */ - ret = fill_empty(cmdctx->cctx->creq->out); + ret = sss_cmd_empty_packet(cmdctx->cctx->creq->out); } else { i = dctx->res->count; ret = fill_service(cmdctx->cctx->creq->out, @@ -1793,7 +1793,7 @@ retservent(struct cli_ctx *cctx, int num) none: if (ret == ENOENT) { - ret = fill_empty(cctx->creq->out); + ret = sss_cmd_empty_packet(cctx->creq->out); } return ret; } |