summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-05-18 15:50:56 +0000
committerLuke Leighton <lkcl@samba.org>1998-05-18 15:50:56 +0000
commitcffaf886da8b0970acb670b58b64d5145122aab1 (patch)
treecfe382f83b3b8e0889572ee611a1832ef1d83429
parent4d63fdc430ff9ff6cd141280c024e83f41bd6744 (diff)
downloadsamba-cffaf886da8b0970acb670b58b64d5145122aab1.tar.gz
samba-cffaf886da8b0970acb670b58b64d5145122aab1.tar.bz2
samba-cffaf886da8b0970acb670b58b64d5145122aab1.zip
removed references to some of the smb_passwd routines from ldap and nis+
code, use pdb_sam_to_smb(...sam21...) calls instead. this is a lot simpler. (This used to be commit d92f4e71c12ce5010f05fa7dd3918a48e7386d1e)
-rw-r--r--source3/include/proto.h11
-rw-r--r--source3/passdb/nispass.c56
-rw-r--r--source3/passdb/passdb.c146
3 files changed, 96 insertions, 117 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4ef785357c..6f1f9e038c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1216,15 +1216,12 @@ BOOL resolve_name(char *name, struct in_addr *return_ip);
void *startnisppwent(BOOL update);
void endnisppwent(void *vp);
struct sam_passwd *getnisp21pwent(void *vp);
-struct smb_passwd *getnisppwent(void *vp);
unsigned long getnisppwpos(void *vp);
BOOL setnisppwpos(void *vp, unsigned long tok);
BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd);
-BOOL add_nisppwd_entry(struct smb_passwd *newpwd);
BOOL mod_nisp21pwd_entry(struct sam_passwd* pwd, BOOL override);
-BOOL mod_nisppwd_entry(struct smb_passwd* pwd, BOOL override);
-struct smb_passwd *getnisppwnam(char *name);
-struct smb_passwd *getnisppwuid(int smb_userid);
+struct sam_passwd *getnisp21pwnam(char *name);
+struct sam_passwd *getnisp21pwuid(int smb_userid);
/*The following definitions come from nmbd.c */
@@ -1586,12 +1583,14 @@ BOOL add_sampwd_entry(struct smb_passwd *newpwd);
BOOL add_sam21pwd_entry(struct sam_passwd *newpwd);
BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override);
BOOL mod_sam21pwd_entry(struct sam_passwd* pwd, BOOL override);
-struct smb_passwd *getsampwnam(char *name);
struct sam_passwd *getsam21pwnam(char *name);
+struct smb_passwd *getsampwnam(char *name);
struct smb_passwd *getsampwuid(uid_t smb_userid);
struct sam_passwd *getsam21pwrid(uint32 rid);
+void pdb_init_dispinfo(struct sam_disp_info *user);
void pdb_init_smb(struct smb_passwd *user);
void pdb_init_sam(struct sam_passwd *user);
+struct sam_disp_info *pdb_sam_to_dispinfo(struct sam_passwd *user);
struct smb_passwd *pdb_sam_to_smb(struct sam_passwd *user);
struct sam_passwd *pdb_smb_to_sam(struct smb_passwd *user);
time_t pdb_get_last_set_time(char *p);
diff --git a/source3/passdb/nispass.c b/source3/passdb/nispass.c
index a41c47a0e7..5c906c53e7 100644
--- a/source3/passdb/nispass.c
+++ b/source3/passdb/nispass.c
@@ -168,18 +168,6 @@ struct sam_passwd *getnisp21pwent(void *vp)
}
/*************************************************************************
- Routine to return the next entry in the nisplus passwd list.
-
- do not call this function directly. use passdb.c instead.
-
- *************************************************************************/
-struct smb_passwd *getnisppwent(void *vp)
-{
- DEBUG(5,("getnisppwent: end of file reached.\n"));
- return NULL;
-}
-
-/*************************************************************************
Return the current position in the nisplus passwd list as an unsigned long.
This must be treated as an opaque token.
@@ -211,16 +199,6 @@ BOOL setnisppwpos(void *vp, unsigned long tok)
*************************************************************************/
BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd)
{
-}
-
-/************************************************************************
- Routine to add an entry to the nisplus passwd file.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-BOOL add_nisppwd_entry(struct smb_passwd *newpwd)
-{
/* Static buffers we will return. */
static pstring user_name;
@@ -375,25 +353,9 @@ BOOL mod_nisp21pwd_entry(struct sam_passwd* pwd, BOOL override)
}
/************************************************************************
- Routine to search the nisplus passwd file for an entry matching the username.
- and then modify its password entry. We can't use the startnisppwent()/
- getnisppwent()/endnisppwent() 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
-
- do not call this function directly. use passdb.c instead.
-
-************************************************************************/
-BOOL mod_nisppwd_entry(struct smb_passwd* pwd, BOOL override)
-{
- return False;
-}
-
-/************************************************************************
- makes a struct smb_passwd from a NIS+ result.
+ makes a struct sam_passwd from a NIS+ result.
************************************************************************/
-static BOOL make_smb_from_nisp(struct smb_passwd *pw_buf, nis_result *result)
+static BOOL make_sam_from_nisp(struct sam_passwd *pw_buf, nis_result *result)
{
int uidval;
static pstring user_name;
@@ -404,7 +366,7 @@ static BOOL make_smb_from_nisp(struct smb_passwd *pw_buf, nis_result *result)
if (pw_buf == NULL || result == NULL) return False;
- bzero(pw_buf, sizeof(*pw_buf));
+ pdb_init_sam(pw_buf);
if (result->status != NIS_SUCCESS)
{
@@ -458,10 +420,10 @@ static BOOL make_smb_from_nisp(struct smb_passwd *pw_buf, nis_result *result)
/*************************************************************************
Routine to search the nisplus passwd file for an entry matching the username
*************************************************************************/
-struct smb_passwd *getnisppwnam(char *name)
+struct sam_passwd *getnisp21pwnam(char *name)
{
/* Static buffers we will return. */
- static struct smb_passwd pw_buf;
+ static struct sam_passwd pw_buf;
nis_result *result;
pstring nisname;
BOOL ret;
@@ -494,7 +456,7 @@ struct smb_passwd *getnisppwnam(char *name)
return NULL;
}
- ret = make_smb_from_nisp(&pw_buf, result);
+ ret = make_sam_from_nisp(&pw_buf, result);
nis_freeresult(result);
return ret ? &pw_buf : NULL;
@@ -503,10 +465,10 @@ struct smb_passwd *getnisppwnam(char *name)
/*************************************************************************
Routine to search the nisplus passwd file for an entry matching the username
*************************************************************************/
-struct smb_passwd *getnisppwuid(int smb_userid)
+struct sam_passwd *getnisp21pwuid(int smb_userid)
{
/* Static buffers we will return. */
- static struct smb_passwd pw_buf;
+ static struct sam_passwd pw_buf;
nis_result *result;
pstring nisname;
BOOL ret;
@@ -539,7 +501,7 @@ struct smb_passwd *getnisppwuid(int smb_userid)
return NULL;
}
- ret = make_smb_from_nisp(&pw_buf, result);
+ ret = make_sam_from_nisp(&pw_buf, result);
nis_freeresult(result);
return ret ? &pw_buf : NULL;
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index b43333f389..c7de4f448c 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -94,11 +94,11 @@ void endsampwent(void *vp)
struct smb_passwd *getsampwent(void *vp)
{
#ifdef USE_NISPLUS_DB
- return getnisppwent(vp);
+ return pdb_sam_to_smb(getnisppwent(vp);
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- return getldappwent(vp);
+ return pdb_sam_to_smb(getldap21pwent(vp));
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
@@ -111,28 +111,19 @@ struct smb_passwd *getsampwent(void *vp)
*************************************************************************/
struct sam_disp_info *getsamdispent(void *vp)
{
- struct sam_passwd *pwd = NULL;
- static struct sam_disp_info disp_info;
-
#ifdef USE_NISPLUS_DB
- pwd = getnisp21pwent(vp);
+ return pdb_sam_to_dispinfo(getnisp21pwent(vp));
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- pwd = getldap21pwent(vp);
+ return pdb_sam_to_dispinfo(getldap21pwent(vp));
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
- pwd = getsmb21pwent(vp);
+ return pdb_sam_to_dispinfo(getsmb21pwent(vp));
#endif /* USE_SMBPASS_DB */
- if (pwd == NULL) return NULL;
-
- disp_info.smb_name = pwd->smb_name;
- disp_info.full_name = pwd->full_name;
- disp_info.user_rid = pwd->user_rid;
-
- return &disp_info;
+ return NULL;
}
/*************************************************************************
@@ -141,16 +132,18 @@ struct sam_disp_info *getsamdispent(void *vp)
struct sam_passwd *getsam21pwent(void *vp)
{
#ifdef USE_NISPLUS_DB
- return getnisp21pwent(vp);
+ return getnisp21pwent(vp);
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- return getldap21pwent(vp);
+ return getldap21pwent(vp);
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
- return getsmb21pwent(vp);
+ return getsmb21pwent(vp);
#endif /* USE_SMBPASS_DB */
+
+ return NULL;
}
/*************************************************************************
@@ -160,15 +153,15 @@ struct sam_passwd *getsam21pwent(void *vp)
unsigned long getsampwpos(void *vp)
{
#ifdef USE_NISPLUS_DB
- return getnisppwpos(vp);
+ return getnisppwpos(vp);
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- return getldappwpos(vp);
+ return getldappwpos(vp);
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
- return getsmbpwpos(vp);
+ return getsmbpwpos(vp);
#endif /* USE_SMBPASS_DB */
}
@@ -201,7 +194,7 @@ BOOL add_sampwd_entry(struct smb_passwd *newpwd)
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- return add_ldappwd_entry(newpwd);
+ return add_ldap21pwd_entry(pdb_smb_to_sam(newpwd));
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
@@ -215,15 +208,15 @@ BOOL add_sampwd_entry(struct smb_passwd *newpwd)
BOOL add_sam21pwd_entry(struct sam_passwd *newpwd)
{
#ifdef USE_NISPLUS_DB
- return add_nisp21pwd_entry(newpwd);
+ return add_nisp21pwd_entry(newpwd);
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- return add_ldap21pwd_entry(newpwd);
+ return add_ldap21pwd_entry(newpwd);
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
- return add_smb21pwd_entry(newpwd);
+ return add_smb21pwd_entry(newpwd);
#endif /* USE_SMBPASS_DB */
}
@@ -242,7 +235,7 @@ BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override)
#endif /* USE_NISPLUS_DB */
#ifdef USE_LDAP_DB
- return mod_ldappwd_entry(pwd, override);
+ return mod_ldap21pwd_entry(pdb_smb_to_sam(pwd), override);
#endif /* USE_LDAP_DB */
#ifdef USE_SMBPASS_DB
@@ -317,24 +310,6 @@ static struct smb_passwd *_getsampwnam(char *name)
}
/************************************************************************
- Routine to search sam passwd by name.
-*************************************************************************/
-struct smb_passwd *getsampwnam(char *name)
-{
-#ifdef USE_NISPLUS_DB
- return _getsampwnam(name);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return _getsampwnam(name);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return _getsampwnam(name);
-#endif /* USE_SMBPASS_DB */
-}
-
-/************************************************************************
Routine to search sam passwd by name. use this if your database
does not have search facilities.
*************************************************************************/
@@ -384,6 +359,24 @@ struct sam_passwd *getsam21pwnam(char *name)
}
/************************************************************************
+ Routine to search sam passwd by name.
+*************************************************************************/
+struct smb_passwd *getsampwnam(char *name)
+{
+#ifdef USE_NISPLUS_DB
+ return pdb_sam_to_smb(_getsampwnam(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 _getsampwnam(name);
+#endif /* USE_SMBPASS_DB */
+}
+
+/************************************************************************
Routine to search sam passwd by uid. use this if your database
does not have search facilities.
*************************************************************************/
@@ -414,24 +407,6 @@ static struct smb_passwd *_getsampwuid(uid_t smb_userid)
return pwd;
}
-/************************************************************************
- Routine to search sam passwd by uid.
-*************************************************************************/
-struct smb_passwd *getsampwuid(uid_t smb_userid)
-{
-#ifdef USE_NISPLUS_DB
- return _getsampwuid(smb_userid);
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
- return _getsampwuid(smb_userid);
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
- return _getsampwuid(smb_userid);
-#endif /* USE_SMBPASS_DB */
-}
-
/************************************************************************
Routine to search sam passwd by rid. use this if your database
@@ -465,6 +440,24 @@ static struct sam_passwd *_getsam21pwrid(uint32 rid)
}
/************************************************************************
+ Routine to search sam passwd by uid.
+*************************************************************************/
+struct smb_passwd *getsampwuid(uid_t smb_userid)
+{
+#ifdef USE_NISPLUS_DB
+ return pdb_sam_to_smb(_getsampwuid(smb_userid));
+#endif /* USE_NISPLUS_DB */
+
+#ifdef USE_LDAP_DB
+ return pdb_sam_to_smb(_getsam21pwuid(smb_userid));
+#endif /* USE_LDAP_DB */
+
+#ifdef USE_SMBPASS_DB
+ return _getsampwuid(smb_userid);
+#endif /* USE_SMBPASS_DB */
+}
+
+/************************************************************************
Routine to search sam passwd by rid.
*************************************************************************/
struct sam_passwd *getsam21pwrid(uint32 rid)
@@ -493,12 +486,20 @@ struct sam_passwd *getsam21pwrid(uint32 rid)
**********************************************************/
/*************************************************************
+ initialises a struct sam_disp_info.
+ **************************************************************/
+void pdb_init_dispinfo(struct sam_disp_info *user)
+{
+ if (user == NULL) return;
+ bzero(user, sizeof(*user));
+}
+
+/*************************************************************
initialises a struct smb_passwd.
**************************************************************/
void pdb_init_smb(struct smb_passwd *user)
{
if (user == NULL) return;
-
bzero(user, sizeof(*user));
user->pass_last_set_time = (time_t)-1;
}
@@ -509,7 +510,6 @@ void pdb_init_smb(struct smb_passwd *user)
void pdb_init_sam(struct sam_passwd *user)
{
if (user == NULL) return;
-
bzero(user, sizeof(*user));
user->logon_time = (time_t)-1;
user->logoff_time = (time_t)-1;
@@ -519,6 +519,24 @@ void pdb_init_sam(struct sam_passwd *user)
user->pass_must_change_time = (time_t)-1;
}
+/*************************************************************************
+ 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;
+
+ if (user == NULL) return NULL;
+
+ pdb_init_dispinfo(&disp_info);
+
+ disp_info.smb_name = user->smb_name;
+ disp_info.full_name = user->full_name;
+ disp_info.user_rid = user->user_rid;
+
+ return &disp_info;
+}
+
/*************************************************************
converts a sam_passwd structure to a smb_passwd structure.
**************************************************************/