Project

General

Profile

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