/*The following definitions come from ldap.c */
-BOOL add_ldappwd_entry(struct smb_passwd *newpwd);
-BOOL mod_ldappwd_entry(struct smb_passwd *pwd, BOOL override);
-BOOL add_ldap21pwd_entry(struct sam_passwd *newpwd);
-BOOL mod_ldap21pwd_entry(struct sam_passwd *pwd, BOOL override);
-void *startldappwent(BOOL update);
-struct smb_passwd *getldappwent(void *vp);
-struct sam_passwd *getldap21pwent(void *vp);
-void endldappwent(void *vp);
-unsigned long getldappwpos(void *vp);
-BOOL setldappwpos(void *vp, unsigned long tok);
+struct passdb_ops *ldap_initialize_password_db(void);
/*The following definitions come from lib/rpc/client/cli_login.c */
/*The following definitions come from nisppass.c */
-void *startnisppwent(BOOL update);
-void endnisppwent(void *vp);
-struct sam_passwd *getnisp21pwent(void *vp);
-unsigned long getnisppwpos(void *vp);
-BOOL setnisppwpos(void *vp, unsigned long tok);
-BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd);
-BOOL mod_nisp21pwd_entry(struct sam_passwd* pwd, BOOL override);
-struct sam_passwd *getnisp21pwnam(char *name);
-struct sam_passwd *getnisp21pwuid(int smb_userid);
+struct passdb_ops *nisplus_initialize_password_db(void);
/*The following definitions come from nmbd.c */
/*The following definitions come from passdb.c */
+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);
BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override);
struct smb_passwd *getsmbpwnam(char *name);
struct smb_passwd *getsmbpwuid(uid_t smb_userid);
+struct sam_passwd *iterate_getsam21pwnam(char *name);
+struct sam_passwd *iterate_getsam21pwuid(uint32 uid);
struct sam_disp_info *getsamdispent(void *vp);
struct sam_passwd *getsam21pwent(void *vp);
BOOL add_sam21pwd_entry(struct sam_passwd *newpwd);
/*The following definitions come from smbpass.c */
-void *startsmbfilepwent(BOOL update);
-void endsmbfilepwent(void *vp);
-struct sam_passwd *getsmbfile21pwent(void *vp);
struct smb_passwd *getsmbfilepwent(void *vp);
-unsigned long getsmbfilepwpos(void *vp);
-BOOL setsmbfilepwpos(void *vp, unsigned long tok);
-BOOL add_smbfile21pwd_entry(struct sam_passwd *newpwd);
-BOOL add_smbfilepwd_entry(struct smb_passwd *newpwd);
BOOL mod_smbfile21pwd_entry(struct sam_passwd* pwd, BOOL override);
BOOL mod_smbfilepwd_entry(struct smb_passwd* pwd, BOOL override);
+struct passdb_ops *file_initialize_password_db(void);
/*The following definitions come from smbpassfile.c */
char *full_name; /* user's full name string */
};
-
/* DOM_CHAL - challenge info */
typedef struct chal_info
{
unsigned (*hash_size)(void);
};
+/*
+ * Each implementation of the password database code needs
+ * to support the following operations.
+ */
+
+struct passdb_ops {
+ /*
+ * Password database ops.
+ */
+ void *(*startsmbpwent)(BOOL);
+ void (*endsmbpwent)(void *);
+ unsigned long (*getsmbpwpos)(void *);
+ BOOL (*setsmbpwpos)(void *, unsigned long);
+ /*
+ * smb password database query functions.
+ */
+ struct smb_passwd *(*getsmbpwnam)(char *);
+ struct smb_passwd *(*getsmbpwuid)(uid_t);
+ struct smb_passwd *(*getsmbpwent)(void *);
+ /*
+ * smb password database modification functions.
+ */
+ BOOL (*add_smbpwd_entry)(struct smb_passwd *);
+ BOOL (*mod_smbpwd_entry)(struct smb_passwd *, BOOL);
+
+ /*
+ * Functions that manupulate a struct sam_passwd.
+ */
+ struct sam_passwd *(*getsam21pwent)(void *);
+
+ struct sam_passwd *(*getsam21pwnam)(char *);
+ struct sam_passwd *(*getsam21pwuid)(uint32);
+
+ BOOL (*add_sam21pwd_entry)(struct sam_passwd *);
+ BOOL (*mod_sam21pwd_entry)(struct sam_passwd *, BOOL);
+};
/* this is used for smbstatus */
+
struct connect_record
{
int magic;
do not call this function directly. use passdb.c instead.
*************************************************************************/
-BOOL add_ldappwd_entry(struct smb_passwd *newpwd)
+static BOOL add_ldappwd_entry(struct smb_passwd *newpwd)
{
return (modadd_ldappwd_entry(newpwd, ADD_USER) );
}
do not call this function directly. use passdb.c instead.
************************************************************************/
-BOOL mod_ldappwd_entry(struct smb_passwd *pwd, BOOL override)
+static BOOL mod_ldappwd_entry(struct smb_passwd *pwd, BOOL override)
{
return (modadd_ldappwd_entry(pwd, MODIFY_USER) );
}
do not call this function directly. use passdb.c instead.
*************************************************************************/
-BOOL add_ldap21pwd_entry(struct sam_passwd *newpwd)
+static BOOL add_ldap21pwd_entry(struct sam_passwd *newpwd)
{
return( modadd_ldappwd_entry(newpwd, ADD_USER)?
modadd_ldap21pwd_entry(newpwd, ADD_USER):False);
do not call this function directly. use passdb.c instead.
************************************************************************/
-BOOL mod_ldap21pwd_entry(struct sam_passwd *pwd, BOOL override)
+static BOOL mod_ldap21pwd_entry(struct sam_passwd *pwd, BOOL override)
{
return( modadd_ldappwd_entry(pwd, MODIFY_USER)?
modadd_ldap21pwd_entry(pwd, MODIFY_USER):False);
do not call this function directly. use passdb.c instead.
****************************************************************/
-void *startldappwent(BOOL update)
+static void *startldappwent(BOOL update)
{
int scope = LDAP_SCOPE_ONELEVEL;
int rc;
do not call this function directly. use passdb.c instead.
*************************************************************************/
-struct smb_passwd *getldappwent(void *vp)
+static struct smb_passwd *getldappwent(void *vp)
{
static struct smb_passwd user;
struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
do not call this function directly. use passdb.c instead.
*************************************************************************/
-struct sam_passwd *getldap21pwent(void *vp)
+static struct sam_passwd *getldap21pwent(void *vp)
{
static struct sam_passwd user;
struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
do not call this function directly. use passdb.c instead.
****************************************************************/
-void endldappwent(void *vp)
+static void endldappwent(void *vp)
{
struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
ldap_msgfree(ldap_vp->result);
do not call this function directly. use passdb.c instead.
*************************************************************************/
-unsigned long getldappwpos(void *vp)
+static unsigned long getldappwpos(void *vp)
{
return 0;
}
do not call this function directly. use passdb.c instead.
*************************************************************************/
-BOOL setldappwpos(void *vp, unsigned long tok)
+static BOOL setldappwpos(void *vp, unsigned long tok)
{
return False;
}
+/*
+ * Ldap derived functions.
+ */
+
+static struct smb_passwd *getldappwnam(char *name)
+{
+ return pdb_sam_to_smb(iterate_getsam21pwnam(name));
+}
+
+static struct smb_passwd *getldappwuid(uid_t smb_userid)
+{
+ return pdb_sam_to_smb(iterate_getsam21pwuid(smb_userid));
+}
+
+static struct smb_passwd *getldappwent(void *vp)
+{
+ return pdb_sam_to_smb(getldap21pwent(vp));
+}
+
+static BOOL add_ldappwd_entry(struct smb_passwd *newpwd)
+{
+ return add_ldap21pwd_entry(pdb_smb_to_sam(newpwd));
+}
+
+static BOOL mod_ldappwd_entry(struct smb_passwd* pwd, BOOL override)
+{
+ return mod_ldap21pwd_entry(pdb_smb_to_sam(pwd), override);
+}
+
+static struct passdb_ops ldap_ops = {
+ startldappwent,
+ endldappwent,
+ getldappwpos,
+ setldappwpos,
+ getldappwnam,
+ getldappwuid,
+ getldappwent,
+ add_ldappwd_entry,
+ mod_ldappwd_entry,
+ getldap21pwent,
+ iterate_getsam21pwnam, /* From passdb.c */
+ iterate_getsam21pwuid, /* From passdb.c */
+ add_ldap21pwd_entry,
+ mod_ldap21pwd_entry
+};
+
+struct passdb_ops *ldap_initialize_password_db(void)
+{
+ return &ldap_ops;
+}
+
#else
void dummy_function(void) { } /* stop some compilers complaining */
#endif
do not call this function directly. use passdb.c instead.
****************************************************************/
-void *startnisppwent(BOOL update)
+static void *startnisppwent(BOOL update)
{
return NULL;
}
/***************************************************************
End enumeration of the nisplus passwd list.
****************************************************************/
-void endnisppwent(void *vp)
+static void endnisppwent(void *vp)
{
}
do not call this function directly. use passdb.c instead.
*************************************************************************/
-struct sam_passwd *getnisp21pwent(void *vp)
+static struct sam_passwd *getnisp21pwent(void *vp)
{
return NULL;
}
do not call this function directly. use passdb.c instead.
*************************************************************************/
-unsigned long getnisppwpos(void *vp)
+static unsigned long getnisppwpos(void *vp)
{
return 0;
}
do not call this function directly. use passdb.c instead.
*************************************************************************/
-BOOL setnisppwpos(void *vp, unsigned long tok)
+static BOOL setnisppwpos(void *vp, unsigned long tok)
{
return False;
}
do not call this function directly. use passdb.c instead.
*************************************************************************/
-BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd)
+static BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd)
{
/* Static buffers we will return. */
static pstring user_name;
do not call this function directly. use passdb.c instead.
************************************************************************/
-BOOL mod_nisp21pwd_entry(struct sam_passwd* pwd, BOOL override)
+static BOOL mod_nisp21pwd_entry(struct sam_passwd* pwd, BOOL override)
{
return False;
}
/*************************************************************************
Routine to search the nisplus passwd file for an entry matching the username
*************************************************************************/
-struct sam_passwd *getnisp21pwnam(char *name)
+static struct sam_passwd *getnisp21pwnam(char *name)
{
/* Static buffers we will return. */
static struct sam_passwd pw_buf;
/*************************************************************************
Routine to search the nisplus passwd file for an entry matching the username
*************************************************************************/
-struct sam_passwd *getnisp21pwuid(int smb_userid)
+static struct sam_passwd *getnisp21pwuid(int smb_userid)
{
/* Static buffers we will return. */
static struct sam_passwd pw_buf;
return ret ? &pw_buf : NULL;
}
+/*
+ * Derived functions for NIS+.
+ */
+
+static struct smb_passwd *getnispwnam(char *name)
+{
+ return pdb_sam_to_smb(iterate_getsam21pwnam(name));
+}
+
+static struct smb_passwd *getnispwuid(uid_t smb_userid)
+{
+ return pdb_sam_to_smb(iterate_getsam21pwuid(smb_userid));
+}
+
+static struct smb_passwd *getnispwent(void *vp)
+{
+ return pdb_sam_to_smb(getnisp21pwent(vp));
+}
+
+static BOOL add_nispwd_entry(struct smb_passwd *newpwd)
+{
+ return add_nisp21pwd_entry(pdb_smb_to_sam(newpwd));
+}
+
+static BOOL mod_nispwd_entry(struct smb_passwd* pwd, BOOL override)
+{
+ return mod_nisp21pwd_entry(pdb_smb_to_sam(pwd), override);
+}
+
+static struct passdb_ops nispasswd_ops = {
+ startnisppwent,
+ endnisppwent,
+ getnisppwpos,
+ setnisppwpos,
+ getnispwnam,
+ getsmbpwuid,
+ getnispwent,
+ add_nispwd_entry,
+ mod_nispwd_entry,
+ getnisp21pwent,
+ iterate_getsam21pwnam, /* Found in passdb.c */
+ iterate_getsam21pwuid, /* Found in passdb.c */
+ add_nisp21pwd_entry,
+ mod_nisp21pwd_entry
+};
+
+struct passdb_ops *nisplus_initialize_password_db(void)
+{
+ return &nispasswd_ops;
+}
+
#else
void nisplus_dummy_function(void) { } /* stop some compilers complaining */
#endif /* USE_NISPLUS_DB */
DOM_SID global_machine_sid;
/*
- * TODO NOTE. All these functions will be abstracted into a structure
+ * NOTE. All these functions are abstracted into a structure
* that points to the correct function for the selected database. JRA.
*/
+static struct passdb_ops *pdb_ops;
+
/*
* Functions that return/manipulate a struct smb_passwd.
*/
/************************************************************************
- Routine to search smb passwd by uid. use this if your database
+ Utility function to search smb passwd by uid. use this if your database
does not have search facilities.
*************************************************************************/
-static struct smb_passwd *_getsmbpwuid(uid_t smb_userid)
+struct smb_passwd *iterate_getsmbpwuid(uid_t smb_userid)
{
struct smb_passwd *pwd = NULL;
void *fp = NULL;
- DEBUG(10, ("getsmbpwuid: search by smb_userid: %x\n", smb_userid));
+ DEBUG(10, ("iterate_getsmbpwuid: search by smb_userid: %x\n", smb_userid));
/* Open the smb password database - not for update. */
fp = startsmbpwent(False);
if (fp == NULL)
{
- DEBUG(0, ("getsmbpwuid: unable to open smb password database.\n"));
+ DEBUG(0, ("iterate_getsmbpwuid: unable to open smb password database.\n"));
return NULL;
}
if (pwd != NULL)
{
- DEBUG(10, ("getsmbpwuid: found by smb_userid: %x\n", smb_userid));
+ DEBUG(10, ("iterate_getsmbpwuid: found by smb_userid: %x\n", smb_userid));
}
endsmbpwent(fp);
}
/************************************************************************
- Routine to search smb passwd by name. use this if your database
+ Utility function to search smb passwd by name. use this if your database
does not have search facilities.
*************************************************************************/
-static struct smb_passwd *_getsmbpwnam(char *name)
+struct smb_passwd *iterate_getsmbpwnam(char *name)
{
struct smb_passwd *pwd = NULL;
void *fp = NULL;
- DEBUG(10, ("getsmbpwnam: search by name: %s\n", name));
+ DEBUG(10, ("iterate_getsmbpwnam: search by name: %s\n", name));
/* Open the sam password file - not for update. */
fp = startsmbpwent(False);
if (fp == NULL)
{
- DEBUG(0, ("_getsmbpwnam: unable to open smb password database.\n"));
+ DEBUG(0, ("iterate_getsmbpwnam: unable to open smb password database.\n"));
return NULL;
}
if (pwd != NULL)
{
- DEBUG(10, ("_getsmbpwnam: found by name: %s\n", name));
+ DEBUG(10, ("iterate_getsmbpwnam: found by name: %s\n", name));
}
endsmbpwent(fp);
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.
void *startsmbpwent(BOOL update)
{
-#ifdef USE_NISPLUS_DB
- return startnisppwent(update);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return startldappwent(update);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return startsmbfilepwent(update);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->startsmbpwent(update);
}
/***************************************************************
void endsmbpwent(void *vp)
{
-#ifdef USE_NISPLUS_DB
- endnisppwent(vp);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- endldappwent(vp);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- endsmbfilepwent(vp);
-#endif /* USE_SMBPASS_DB */
+ pdb_ops->endsmbpwent(vp);
}
/*************************************************************************
- Routine to return the next entry in the sam passwd list.
+ Routine to return the next entry in the smb passwd list.
*************************************************************************/
struct smb_passwd *getsmbpwent(void *vp)
{
-#ifdef USE_NISPLUS_DB
- return pdb_sam_to_smb(getnisp21pwent(vp));
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return pdb_sam_to_smb(getldap21pwent(vp));
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return getsmbfilepwent(vp);
-#endif /* USE_SMBPASS_DB */
- return NULL;
+ return pdb_ops->getsmbpwent(vp);
}
/*************************************************************************
unsigned long getsmbpwpos(void *vp)
{
-#ifdef USE_NISPLUS_DB
- return getnisppwpos(vp);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return getldappwpos(vp);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return getsmbfilepwpos(vp);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->getsmbpwpos(vp);
}
/*************************************************************************
BOOL setsmbpwpos(void *vp, unsigned long tok)
{
-#ifdef USE_NISPLUS_DB
- return setnisppwpos(vp, tok);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return setldappwpos(vp, tok);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return setsmbfilepwpos(vp, tok);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->setsmbpwpos(vp, tok);
}
/************************************************************************
BOOL add_smbpwd_entry(struct smb_passwd *newpwd)
{
-#ifdef USE_NISPLUS_DB
- return add_nisp21pwd_entry(pdb_smb_to_sam(newpwd));
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return add_ldap21pwd_entry(pdb_smb_to_sam(newpwd));
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return add_smbfilepwd_entry(newpwd);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->add_smbpwd_entry(newpwd);
}
/************************************************************************
BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override)
{
-#ifdef USE_NISPLUS_DB
- return mod_nisp21pwd_entry(pdb_smb_to_sam(pwd), override);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return mod_ldap21pwd_entry(pdb_smb_to_sam(pwd), override);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return mod_smbfilepwd_entry(pwd, override);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->mod_smbpwd_entry(pwd, override);
}
/************************************************************************
struct smb_passwd *getsmbpwnam(char *name)
{
-#ifdef USE_NISPLUS_DB
- return pdb_sam_to_smb(_getsam21pwnam(name));
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return pdb_sam_to_smb(_getsam21pwnam(name));
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return _getsmbpwnam(name);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->getsmbpwnam(name);
}
/************************************************************************
struct smb_passwd *getsmbpwuid(uid_t smb_userid)
{
-#ifdef USE_NISPLUS_DB
- return pdb_sam_to_smb(_getsam21pwrid(smb_userid));
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return pdb_sam_to_smb(_getsam21pwrid(smb_userid));
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return _getsmbpwuid(smb_userid);
-#endif /* USE_SMBPASS_DB */
+ return pdb_ops->getsmbpwuid(smb_userid);
}
/*
* Functions that manupulate a struct sam_passwd.
*/
-/*************************************************************************
- Routine to return the next entry in the sam passwd list.
- *************************************************************************/
-
-struct sam_disp_info *getsamdispent(void *vp)
-{
-#ifdef USE_NISPLUS_DB
- return pdb_sam_to_dispinfo(getnisp21pwent(vp));
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return pdb_sam_to_dispinfo(getldap21pwent(vp));
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return pdb_sam_to_dispinfo(getsmbfile21pwent(vp));
-#endif /* USE_SMBPASS_DB */
-
- return NULL;
-}
-
-/*************************************************************************
- Routine to return the next entry in the sam passwd list.
- *************************************************************************/
-
-struct sam_passwd *getsam21pwent(void *vp)
-{
-#ifdef USE_NISPLUS_DB
- return getnisp21pwent(vp);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return getldap21pwent(vp);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return getsmbfile21pwent(vp);
-#endif /* USE_SMBPASS_DB */
-
- return NULL;
-}
-
-/************************************************************************
- Routine to add an entry to the sam passwd file.
-*************************************************************************/
-
-BOOL add_sam21pwd_entry(struct sam_passwd *newpwd)
-{
-#ifdef USE_NISPLUS_DB
- return add_nisp21pwd_entry(newpwd);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return add_ldap21pwd_entry(newpwd);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return add_smbfile21pwd_entry(newpwd);
-#endif /* USE_SMBPASS_DB */
-}
-
/************************************************************************
- Routine to search the sam passwd database 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_sam21pwd_entry(struct sam_passwd* pwd, BOOL override)
-{
-#ifdef USE_NISPLUS_DB
- return mod_nisp21pwd_entry(pwd, override);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return mod_ldap21pwd_entry(pwd, override);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return mod_smbfile21pwd_entry(pwd, override);
-#endif /* USE_SMBPASS_DB */
-}
-
-/************************************************************************
- Routine to search sam passwd by name. use this if your database
+ Utility function to search sam passwd by name. use this if your database
does not have search facilities.
*************************************************************************/
-static struct sam_passwd *_getsam21pwnam(char *name)
+struct sam_passwd *iterate_getsam21pwnam(char *name)
{
struct sam_passwd *pwd = NULL;
void *fp = NULL;
- DEBUG(10, ("_getsam21pwnam: search by name: %s\n", name));
+ DEBUG(10, ("iterate_getsam21pwnam: search by name: %s\n", name));
/* Open the smb password database - not for update. */
fp = startsmbpwent(False);
if (fp == NULL)
{
- DEBUG(0, ("_getsam21pwnam: unable to open sam password database.\n"));
+ DEBUG(0, ("iterate_getsam21pwnam: unable to open sam password database.\n"));
return NULL;
}
- while ((pwd = getsam21pwent(fp)) != NULL && !strequal(pwd->smb_name, name));
+ while ((pwd = getsam21pwent(fp)) != NULL && !strequal(pwd->smb_name, name))
+ ;
if (pwd != NULL)
{
- DEBUG(10, ("_getsam21pwnam: found by name: %s\n", name));
+ DEBUG(10, ("iterate_getsam21pwnam: found by name: %s\n", name));
}
endsmbpwent(fp);
return pwd;
}
-
/************************************************************************
- Routine to search sam passwd by name.
-*************************************************************************/
-
-struct sam_passwd *getsam21pwnam(char *name)
-{
-#ifdef USE_NISPLUS_DB
- return _getsam21pwnam(name);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return _getsam21pwnam(name);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return _getsam21pwnam(name);
-#endif /* USE_SMBPASS_DB */
-}
-
-/************************************************************************
- Routine to search sam passwd by uid. use this if your database
+ Utility function to search sam passwd by uid. use this if your database
does not have search facilities.
*************************************************************************/
-static struct sam_passwd *_getsam21pwuid(uint32 uid)
+struct sam_passwd *iterate_getsam21pwuid(uint32 uid)
{
struct sam_passwd *pwd = NULL;
void *fp = NULL;
- DEBUG(10, ("_getsam21pwuid: search by uid: %x\n", uid));
+ DEBUG(10, ("iterate_getsam21pwuid: search by uid: %x\n", uid));
/* Open the smb password file - not for update. */
fp = startsmbpwent(False);
if (fp == NULL)
{
- DEBUG(0, ("_getsam21pwuid: unable to open sam password database.\n"));
+ DEBUG(0, ("iterate_getsam21pwuid: unable to open sam password database.\n"));
return NULL;
}
if (pwd != NULL)
{
- DEBUG(10, ("_getsam21pwuid: found by smb_userid: %x\n", uid));
+ DEBUG(10, ("iterate_getsam21pwuid: found by smb_userid: %x\n", uid));
}
endsmbpwent(fp);
return pwd;
}
+/*************************************************************************
+ Routine to return the next entry in the sam passwd list.
+ *************************************************************************/
+
+struct sam_disp_info *getsamdispent(void *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)
+{
+ return pdb_ops->getsam21pwent(vp);
+}
+
/************************************************************************
- Routine to search sam passwd by uid.
+ Routine to add an entry to the sam passwd file.
*************************************************************************/
-struct sam_passwd *getsam21pwuid(uint32 uid)
+BOOL add_sam21pwd_entry(struct sam_passwd *newpwd)
{
-#ifdef USE_NISPLUS_DB
- return _getsam21pwuid(uid);
-#endif /* USE_NISPLUS_DB */
+ return pdb_ops->add_sam21pwd_entry(newpwd);
+}
-#ifdef USE_LDAP_DB
- return _getsam21pwuid(uid);
-#endif /* USE_LDAP_DB */
+/************************************************************************
+ Routine to search the sam passwd database 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
+************************************************************************/
-#ifdef USE_SMBPASS_DB
- return _getsam21pwuid(uid);
-#endif /* USE_SMBPASS_DB */
+BOOL mod_sam21pwd_entry(struct sam_passwd* pwd, BOOL override)
+{
+ return pdb_ops->mod_sam21pwd_entry(pwd, override);
+}
+
+
+/************************************************************************
+ Routine to search sam passwd by name.
+*************************************************************************/
+
+struct sam_passwd *getsam21pwnam(char *name)
+{
+ return pdb_ops->getsam21pwnam(name);
+}
+
+/************************************************************************
+ Routine to search sam passwd by uid.
+*************************************************************************/
+
+struct sam_passwd *getsam21pwuid(uint32 uid)
+{
+ return pdb_ops->getsam21pwuid(uid);
}
/*************************************************************************
Routine to return the next entry in the sam passwd list.
*************************************************************************/
+
struct sam_disp_info *pdb_sam_to_dispinfo(struct sam_passwd *user)
{
static struct sam_disp_info disp_info;
BOOL pdb_rid_is_user(uint32 rid)
{
/* Punt for now - we need to look at the encoding here. JRA. */
- return False;
+ return True;
}
/***************************************************************
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 *startsmbfilepwent(BOOL update)
+static void *startsmbfilepwent(BOOL update)
{
FILE *fp = NULL;
char *pfile = lp_smb_passwd_file();
/***************************************************************
End enumeration of the smbpasswd list.
****************************************************************/
-void endsmbfilepwent(void *vp)
+
+static void endsmbfilepwent(void *vp)
{
FILE *fp = (FILE *)vp;
- the smbpasswd file
- the unix password database
- smb.conf options (not done at present).
-
- do not call this function directly. use passdb.c instead.
-
*************************************************************************/
-struct sam_passwd *getsmbfile21pwent(void *vp)
+
+static struct sam_passwd *getsmbfile21pwent(void *vp)
{
struct smb_passwd *pw_buf = getsmbfilepwent(vp);
static struct sam_passwd user;
/*************************************************************************
Routine to return the next entry in the smbpasswd list.
-
- do not call this function directly. use passdb.c instead.
-
*************************************************************************/
+
struct smb_passwd *getsmbfilepwent(void *vp)
{
/* Static buffers we will return. */
/*************************************************************************
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 getsmbfilepwpos(void *vp)
+
+static unsigned long getsmbfilepwpos(void *vp)
{
return (unsigned long)ftell((FILE *)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 setsmbfilepwpos(void *vp, unsigned long tok)
+
+static BOOL setsmbfilepwpos(void *vp, unsigned long tok)
{
return !fseek((FILE *)vp, tok, SEEK_SET);
}
/************************************************************************
Routine to add an entry to the smbpasswd file.
-
- do not call this function directly. use passdb.c instead.
-
*************************************************************************/
-BOOL add_smbfile21pwd_entry(struct sam_passwd *newpwd)
+
+static BOOL add_smbfile21pwd_entry(struct sam_passwd *newpwd)
{
return False;
}
/************************************************************************
Routine to add an entry to the smbpasswd file.
-
- do not call this function directly. use passdb.c instead.
-
*************************************************************************/
-BOOL add_smbfilepwd_entry(struct smb_passwd *newpwd)
+
+static BOOL add_smbfilepwd_entry(struct smb_passwd *newpwd)
{
char *pfile = lp_smb_passwd_file();
struct smb_passwd *pwd = NULL;
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_smbfile21pwd_entry(struct sam_passwd* pwd, BOOL override)
{
return False;
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_smbfilepwd_entry(struct smb_passwd* pwd, BOOL override)
{
/* Static buffers we will return. */
fclose(fp);
return True;
}
+
+static struct passdb_ops file_ops = {
+ startsmbfilepwent,
+ endsmbfilepwent,
+ getsmbfilepwpos,
+ setsmbfilepwpos,
+ iterate_getsmbpwnam, /* In passdb.c */
+ iterate_getsmbpwuid, /* In passdb.c */
+ getsmbfilepwent,
+ add_smbfilepwd_entry,
+ mod_smbfilepwd_entry,
+ getsmbfile21pwent,
+ iterate_getsam21pwnam, /* In passdb.c */
+ iterate_getsam21pwuid, /* In passdb.c */
+ add_smbfile21pwd_entry,
+ mod_smbfile21pwd_entry
+};
+
+struct passdb_ops *file_initialize_password_db(void)
+{
+ return &file_ops;
+}
+
#else
static void dummy_function(void) { } /* stop some compilers complaining */
#endif /* USE_SMBPASS_DB */
if (!locking_init(0))
exit(1);
+ if(!initialize_password_db())
+ exit(1);
+
/* possibly reload the services file. */
reload_services(True);
charset_initialise();
+ if(!initialize_password_db()) {
+ fprintf(stderr, "%s: Can't setup password database vectors.\n", prog_name);
+ exit(1);
+ }
+
if (!lp_load(servicesf,True,False,False)) {
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", prog_name, servicesf);
+ exit(1);
}
if(!get_myname(myhostname,NULL)) {