diff --git a/lam/lib/profiles.inc b/lam/lib/profiles.inc index 431d7148..151a8018 100644 --- a/lam/lib/profiles.inc +++ b/lam/lib/profiles.inc @@ -79,7 +79,8 @@ function getHostProfiles() { // loads an user profile with name $profile (without .pru) // the return value is an account object -function loadUserProfile($profile) { +// if $timestamps is true, smb_pwdcanchange and smb_pwdmustchange are returned as timestamp +function loadUserProfile($profile, $timestamps=True) { if (!eregi("^([0-9]|[a-z]|-|_)*$", $profile)) exit; $acc = new account(); $file = substr(__FILE__, 0, strlen(__FILE__) - 17) . "/config/profiles/users/" . $profile . ".pru"; @@ -126,16 +127,8 @@ function loadUserProfile($profile) { $acc->unix_pwdmaxage = chop(substr($line, 16, strlen($line)-16)); continue; } - if (substr($line, 0, 20) == "unix_pwdexpire_day: ") { - $acc->unix_pwdexpire_day = chop(substr($line, 20, strlen($line)-20)); - continue; - } - if (substr($line, 0, 20) == "unix_pwdexpire_mon: ") { - $acc->unix_pwdexpire_mon = chop(substr($line, 20, strlen($line)-20)); - continue; - } - if (substr($line, 0, 20) == "unix_pwdexpire_yea: ") { - $acc->unix_pwdexpire_yea = chop(substr($line, 20, strlen($line)-20)); + if (substr($line, 0, 16) == "unix_pwdexpire: ") { + $acc->unix_pwdexpire = chop(substr($line, 16, strlen($line)-16)); continue; } if (substr($line, 0, 18) == "unix_deactivated: ") { @@ -150,6 +143,10 @@ function loadUserProfile($profile) { $acc->smb_useunixpwd = chop(substr($line, 16, strlen($line)-16)); continue; } + if (substr($line, 0, 12) == "smb_flagsD: ") { + $acc->smb_flagsD = chop(substr($line, 12, strlen($line)-12)); + continue; + } if (substr($line, 0, 18) == "smb_pwdcanchange: ") { $acc->smb_pwdcanchange = chop(substr($line, 18, strlen($line)-18)); continue; @@ -184,6 +181,11 @@ function loadUserProfile($profile) { } } fclose($file); + // set timestamps if needed + if ($timestamps) { + $acct->smb_pwdcanchange = ($acct->smb_pwdcanchange * 86400) + time(); + $acct->smb_pwdmustchange = ($acct->smb_pwdmustchange * 86400) + time(); + } } else { StatusMessage("ERROR", "", _("Unable to load profile! ") . $file); @@ -218,62 +220,6 @@ function loadHostProfile($profile) { $acc->general_group = chop(substr($line, 15, strlen($line)-15)); continue; } - if (substr($line, 0, 18) == "general_groupadd: ") { - $acc->general_groupadd = explode(";", chop(substr($line, 18, strlen($line)-18))); - continue; - } - if (substr($line, 0, 18) == "unix_password_no: ") { - $acc->unix_password_no = chop(substr($line, 18, strlen($line)-18)); - continue; - } - if (substr($line, 0, 14) == "unix_pwdwarn: ") { - $acc->unix_pwdwarn = chop(substr($line, 14, strlen($line)-14)); - continue; - } - if (substr($line, 0, 20) == "unix_pwdallowlogin: ") { - $acc->unix_pwdallowlogin = chop(substr($line, 20, strlen($line)-20)); - continue; - } - if (substr($line, 0, 16) == "unix_pwdminage: ") { - $acc->unix_pwdminage = chop(substr($line, 16, strlen($line)-16)); - continue; - } - if (substr($line, 0, 16) == "unix_pwdmaxage: ") { - $acc->unix_pwdmaxage = chop(substr($line, 16, strlen($line)-16)); - continue; - } - if (substr($line, 0, 20) == "unix_pwdexpire_day: ") { - $acc->unix_pwdexpire_day = chop(substr($line, 20, strlen($line)-20)); - continue; - } - if (substr($line, 0, 20) == "unix_pwdexpire_mon: ") { - $acc->unix_pwdexpire_mon = chop(substr($line, 20, strlen($line)-20)); - continue; - } - if (substr($line, 0, 20) == "unix_pwdexpire_yea: ") { - $acc->unix_pwdexpire_yea = chop(substr($line, 20, strlen($line)-20)); - continue; - } - if (substr($line, 0, 18) == "unix_deactivated: ") { - $acc->unix_deactivated = chop(substr($line, 18, strlen($line)-18)); - continue; - } - if (substr($line, 0, 17) == "smb_password_no: ") { - $acc->smb_password_no = chop(substr($line, 17, strlen($line)-17)); - continue; - } - if (substr($line, 0, 16) == "smb_useunixpwd: ") { - $acc->smb_useunixpwd = chop(substr($line, 16, strlen($line)-16)); - continue; - } - if (substr($line, 0, 18) == "smb_pwdcanchange: ") { - $acc->smb_pwdcanchange = chop(substr($line, 18, strlen($line)-18)); - continue; - } - if (substr($line, 0, 19) == "smb_pwdmustchange: ") { - $acc->smb_pwdmustchange = chop(substr($line, 19, strlen($line)-19)); - continue; - } if (substr($line, 0, 12) == "smb_domain: ") { $acc->smb_domain = chop(substr($line, 12, strlen($line)-12)); continue; @@ -328,12 +274,11 @@ function saveUserProfile($account, $profile) { if (isset($account->unix_pwdallowlogin)) fputs($file, "unix_pwdallowlogin: " . $account->unix_pwdallowlogin . "\n"); if (isset($account->unix_pwdminage)) fputs($file, "unix_pwdminage: " . $account->unix_pwdminage . "\n"); if (isset($account->unix_pwdmaxage)) fputs($file, "unix_pwdmaxage: " . $account->unix_pwdmaxage . "\n"); - if (isset($account->unix_pwdexpire_day)) fputs($file, "unix_pwdexpire_day: " . $account->unix_pwdexpire_day . "\n"); - if (isset($account->unix_pwdexpire_mon)) fputs($file, "unix_pwdexpire_mon: " . $account->unix_pwdexpire_mon . "\n"); - if (isset($account->unix_pwdexpire_yea)) fputs($file, "unix_pwdexpire_yea: " . $account->unix_pwdexpire_yea . "\n"); + if (isset($account->unix_pwdexpire)) fputs($file, "unix_pwdexpire: " . $account->unix_pwdexpire . "\n"); if (isset($account->unix_deactivated)) fputs($file, "unix_deactivated: " . $account->unix_deactivated . "\n"); if (isset($account->smb_password_no)) fputs($file, "smb_password_no: " . $account->smb_password_no . "\n"); if (isset($account->smb_useunixpwd)) fputs($file, "smb_useunixpwd: " . $account->smb_useunixpwd . "\n"); + if (isset($account->smb_flagsD)) fputs($file, "smb_flagsD: " . $account->smb_flagsD . "\n"); if (isset($account->smb_pwdcanchange)) fputs($file, "smb_pwdcanchange: " . $account->smb_pwdcanchange . "\n"); if (isset($account->smb_pwdmustchange)) fputs($file, "smb_pwdmustchange: " . $account->smb_pwdmustchange . "\n"); if (isset($account->smb_homedrive)) fputs($file, "smb_homedrive: " . $account->smb_homedrive . "\n"); @@ -364,20 +309,6 @@ function saveHostProfile($account, $profile) { $file = fopen($path, "w"); // write attributes if (isset($account->general_group)) fputs($file, "general_group: " . $account->general_group . "\n"); - if (isset($account->general_groupadd)) fputs($file, "general_groupadd: " . implode(";", $account->general_groupadd) . "\n"); - if (isset($account->unix_password_no)) fputs($file, "unix_password_no: " . $account->unix_password_no . "\n"); - if (isset($account->unix_pwdwarn)) fputs($file, "unix_pwdwarn: " . $account->unix_pwdwarn . "\n"); - if (isset($account->unix_pwdallowlogin)) fputs($file, "unix_pwdallowlogin: " . $account->unix_pwdallowlogin . "\n"); - if (isset($account->unix_pwdminage)) fputs($file, "unix_pwdminage: " . $account->unix_pwdminage . "\n"); - if (isset($account->unix_pwdmaxage)) fputs($file, "unix_pwdmaxage: " . $account->unix_pwdmaxage . "\n"); - if (isset($account->unix_pwdexpire_day)) fputs($file, "unix_pwdexpire_day: " . $account->unix_pwdexpire_day . "\n"); - if (isset($account->unix_pwdexpire_mon)) fputs($file, "unix_pwdexpire_mon: " . $account->unix_pwdexpire_mon . "\n"); - if (isset($account->unix_pwdexpire_yea)) fputs($file, "unix_pwdexpire_yea: " . $account->unix_pwdexpire_yea . "\n"); - if (isset($account->unix_deactivated)) fputs($file, "unix_deactivated: " . $account->unix_deactivated . "\n"); - if (isset($account->smb_password_no)) fputs($file, "smb_password_no: " . $account->smb_password_no . "\n"); - if (isset($account->smb_useunixpwd)) fputs($file, "smb_useunixpwd: " . $account->smb_useunixpwd . "\n"); - if (isset($account->smb_pwdcanchange)) fputs($file, "smb_pwdcanchange: " . $account->smb_pwdcanchange . "\n"); - if (isset($account->smb_pwdmustchange)) fputs($file, "smb_pwdmustchange: " . $account->smb_pwdmustchange . "\n"); if (isset($account->smb_domain)) fputs($file, "smb_domain: " . $account->smb_domain . "\n"); // close file fclose($file); diff --git a/lam/templates/profedit/profilecreate.php b/lam/templates/profedit/profilecreate.php index 53c5cf5a..75d3e727 100644 --- a/lam/templates/profedit/profilecreate.php +++ b/lam/templates/profedit/profilecreate.php @@ -113,27 +113,11 @@ if ($_GET['type'] == "user") { echo ("

" . _("Back to Profile Editor") . ""); exit; } - if ($_POST['unix_pwdexpire_day'] && is_numeric($_POST['unix_pwdexpire_day'])) { - $acct->unix_pwdexpire_day = $_POST['unix_pwdexpire_day']; + if (is_numeric($_POST['unix_pwdexpire_day']) && is_numeric($_POST['unix_pwdexpire_mon']) && is_numeric($_POST['unix_pwdexpire_yea'])) { + $acct->unix_pwdexpire = mktime(0, 0, 0, $_POST['unix_pwdexpire_mon'], $_POST['unix_pwdexpire_day'], $_POST['unix_pwdexpire_yea']); } else { - StatusMessage("ERROR", "", _("Wrong parameter for password expiry day!") . " " . $_POST['unix_pwdexpire_day']); - echo ("

" . _("Back to Profile Editor") . ""); - exit; - } - if ($_POST['unix_pwdexpire_mon'] && is_numeric($_POST['unix_pwdexpire_mon'])) { - $acct->unix_pwdexpire_mon = $_POST['unix_pwdexpire_mon']; - } - else { - StatusMessage("ERROR", "", _("Wrong parameter for password expiry month!") . " " . $_POST['unix_pwdexpire_mon']); - echo ("

" . _("Back to Profile Editor") . ""); - exit; - } - if ($_POST['unix_pwdexpire_yea'] && is_numeric($_POST['unix_pwdexpire_yea'])) { - $acct->unix_pwdexpire_yea = $_POST['unix_pwdexpire_yea']; - } - else { - StatusMessage("ERROR", "", _("Wrong parameter for password expiry year!") . " " . $_POST['unix_pwdexpire_yea']); + StatusMessage("ERROR", "", _("Wrong parameter for Unix password expiry!")); echo ("

" . _("Back to Profile Editor") . ""); exit; } @@ -157,7 +141,7 @@ if ($_GET['type'] == "user") { $acct->smb_password_no = $_POST['smb_password_no']; } else { - StatusMessage("ERROR", "", _("Wrong parameter for Samba option: no password!") . " " . $_POST['smb_password_no']); + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: Set Samba Password!") . " " . $_POST['smb_password_no']); echo ("

" . _("Back to Profile Editor") . ""); exit; } @@ -165,11 +149,19 @@ if ($_GET['type'] == "user") { $acct->smb_useunixpwd = $_POST['smb_useunixpwd']; } else { - StatusMessage("ERROR", "", _("Wrong parameter for Samba option: use Unix password!") . " " . $_POST['smb_useunixpwd']); + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: Set Unix Password for Samba!") . " " . $_POST['smb_useunixpwd']); echo ("

" . _("Back to Profile Editor") . ""); exit; } - if (($_POST['smb_pwdcanchange'] == "1") || ($_POST['smb_pwdcanchange'] == "0")) { + if (($_POST['smb_flagsD'] == "1") || ($_POST['smb_flagsD'] == "0")) { + $acct->smb_flagsD = $_POST['smb_flagsD']; + } + else { + StatusMessage("ERROR", "", _("Wrong parameter for Samba option: Account does not expire!") . " " . $_POST['smb_flagsD']); + echo ("

" . _("Back to Profile Editor") . ""); + exit; + } + if (!$_POST['smb_pwdcanchange'] || is_numeric($_POST['smb_pwdcanchange'])) { $acct->smb_pwdcanchange = $_POST['smb_pwdcanchange']; } else { @@ -177,7 +169,7 @@ if ($_GET['type'] == "user") { echo ("

" . _("Back to Profile Editor") . ""); exit; } - if (($_POST['smb_pwdmustchange'] == "1") || ($_POST['smb_pwdmustchange'] == "0")) { + if (!$_POST['smb_pwdmustchange'] || is_numeric($_POST['smb_pwdmustchange'])) { $acct->smb_pwdmustchange = $_POST['smb_pwdmustchange']; } else { diff --git a/lam/templates/profedit/profileuser.php b/lam/templates/profedit/profileuser.php index e5a7bb7f..9560f021 100644 --- a/lam/templates/profedit/profileuser.php +++ b/lam/templates/profedit/profileuser.php @@ -55,12 +55,21 @@ for ($i = 0; $i < sizeof($shelllist); $i++) { // check if profile should be edited if ($_GET['edit']) { - $acct = loadUserProfile($_GET['edit']); + $acct = loadUserProfile($_GET['edit'], False); } // search available groups $groups = findgroups(); +// calculate date for unix password expiry +if ($acct->unix_pwdexpire) { +$tstamp = $acct->unix_pwdexpire; +$tdate = date(dmY, $acct->unix_pwdexpire); +$unix_pwdexpire_day = substr($tdate, 0, 2); +$unix_pwdexpire_mon = substr($tdate, 2, 2); +$unix_pwdexpire_yea = substr($tdate, 4, 4); +} + // display formular echo ("
\n"); @@ -162,19 +171,19 @@ echo ("" . _("Account expires on") . ": \n"); echo ("\n"); echo ("\n"); echo ("\n"); echo (""); @@ -225,23 +234,31 @@ echo ("\n"); echo ("" . _("Help") . "\n"); echo ("\n"); +// password expires +echo ("\n"); +echo ("" . _("Password does not expire") . ": \n"); +echo ("\n"); +echo ("" . _("Help") . "\n"); +echo ("\n"); + // user can change his password echo ("\n"); echo ("" . _("User can change password") . ": \n"); -echo ("\n"); +echo ("\n"); +echo ("smb_pwdcanchange . "\">\n"); +echo ("\n"); echo ("" . _("Help") . "\n"); echo ("\n"); // user must change his password echo ("\n"); echo ("" . _("User must change password") . ": \n"); -echo ("\n"); +echo ("\n"); +echo ("smb_pwdmustchange . "\">\n"); +echo ("\n"); echo ("" . _("Help") . "\n"); echo ("\n");