From 175e598dccd042c0f8b045db45fbe3ae928a7387 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 13 Jan 1999 00:48:25 +0000 Subject: [PATCH] Fixed the "You password will expire in 0 days. Would you like to change it now?" message when you login to a Samba Controlled domain. The fix is a hard coded 42 days from right now until you need to change you pasword again time (see passdb/sampassdb.c:pwdb_smb_to_sam()) Also fixed getsmbfilepwent() so that it will read in the last password change time correctly. * Related to this lib/util_pwdb.c:StrnCaseCmp() returns 0 if the strings match. Chouldn't this be the pther way? Oh well. I didn't change the return code as it was used in several other cases (see lib/util_pwdb.c:pwdb_get_last_set_time()) --- source/passdb/sampassdb.c | 27 ++++++++++++++++++++++++++- source/passdb/smbpass.c | 4 ++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/source/passdb/sampassdb.c b/source/passdb/sampassdb.c index 13b1279b2b7..a76701a367b 100644 --- a/source/passdb/sampassdb.c +++ b/source/passdb/sampassdb.c @@ -360,6 +360,8 @@ struct sam_passwd *pwdb_smb_to_sam(struct smb_passwd *user) static struct sam_passwd pw_buf; static fstring nt_name; static fstring unix_name; + static time_t t; + static int time_count = 0; if (user == NULL) return NULL; @@ -374,7 +376,30 @@ struct sam_passwd *pwdb_smb_to_sam(struct smb_passwd *user) pw_buf.smb_passwd = user->smb_passwd; pw_buf.smb_nt_passwd = user->smb_nt_passwd; pw_buf.acct_ctrl = user->acct_ctrl; - unix_to_nt_time(&pw_buf.pass_last_set_time, user->pass_last_set_time); + + /* Just update the time counter every 1,000 times though this function */ + switch (time_count) { + case 0: + DEBUG(3, ("Called time() in smb_to_sam function\n")); + time (&t); + time_count++; + break; + case 1000: + time_count = 0; + break; + default: + time_count++; + break; + } + + if ( user->pass_last_set_time == (time_t)-1 ) + { + user->pass_last_set_time = t; + } + unix_to_nt_time(&pw_buf.pass_last_set_time, user->pass_last_set_time); + unix_to_nt_time(&pw_buf.pass_can_change_time , user->pass_last_set_time); + unix_to_nt_time(&pw_buf.pass_must_change_time, t+3628800); + return &pw_buf; } diff --git a/source/passdb/smbpass.c b/source/passdb/smbpass.c index 8972351d90e..b1ca9ad0717 100644 --- a/source/passdb/smbpass.c +++ b/source/passdb/smbpass.c @@ -208,6 +208,10 @@ static struct smb_passwd *getsmbfilepwent(void *vp) } /* Now try and get the last change time. */ + while (*p != ']' && *p != ':') + { + p++; + } if (*p == ']') { p++; -- 2.11.4.GIT