From 54a2421d8bd3594d58401de90b6c61db0c8900c7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 26 Aug 2010 18:38:59 +1000 Subject: [PATCH] s4-privs Add a lookup by index of privilages Now that privileges are no longer given luid values sequentially, we need another way to look them up for enumeration. Andrew Bartlett Signed-off-by: Andrew Tridgell --- source4/libcli/security/privilege.c | 11 +++++++++++ source4/rpc_server/lsa/dcesrv_lsa.c | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source4/libcli/security/privilege.c b/source4/libcli/security/privilege.c index c21e1cbb6f9..9fd71928839 100644 --- a/source4/libcli/security/privilege.c +++ b/source4/libcli/security/privilege.c @@ -235,6 +235,17 @@ enum sec_privilege sec_privilege_from_mask(uint64_t mask) return -1; } +/* + map a privilege name to a privilege id. Return -1 if not found +*/ +enum sec_privilege sec_privilege_from_index(int idx) +{ + if (idx >= 0 && idxin.handle, LSA_HANDLE_POLICY); @@ -298,12 +299,11 @@ static NTSTATUS dcesrv_lsa_EnumPrivs(struct dcesrv_call_state *dce_call, TALLOC_ state = h->data; i = *r->in.resume_handle; - if (i == 0) i = 1; - while ((privname = sec_privilege_name(i)) && + while (((priv = sec_privilege_from_index(i)) != -1) && r->out.privs->count < r->in.max_count) { struct lsa_PrivEntry *e; - + privname = sec_privilege_name(priv); r->out.privs->privs = talloc_realloc(r->out.privs, r->out.privs->privs, struct lsa_PrivEntry, -- 2.34.1