[PATCH] consistently add the workgroup prefix to names in s4 winbindd nsswitch code

Michael Adam obnox at samba.org
Tue Feb 26 17:33:12 MST 2013


Hi,

the attached patchset for master implements $subject.
I'd appreciate if someone could review and possibly push it.

Cheers - Michael

-------------- next part --------------
From 072ccabc8e9e69a59bab1a03eac43787644326fa Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 27 Feb 2013 00:45:55 +0100
Subject: [PATCH 1/2] s4:winbindd: do not drop the workgroup name in the
 getgrnam and getgrent calls.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/winbind/wb_cmd_getgrnam.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/source4/winbind/wb_cmd_getgrnam.c b/source4/winbind/wb_cmd_getgrnam.c
index 7073209..d75a460 100644
--- a/source4/winbind/wb_cmd_getgrnam.c
+++ b/source4/winbind/wb_cmd_getgrnam.c
@@ -24,6 +24,7 @@
 #include "winbind/wb_server.h"
 #include "winbind/wb_helper.h"
 #include "smbd/service_task.h"
+#include "param/param.h"
 
 struct cmd_getgrnam_state {
 	struct composite_context *ctx;
@@ -105,6 +106,7 @@ static void cmd_getgrnam_recv_group_info(struct composite_context *ctx)
 			ctx->async.private_data, struct cmd_getgrnam_state);
 	struct libnet_GroupInfo *group_info;
 	struct winbindd_gr *gr;
+	char *group_name_with_domain;
 
 	DEBUG(5, ("cmd_getgrnam_recv_group_info called\n"));
 
@@ -117,7 +119,15 @@ static void cmd_getgrnam_recv_group_info(struct composite_context *ctx)
 	state->ctx->status = libnet_GroupInfo_recv(ctx, state, group_info);
 	if(!composite_is_ok(state->ctx)) return;
 
-	WBSRV_SAMBA3_SET_STRING(gr->gr_name, group_info->out.group_name);
+	group_name_with_domain = talloc_asprintf(gr, "%s%s%s",
+		state->workgroup_name,
+		lpcfg_winbind_separator(state->service->task->lp_ctx),
+		group_info->out.group_name);
+	if (composite_nomem(group_name_with_domain, state->ctx)) {
+		return;
+	}
+
+	WBSRV_SAMBA3_SET_STRING(gr->gr_name, group_name_with_domain);
 	WBSRV_SAMBA3_SET_STRING(gr->gr_passwd, "*");
 	gr->num_gr_mem = group_info->out.num_members;
 	gr->gr_mem_ofs = 0;
-- 
1.7.9.5


From 8fee1e72b888a9ec17a85eccc7879bd4f9f00c95 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 27 Feb 2013 01:04:46 +0100
Subject: [PATCH 2/2] s4:winbindd: do not drop the workgroup name in the
 getgrgid call

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/winbind/wb_cmd_getgrgid.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/source4/winbind/wb_cmd_getgrgid.c b/source4/winbind/wb_cmd_getgrgid.c
index fe946ed..8ca93db 100644
--- a/source4/winbind/wb_cmd_getgrgid.c
+++ b/source4/winbind/wb_cmd_getgrgid.c
@@ -23,6 +23,7 @@
 #include "libcli/composite/composite.h"
 #include "winbind/wb_server.h"
 #include "smbd/service_task.h"
+#include "param/param.h"
 
 struct cmd_getgrgid_state {
 	struct composite_context *ctx;
@@ -127,6 +128,7 @@ static void cmd_getgrgid_recv_group_info(struct composite_context *ctx)
 				struct cmd_getgrgid_state);
 	struct libnet_GroupInfo *group_info;
 	struct winbindd_gr *gr;
+	char *group_name_with_domain;
 
 	DEBUG(5, ("cmd_getgrgid_recv_group_info called\n"));
 
@@ -139,7 +141,15 @@ static void cmd_getgrgid_recv_group_info(struct composite_context *ctx)
 	state->ctx->status = libnet_GroupInfo_recv(ctx, state, group_info);
 	if (!composite_is_ok(state->ctx)) return;
 
-	WBSRV_SAMBA3_SET_STRING(gr->gr_name, group_info->out.group_name);
+	group_name_with_domain = talloc_asprintf(gr, "%s%s%s",
+		state->workgroup,
+		lpcfg_winbind_separator(state->service->task->lp_ctx),
+		group_info->out.group_name);
+	if (composite_nomem(group_name_with_domain, state->ctx)) {
+		return;
+	}
+
+	WBSRV_SAMBA3_SET_STRING(gr->gr_name, group_name_with_domain);
 	WBSRV_SAMBA3_SET_STRING(gr->gr_passwd, "*");
 
 	gr->gr_gid = state->gid;
-- 
1.7.9.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 206 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20130227/ee4bb102/attachment.pgp>


More information about the samba-technical mailing list