summaryrefslogtreecommitdiff
path: root/source3/winbindd/wb_queryuser.c
diff options
context:
space:
mode:
authorUri Simchoni <uri@samba.org>2017-06-07 20:33:57 +0300
committerJeremy Allison <jra@samba.org>2017-07-21 19:11:13 +0200
commitc819c7d58f05692628eb9673dfdca5dc1d212d43 (patch)
tree2e22957bd9417a54c161074fc23ae99368acb50d /source3/winbindd/wb_queryuser.c
parente3a151e2472d97891c97cc898f27f3ccf712bf35 (diff)
downloadsamba-c819c7d58f05692628eb9673dfdca5dc1d212d43.tar.gz
winbindd: queryuser - only get group name if needed
When calculating the user entry for a user, the primary group id *name* might be needed if it is part of a home dir / shell template (%g or %G). Only resolve primary group SID to primary group name if it is needed, thereby saving a round-trip to the DC (and better handling situations where it is disconnected). Signed-off-by: Uri Simchoni <uri@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/winbindd/wb_queryuser.c')
-rw-r--r--source3/winbindd/wb_queryuser.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/source3/winbindd/wb_queryuser.c b/source3/winbindd/wb_queryuser.c
index 69b4c8dad5a..1c91949c255 100644
--- a/source3/winbindd/wb_queryuser.c
+++ b/source3/winbindd/wb_queryuser.c
@@ -202,6 +202,8 @@ static void wb_queryuser_done(struct tevent_req *subreq)
req, struct wb_queryuser_state);
struct wbint_userinfo *info = state->info;
NTSTATUS status, result;
+ bool need_group_name = false;
+ const char *tmpl = NULL;
status = dcerpc_wbint_GetNssInfo_recv(subreq, info, &result);
TALLOC_FREE(subreq);
@@ -236,7 +238,16 @@ static void wb_queryuser_done(struct tevent_req *subreq)
return;
}
- if (state->info->primary_group_name == NULL) {
+ tmpl = lp_template_homedir();
+ if(strstr_m(tmpl, "%g") || strstr_m(tmpl, "%G")) {
+ need_group_name = true;
+ }
+ tmpl = lp_template_shell();
+ if(strstr_m(tmpl, "%g") || strstr_m(tmpl, "%G")) {
+ need_group_name = true;
+ }
+
+ if (need_group_name && state->info->primary_group_name == NULL) {
subreq = wb_lookupsid_send(state, state->ev, &info->group_sid);
if (tevent_req_nomem(subreq, req)) {
return;
@@ -291,6 +302,8 @@ static void wb_queryuser_got_gid(struct tevent_req *subreq)
req, struct wb_queryuser_state);
struct unixid xid;
NTSTATUS status;
+ bool need_group_name = false;
+ const char *tmpl = NULL;
status = wb_sids2xids_recv(subreq, &xid, 1);
TALLOC_FREE(subreq);
@@ -305,7 +318,16 @@ static void wb_queryuser_got_gid(struct tevent_req *subreq)
state->info->primary_gid = xid.id;
- if (state->info->primary_group_name == NULL) {
+ tmpl = lp_template_homedir();
+ if(strstr_m(tmpl, "%g") || strstr_m(tmpl, "%G")) {
+ need_group_name = true;
+ }
+ tmpl = lp_template_shell();
+ if(strstr_m(tmpl, "%g") || strstr_m(tmpl, "%G")) {
+ need_group_name = true;
+ }
+
+ if (need_group_name && state->info->primary_group_name == NULL) {
subreq = wb_lookupsid_send(state, state->ev,
&state->info->group_sid);
if (tevent_req_nomem(subreq, req)) {