Project

General

Profile

Download (2.75 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php -f
2
<?php
3 1b8df11b Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	rc.initial.password
6
	part of m0n0wall (http://m0n0.ch/wall)
7 a78ca285 Scott Ullrich
8 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 a78ca285 Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 a78ca285 Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 a78ca285 Scott Ullrich
17 5b237745 Scott Ullrich
	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 a78ca285 Scott Ullrich
21 5b237745 Scott Ullrich
	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 2a7a9e3b Scott Ullrich
35 5b237745 Scott Ullrich
	require_once("config.inc");
36 2a7a9e3b Scott Ullrich
	require("auth.inc");
37 5b237745 Scott Ullrich
	require_once("functions.inc");
38 2a7a9e3b Scott Ullrich
	require_once("shaper.inc");
39 a78ca285 Scott Ullrich
40 5b237745 Scott Ullrich
	$fp = fopen('php://stdin', 'r');
41 a78ca285 Scott Ullrich
42 fa66bc7b Scott Ullrich
	echo "\n" . gettext('
43 bfea87ff Matthew Grooms
The webConfigurator admin password and privileges will be reset to the default (which is "' . strtolower($g['product_name']) . '").') . "\n" .
44 fa66bc7b Scott Ullrich
	gettext('Do you want to proceed [y|n]?');
45 5b237745 Scott Ullrich
46
	if (strcasecmp(chop(fgets($fp)), "y") == 0) {
47 659fa7f2 Matthew Grooms
		$admin_user =& getUserEntryByUID(0);
48
		if (!$admin_user) {
49
			echo "Failed to locate the admin user account! Attempting to restore access.\n";
50
			$admin_user = array();
51
			$admin_user['uid'] = 0;
52
			if (!is_array($config['system']['user']))
53
				$config['system']['user'] = array();
54
			$config['system']['user'][] = $admin_user;
55 45ee90ed Matthew Grooms
		}
56 a78ca285 Scott Ullrich
57 659fa7f2 Matthew Grooms
		$admin_user['name'] = "admin";
58
		$admin_user['scope'] = "system";
59 bfea87ff Matthew Grooms
		$admin_user['priv'] = array("user-shell-access");
60 659fa7f2 Matthew Grooms
61
		local_user_set_password($admin_user, strtolower($g['product_name']));
62
		local_user_set($admin_user);
63
		write_config(gettext("password changed from console menu"));
64
65 fa66bc7b Scott Ullrich
		echo "\n" . gettext('
66 709cc6e0 Bill Marquette
The password for the webConfigurator has been reset and 
67 fa66bc7b Scott Ullrich
the default username has been set to "admin".') . "\n" .
68
		gettext('
69 5b237745 Scott Ullrich
Remember to set the password to something else than
70 fa66bc7b Scott Ullrich
the default as soon as you have logged into the webConfigurator.') . "\n" .
71
		gettext("Press ENTER to continue.");
72 a78ca285 Scott Ullrich
73 5b237745 Scott Ullrich
		fgets($fp);
74
	}
75 45ee90ed Matthew Grooms
?>