diff options
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/include/smb.h | 1 | ||||
-rw-r--r-- | source3/passdb/ldap.c | 35 | ||||
-rw-r--r-- | source3/passdb/nispass.c | 62 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 256 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 18 |
6 files changed, 179 insertions, 196 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 177a45c9c0..9256520efe 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/include/smb.h b/source3/include/smb.h index 8687f618e4..cc0ce07495 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -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 *); }; diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c index 4ee53edbef..b644e8bb69 100644 --- a/source3/passdb/ldap.c +++ b/source3/passdb/ldap.c @@ -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) diff --git a/source3/passdb/nispass.c b/source3/passdb/nispass.c index cb49f15059..ea379f5874 100644 --- a/source3/passdb/nispass.c +++ b/source3/passdb/nispass.c @@ -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) diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index d7ba8479bf..599a463d89 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -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. */ @@ -123,32 +174,6 @@ struct smb_passwd *iterate_getsmbpwnam(char *name) } /*************************************************************** - 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. @@ -185,19 +210,7 @@ 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 pdb_ops->getsmbpwent(vp); } /************************************************************************* @@ -238,19 +251,7 @@ 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)); + return pdb_ops->add_smbpwd_entry(newpwd); } /************************************************************************ @@ -264,19 +265,7 @@ 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); + return pdb_ops->mod_smbpwd_entry(pwd, override); } /************************************************************************ @@ -285,19 +274,7 @@ BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override) 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)); + return pdb_ops->getsmbpwnam(name); } /************************************************************************ @@ -306,19 +283,7 @@ struct smb_passwd *getsmbpwnam(char *name) 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))); + return pdb_ops->getsmbpwuid(smb_userid); } /* @@ -433,15 +398,19 @@ struct sam_passwd *iterate_getsam21pwuid(uid_t uid) } /************************************************************************* + 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)); + return pdb_ops->getsamdisprid(rid); } /************************************************************************* @@ -449,11 +418,7 @@ struct sam_disp_info *getsamdisprid(uint32 rid) *************************************************************************/ 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)); + return pdb_ops->getsamdispent(vp); } /************************************************************************* @@ -462,19 +427,7 @@ struct sam_disp_info *getsamdispent(void *vp) 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)); + return pdb_ops->getsam21pwent(vp); } /************************************************************************ @@ -483,19 +436,7 @@ struct sam_passwd *getsam21pwent(void *vp) 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)); + return pdb_ops->add_sam21pwd_entry(newpwd); } /************************************************************************ @@ -509,19 +450,7 @@ 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); + return pdb_ops->mod_sam21pwd_entry(pwd, override); } @@ -531,19 +460,7 @@ 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)); + return pdb_ops->getsam21pwnam(name); } /************************************************************************ @@ -552,19 +469,7 @@ struct sam_passwd *getsam21pwnam(char *name) 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))); + return pdb_ops->getsam21pwrid(rid); } /************************************************************************ @@ -573,22 +478,12 @@ struct sam_passwd *getsam21pwrid(uint32 rid) 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)); + return pdb_ops->getsam21pwuid(uid); } + + /********************************************************** ********************************************************** @@ -1143,3 +1038,4 @@ BOOL pdb_rid_is_user(uint32 rid) */ return True; } + diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index ff06905927..d03a5eb75d 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -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) |