diff options
author | Luke Leighton <lkcl@samba.org> | 1998-11-29 20:06:52 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1998-11-29 20:06:52 +0000 |
commit | b1d1c1337c69c6f6bf25ab932a1a6a757e3ea2ae (patch) | |
tree | be7baa9fd1609e55681b1c4c2e8f77a286ce54c4 /source/passdb/sampass.c | |
parent | 5d5d7e4de7d1514ab87b07ede629de8aa00519a1 (diff) | |
download | samba-b1d1c1337c69c6f6bf25ab932a1a6a757e3ea2ae.tar.gz samba-b1d1c1337c69c6f6bf25ab932a1a6a757e3ea2ae.tar.xz samba-b1d1c1337c69c6f6bf25ab932a1a6a757e3ea2ae.zip |
"retired" two modules to preserve their cvs history.
added their replacements, added sam password database API modules
Diffstat (limited to 'source/passdb/sampass.c')
-rw-r--r-- | source/passdb/sampass.c | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/source/passdb/sampass.c b/source/passdb/sampass.c new file mode 100644 index 00000000000..967e0502e38 --- /dev/null +++ b/source/passdb/sampass.c @@ -0,0 +1,198 @@ +/* + * Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup + * Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 675 + * Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#ifdef USE_SMBPASS_DB + +extern int DEBUGLEVEL; +extern pstring samlogon_user; +extern BOOL sam_logon_in_ssb; + +extern DOM_SID global_sam_sid; + +/*************************************************************** + Start to enumerate the smbpasswd list. Returns a void pointer + to ensure no modification outside this module. +****************************************************************/ + +void *startsamfilepwent(BOOL update) +{ + return startsmbpwent(update); +} + +/*************************************************************** + End enumeration of the smbpasswd list. +****************************************************************/ + +void endsamfilepwent(void *vp) +{ + endsmbpwent(vp); +} + +/************************************************************************* + Return the current position in the smbpasswd list as an SMB_BIG_UINT. + This must be treated as an opaque token. +*************************************************************************/ + +SMB_BIG_UINT getsamfilepwpos(void *vp) +{ + return getsmbpwpos(vp); +} + +/************************************************************************* + Set the current position in the smbpasswd list from an SMB_BIG_UINT. + This must be treated as an opaque token. +*************************************************************************/ + +BOOL setsamfilepwpos(void *vp, SMB_BIG_UINT tok) +{ + return setsmbpwpos(vp, tok); +} + +/************************************************************************* + Routine to return the next entry in the smbpasswd list. + this function is a nice, messy combination of reading: + - the smbpasswd file + - the unix password database + - smb.conf options (not done at present). + *************************************************************************/ + +static struct sam_passwd *getsamfile21pwent(void *vp) +{ + struct sam_passwd *user; + + static pstring full_name; + static pstring home_dir; + static pstring home_drive; + static pstring logon_script; + static pstring profile_path; + static pstring acct_desc; + static pstring workstations; + + DEBUG(5,("getsamfile21pwent\n")); + + user = pwdb_smb_to_sam(getsmbpwent(vp)); + if (user == NULL) + { + return NULL; + } + + /* + * get all the other gubbins we need + */ + + pstrcpy(samlogon_user, user->nt_name); + + if (samlogon_user[strlen(samlogon_user)-1] == '$' && + user->group_rid != DOMAIN_GROUP_RID_USERS) + { + DEBUG(0,("trust account %s should be in DOMAIN_GROUP_RID_USERS\n", + samlogon_user)); + } + + /* XXXX hack to get standard_sub_basic() to use sam logon username */ + /* possibly a better way would be to do a become_user() call */ + sam_logon_in_ssb = True; + + pstrcpy(full_name , ""); + pstrcpy(logon_script , lp_logon_script ()); + pstrcpy(profile_path , lp_logon_path ()); + pstrcpy(home_drive , lp_logon_drive ()); + pstrcpy(home_dir , lp_logon_home ()); + pstrcpy(acct_desc , ""); + pstrcpy(workstations , ""); + + sam_logon_in_ssb = False; + + user->full_name = full_name; + user->home_dir = home_dir; + user->dir_drive = home_drive; + user->logon_script = logon_script; + user->profile_path = profile_path; + user->acct_desc = acct_desc; + user->workstations = workstations; + + user->unknown_str = NULL; /* don't know, yet! */ + user->munged_dial = NULL; /* "munged" dial-back telephone number */ + + user->unknown_3 = 0xffffff; /* don't know */ + user->logon_divs = 168; /* hours per week */ + user->hours_len = 21; /* 21 times 8 bits = 168 */ + memset(user->hours, 0xff, user->hours_len); /* available at all hours */ + user->unknown_5 = 0x00020000; /* don't know */ + user->unknown_6 = 0x000004ec; /* don't know */ + + return user; +} + +/* + * Stub functions - implemented in terms of others. + */ + +static BOOL mod_samfile21pwd_entry(struct sam_passwd* pwd, BOOL override) +{ + return mod_smbpwd_entry(pwdb_sam_to_smb(pwd), override); +} + +static BOOL add_samfile21pwd_entry(struct sam_passwd *newpwd) +{ + return add_smbpwd_entry(pwdb_sam_to_smb(newpwd)); +} + +static struct sam_disp_info *getsamfiledispntnam(const char *name) +{ + return pwdb_sam_to_dispinfo(getsam21pwntnam(name)); +} + +static struct sam_disp_info *getsamfiledisprid(uint32 rid) +{ + return pwdb_sam_to_dispinfo(getsam21pwrid(rid)); +} + +static struct sam_disp_info *getsamfiledispent(void *vp) +{ + return pwdb_sam_to_dispinfo(getsam21pwent(vp)); +} + +static struct sam_passdb_ops file_ops = { + startsamfilepwent, + endsamfilepwent, + getsamfilepwpos, + setsamfilepwpos, + iterate_getsam21pwntnam, + iterate_getsam21pwuid, + iterate_getsam21pwrid, + getsamfile21pwent, + add_samfile21pwd_entry, + mod_samfile21pwd_entry, + getsamfiledispntnam, + getsamfiledisprid, + getsamfiledispent +}; + +struct sam_passdb_ops *file_initialise_sam_password_db(void) +{ + return &file_ops; +} + +#else + /* Do *NOT* make this function static. It breaks the compile on gcc. JRA */ + void sampass_dummy_function(void) { } /* stop some compilers complaining */ +#endif /* USE_SMBPASS_DB */ |