Postfix Admin Setup Checker

Running software:

"; print "

Checking for dependencies:\n"; print "

"; if ($error != 0) { print "

Please fix the errors listed above.

"; } else { print "

Everything seems fine... attempting to create/update database structure

\n"; require_once($incpath.'/upgrade.php'); $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text']; $pAdminCreate_admin_password_text = ""; $tUsername = ''; $tMessage = ''; $lostpw_error = 0; $setuppw = ""; if (isset($CONF['setup_password'])) $setuppw = $CONF['setup_password']; if (safepost("form") == "setuppw") { # "setup password" form submitted if (safepost('setup_password') != safepost('setup_password2')) { $tMessage = "The two passwords differ!"; $lostpw_error = 1; } else { list ($lostpw_error, $lostpw_result) = check_setup_password(safepost('setup_password'), 1); $tMessage = $lostpw_result; $setuppw = "changed"; } } elseif (safepost("form") == "createadmin") { # "create admin" form submitted list ($pw_check_error, $pw_check_result) = check_setup_password(safepost('setup_password')); if ($pw_check_result != 'pass_OK') { $error += 1; $tMessage = $pw_check_result; } if($error == 0 && $pw_check_result == 'pass_OK') { if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); // XXX need to ensure domains table includes an 'ALL' entry. $table_domain = table_by_key('domain'); $r = db_query("SELECT * FROM $table_domain WHERE domain = 'ALL'"); if($r['rows'] == 0) { db_insert('domain', array('domain' => 'ALL')); // all other fields should default through the schema. } list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, array('ALL'), TRUE); if ($error != 0) { if (isset ($_POST['fUsername'])) $tUsername = escape_string ($_POST['fUsername']); } } } if ( ($setuppw == "" || $setuppw == "changeme" || safeget("lostpw") == 1 || $lostpw_error != 0) /* && $_SERVER['REQUEST_METHOD'] != "POST" */ ) { # show "create setup password" form ?>

Change setup password

Setup password
Setup password (again)

Create superadmin account

Setup password Lost password?
 
Since version 2.3 there is no requirement to delete setup.php!
\n"; print "Check the config.inc.php file for any other settings that you might need to change!
\n"; } ?>
0 (or 1), 'message => text ) */ function check_setup_password($password, $lostpw_mode = 0) { global $CONF; $error = 1; # be pessimistic $setuppw = ""; if (isset($CONF['setup_password'])) $setuppw = $CONF['setup_password']; list($confsalt, $confpass, $trash) = explode(':', $setuppw . '::'); $pass = encrypt_setup_password($password, $confsalt); if ($password == "" ) { # no password specified? $result = "Setup password must be specified
If you didn't set up a setup password yet, enter the password you want to use."; } elseif (strlen($password) < $CONF['min_password_length']) { # password too short? $result = "The setup password you entered is too short. Please choose a better one."; } elseif ($pass == $setuppw && $lostpw_mode == 0) { # correct passsword (and not asking for a new password) $result = "pass_OK"; $error = 0; } else { $pass = encrypt_setup_password($password, generate_setup_password_salt()); $result = ""; if ($lostpw_mode == 1) { $error = 0; # non-matching password is expected when the user asks for a new password } else { $result = '

Setup password not specified correctly

'; } $result .= '

If you want to use the password you entered as setup password, edit config.inc.php and set

'; $result .= "
\$CONF['setup_password'] = '$pass';
"; } return array ($error, $result); } /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?>