new job logging

This commit is contained in:
Roland Gruber 2017-10-29 15:55:00 +01:00
parent 57c169e700
commit ea30293724
1 changed files with 12 additions and 12 deletions

View File

@ -862,11 +862,11 @@ if (interface_exists('\LAM\JOB\Job', false)) {
protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) {
// skip if user is locked // skip if user is locked
if (!empty($user['userpassword'][0]) && !pwd_is_enabled($user['userpassword'][0])) { if (!empty($user['userpassword'][0]) && !pwd_is_enabled($user['userpassword'][0])) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' is locked.'); $this->jobResultLog->logDebug($user['dn'] . ' is locked.');
return; return;
} }
if ($user['shadowmax'][0] < 1) { if ($user['shadowmax'][0] < 1) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' does not expire.'); $this->jobResultLog->logDebug($user['dn'] . ' does not expire.');
return; return;
} }
@ -874,39 +874,39 @@ if (interface_exists('\LAM\JOB\Job', false)) {
// calculate time when password expires // calculate time when password expires
$lastPwdTimeUnix = $user['shadowlastchange'][0] * 3600 * 24; $lastPwdTimeUnix = $user['shadowlastchange'][0] * 3600 * 24;
$lastPwdTime = new DateTime('@' . $lastPwdTimeUnix, new DateTimeZone('UTC')); $lastPwdTime = new DateTime('@' . $lastPwdTimeUnix, new DateTimeZone('UTC'));
logNewMessage(LOG_DEBUG, "Last password change on " . $lastPwdTime->format('Y-m-d')); $this->jobResultLog->logDebug("Last password change on " . $lastPwdTime->format('Y-m-d'));
$numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0]; $numDaysToWarn = $options[$this->getConfigPrefix() . '_mailNotificationPeriod' . $jobID][0];
if (!empty($user['shadowwarning'][0]) && ($user['shadowwarning'][0] > 0)) { if (!empty($user['shadowwarning'][0]) && ($user['shadowwarning'][0] > 0)) {
$numDaysToWarn += $user['shadowwarning'][0]; $numDaysToWarn += $user['shadowwarning'][0];
} }
logNewMessage(LOG_DEBUG, "Number of days before warning " . $numDaysToWarn); $this->jobResultLog->logDebug("Number of days before warning " . $numDaysToWarn);
$numDaysToExpire = $user['shadowmax'][0]; $numDaysToExpire = $user['shadowmax'][0];
$expireTime = $lastPwdTime->add(new DateInterval('P' . $numDaysToExpire . 'D')); $expireTime = $lastPwdTime->add(new DateInterval('P' . $numDaysToExpire . 'D'));
logNewMessage(LOG_DEBUG, "Password expires on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Password expires on " . $expireTime->format('Y-m-d'));
// skip already expired accounts // skip already expired accounts
if ($expireTime <= $now) { if ($expireTime <= $now) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' already expired'); $this->jobResultLog->logDebug($user['dn'] . ' already expired');
return; return;
} }
// calculate time of notification // calculate time of notification
$notifyTime = clone $expireTime; $notifyTime = clone $expireTime;
$notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D')); $notifyTime->sub(new DateInterval('P' . $numDaysToWarn . 'D'));
$notifyTime->setTimeZone(getTimeZone()); $notifyTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Password notification on " . $notifyTime->format('Y-m-d H:i')); $this->jobResultLog->logDebug("Password notification on " . $notifyTime->format('Y-m-d H:i'));
// skip if notification is in the future // skip if notification is in the future
if ($notifyTime > $now) { if ($notifyTime > $now) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' does not need notification yet.'); $this->jobResultLog->logDebug($user['dn'] . ' does not need notification yet.');
return; return;
} }
$dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $user['dn']); $dbLastChange = $this->getDBLastPwdChangeTime($jobID, $pdo, $user['dn']);
// skip entries where mail was already sent // skip entries where mail was already sent
if ($dbLastChange == $user['shadowlastchange'][0]) { if ($dbLastChange == $user['shadowlastchange'][0]) {
logNewMessage(LOG_DEBUG, $user['dn'] . ' was already notified.'); $this->jobResultLog->logDebug($user['dn'] . ' was already notified.');
return; return;
} }
if ($isDryRun) { if ($isDryRun) {
// no action for dry run // no action for dry run
logNewMessage(LOG_NOTICE, 'Not sending email to ' . $user['dn'] . ' because of dry run.'); $this->jobResultLog->logInfo('Not sending email to ' . $user['dn'] . ' because of dry run.');
return; return;
} }
// send email // send email
@ -972,7 +972,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) { protected function checkSingleUser($jobID, $options, &$pdo, $now, $policyOptions, $user, $isDryRun) {
$expireTimeUnix = $user['shadowexpire'][0] * 3600 * 24; $expireTimeUnix = $user['shadowexpire'][0] * 3600 * 24;
$expireTime = new DateTime('@' . $expireTimeUnix, new DateTimeZone('UTC')); $expireTime = new DateTime('@' . $expireTimeUnix, new DateTimeZone('UTC'));
logNewMessage(LOG_DEBUG, "Expiration on " . $expireTime->format('Y-m-d')); $this->jobResultLog->logDebug("Expiration on " . $expireTime->format('Y-m-d'));
$delay = 0; $delay = 0;
if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) { if (!empty($options[$this->getConfigPrefix() . '_delay' . $jobID][0])) {
$delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0]; $delay = $options[$this->getConfigPrefix() . '_delay' . $jobID][0];
@ -982,7 +982,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
$actionTime->add(new DateInterval('P' . $delay . 'D')); $actionTime->add(new DateInterval('P' . $delay . 'D'));
} }
$actionTime->setTimeZone(getTimeZone()); $actionTime->setTimeZone(getTimeZone());
logNewMessage(LOG_DEBUG, "Action time on " . $actionTime->format('Y-m-d')); $this->jobResultLog->logDebug("Action time on " . $actionTime->format('Y-m-d'));
if ($actionTime <= $now) { if ($actionTime <= $now) {
$this->performAction($jobID, $options, $user, $isDryRun); $this->performAction($jobID, $options, $user, $isDryRun);
} }