summaryrefslogtreecommitdiff
path: root/src/responder/nss
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-20 19:51:24 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:16 -0400
commitb2d78dfb2cdd6391be62812513ed26d6f4f454c5 (patch)
treea4fec70f497614fa1d75519da0ae49dea2456688 /src/responder/nss
parent88e7576d8bf00bfd0eaed8731b7eee1d6b6e05a1 (diff)
downloadsssd-b2d78dfb2cdd6391be62812513ed26d6f4f454c5.tar.gz
sssd-b2d78dfb2cdd6391be62812513ed26d6f4f454c5.tar.bz2
sssd-b2d78dfb2cdd6391be62812513ed26d6f4f454c5.zip
Adjust fill_pwent and fill_grent
fill_pwent should return the number of users actually processed. Otherwise in case of a recoverable error we may end up skipping a large chunk of users. fill_grent doesn't need to distinguish between number of entries and number of groups to process since we started adding memberuid. Remove remnants that are not useful anymore.
Diffstat (limited to 'src/responder/nss')
-rw-r--r--src/responder/nss/nsssrv_cmd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 4bd08e4b..2539c8b9 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -180,7 +180,7 @@ static int fill_pwent(struct sss_packet *packet,
struct nss_ctx *nctx,
bool filter_users,
struct ldb_message **msgs,
- int count)
+ int *count)
{
struct ldb_message *msg;
uint8_t *body;
@@ -206,7 +206,7 @@ static int fill_pwent(struct sss_packet *packet,
rp = 2*sizeof(uint32_t);
num = 0;
- for (i = 0; i < count; i++) {
+ for (i = 0; i < *count; i++) {
msg = msgs[i];
name = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
@@ -305,6 +305,8 @@ static int fill_pwent(struct sss_packet *packet,
}
done:
+ *count = i;
+
/* if there are no results just return ENOENT,
* let the caller decide if this is the last packet or not */
if (!packet_initialized) return ENOENT;
@@ -322,6 +324,7 @@ static int nss_cmd_getpw_send_reply(struct nss_dom_ctx *dctx, bool filter)
struct cli_ctx *cctx = cmdctx->cctx;
struct nss_ctx *nctx;
int ret;
+ int i;
nctx = talloc_get_type(cctx->rctx->pvt_ctx, struct nss_ctx);
@@ -331,10 +334,11 @@ static int nss_cmd_getpw_send_reply(struct nss_dom_ctx *dctx, bool filter)
if (ret != EOK) {
return EFAULT;
}
+ i = dctx->res->count;
ret = fill_pwent(cctx->creq->out,
dctx->domain,
nctx, filter,
- dctx->res->msgs, dctx->res->count);
+ dctx->res->msgs, &i);
if (ret) {
return ret;
}
@@ -1182,9 +1186,10 @@ static int nss_cmd_retpwent(struct cli_ctx *cctx, int num)
if (n > num) n = num;
msgs = &(pdom->res->msgs[pdom->cur]);
- pdom->cur += n;
- ret = fill_pwent(cctx->creq->out, pdom->domain, nctx, true, msgs, n);
+ ret = fill_pwent(cctx->creq->out, pdom->domain, nctx, true, msgs, &n);
+
+ pdom->cur += n;
}
none:
@@ -1286,7 +1291,7 @@ static int fill_grent(struct sss_packet *packet,
struct nss_ctx *nctx,
bool filter_groups,
struct ldb_message **msgs,
- int max, int *count)
+ int *count)
{
struct ldb_message *msg;
struct ldb_message_element *el;
@@ -1337,11 +1342,6 @@ static int fill_grent(struct sss_packet *packet,
continue;
}
- /* if we reached the max allowed entries, simply return */
- if (num >= max) {
- goto done;
- }
-
/* new result starts at end of previous result */
rzero += rsize;
rsize = 0;
@@ -1546,7 +1546,7 @@ static int nss_cmd_getgr_send_reply(struct nss_dom_ctx *dctx, bool filter)
ret = fill_grent(cctx->creq->out,
dctx->domain,
nctx, filter,
- dctx->res->msgs, 1, &i);
+ dctx->res->msgs, &i);
if (ret) {
return ret;
}
@@ -2253,7 +2253,7 @@ static int nss_cmd_retgrent(struct cli_ctx *cctx, int num)
ret = fill_grent(cctx->creq->out,
gdom->domain,
- nctx, true, msgs, n, &n);
+ nctx, true, msgs, &n);
gdom->cur += n;
}