diff -uNr samba-3.0.10.orig/source/lib/substitute.c samba-3.0.10/source/lib/substitute.c --- samba-3.0.10.orig/source/lib/substitute.c 2004-12-15 23:33:12.000000000 +0900 +++ samba-3.0.10/source/lib/substitute.c 2004-12-27 11:56:54.000000000 +0900 @@ -607,7 +607,8 @@ gid_t gid) { char *a, *t; - a = alloc_sub_specified(input_string, username, domain, uid, gid); + char *grpname = NULL; + a = alloc_sub_specified(input_string, username, domain, uid, gid, grpname); if (!a) return NULL; t = talloc_strdup(mem_ctx, a); SAFE_FREE(a); @@ -618,7 +619,8 @@ const char *username, const char *domain, uid_t uid, - gid_t gid) + gid_t gid, + const char *grpname) { char *a_string, *ret_string; char *b, *p, *s, *t; @@ -642,14 +644,20 @@ break; case 'G' : if (gid != -1) { - t = realloc_string_sub(t, "%G", gidtoname(gid)); + if (grpname == NULL) + t = realloc_string_sub(t, "%G", gidtoname(gid)); + else + t = realloc_string_sub(t, "%G", grpname); } else { t = realloc_string_sub(t, "%G", "NO_GROUP"); } break; case 'g' : if (gid != -1) { - t = realloc_string_sub(t, "%g", gidtoname(gid)); + if (grpname == NULL) + t = realloc_string_sub(t, "%g", gidtoname(gid)); + else + t = realloc_string_sub(t, "%g", grpname); } else { t = realloc_string_sub(t, "%g", "NO_GROUP"); } diff -uNr samba-3.0.10.orig/source/nsswitch/winbindd_user.c samba-3.0.10/source/nsswitch/winbindd_user.c --- samba-3.0.10.orig/source/nsswitch/winbindd_user.c 2004-12-15 23:33:14.000000000 +0900 +++ samba-3.0.10/source/nsswitch/winbindd_user.c 2004-12-24 17:47:01.000000000 +0900 @@ -40,6 +40,10 @@ char *homedir; char *shell; fstring sid_string; + fstring domainame; + fstring grpname; + fstring output_grpname; + enum SID_NAME_USE type; if (!pw || !dom_name || !user_name) return False; @@ -79,7 +83,13 @@ fstrcpy(current_user_info.domain, dom_name); - homedir = alloc_sub_specified(lp_template_homedir(), user_name, dom_name, pw->pw_uid, pw->pw_gid); + /* Groupname */ + if (!winbindd_lookup_name_by_sid(group_sid, domainame, grpname, &type)) + DEBUG(1, ("could not lookup sid\n")); + + fill_domain_username(output_grpname, dom_name, grpname); + + homedir = alloc_sub_specified(lp_template_homedir(), user_name, dom_name, pw->pw_uid, pw->pw_gid, output_grpname); if (!homedir) return False; @@ -88,7 +98,7 @@ SAFE_FREE(homedir); - shell = alloc_sub_specified(lp_template_shell(), user_name, dom_name, pw->pw_uid, pw->pw_gid); + shell = alloc_sub_specified(lp_template_shell(), user_name, dom_name, pw->pw_uid, pw->pw_gid, output_grpname); if (!shell) return False;