2 * Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
3 * Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 675
17 * Mass Ave, Cambridge, MA 02139, USA.
24 extern int DEBUGLEVEL;
27 extern DOM_SID global_sam_sid;
29 /***************************************************************
30 Start to enumerate the grppasswd list. Returns a void pointer
31 to ensure no modification outside this module.
32 ****************************************************************/
34 static void *startgrpunixpwent(BOOL update)
40 /***************************************************************
41 End enumeration of the grppasswd list.
42 ****************************************************************/
44 static void endgrpunixpwent(void *vp)
49 /*************************************************************************
50 Return the current position in the grppasswd list as an SMB_BIG_UINT.
51 This must be treated as an opaque token.
52 *************************************************************************/
53 static SMB_BIG_UINT getgrpunixpwpos(void *vp)
55 return (SMB_BIG_UINT)0;
58 /*************************************************************************
59 Set the current position in the grppasswd list from an SMB_BIG_UINT.
60 This must be treated as an opaque token.
61 *************************************************************************/
62 static BOOL setgrpunixpwpos(void *vp, SMB_BIG_UINT tok)
67 /*************************************************************************
68 Routine to return the next entry in the smbdomaingroup list.
69 *************************************************************************/
70 BOOL get_unixgroup_members(struct group *grp,
71 int *num_mem, DOMAIN_GRP_MEMBER **members)
76 if (num_mem == NULL || members == NULL)
84 for (i = 0; (unix_name = grp->gr_mem[i]) != NULL; i++)
88 if (!lookupsmbgrpnam(unix_name, &gmep) &&
89 !lookupsmbpwnam (unix_name, &gmep))
94 if (gmep.type != SID_NAME_DOM_GRP &&
95 gmep.type != SID_NAME_USER &&
96 gmep.type != SID_NAME_WKN_GRP)
98 DEBUG(0,("group database: name %s is not in a Domain Group\n",
103 if (!sid_front_equal(&global_sam_sid, &gmep.sid))
105 DEBUG(0,("group database: could not resolve name %s (wrong Domain SID)\n",
110 (*members) = Realloc((*members), ((*num_mem)+1) * sizeof(DOMAIN_GRP_MEMBER));
111 if ((*members) == NULL)
116 fstrcpy((*members)[(*num_mem)].name, gmep.nt_name);
117 (*members)[(*num_mem)].attr = 0x07;
123 /*************************************************************************
124 Routine to return the next entry in the domain group list.
126 if we are not a PDC or BDC, then we do NOT support Domain groups, only
127 aliases. try running MUSRMGR.EXE or running USRMGR.EXE selected on a
128 workstation, you will find that no Domain groups are listed: only aliases.
130 so, as a PDC or BDC, all unix groups not explicitly mapped using
131 map_group_gid() are treated as Domain groups.
133 *************************************************************************/
134 static DOMAIN_GRP *getgrpunixpwent(void *vp, DOMAIN_GRP_MEMBER **mem, int *num_mem)
136 /* Static buffers we will return. */
137 static DOMAIN_GRP gp_buf;
138 struct group *unix_grp;
140 if (lp_server_role() == ROLE_DOMAIN_NONE ||
141 lp_server_role() == ROLE_DOMAIN_MEMBER)
144 * only PDC and BDC have domain groups in the SAM.
145 * (however as member of domain you can have LOCAL groups,
146 * but that's dealt with in the aliasdb...)
152 gpdb_init_grp(&gp_buf);
154 fstrcpy(gp_buf.comment, "");
157 /* cycle through unix groups */
158 while ((unix_grp = getgrent()) != NULL)
161 DEBUG(10,("getgrpunixpwent: enum unix group entry %s\n",
164 if (!lookupsmbgrpgid(unix_grp->gr_gid, &gmep))
169 if (gmep.type != SID_NAME_DOM_GRP &&
170 gmep.type != SID_NAME_WKN_GRP)
175 sid_split_rid(&gmep.sid, &gp_buf.rid);
176 if (!sid_equal(&gmep.sid, &global_sam_sid))
181 fstrcpy(gp_buf.name, gmep.nt_name);
185 if (unix_grp == NULL)
190 /* get the user's domain groups. there are a maximum of 32 */
192 if (mem != NULL && num_mem != NULL)
197 get_unixgroup_members(unix_grp, num_mem, mem);
202 make_group_line(linebuf, sizeof(linebuf), &gp_buf, mem, num_mem);
203 DEBUG(10,("line: '%s'\n", linebuf));
209 /************************************************************************
210 Routine to add an entry to the grppasswd file.
211 *************************************************************************/
213 static BOOL add_grpunixgrp_entry(DOMAIN_GRP *newgrp)
215 DEBUG(0, ("add_grpunixgrp_entry: NOT IMPLEMENTED\n"));
219 /************************************************************************
220 Routine to search the grppasswd file for an entry matching the groupname.
221 and then modify its group entry. We can't use the startgrppwent()/
222 getgrppwent()/endgrppwent() interfaces here as we depend on looking
223 in the actual file to decide how much room we have to write data.
224 override = False, normal
225 override = True, override XXXXXXXX'd out group or NO PASS
226 ************************************************************************/
228 static BOOL mod_grpunixgrp_entry(DOMAIN_GRP* grp)
230 DEBUG(0, ("mod_grpunixgrp_entry: NOT IMPLEMENTED\n"));
235 static struct groupdb_ops unix_ops =
242 iterate_getgroupntnam, /* In groupdb.c */
243 iterate_getgroupgid, /* In groupdb.c */
244 iterate_getgrouprid, /* In groupdb.c */
247 add_grpunixgrp_entry,
248 mod_grpunixgrp_entry,
250 iterate_getusergroupsnam /* in groupdb.c */
253 struct groupdb_ops *unix_initialise_group_db(void)
259 /* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
260 void unix_grppass_dummy_function(void) { } /* stop some compilers complaining */
261 #endif /* USE_SMBPASS_DB */