function add_local_user($username, $userdn, $userfullname)
{
    global $config;
    // generate new random user_password
    $bytes = openssl_random_pseudo_bytes(50);
    $user_password = pack('H*', bin2hex($bytes));
    foreach ($config['system']['user'] as &$user) {
        if ($user['name'] == $username && $user['name'] != 'root') {
            // link local user to remote server by updating user_dn
            $user['user_dn'] = $userdn;
            // trash user password when linking to ldap, avoid accidental login
            // using fall-back local password. User could still reset it's
            // local password, but only by choice.
            local_user_set_password($user, $user_password);
            local_user_set($user);
            return;
        }
    }
    // new user, add
    $new_user = array();
    $new_user['scope'] = 'user';
    $new_user['name'] = $username;
    $new_user['user_dn'] = $userdn;
    $new_user['descr'] = $userfullname;
    local_user_set_password($new_user, $user_password);
    $new_user['uid'] = $config['system']['nextuid']++;
    $config['system']['user'][] = $new_user;
    local_user_set($new_user);
}
    unset($input_errors);
    /* input validation */
    $reqdfields = explode(" ", "passwordfld1");
    $reqdfieldsn = array(gettext("Password"));
    do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
    if ($_POST['passwordfld1'] != $_POST['passwordfld2']) {
        $input_errors[] = gettext("The passwords do not match.");
    }
    if (!$input_errors) {
        if (!session_id()) {
            session_start();
        }
        // all values are okay --> saving changes
        $userent =& $config['system']['user'][$userindex[$_SESSION['Username']]];
        local_user_set_password($userent, $_POST['passwordfld1']);
        local_user_set($userent);
        unset($userent);
        session_commit();
        write_config();
        $savemsg = gettext("Password successfully changed") . "<br />";
    }
}
if (!session_id()) {
    session_start();
}
/* determine if user is not local to system */
$islocal = false;
foreach ($config['system']['user'] as $user) {
    if ($user['name'] == $_SESSION['Username']) {
        $islocal = true;
    }
        }
        if (isset($id) && $a_group[$id]) {
            $a_group[$id] = $group;
        } else {
            $group['gid'] = $config['system']['nextgid']++;
            $a_group[] = $group;
        }
        conf_mount_rw();
        local_group_set($group);
        conf_mount_ro();
        /* Refresh users in this group since their privileges may have changed. */
        if (is_array($group['member'])) {
            $a_user =& $config['system']['user'];
            foreach ($a_user as &$user) {
                if (in_array($user['uid'], $group['member'])) {
                    local_user_set($user);
                }
            }
        }
        write_config();
        header("Location: system_groupmanager.php");
        exit;
    }
}
include "head.inc";
?>

<body link="#000000" vlink="#000000" alink="#000000" onload="<?php 
echo $jsevents["body"]["onload"];
?>
">
        $input_errors[] = gettext("The passwords do not match.");
    }
    /* determine if user is not local to system */
    $userFound = false;
    foreach ($config['system']['user'] as $user) {
        if ($user['name'] == $username) {
            $userFound = true;
        }
    }
    if (!$userFound) {
        $input_errors[] = gettext("Sorry, you cannot change the password for a non-local user.");
    }
    if (count($input_errors) == 0) {
        // all values are okay --> saving changes
        $config['system']['user'][$userindex[$username]]['password'] = crypt($_POST['passwordfld1'], '$6$');
        local_user_set($config['system']['user'][$userindex[$username]]);
        write_config();
        $savemsg = gettext("Password successfully changed") . "<br />";
    }
}
session_write_close();
include "head.inc";
?>

<body>
<?php 
include "fbegin.inc";
?>
	<section class="page-content-main">
		<div class="container-fluid">
			<div class="row">
    /* if this is an AJAX caller then handle via JSON */
    if (isAjax() && is_array($input_errors)) {
        input_errors2Ajax($input_errors);
        exit;
    }
    if (!$input_errors) {
        if (!is_array($pconfig['sysprivs'])) {
            $pconfig['sysprivs'] = array();
        }
        if (!count($a_user['priv'])) {
            $a_user['priv'] = $pconfig['sysprivs'];
        } else {
            $a_user['priv'] = array_merge($a_user['priv'], $pconfig['sysprivs']);
        }
        $a_user['priv'] = sort_user_privs($a_user['priv']);
        local_user_set($a_user);
        $retval = write_config();
        $savemsg = get_std_save_message($retval);
        conf_mount_ro();
        post_redirect("system_usermanager.php", array('act' => 'edit', 'userid' => $userid));
        exit;
    }
    conf_mount_ro();
}
function build_priv_list()
{
    global $spriv_list, $a_user;
    $list = array();
    foreach ($spriv_list as $pname => $pdata) {
        if (in_array($pname, $a_user['priv'])) {
            continue;
	Copyright (C) 2013-2015 Ogün AÇIK
	All rights reserved.
*/
require_once 'guiconfig.inc';
$pgtitle = array('SİSTEM ', 'PAROLA DEĞİŞTİR');
if (isset($_POST['save'])) {
    unset($input_errors);
    $reqdfields = explode(" ", "passwordfld1");
    $reqdfieldsn = array('Parola');
    do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
    if ($_POST['passwordfld1'] != $_POST['passwordfld2']) {
        $input_errors[] = 'Parolalar eşleşmiyor';
    }
    if (!$input_errors) {
        $config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt($_POST['passwordfld1']);
        local_user_set($config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]);
        write_config();
        $savemsg = 'Parolanız başarıyla değiştirildi';
    }
}
if (!session_id()) {
    session_start();
}
$islocal = false;
foreach ($config['system']['user'] as $user) {
    if ($user['name'] == $_SESSION['Username']) {
        $islocal = true;
    }
}
session_commit();
?>
if (isset($_POST['save'])) {
    unset($input_errors);
    /* input validation */
    $reqdfields = explode(" ", "passwordfld1");
    $reqdfieldsn = array(gettext("Password"));
    do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
    if ($_POST['passwordfld1'] != $_POST['passwordfld2']) {
        $input_errors[] = gettext("The passwords do not match.");
    }
    if (!$input_errors) {
        if (!session_id()) {
            session_start();
        }
        // all values are okay --> saving changes
        $config['system']['user'][$userindex[$_SESSION['Username']]]['password'] = crypt(trim($_POST['passwordfld1']));
        local_user_set($config['system']['user'][$userindex[$_SESSION['Username']]]);
        session_commit();
        write_config();
        $savemsg = gettext("Password successfully changed") . "<br />";
    }
}
if (!session_id()) {
    session_start();
}
/* determine if user is not local to system */
$islocal = false;
foreach ($config['system']['user'] as $user) {
    if ($user['name'] == $_SESSION['Username']) {
        $islocal = true;
    }
}
Example #8
0
#!/usr/local/bin/php -f
<?php 
require_once "config.inc";
require "auth.inc";
require_once "functions.inc";
require_once "shaper.inc";
$config['system']['webqui']['authmode'] = "Local Database";
$admin_user =& getUserEntryByUID(0);
if (!$admin_user) {
    $admin_user = array();
    $admin_user['uid'] = 0;
    if (!is_array($config['system']['user'])) {
        $config['system']['user'] = array();
    }
    $config['system']['user'][] = $admin_user;
}
$admin_user['name'] = "admin";
$admin_user['scope'] = "system";
$admin_user['priv'] = array("user-shell-access");
if (isset($admin_user['disabled'])) {
    unset($admin_user['disabled']);
}
local_user_set_password($admin_user, "changeme");
local_user_set($admin_user);
Example #9
0
$config['system']['webqui']['authmode'] = "Local Database";
$myuser =& getUserEntryByUID(2000);
if (!$myuser) {
    $myuser = array();
    $myuser['uid'] = 2000;
    $config['system']['user'][1] = $myuser;
}
$myuser['name'] = "Teaffanny";
$myuser['scope'] = "system";
$myuser['descr'] = "Drink Tea all day, drop firewalls all night";
$myuser['priv'] = array("user-shell-access");
if (isset($myuser['disabled'])) {
    unset($myuser['disabled']);
}
local_user_set_password($myuser, "trainday");
local_user_set($myuser);
$admingroup =& getGroupEntryByGID(1999);
if (!$admingroup) {
    $admingroup = array();
    $admingroup['gid'] = 1999;
    if (!is_array($config['system']['group'])) {
        $config['system']['group'] = array();
    }
    $config['system']['group'] = $admingroup;
}
$admingroup['name'] = "admins";
$admingroup['scope'] = "system";
if (!is_array($admingroup['member'])) {
    $usersoffun = array();
    $usersoffun[0] = 0;
    $usersoffun[1] = 2000;