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;
25 extern DOM_SID global_sam_sid;
27 /***************************************************************
28 Start to enumerate the smbpasswd list. Returns a void pointer
29 to ensure no modification outside this module.
30 ****************************************************************/
32 static void *startsmbunixgrpent(BOOL update)
34 return startsmbpwent(False);
37 /***************************************************************
38 End enumeration of the smbpasswd list.
39 ****************************************************************/
41 static void endsmbunixgrpent(void *vp)
46 /*************************************************************************
47 Return the current position in the smbpasswd list as an SMB_BIG_UINT.
48 This must be treated as an opaque token.
49 *************************************************************************/
51 static SMB_BIG_UINT getsmbunixgrppos(void *vp)
53 return getsmbpwpos(vp);
56 /*************************************************************************
57 Set the current position in the smbpasswd list from an SMB_BIG_UINT.
58 This must be treated as an opaque token.
59 *************************************************************************/
61 static BOOL setsmbunixgrppos(void *vp, SMB_BIG_UINT tok)
63 return setsmbpwpos(vp, tok);
66 /*************************************************************************
67 Routine to return the next smbpassgroup entry
68 *************************************************************************/
69 static struct smb_passwd *getsmbunixgrpent(void *vp,
70 uint32 **grp_rids, int *num_grps,
71 uint32 **als_rids, int *num_alss)
73 /* Static buffers we will return. */
74 struct sam_passwd *pw_buf;
83 DEBUG(0,("getsmbunixgrpent: Bad password file pointer.\n"));
87 pw_buf = getsam21pwent(vp);
94 fstrcpy(unix_name, pw_buf->unix_name);
102 if (als_rids != NULL)
108 if (als_rids == NULL && grp_rids == NULL)
110 /* they didn't want to know the members. */
111 return pwdb_sam_to_smb(pw_buf);
115 * find all unix groups
118 if (get_unixgroups(unix_name, pw_buf->unix_uid, pw_buf->unix_gid, &unixgrps, &grps))
124 * check each unix group for a mapping as an nt alias or an nt group
127 for (i = 0; i < unixgrps && !failed; i++)
132 * find the unix name for each user's group.
133 * assume the unix group is an nt name (alias? group? user?)
134 * (user or not our own domain will be an error).
136 * oh, oh, can anyone spot what's missing heeere?
137 * you guessed it: built-in aliases. those are in
138 * Domain S-1-5-20, and NT Domain Users can only
139 * have lists of RIDs as groups.
141 * doesn't stop you making NT Domain Users a member
142 * of a BUILTIN Alias (e.g "Administrators" or "Power Users")
143 * it's just that there's no way to tell that from this
144 * API call: wrong domain, sorry.
150 if (!lookupsmbgrpgid(grps[i], &gmep))
155 sid_split_rid(&gmep.sid, &rid);
156 if (!sid_equal(&global_sam_sid, &gmep.sid))
165 if (als_rids != NULL && add_num_to_list(als_rids, num_alss, rid) == NULL)
171 case SID_NAME_DOM_GRP:
172 case SID_NAME_WKN_GRP:
174 if (grp_rids != NULL && add_num_to_list(grp_rids, num_grps, rid) == NULL)
189 if (grp_rids != NULL && (*grp_rids) != NULL)
195 if (als_rids != NULL && (*als_rids) != NULL)
204 return pwdb_sam_to_smb(pw_buf);
207 static struct passgrp_ops smbunixgrp_ops =
213 iterate_getsmbgrpntnam, /* In passgrp.c */
214 iterate_getsmbgrpuid, /* In passgrp.c */
215 iterate_getsmbgrprid, /* In passgrp.c */
219 struct passgrp_ops *unix_initialise_password_grp(void)
221 return &smbunixgrp_ops;
225 /* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
226 void smbpassgroupunix_dummy_function(void) { } /* stop some compilers complaining */
227 #endif /* USE_SMBPASS_DB */