#include "includes.h"
-extern struct timeval smb_last_time;
-
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
DATA_BLOB *user_sess_key,
DATA_BLOB *lm_sess_key)
{
- uint16 acct_ctrl;
+ uint32 acct_ctrl;
const uint8 *lm_pw, *nt_pw;
const char *username = pdb_get_username(sampass);
const uint8 *hours;
struct tm *utctime;
time_t lasttime;
+ const char *asct;
uint8 bitmask, bitpos;
hours = pdb_get_hours(sampass);
return True;
}
- lasttime = (time_t)smb_last_time.tv_sec;
+ lasttime = time(NULL);
utctime = gmtime(&lasttime);
+ if (!utctime) {
+ DEBUG(1, ("logon_hours_ok: failed to get gmtime. Failing logon for user %s\n",
+ pdb_get_username(sampass) ));
+ return False;
+ }
/* find the corresponding byte and bit */
bitpos = (utctime->tm_wday * 24 + utctime->tm_hour) % 168;
bitmask = 1 << (bitpos % 8);
if (! (hours[bitpos/8] & bitmask)) {
- DEBUG(1,("logon_hours_ok: Account for user %s not allowed to logon at this time (%s).\n",
- pdb_get_username(sampass),
- asctime(localtime(&lasttime)) ));
+ struct tm *t = localtime(&lasttime);
+ if (!t) {
+ asct = "INVALID TIME";
+ } else {
+ asct = asctime(t);
+ if (!asct) {
+ asct = "INVALID TIME";
+ }
+ }
+
+ DEBUG(1, ("logon_hours_ok: Account for user %s not allowed to "
+ "logon at this time (%s).\n",
+ pdb_get_username(sampass), asct ));
return False;
}
+ asct = asctime(utctime);
DEBUG(5,("logon_hours_ok: user %s allowed to logon at this time (%s)\n",
- pdb_get_username(sampass), asctime(utctime) ));
+ pdb_get_username(sampass), asct ? asct : "UNKNOWN TIME" ));
return True;
}
struct samu *sampass,
const auth_usersupplied_info *user_info)
{
- uint16 acct_ctrl = pdb_get_acct_ctrl(sampass);
+ uint32 acct_ctrl = pdb_get_acct_ctrl(sampass);
char *workstation_list;
time_t kickoff_time;
return NT_STATUS_ACCOUNT_EXPIRED;
}
- if (!(pdb_get_acct_ctrl(sampass) & ACB_PWNOEXP)) {
+ if (!(pdb_get_acct_ctrl(sampass) & ACB_PWNOEXP) && !(pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ)) {
time_t must_change_time = pdb_get_pass_must_change_time(sampass);
time_t last_set_time = pdb_get_pass_last_set_time(sampass);
/* check for immediate expiry "must change at next logon" */
- if (must_change_time == 0 && last_set_time != 0) {
+ if (last_set_time == 0) {
DEBUG(1,("sam_account_ok: Account for user '%s' password must change!.\n", pdb_get_username(sampass)));
return NT_STATUS_PASSWORD_MUST_CHANGE;
}
BOOL ret;
NTSTATUS nt_status;
NTSTATUS update_login_attempts_status;
- DATA_BLOB user_sess_key = data_blob(NULL, 0);
- DATA_BLOB lm_sess_key = data_blob(NULL, 0);
+ DATA_BLOB user_sess_key = data_blob_null;
+ DATA_BLOB lm_sess_key = data_blob_null;
BOOL updated_autolock = False, updated_badpw = False;
if (!user_info || !auth_context) {
return NT_STATUS_UNSUCCESSFUL;
}
- /* Can't use the talloc version here, because the returned struct gets
- kept on the server_info */
+ /* the returned struct gets kept on the server_info, by means
+ of a steal further down */
- if ( !(sampass = samu_new( NULL )) ) {
+ if ( !(sampass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
}
lm_sess_key.length);
data_blob_free(&lm_sess_key);
+ (*server_info)->was_mapped |= user_info->was_mapped;
+
return nt_status;
}