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 pstring samlogon_user;
26 extern BOOL sam_logon_in_ssb;
28 extern DOM_SID global_sam_sid;
30 /***************************************************************
31 Start to enumerate the smbpasswd list. Returns a void pointer
32 to ensure no modification outside this module.
33 ****************************************************************/
35 void *startsamfilepwent(BOOL update)
37 return startsmbpwent(update);
40 /***************************************************************
41 End enumeration of the smbpasswd list.
42 ****************************************************************/
44 void endsamfilepwent(void *vp)
49 /*************************************************************************
50 Return the current position in the smbpasswd list as an SMB_BIG_UINT.
51 This must be treated as an opaque token.
52 *************************************************************************/
54 SMB_BIG_UINT getsamfilepwpos(void *vp)
56 return getsmbpwpos(vp);
59 /*************************************************************************
60 Set the current position in the smbpasswd list from an SMB_BIG_UINT.
61 This must be treated as an opaque token.
62 *************************************************************************/
64 BOOL setsamfilepwpos(void *vp, SMB_BIG_UINT tok)
66 return setsmbpwpos(vp, tok);
69 /*************************************************************************
70 Routine to return the next entry in the smbpasswd list.
71 this function is a nice, messy combination of reading:
73 - the unix password database
74 - smb.conf options (not done at present).
75 *************************************************************************/
77 static struct sam_passwd *getsamfile21pwent(void *vp)
79 struct sam_passwd *user;
81 static pstring full_name;
82 static pstring home_dir;
83 static pstring home_drive;
84 static pstring logon_script;
85 static pstring profile_path;
86 static pstring acct_desc;
87 static pstring workstations;
89 DEBUG(5,("getsamfile21pwent\n"));
91 user = pwdb_smb_to_sam(getsmbpwent(vp));
98 * get all the other gubbins we need
101 pstrcpy(samlogon_user, user->nt_name);
103 if (samlogon_user[strlen(samlogon_user)-1] == '$' &&
104 user->group_rid != DOMAIN_GROUP_RID_USERS)
106 DEBUG(0,("trust account %s should be in DOMAIN_GROUP_RID_USERS\n",
110 /* XXXX hack to get standard_sub_basic() to use sam logon username */
111 /* possibly a better way would be to do a become_user() call */
112 sam_logon_in_ssb = True;
114 pstrcpy(full_name , "");
115 pstrcpy(logon_script , lp_logon_script ());
116 pstrcpy(profile_path , lp_logon_path ());
117 pstrcpy(home_drive , lp_logon_drive ());
118 pstrcpy(home_dir , lp_logon_home ());
119 pstrcpy(acct_desc , "");
120 pstrcpy(workstations , "");
122 sam_logon_in_ssb = False;
124 user->full_name = full_name;
125 user->home_dir = home_dir;
126 user->dir_drive = home_drive;
127 user->logon_script = logon_script;
128 user->profile_path = profile_path;
129 user->acct_desc = acct_desc;
130 user->workstations = workstations;
132 user->unknown_str = NULL; /* don't know, yet! */
133 user->munged_dial = NULL; /* "munged" dial-back telephone number */
135 user->unknown_3 = 0xffffff; /* don't know */
136 user->logon_divs = 168; /* hours per week */
137 user->hours_len = 21; /* 21 times 8 bits = 168 */
138 memset(user->hours, 0xff, user->hours_len); /* available at all hours */
139 user->unknown_5 = 0x00020000; /* don't know */
140 user->unknown_6 = 0x000004ec; /* don't know */
146 * Stub functions - implemented in terms of others.
149 static BOOL mod_samfile21pwd_entry(struct sam_passwd* pwd, BOOL override)
151 return mod_smbpwd_entry(pwdb_sam_to_smb(pwd), override);
154 static BOOL add_samfile21pwd_entry(struct sam_passwd *newpwd)
156 return add_smbpwd_entry(pwdb_sam_to_smb(newpwd));
159 static struct sam_disp_info *getsamfiledispntnam(const char *name)
161 return pwdb_sam_to_dispinfo(getsam21pwntnam(name));
164 static struct sam_disp_info *getsamfiledisprid(uint32 rid)
166 return pwdb_sam_to_dispinfo(getsam21pwrid(rid));
169 static struct sam_disp_info *getsamfiledispent(void *vp)
171 return pwdb_sam_to_dispinfo(getsam21pwent(vp));
174 static struct sam_passdb_ops file_ops = {
179 iterate_getsam21pwntnam,
180 iterate_getsam21pwuid,
181 iterate_getsam21pwrid,
183 add_samfile21pwd_entry,
184 mod_samfile21pwd_entry,
190 struct sam_passdb_ops *file_initialise_sam_password_db(void)
196 /* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
197 void sampass_dummy_function(void) { } /* stop some compilers complaining */
198 #endif /* USE_SMBPASS_DB */