summaryrefslogtreecommitdiffstats
path: root/etc/inc/config.inc
diff options
context:
space:
mode:
authorMatthew Grooms <mgrooms@pfsense.org>2008-07-25 02:28:31 +0000
committerMatthew Grooms <mgrooms@pfsense.org>2008-07-25 02:28:31 +0000
commit45ee90edb38f3c52a242d248468a992bf19f1c44 (patch)
tree14e5a6b3c6a7ff340858442dddc9241b3e8fc9a0 /etc/inc/config.inc
parent8057888036bfcacd59c9d0fcf235aba5dc65682b (diff)
downloadpfsense-45ee90edb38f3c52a242d248468a992bf19f1c44.zip
pfsense-45ee90edb38f3c52a242d248468a992bf19f1c44.tar.gz
Rewrite portions of the user manager to ensure data is properly synced to
the system password and group databases. This is to provide better support for centralized user management when local account administration is preferred. I also took this opportunity to do some housekeeping. A lot of funtions that were only being used in one place or not at all were removed. The user page privelege checks were also simplified in preperation for future work in this area.
Diffstat (limited to 'etc/inc/config.inc')
-rw-r--r--etc/inc/config.inc95
1 files changed, 77 insertions, 18 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index cb12d94..5e58689 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -1470,7 +1470,7 @@ function convert_config() {
}
/* Convert 4.7 -> 4.8 */
- if ($config['version'] <= 4.7) {
+ if ($config['version'] <= 4.7) {
$config['dyndnses']['dyndns'] = array();
if (isset($config['dyndns']['enable'])) {
$tempdyn = array();
@@ -1502,7 +1502,7 @@ function convert_config() {
$config['dnsupdates']['dnsupdate'][] = $pconfig;
unset($config['dnsupdate']);
}
-
+
if (is_array($config['pppoe'])) {
$pconfig = array();
$pconfig['username'] = $config['pppoe']['username'];
@@ -1518,28 +1518,87 @@ function convert_config() {
$config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
}
if (is_array($config['pptp'])) {
- $pconfig = array();
- $pconfig['username'] = $config['pptp']['username'];
- $pconfig['password'] = $config['pptp']['password'];
- $pconfig['provider'] = $config['pptp']['provider'];
- $pconfig['ondemand'] = isset($config['pptp']['ondemand']);
- $pconfig['timeout'] = $config['pptp']['timeout'];
- unset($config['pptp']);
- $config['interfaces']['wan']['username'] = $pconfig['username'];
- $config['interfaces']['wan']['password'] = $pconfig['password'];
- $config['interfaces']['wan']['provider'] = $pconfig['provider'];
- $config['interfaces']['wan']['username'] = isset($pconfig['ondemand']
-);
- $config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
- }
+ $pconfig = array();
+ $pconfig['username'] = $config['pptp']['username'];
+ $pconfig['password'] = $config['pptp']['password'];
+ $pconfig['provider'] = $config['pptp']['provider'];
+ $pconfig['ondemand'] = isset($config['pptp']['ondemand']);
+ $pconfig['timeout'] = $config['pptp']['timeout'];
+ unset($config['pptp']);
+ $config['interfaces']['wan']['username'] = $pconfig['username'];
+ $config['interfaces']['wan']['password'] = $pconfig['password'];
+ $config['interfaces']['wan']['provider'] = $pconfig['provider'];
+ $config['interfaces']['wan']['username'] = isset($pconfig['ondemand'] );
+ $config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
+ }
$config['version'] = 4.8;
}
+ /* Convert 4.8 -> 4.9 */
+ if ($config['version'] <= 4.8) {
+
+ /* setup new all users group */
+ $all = array();
+ $all['name'] = "all";
+ $all['description'] = "All Users";
+ $all['scope'] = "System";
+ $all['gid'] = 1998;
+ $all['member'] = array();
+
+ if (!is_array($config['system']['group']))
+ $config['system']['group'] = array();
+
+ /* work around broken uid assignments */
+ $config['system']['nextuid'] = 2000;
+ foreach ($config['system']['user'] as & $user) {
+ if (isset($user['uid']) && !$user['uid'])
+ continue;
+ $user['uid'] = $config['system']['nextuid']++;
+ }
+
+ /* work around broken gid assignments */
+ $config['system']['nextgid'] = 2000;
+ foreach ($config['system']['group'] as & $group) {
+ if ($group['name'] == $g['admin_group'])
+ $group['gid'] = 1999;
+ else
+ $group['gid'] = $config['system']['nextgid']++;
+ }
+
+ /* build group membership information */
+ foreach ($config['system']['group'] as & $group) {
+ $group['member'] = array();
+ foreach ($config['system']['user'] as & $user) {
+ $groupnames = explode(",", $user['groupname']);
+ if (in_array($group['name'],$groupnames))
+ $group['member'][] = $user['uid'];
+ }
+ }
+
+ /* reset user group information */
+ foreach ($config['system']['user'] as & $user) {
+ unset($user['groupname']);
+ $all['member'][] = $user['uid'];
+ }
+
+ /* insert new all group */
+ $groups = Array();
+ $groups[] = $all;
+ $groups = array_merge($config['system']['group'],$groups);
+ $config['system']['group'] = $groups;
+ set_local_group($all);
+
+ /* sync all local account information */
+ sync_local_accounts();
+
+ $config['version'] = 4.9;
+ }
+
$now = date("H:i:s");
log_error("Ended Configuration upgrade at $now");
-// if ($prev_version != $config['version'])
+ if ($prev_version != $config['version'])
write_config("Upgraded config version level from {$prev_version} to {$config['version']}");
}
@@ -2434,4 +2493,4 @@ function set_device_perms() {
if($g['booting']) echo ".";
$config = parse_config();
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud