diff options
author | Luke Leighton <lkcl@samba.org> | 1998-05-07 18:19:05 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1998-05-07 18:19:05 +0000 |
commit | d8d9f7723337c267a8740750fe19a6387cfbb1f6 (patch) | |
tree | 224590bcd9c5d6d60c5a519741c0662834ba4a1d /source3/passdb | |
parent | 51f88b4f7c0b87dd4a8932168c512b29a4915045 (diff) | |
download | samba-d8d9f7723337c267a8740750fe19a6387cfbb1f6.tar.gz samba-d8d9f7723337c267a8740750fe19a6387cfbb1f6.tar.bz2 samba-d8d9f7723337c267a8740750fe19a6387cfbb1f6.zip |
created "passdb.c" which is an interface point to (at present) either
smbpasswd or ldap passwd, at compile-time (-DUSE_LDAP).
_none_ of the functions in ldap.c or smbpass.c should be called directly:
only those in passdb.c should be used.
-DUSE_LDAP is unlikely to compile at the moment.
(This used to be commit 57b01ad4ffb14ebd600d4e66602b54ed987f6106)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/ldap.c | 22 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 149 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 75 |
3 files changed, 213 insertions, 33 deletions
diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c index fedc31cbfc..d9387dfcc4 100644 --- a/source3/passdb/ldap.c +++ b/source3/passdb/ldap.c @@ -475,7 +475,7 @@ static void ldap_get_machine(LDAP *ldap_struct,LDAPMessage *entry, /******************************************************************* find a user or a machine return a smbpass struct. ******************************************************************/ -struct smb_passwd *ldap_get_smbpwd_entry(char *name, int smb_userid) +static struct smb_passwd *ldap_get_smbpwd_entry(char *name, int smb_userid) { LDAP *ldap_struct; LDAPMessage *result; @@ -560,4 +560,24 @@ struct smb_passwd *ldap_get_smbpwd_entry(char *name, int smb_userid) return(&ldap_passwd); } + +/************************************************************************ + Routine to search ldap passwd by name. +*************************************************************************/ + +struct smb_passwd *getldappwnam(char *name) +{ + return ldap_get_smbpwd_entry(name, 0); +} + +/************************************************************************ + Routine to search ldap passwd by uid. +*************************************************************************/ + +struct smb_passwd *getldappwuid(unsigned int uid) +{ + return ldap_get_smbpwd_entry(NULL, uid); +} + + #endif diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c new file mode 100644 index 0000000000..9e5b3ef145 --- /dev/null +++ b/source3/passdb/passdb.c @@ -0,0 +1,149 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + Password and authentication handling + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 + + 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" + +extern int DEBUGLEVEL; + +/************************************************************************ + Routine to search sam passwd by name. +*************************************************************************/ + +struct smb_passwd *getsampwnam(char *name) +{ +#ifdef USE_LDAP + return getldappwnam(name); +#else + return getsmbpwnam(name); +#endif /* USE_LDAP */ +} + +/************************************************************************ + Routine to search sam passwd by uid. +*************************************************************************/ + +struct smb_passwd *getsampwuid(unsigned int uid) +{ +#ifdef USE_LDAP + return getldappwuid(uid); +#else + return getsmbpwuid(uid); +#endif /* USE_LDAP */ +} + +/*************************************************************** + Start to enumerate the sam passwd list. Returns a void pointer + to ensure no modification outside this module. +****************************************************************/ + +void *startsampwent(BOOL update) +{ +#ifdef USE_LDAP + return startldappwent(update); +#else + return startsmbpwent(update); +#endif /* USE_LDAP */ +} + +/*************************************************************** + End enumeration of the sam passwd list. +****************************************************************/ + +void endsampwent(void *vp) +{ +#ifdef USE_LDAP + endldappwent(vp); +#else + endsmbpwent(vp); +#endif /* USE_LDAP */ +} + +/************************************************************************* + Routine to return the next entry in the sam passwd list. + *************************************************************************/ + +struct smb_passwd *getsampwent(void *vp) +{ +#ifdef USE_LDAP + return getldappwent(vp); +#else + return getsmbpwent(vp); +#endif /* USE_LDAP */ +} + +/************************************************************************* + Return the current position in the sam passwd list as an unsigned long. + This must be treated as an opaque token. + *************************************************************************/ +unsigned long getsampwpos(void *vp) +{ +#ifdef USE_LDAP + return getldappwpos(vp); +#else + return getsmbpwpos(vp); +#endif /* USE_LDAP */ +} + +/************************************************************************* + Set the current position in the sam passwd list from unsigned long. + This must be treated as an opaque token. + *************************************************************************/ +BOOL setsampwpos(void *vp, unsigned long tok) +{ +#ifdef USE_LDAP + return setldappwpos(vp, tok); +#else + return setsmbpwpos(vp, tok); +#endif /* USE_LDAP */ +} + +/************************************************************************ + Routine to add an entry to the sam passwd file. +*************************************************************************/ + +BOOL add_sampwd_entry(struct smb_passwd *newpwd) +{ +#ifdef USE_LDAP + return add_ldappwd_entry(newpwd); +#else + return add_smbpwd_entry(newpwd); +#endif /* USE_LDAP */ +} + +/************************************************************************ + Routine to search the sam passwd file for an entry matching the username. + and then modify its password entry. We can't use the startsampwent()/ + getsampwent()/endsampwent() interfaces here as we depend on looking + in the actual file to decide how much room we have to write data. + override = False, normal + override = True, override XXXXXXXX'd out password or NO PASS +************************************************************************/ + +BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override) +{ +#ifdef USE_LDAP + return mod_ldappwd_entry(pwd, override); +#else + return mod_smbpwd_entry(pwd, override); +#endif /* USE_LDAP */ +} + diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index 56eade7cd3..defadadf69 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -17,6 +17,17 @@ * Mass Ave, Cambridge, MA 02139, USA. */ +/*X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X* + *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X* + *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X* + + DO NOT CALL ANY OF THE ROUTINES IN THIS MODULE DIRECTLY. + USE passdb.c INSTEAD. + + *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X* + *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X* + *X*X*X*X*X*X*X**X*X*X*X*X*X*X**X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*X*/ + #include "includes.h" extern int DEBUGLEVEL; @@ -112,7 +123,10 @@ static BOOL pw_file_unlock(int fd, int *plock_depth) /*************************************************************** Start to enumerate the smbpasswd list. Returns a void pointer to ensure no modification outside this module. -****************************************************************/ + + do not call this function directly. use passdb.c instead. + + ****************************************************************/ void *startsmbpwent(BOOL update) { @@ -192,6 +206,9 @@ static int gethexpwd(char *p, char *pwd) /************************************************************************* Routine to return the next entry in the smbpasswd list. + + do not call this function directly. use passdb.c instead. + *************************************************************************/ struct smb_passwd *getsmbpwent(void *vp) @@ -482,8 +499,10 @@ struct smb_passwd *getsmbpwent(void *vp) /************************************************************************* Return the current position in the smbpasswd list as an unsigned long. This must be treated as an opaque token. -*************************************************************************/ + do not call this function directly. use passdb.c instead. + +*************************************************************************/ unsigned long getsmbpwpos(void *vp) { return (unsigned long)ftell((FILE *)vp); @@ -492,8 +511,10 @@ unsigned long getsmbpwpos(void *vp) /************************************************************************* Set the current position in the smbpasswd list from unsigned long. This must be treated as an opaque token. -*************************************************************************/ + do not call this function directly. use passdb.c instead. + +*************************************************************************/ BOOL setsmbpwpos(void *vp, unsigned long tok) { return !fseek((FILE *)vp, tok, SEEK_SET); @@ -503,7 +524,6 @@ BOOL setsmbpwpos(void *vp, unsigned long tok) Routine to search the smbpasswd file for an entry matching the username or user id. if the name is NULL, then the smb_uid is used instead. *************************************************************************/ - static struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid) { struct smb_passwd *pwd = NULL; @@ -549,31 +569,25 @@ static struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid) } /************************************************************************ - Routine to search smbpasswd by name. + Routine to search smb passwd by name. *************************************************************************/ struct smb_passwd *getsmbpwnam(char *name) { -#ifdef USE_LDAP - return ldap_get_smbpwd_entry(name, 0); -#else /* USE_LDAP */ return get_smbpwd_entry(name, 0); -#endif /* USE_LDAP */ } + /************************************************************************ - Routine to search smbpasswd by uid. + Routine to search smb passwd by uid. *************************************************************************/ struct smb_passwd *getsmbpwuid(unsigned int uid) { -#ifdef USE_LDAP - return ldap_get_smbpwd_entry(NULL, uid); -#else /* USE_DLAP */ return get_smbpwd_entry(NULL, uid); -#endif /* USE_LDAP */ } + /********************************************************** Encode the account control bits into a string. **********************************************************/ @@ -585,24 +599,15 @@ char *encode_acct_ctrl(uint16 acct_ctrl) *p++ = '['; - if(acct_ctrl & ACB_HOMDIRREQ) - *p++ = 'H'; - if(acct_ctrl & ACB_TEMPDUP) - *p++ = 'T'; - if(acct_ctrl & ACB_NORMAL) - *p++ = 'U'; - if(acct_ctrl & ACB_MNS) - *p++ = 'M'; - if(acct_ctrl & ACB_WSTRUST) - *p++ = 'W'; - if(acct_ctrl & ACB_SVRTRUST) - *p++ = 'S'; - if(acct_ctrl & ACB_AUTOLOCK) - *p++ = 'L'; - if(acct_ctrl & ACB_PWNOEXP) - *p++ = 'X'; - if(acct_ctrl & ACB_DOMTRUST) - *p++ = 'I'; + if (acct_ctrl & ACB_HOMDIRREQ) *p++ = 'H'; + if (acct_ctrl & ACB_TEMPDUP ) *p++ = 'T'; + if (acct_ctrl & ACB_NORMAL ) *p++ = 'U'; + if (acct_ctrl & ACB_MNS ) *p++ = 'M'; + if (acct_ctrl & ACB_WSTRUST ) *p++ = 'W'; + if (acct_ctrl & ACB_SVRTRUST ) *p++ = 'S'; + if (acct_ctrl & ACB_AUTOLOCK ) *p++ = 'L'; + if (acct_ctrl & ACB_PWNOEXP ) *p++ = 'X'; + if (acct_ctrl & ACB_DOMTRUST ) *p++ = 'I'; *p++ = ']'; *p = '\0'; @@ -611,6 +616,9 @@ char *encode_acct_ctrl(uint16 acct_ctrl) /************************************************************************ Routine to add an entry to the smbpasswd file. + + do not call this function directly. use passdb.c instead. + *************************************************************************/ BOOL add_smbpwd_entry(struct smb_passwd *newpwd) @@ -742,6 +750,9 @@ Error was %s. Password file may be corrupt ! Please examine by hand !\n", in the actual file to decide how much room we have to write data. override = False, normal override = True, override XXXXXXXX'd out password or NO PASS + + do not call this function directly. use passdb.c instead. + ************************************************************************/ BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override) |