1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
rc.initial.password
|
6
|
part of m0n0wall (http://m0n0.ch/wall)
|
7
|
|
8
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
9
|
All rights reserved.
|
10
|
|
11
|
Redistribution and use in source and binary forms, with or without
|
12
|
modification, are permitted provided that the following conditions are met:
|
13
|
|
14
|
1. Redistributions of source code must retain the above copyright notice,
|
15
|
this list of conditions and the following disclaimer.
|
16
|
|
17
|
2. Redistributions in binary form must reproduce the above copyright
|
18
|
notice, this list of conditions and the following disclaimer in the
|
19
|
documentation and/or other materials provided with the distribution.
|
20
|
|
21
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
POSSIBILITY OF SUCH DAMAGE.
|
31
|
*/
|
32
|
|
33
|
/* parse the configuration and include all functions used below */
|
34
|
|
35
|
require_once("config.inc");
|
36
|
require("auth.inc");
|
37
|
require_once("functions.inc");
|
38
|
require_once("shaper.inc");
|
39
|
|
40
|
$fp = fopen('php://stdin', 'r');
|
41
|
|
42
|
echo "\n" . gettext('
|
43
|
The webConfigurator admin password and privileges will be reset to the default (which is "' . strtolower($g['product_name']) . '").') . "\n" .
|
44
|
gettext('Do you want to proceed [y|n]?');
|
45
|
|
46
|
if (strcasecmp(chop(fgets($fp)), "y") == 0) {
|
47
|
if (isset($config['system']['webgui']['authmode']) &&
|
48
|
$config['system']['webgui']['authmode'] != "Local Database") {
|
49
|
echo "\n" . gettext('
|
50
|
The User manager authentication server is set to "' . $config['system']['webgui']['authmode'] . '".') . "\n" .
|
51
|
gettext('Do you want to set it back to Local Database [y|n]?');
|
52
|
if (strcasecmp(chop(fgets($fp)), "y") == 0)
|
53
|
$config['system']['webgui']['authmode'] = "Local Database";
|
54
|
}
|
55
|
$admin_user =& getUserEntryByUID(0);
|
56
|
if (!$admin_user) {
|
57
|
echo "Failed to locate the admin user account! Attempting to restore access.\n";
|
58
|
$admin_user = array();
|
59
|
$admin_user['uid'] = 0;
|
60
|
if (!is_array($config['system']['user']))
|
61
|
$config['system']['user'] = array();
|
62
|
$config['system']['user'][] = $admin_user;
|
63
|
}
|
64
|
|
65
|
$admin_user['name'] = "admin";
|
66
|
$admin_user['scope'] = "system";
|
67
|
$admin_user['priv'] = array("user-shell-access");
|
68
|
|
69
|
if (isset($admin_user['disabled']))
|
70
|
unset($admin_user['disabled']);
|
71
|
|
72
|
local_user_set_password($admin_user, strtolower($g['product_name']));
|
73
|
local_user_set($admin_user);
|
74
|
write_config(gettext("password changed from console menu"));
|
75
|
|
76
|
echo "\n" . gettext('
|
77
|
The password for the webConfigurator has been reset and
|
78
|
the default username has been set to "admin".') . "\n" .
|
79
|
gettext('
|
80
|
Remember to set the password to something else than
|
81
|
the default as soon as you have logged into the webConfigurator.') . "\n" .
|
82
|
gettext("Press ENTER to continue.");
|
83
|
|
84
|
fgets($fp);
|
85
|
}
|
86
|
?>
|