1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-11 08:23:49 +03:00

removed "default" system for password database api: all functions must

be supported.  there are some stub routines in passdb.c which can be
copied into a password database api which do conversion.  the module
writer can choose which of these to provide full support for instead
of using the conversion routines.
This commit is contained in:
Luke Leighton
-
parent 0193dd21c3
commit d906ac5941
6 changed files with 179 additions and 196 deletions

View File

@@ -1555,9 +1555,9 @@ BOOL pm_process( char *FileName,
/*The following definitions come from passdb.c */
BOOL initialize_password_db(void);
struct smb_passwd *iterate_getsmbpwuid(uid_t smb_userid);
struct smb_passwd *iterate_getsmbpwnam(char *name);
BOOL initialize_password_db(void);
void *startsmbpwent(BOOL update);
void endsmbpwent(void *vp);
struct smb_passwd *getsmbpwent(void *vp);
@@ -1570,6 +1570,7 @@ struct smb_passwd *getsmbpwuid(uid_t smb_userid);
struct sam_passwd *iterate_getsam21pwnam(char *name);
struct sam_passwd *iterate_getsam21pwrid(uint32 rid);
struct sam_passwd *iterate_getsam21pwuid(uid_t uid);
struct sam_disp_info *getsamdispnam(char *name);
struct sam_disp_info *getsamdisprid(uint32 rid);
struct sam_disp_info *getsamdispent(void *vp);
struct sam_passwd *getsam21pwent(void *vp);

View File

@@ -693,6 +693,7 @@ struct passdb_ops {
/*
* sam query display info functions.
*/
struct sam_disp_info *(*getsamdispnam)(char *);
struct sam_disp_info *(*getsamdisprid)(uint32);
struct sam_disp_info *(*getsamdispent)(void *);
};

View File

@@ -20,7 +20,7 @@
*/
#ifdef USE_LDAP
#ifdef USE_LDAP_DB
#include "includes.h"
@@ -945,6 +945,26 @@ static BOOL mod_ldappwd_entry(struct smb_passwd* pwd, BOOL override)
return mod_ldap21pwd_entry(pdb_smb_to_sam(pwd), override);
}
static struct sam_disp_info *getldapdispnam(char *name)
{
return pdb_sam_to_dispinfo(getldap21pwnam(name));
}
static struct sam_disp_info *getldapdisprid(uint32 rid)
{
return pdb_sam_to_dispinfo(getldap21pwrid(rid));
}
static struct sam_disp_info *getldapdispent(void *vp)
{
return pdb_sam_to_dispinfo(getldap21pwent(vp));
}
static struct sam_passwd *getldap21pwuid(uid_t uid)
{
return pdb_smb_to_sam(iterate_getsam21pwuid(pdb_uid_to_user_rid(uid)));
}
static struct passdb_ops ldap_ops =
{
startldappwent,
@@ -952,18 +972,19 @@ static struct passdb_ops ldap_ops =
getldappwpos,
setldappwpos,
getldappwnam,
NULL, /* getldappwuid, */
NULL, /* getldappwent, */
NULL, /* add_ldappwd_entry, */
NULL, /* mod_ldappwd_entry, */
getldappwuid,
getldappwent,
add_ldappwd_entry,
mod_ldappwd_entry,
getldap21pwent,
iterate_getsam21pwnam, /* From passdb.c */
iterate_getsam21pwuid, /* From passdb.c */
iterate_getsam21pwrid, /* From passdb.c */
add_ldap21pwd_entry,
mod_ldap21pwd_entry,
NULL, /* getsamdisprid, */
NULL /* getsamdispent */
getldapdispnam,
getldapdisprid,
getldapdispent
};
struct passdb_ops *ldap_initialize_password_db(void)

View File

@@ -509,24 +509,70 @@ static struct sam_passwd *getnisp21pwrid(uint32 rid)
* Derived functions for NIS+.
*/
static struct smb_passwd *getnisppwent(void *vp)
{
return pdb_sam_to_smb(getnisp21pwent(vp));
}
static BOOL add_nisppwd_entry(struct smb_passwd *newpwd)
{
return add_nisp21pwd_entry(pdb_smb_to_sam(newpwd));
}
static BOOL mod_nisppwd_entry(struct smb_passwd* pwd, BOOL override)
{
return mod_nisp21pwd_entry(pdb_smb_to_sam(pwd), override);
}
static struct smb_passwd *getnisppwnam(char *name)
{
return pdb_sam_to_smb(getnisp21pwnam(name));
}
static struct sam_passwd *getnisp21pwuid(uid_t smb_userid)
{
return getnisp21pwrid(pdb_uid_to_user_rid(smb_userid));
}
static struct smb_passwd *getnisppwuid(uid_t smb_userid)
{
return pdb_sam_to_smb(getnisp21pwuid(smb_userid));
}
static struct sam_disp_info *getnispdispnam(char *name)
{
return pdb_sam_to_dispinfo(getnisp21pwnam(name));
}
static struct sam_disp_info *getnispdisprid(uint32 rid)
{
return pdb_sam_to_dispinfo(getnisp21pwrid(rid));
}
static struct sam_disp_info *getnispdispent(void *vp)
{
return pdb_sam_to_dispinfo(getnisp21pwent(vp));
}
static struct passdb_ops nispasswd_ops = {
startnisppwent,
endnisppwent,
getnisppwpos,
setnisppwpos,
NULL, /* getnispwnam, */
NULL, /* getnispwuid, */
NULL, /* getnispwent, */
NULL, /* add_nispwd_entry, */
NULL, /* mod_nispwd_entry, */
getnisppwnam,
getnisppwuid,
getnisppwent,
add_nisppwd_entry,
mod_nisppwd_entry,
getnisp21pwent,
getnisp21pwnam,
NULL, /* getsam21pwuid */
getnisp21pwuid,
getnisp21pwrid,
add_nisp21pwd_entry,
mod_nisp21pwd_entry,
NULL, /* getsamdisprid */
NULL /* getsamdispent */
getnispdispnam,
getnispdisprid,
getnispdispent
};
struct passdb_ops *nisplus_initialize_password_db(void)

View File

@@ -46,12 +46,63 @@ DOM_SID global_machine_sid;
*
* password database writers are recommended to implement the sam_passwd
* functions in a first pass, as struct sam_passwd contains more
* information, needed by the NT Domain support. lkcl.
* information, needed by the NT Domain support.
*
* a full example set of derivative functions are listed below. an API
* writer is expected to cut/paste these into their module, replace
* either one set (struct smb_passwd) or the other (struct sam_passwd)
* OR both, and optionally also to write display info routines
* (struct sam_disp_info). lkcl
*
*/
#if 0
static struct smb_passwd *getPDBpwent (void *vp) { return pdb_sam_to_smb(getPDB21pwent(vp)); }
static BOOL add_PDBpwd_entry (struct smb_passwd *newpwd) { return add_PDB21pwd_entry(pdb_smb_to_sam(newpwd)); }
static BOOL mod_PDBpwd_entry (struct smb_passwd* pwd, BOOL override) { return mod_PDB21pwd_entry(pdb_smb_to_sam(pwd), override); }
static struct smb_passwd *getPDBpwnam (char *name) { return pdb_sam_to_smb(getPDB21pwnam(name)); }
static struct smb_passwd *getPDBpwuid (uid_t smb_userid) { return pdb_sam_to_smb(getPDB21pwuid(pdb_uid_to_user_rid(smb_userid))); }
static struct sam_passwd *getPDB21pwent (void *vp) { return pdb_smb_to_sam(getPDBpwent(vp)); }
static BOOL add_PDB21pwd_entry (struct sam_passwd *newpwd) { return add_PDBpwd_entry(pdb_sam_to_smb(newpwd)); }
static BOOL mod_PDB21pwd_entry (struct sam_passwd* pwd, BOOL override) { return mod_PDBpwd_entry(pdb_sam_to_smb(pwd), override); }
static struct sam_passwd *getPDB21pwnam (char *name) { return pdb_smb_to_sam(getPDBpwnam(name)); }
static struct sam_passwd *getPDB21pwrid (uint32 rid) { return pdb_smb_to_sam(getPDBpwuid(pdb_user_rid_to_uid(rid))); }
static struct sam_passwd *getPDB21pwuid (uid_t uid) { return pdb_smb_to_sam(getPDBpwuid(uid)); }
static struct sam_disp_info *getPDBdispnam (char *name) { return pdb_sam_to_dispinfo(getPDB21pwnam(name)); }
static struct sam_disp_info *getPDBdisprid (uint32 rid) { return pdb_sam_to_dispinfo(getPDB21pwrid(rid)); }
static struct sam_disp_info *getPDBdispent (void *vp) { return pdb_sam_to_dispinfo(getPDB21pwent(vp)); }
#endif /* 0 */
static struct passdb_ops *pdb_ops;
/***************************************************************
Initialize the password db operations.
***************************************************************/
BOOL initialize_password_db(void)
{
if (pdb_ops)
{
return True;
}
#ifdef USE_NISPLUS_DB
pdb_ops = nisplus_initialize_password_db();
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
pdb_ops = ldap_initialize_password_db();
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
pdb_ops = file_initialize_password_db();
#endif /* USE_SMBPASS_DB */
return (pdb_ops != NULL);
}
/*
* Functions that return/manipulate a struct smb_passwd.
*/
@@ -122,32 +173,6 @@ struct smb_passwd *iterate_getsmbpwnam(char *name)
return pwd;
}
/***************************************************************
Initialize the password db operations.
***************************************************************/
BOOL initialize_password_db(void)
{
if (pdb_ops)
{
return True;
}
#ifdef USE_NISPLUS_DB
pdb_ops = nisplus_initialize_password_db();
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
pdb_ops = ldap_initialize_password_db();
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
pdb_ops = file_initialize_password_db();
#endif /* USE_SMBPASS_DB */
return (pdb_ops != NULL);
}
/***************************************************************
Start to enumerate the smb or sam passwd list. Returns a void pointer
to ensure no modification outside this module.
@@ -184,21 +209,9 @@ void endsmbpwent(void *vp)
*************************************************************************/
struct smb_passwd *getsmbpwent(void *vp)
{
if (pdb_ops->getsmbpwent == NULL && pdb_ops->getsam21pwent == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsmbpwent: getsmbpwent() and getsam21pwent() not supported!\n"));
return NULL;
}
if (pdb_ops->getsmbpwent != NULL)
{
return pdb_ops->getsmbpwent(vp);
}
return pdb_sam_to_smb(pdb_ops->getsam21pwent(vp));
}
/*************************************************************************
Return the current position in the smb passwd list as an unsigned long.
@@ -237,21 +250,9 @@ BOOL setsmbpwpos(void *vp, unsigned long tok)
*************************************************************************/
BOOL add_smbpwd_entry(struct smb_passwd *newpwd)
{
if (pdb_ops->add_smbpwd_entry == NULL && pdb_ops->add_sam21pwd_entry == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("add_smbpwd_entry: add_smbpwd_entry() and add_sam21pwd_entry() not supported!\n"));
return False;
}
if (pdb_ops->add_smbpwd_entry != NULL)
{
return pdb_ops->add_smbpwd_entry(newpwd);
}
return pdb_ops->add_sam21pwd_entry(pdb_smb_to_sam(newpwd));
}
/************************************************************************
Routine to search the smb passwd file for an entry matching the username.
@@ -263,63 +264,27 @@ BOOL add_smbpwd_entry(struct smb_passwd *newpwd)
************************************************************************/
BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override)
{
if (pdb_ops->mod_smbpwd_entry == NULL && pdb_ops->mod_sam21pwd_entry == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("mod_smbpwd_entry: mod_smbpwd_entry() and mod_sam21pwd_entry() not supported!\n"));
return False;
}
if (pdb_ops->mod_smbpwd_entry != NULL)
{
return pdb_ops->mod_smbpwd_entry(pwd, override);
}
return pdb_ops->mod_sam21pwd_entry(pdb_smb_to_sam(pwd), override);
}
/************************************************************************
Routine to search smb passwd by name.
*************************************************************************/
struct smb_passwd *getsmbpwnam(char *name)
{
if (pdb_ops->getsmbpwnam == NULL && pdb_ops->getsam21pwnam == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsmbpwnam: getsmbpwnam() and getsam21pwnam() not supported!\n"));
return NULL;
}
if (pdb_ops->getsam21pwnam != NULL)
{
return pdb_ops->getsmbpwnam(name);
}
return pdb_sam_to_smb(getsam21pwnam(name));
}
/************************************************************************
Routine to search smb passwd by uid.
*************************************************************************/
struct smb_passwd *getsmbpwuid(uid_t smb_userid)
{
if (pdb_ops->getsmbpwuid == NULL && pdb_ops->getsam21pwrid == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsmbpwuid: getsmbpwuid() and getsam21pwrid() not supported!\n"));
return NULL;
}
if (pdb_ops->getsmbpwuid != NULL)
{
return pdb_ops->getsmbpwuid(smb_userid);
}
return pdb_sam_to_smb(pdb_ops->getsam21pwuid(pdb_uid_to_user_rid(smb_userid)));
}
/*
* Functions that manupulate a struct sam_passwd.
@@ -432,71 +397,47 @@ struct sam_passwd *iterate_getsam21pwuid(uid_t uid)
return pwd;
}
/*************************************************************************
Routine to return a display info structure, by name
*************************************************************************/
struct sam_disp_info *getsamdispnam(char *name)
{
return pdb_ops->getsamdispnam(name);
}
/*************************************************************************
Routine to return a display info structure, by rid
*************************************************************************/
struct sam_disp_info *getsamdisprid(uint32 rid)
{
if (pdb_ops->getsamdisprid != NULL)
{
return pdb_ops->getsamdisprid(rid);
}
return pdb_sam_to_dispinfo(pdb_ops->getsam21pwrid(rid));
}
/*************************************************************************
Routine to return the next entry in the sam passwd list.
*************************************************************************/
struct sam_disp_info *getsamdispent(void *vp)
{
if (pdb_ops->getsamdispent != NULL)
{
return pdb_ops->getsamdispent(vp);
}
return pdb_sam_to_dispinfo(pdb_ops->getsam21pwent(vp));
}
/*************************************************************************
Routine to return the next entry in the sam passwd list.
*************************************************************************/
struct sam_passwd *getsam21pwent(void *vp)
{
if (pdb_ops->getsmbpwent == NULL && pdb_ops->getsam21pwent == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsmbpwent: getsmbpwent() and getsam21pwent() not supported!\n"));
return NULL;
}
if (pdb_ops->getsam21pwent != NULL)
{
return pdb_ops->getsam21pwent(vp);
}
return pdb_smb_to_sam(pdb_ops->getsmbpwent(vp));
}
/************************************************************************
Routine to add an entry to the sam passwd file.
*************************************************************************/
BOOL add_sam21pwd_entry(struct sam_passwd *newpwd)
{
if (pdb_ops->add_smbpwd_entry == NULL && pdb_ops->add_sam21pwd_entry == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("add_smbpwd_entry: add_smbpwd_entry() and add_sam21pwd_entry() not supported!\n"));
return False;
}
if (pdb_ops->add_sam21pwd_entry != NULL)
{
return pdb_ops->add_sam21pwd_entry(newpwd);
}
return pdb_ops->add_smbpwd_entry(pdb_sam_to_smb(newpwd));
}
/************************************************************************
Routine to search the sam passwd database for an entry matching the username.
@@ -508,21 +449,9 @@ BOOL add_sam21pwd_entry(struct sam_passwd *newpwd)
************************************************************************/
BOOL mod_sam21pwd_entry(struct sam_passwd* pwd, BOOL override)
{
if (pdb_ops->mod_smbpwd_entry == NULL && pdb_ops->mod_sam21pwd_entry == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("mod_smbpwd_entry: mod_smbpwd_entry() and mod_sam21pwd_entry() not supported!\n"));
return False;
}
if (pdb_ops->mod_sam21pwd_entry != NULL)
{
return pdb_ops->mod_sam21pwd_entry(pwd, override);
}
return pdb_ops->mod_smbpwd_entry(pdb_sam_to_smb(pwd), override);
}
/************************************************************************
@@ -530,63 +459,29 @@ BOOL mod_sam21pwd_entry(struct sam_passwd* pwd, BOOL override)
*************************************************************************/
struct sam_passwd *getsam21pwnam(char *name)
{
if (pdb_ops->getsmbpwnam == NULL && pdb_ops->getsam21pwnam == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsam21pwnam: getsmbpwnam() and getsam21pwnam() not supported!\n"));
return NULL;
}
if (pdb_ops->getsam21pwnam != NULL)
{
return pdb_ops->getsam21pwnam(name);
}
return pdb_smb_to_sam(getsmbpwnam(name));
}
/************************************************************************
Routine to search sam passwd by rid.
*************************************************************************/
struct sam_passwd *getsam21pwrid(uint32 rid)
{
if (pdb_ops->getsmbpwuid == NULL && pdb_ops->getsam21pwrid == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsam21pwrid: getsmbpwuid() and getsam21pwrid() not supported!\n"));
return NULL;
}
if (pdb_ops->getsam21pwrid != NULL)
{
return pdb_ops->getsam21pwrid(rid);
}
return pdb_smb_to_sam(pdb_ops->getsmbpwuid(pdb_user_rid_to_uid(rid)));
}
/************************************************************************
Routine to search sam passwd by uid.
*************************************************************************/
struct sam_passwd *getsam21pwuid(uid_t uid)
{
if (pdb_ops->getsmbpwuid == NULL && pdb_ops->getsam21pwrid == NULL)
{
/* must have one or the other: this is an error by the password
database implementor for the back-end you are using.
*/
DEBUG(0,("getsam21pwuid: getsmbpwuid() and getsam21pwrid() not supported!\n"));
return NULL;
}
if (pdb_ops->getsam21pwuid != NULL)
{
return pdb_ops->getsam21pwuid(uid);
}
return pdb_smb_to_sam(pdb_ops->getsmbpwuid(uid));
}
/**********************************************************
@@ -1143,3 +1038,4 @@ BOOL pdb_rid_is_user(uint32 rid)
*/
return True;
}

View File

@@ -920,6 +920,21 @@ BOOL mod_smbfilepwd_entry(struct smb_passwd* pwd, BOOL override)
return True;
}
static struct sam_disp_info *getsmbfiledispnam(char *name)
{
return pdb_sam_to_dispinfo(pdb_ops->getsmbfile21pwnam(name));
}
static struct sam_disp_info *getsmbfiledisprid(uint32 rid)
{
return pdb_sam_to_dispinfo(pdb_ops->getsmbfile21pwrid(rid));
}
static struct sam_disp_info *getsmbfiledispent(void *vp)
{
return pdb_sam_to_dispinfo(pdb_ops->getsmbfile21pwent(vp));
}
static struct passdb_ops file_ops = {
startsmbfilepwent,
endsmbfilepwent,
@@ -936,6 +951,9 @@ static struct passdb_ops file_ops = {
iterate_getsam21pwrid, /* In passdb.c */
add_smbfile21pwd_entry,
mod_smbfile21pwd_entry
getsmbfiledispnam,
getsmbfiledisprid,
getsmbfiledispent
};
struct passdb_ops *file_initialize_password_db(void)