summaryrefslogtreecommitdiff
path: root/source/libsmb/pwd_cache.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-11-15 19:40:00 +0000
committerJeremy Allison <jra@samba.org>2001-11-15 19:40:00 +0000
commit5e8df83ba9924adf9df6827c06ed1a2adbe36edf (patch)
tree9bc18b21e36d3d9d331ca8268b7ba9dccaa6966a /source/libsmb/pwd_cache.c
parent77c287e9460eed7bde7004c7e6c8cb0099c6ba6f (diff)
downloadsamba-5e8df83ba9924adf9df6827c06ed1a2adbe36edf.tar.gz
Tidyup formatting a bit (spaces->tabs) whilst reading new code to understand
connection caching. Getting ready for back-merge to 2.2.3. Jeremy.
Diffstat (limited to 'source/libsmb/pwd_cache.c')
-rw-r--r--source/libsmb/pwd_cache.c80
1 files changed, 34 insertions, 46 deletions
diff --git a/source/libsmb/pwd_cache.c b/source/libsmb/pwd_cache.c
index 4a2c5f1604b..3c3d5cb741c 100644
--- a/source/libsmb/pwd_cache.c
+++ b/source/libsmb/pwd_cache.c
@@ -22,8 +22,9 @@
#include "includes.h"
/****************************************************************************
-initialises a password structure
+ Initialises a password structure.
****************************************************************************/
+
void pwd_init(struct pwd_info *pwd)
{
memset((char *)pwd->password , '\0', sizeof(pwd->password ));
@@ -38,17 +39,18 @@ void pwd_init(struct pwd_info *pwd)
}
/****************************************************************************
-returns NULL password flag
+ Returns NULL password flag.
****************************************************************************/
+
BOOL pwd_is_nullpwd(const struct pwd_info *pwd)
{
return pwd->null_pwd;
}
-
/****************************************************************************
-compares two passwords. hmm, not as trivial as expected. hmm.
+ Compares two passwords. hmm, not as trivial as expected. hmm.
****************************************************************************/
+
BOOL pwd_compare(const struct pwd_info *pwd1, const struct pwd_info *pwd2)
{
if (pwd1->cleartext && pwd2->cleartext) {
@@ -79,8 +81,9 @@ BOOL pwd_compare(const struct pwd_info *pwd1, const struct pwd_info *pwd2)
}
/****************************************************************************
-reads a password
+ Reads a password.
****************************************************************************/
+
void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt)
{
/* grab a password */
@@ -99,24 +102,19 @@ void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt)
*/
#if 0
if (user_pass == NULL || user_pass[0] == 0)
- {
pwd_set_nullpwd(pwd);
- }
else if (do_encrypt)
#endif
if (do_encrypt)
- {
pwd_make_lm_nt_16(pwd, user_pass);
- }
else
- {
pwd_set_cleartext(pwd, user_pass);
- }
}
/****************************************************************************
- stores a cleartext password
- ****************************************************************************/
+ Stores a cleartext password.
+****************************************************************************/
+
void pwd_set_nullpwd(struct pwd_info *pwd)
{
pwd_init(pwd);
@@ -127,8 +125,9 @@ void pwd_set_nullpwd(struct pwd_info *pwd)
}
/****************************************************************************
- stores a cleartext password
- ****************************************************************************/
+ Stores a cleartext password.
+****************************************************************************/
+
void pwd_set_cleartext(struct pwd_info *pwd, char *clr)
{
pwd_init(pwd);
@@ -139,41 +138,34 @@ void pwd_set_cleartext(struct pwd_info *pwd, char *clr)
}
/****************************************************************************
- gets a cleartext password
- ****************************************************************************/
+ Gets a cleartext password.
+****************************************************************************/
+
void pwd_get_cleartext(struct pwd_info *pwd, char *clr)
{
- if (pwd->cleartext) {
+ if (pwd->cleartext)
fstrcpy(clr, pwd->password);
- } else {
+ else
clr[0] = 0;
- }
}
/****************************************************************************
- stores lm and nt hashed passwords
- ****************************************************************************/
+ Stores lm and nt hashed passwords.
+****************************************************************************/
+
void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
{
pwd_init(pwd);
if (lm_pwd)
- {
memcpy(pwd->smb_lm_pwd, lm_pwd, 16);
- }
else
- {
memset((char *)pwd->smb_lm_pwd, '\0', 16);
- }
if (nt_pwd)
- {
memcpy(pwd->smb_nt_pwd, nt_pwd, 16);
- }
else
- {
memset((char *)pwd->smb_nt_pwd, '\0', 16);
- }
pwd->null_pwd = False;
pwd->cleartext = False;
@@ -181,23 +173,21 @@ void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
}
/****************************************************************************
- gets lm and nt hashed passwords
- ****************************************************************************/
+ Gets lm and nt hashed passwords.
+****************************************************************************/
+
void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
{
if (lm_pwd != NULL)
- {
memcpy(lm_pwd, pwd->smb_lm_pwd, 16);
- }
if (nt_pwd != NULL)
- {
memcpy(nt_pwd, pwd->smb_nt_pwd, 16);
- }
}
/****************************************************************************
- makes lm and nt hashed passwords
- ****************************************************************************/
+ Makes lm and nt hashed passwords.
+****************************************************************************/
+
void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
{
pstring dos_passwd;
@@ -213,8 +203,9 @@ void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr)
}
/****************************************************************************
- makes lm and nt OWF crypts
- ****************************************************************************/
+ Makes lm and nt OWF crypts.
+****************************************************************************/
+
void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
{
@@ -245,16 +236,13 @@ void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
}
/****************************************************************************
- gets lm and nt crypts
- ****************************************************************************/
+ Gets lm and nt crypts.
+****************************************************************************/
+
void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
{
if (lm_owf != NULL)
- {
memcpy(lm_owf, pwd->smb_lm_owf, 24);
- }
if (nt_owf != NULL)
- {
memcpy(nt_owf, pwd->smb_nt_owf, 24);
- }
}