Project

General

Profile

Download (2.93 KB) Statistics
| Branch: | Tag: | Revision:
1 cb7d18d5 Renato Botelho
#!/usr/local/bin/php-cgi -f
2 5b237745 Scott Ullrich
<?php
3
/*
4 ac24dc24 Renato Botelho
 * rc.initial.password
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
8 ac24dc24 Renato Botelho
 * All rights reserved.
9
 *
10
 * originally part of m0n0wall (http://m0n0.ch/wall)
11 c5d81585 Renato Botelho
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
12 ac24dc24 Renato Botelho
 * All rights reserved.
13
 *
14 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
15
 * you may not use this file except in compliance with the License.
16
 * You may obtain a copy of the License at
17 ac24dc24 Renato Botelho
 *
18 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
19 ac24dc24 Renato Botelho
 *
20 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
21
 * distributed under the License is distributed on an "AS IS" BASIS,
22
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
 * See the License for the specific language governing permissions and
24
 * limitations under the License.
25 ac24dc24 Renato Botelho
 */
26 5b237745 Scott Ullrich
27
	/* parse the configuration and include all functions used below */
28 2a7a9e3b Scott Ullrich
29 5b237745 Scott Ullrich
	require_once("config.inc");
30 c81ef6e2 Phil Davis
	require_once("auth.inc");
31 5b237745 Scott Ullrich
	require_once("functions.inc");
32 2a7a9e3b Scott Ullrich
	require_once("shaper.inc");
33 a78ca285 Scott Ullrich
34 5b237745 Scott Ullrich
	$fp = fopen('php://stdin', 'r');
35 a78ca285 Scott Ullrich
36 fa66bc7b Scott Ullrich
	echo "\n" . gettext('
37 bfea87ff Matthew Grooms
The webConfigurator admin password and privileges will be reset to the default (which is "' . strtolower($g['product_name']) . '").') . "\n" .
38 4e322e2c Phil Davis
	gettext('Do you want to proceed [y|n]?') . " ";
39 5b237745 Scott Ullrich
40
	if (strcasecmp(chop(fgets($fp)), "y") == 0) {
41 61422dd4 Renato Botelho
		if (isset($config['system']['webgui']['authmode']) &&
42 4e322e2c Phil Davis
		    $config['system']['webgui']['authmode'] != "Local Database") {
43 61422dd4 Renato Botelho
			echo "\n" . gettext('
44
The User manager authentication server is set to "' . $config['system']['webgui']['authmode'] . '".') . "\n" .
45 4e322e2c Phil Davis
			gettext('Do you want to set it back to Local Database [y|n]?') . " ";
46 e173dd74 Phil Davis
			if (strcasecmp(chop(fgets($fp)), "y") == 0) {
47 61422dd4 Renato Botelho
				$config['system']['webgui']['authmode'] = "Local Database";
48 e173dd74 Phil Davis
			}
49 61422dd4 Renato Botelho
		}
50 659fa7f2 Matthew Grooms
		$admin_user =& getUserEntryByUID(0);
51
		if (!$admin_user) {
52
			echo "Failed to locate the admin user account! Attempting to restore access.\n";
53
			$admin_user = array();
54
			$admin_user['uid'] = 0;
55 e173dd74 Phil Davis
			if (!is_array($config['system']['user'])) {
56 659fa7f2 Matthew Grooms
				$config['system']['user'] = array();
57 e173dd74 Phil Davis
			}
58 659fa7f2 Matthew Grooms
			$config['system']['user'][] = $admin_user;
59 af1e16c2 jim-p
			$admin_user =& getUserEntryByUID(0);
60 45ee90ed Matthew Grooms
		}
61 a78ca285 Scott Ullrich
62 659fa7f2 Matthew Grooms
		$admin_user['name'] = "admin";
63
		$admin_user['scope'] = "system";
64 bfea87ff Matthew Grooms
		$admin_user['priv'] = array("user-shell-access");
65 659fa7f2 Matthew Grooms
66 e173dd74 Phil Davis
		if (isset($admin_user['disabled'])) {
67 7d88b426 Renato Botelho
			unset($admin_user['disabled']);
68 e173dd74 Phil Davis
		}
69 7d88b426 Renato Botelho
70 9c20c034 jim-p
		if (isset($admin_user['expires'])) {
71
			unset($admin_user['expires']);
72
		}
73
74 659fa7f2 Matthew Grooms
		local_user_set_password($admin_user, strtolower($g['product_name']));
75
		local_user_set($admin_user);
76
		write_config(gettext("password changed from console menu"));
77
78 fa66bc7b Scott Ullrich
		echo "\n" . gettext('
79 4e322e2c Phil Davis
The password for the webConfigurator has been reset and
80 fa66bc7b Scott Ullrich
the default username has been set to "admin".') . "\n" .
81
		gettext('
82 5b237745 Scott Ullrich
Remember to set the password to something else than
83 fa66bc7b Scott Ullrich
the default as soon as you have logged into the webConfigurator.') . "\n" .
84
		gettext("Press ENTER to continue.");
85 a78ca285 Scott Ullrich
86 5b237745 Scott Ullrich
		fgets($fp);
87
	}
88 45ee90ed Matthew Grooms
?>