Пример #1
0
function gmirror_process_updatenotification($mode, $data)
{
    global $config;
    $retval = 0;
    switch ($mode) {
        case UPDATENOTIFY_MODE_NEW:
            $retval |= rc_exec_service("geom load mirror");
            $retval |= disks_raid_gmirror_configure($data);
            break;
        case UPDATENOTIFY_MODE_MODIFIED:
            $retval |= rc_exec_service("geom start mirror");
            break;
        case UPDATENOTIFY_MODE_DIRTY:
            $retval |= disks_raid_gmirror_delete($data);
            if (is_array($config['gmirror']['vdisk'])) {
                $index = array_search_ex($data, $config['gmirror']['vdisk'], "uuid");
                if (false !== $index) {
                    unset($config['gmirror']['vdisk'][$index]);
                    write_config();
                }
            }
            break;
    }
    return $retval;
}
Пример #2
0
function routes_process_updatenotification($mode, $data)
{
    global $config;
    $retval = 0;
    switch ($mode) {
        case UPDATENOTIFY_MODE_NEW:
        case UPDATENOTIFY_MODE_MODIFIED:
            break;
        case UPDATENOTIFY_MODE_DIRTY:
            $cnid = array_search_ex($data, $config['staticroutes']['route'], "uuid");
            if (FALSE !== $index) {
                rc_exec_service("routing delete conf_" . strtr($config['staticroutes']['route'][$cnid]['uuid'], "-", "_"));
                unset($config['staticroutes']['route'][$cnid]);
                write_config();
            }
            break;
    }
    return $retval;
}
Пример #3
0
        $config['ad']['domainname_dns'] = $_POST['domainname_dns'];
        $config['ad']['domainname_netbios'] = $_POST['domainname_netbios'];
        $config['ad']['username'] = $_POST['username'];
        $config['ad']['password'] = $_POST['password'];
        $config['ad']['enable'] = isset($_POST['enable']) ? true : false;
        if ($config['ad']['enable']) {
            $config['samba']['enable'] = true;
            $config['samba']['security'] = "ads";
            $config['samba']['workgroup'] = $_POST['domainname_netbios'];
        }
        write_config();
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            config_lock();
            rc_exec_service("pam");
            rc_exec_service("ldap");
            rc_start_service("nsswitch");
            rc_update_service("samba");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
    }
}
include "fbegin.inc";
?>
<script type="text/javascript">
<!--
function enable_change(enable_change) {
	var endis = !(document.iform.enable.checked || enable_change);
	document.iform.domaincontrollername.disabled = endis;
	document.iform.domainname_dns.disabled = endis;
Пример #4
0
	The views and conclusions contained in the software and documentation are those
	of the authors and should not be interpreted as representing official policies,
	either expressed or implied, of the NAS4Free Project.
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Services"), gettext("Rsync"), gettext("Local"));
if ($_POST) {
    $pconfig = $_POST;
    if (isset($_POST['apply']) && $_POST['apply']) {
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("rsynclocal", "rsynclocal_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("rsync_local");
            $retval |= rc_update_service("cron");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if ($retval == 0) {
            updatenotify_delete("rsynclocal");
        }
    }
}
if (!isset($config['rsync']) || !is_array($config['rsync'])) {
    $config['rsync'] = array();
    if (!isset($config['rsync']['rsynclocal']) || !is_array($config['rsync']['rsynclocal'])) {
        $config['rsync']['rsynclocal'] = array();
    }
} else {
Пример #5
0
                $config['kerberos']['ldapauxparam'][] = $auxparam;
            }
        }
        unset($config['kerberos']['sssdauxparam']);
        foreach (explode("\n", $_POST['sssdauxparam']) as $auxparam) {
            $auxparam = trim($auxparam, "\t\n\r");
            if (!empty($auxparam)) {
                $config['kerberos']['sssdauxparam'][] = $auxparam;
            }
        }
        $config['kerberos']['enable'] = isset($_POST['enable']) ? true : false;
        write_config();
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            config_lock();
            rc_exec_service("kerberos");
            $retval |= rc_update_service("sssd");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
    }
}
include "fbegin.inc";
?>
<script type="text/javascript">
<!--
var types = [ 'sss', 'ldap' ];

function enable_change(enable_change) {
	var endis = !(document.iform.enable.checked || enable_change);
	document.iform.kdc.disabled = endis;
Пример #6
0
	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

	The views and conclusions contained in the software and documentation are those
	of the authors and should not be interpreted as representing official policies,
	either expressed or implied, of the NAS4Free Project.
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("System"), gettext("Advanced"), gettext("rc.conf"));
if ($_POST) {
    if (isset($_POST['apply']) && $_POST['apply']) {
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("rcconf", "rcconf_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("rcconf");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if ($retval == 0) {
            updatenotify_delete("rcconf");
        }
    }
}
if (!isset($config['system']['rcconf']['param']) || !is_array($config['system']['rcconf']['param'])) {
    $config['system']['rcconf']['param'] = array();
}
array_sort_key($config['system']['rcconf']['param'], "name");
$a_rcvar =& $config['system']['rcconf']['param'];
if (isset($_GET['act']) && $_GET['act'] === "del") {
    if ($_GET['uuid'] === "all") {
Пример #7
0
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Access"), gettext("Users"));
if ($_POST) {
    $pconfig = $_POST;
    if ($_POST['apply']) {
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("userdb_user", "userdbuser_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("userdb");
            $retval |= rc_exec_service("websrv_htpasswd");
            $retval |= rc_exec_service("webfm");
            if (isset($config['samba']['enable'])) {
                $retval |= rc_exec_service("smbpasswd");
                $retval |= rc_update_service("samba");
            }
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if ($retval == 0) {
            updatenotify_delete("userdb_user");
        }
    }
}
if (!is_array($config['access']['user'])) {
    $config['access']['user'] = array();
}
array_sort_key($config['access']['user'], "login");
$a_user =& $config['access']['user'];
Пример #8
0
        $config['system']['tune'] = $_POST['tune_enable'] ? true : false;
        $config['system']['zeroconf'] = $_POST['zeroconf'] ? true : false;
        $config['system']['powerd'] = $_POST['powerd'] ? true : false;
        $config['system']['motd'] = base64_encode($_POST['motd']);
        // Encode string, otherwise line breaks will get lost
        $config['system']['sysconsaver']['enable'] = $_POST['sysconsaver'] ? true : false;
        $config['system']['sysconsaver']['blanktime'] = $_POST['sysconsaverblanktime'];
        $config['system']['enableserialconsole'] = $_POST['enableserialconsole'] ? true : false;
        write_config();
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            config_lock();
            $retval |= rc_exec_service("rcconf.sh");
            $retval |= rc_update_service("powerd");
            $retval |= rc_update_service("mdnsresponder");
            $retval |= rc_exec_service("motd");
            if (isset($config['system']['tune'])) {
                $retval |= rc_update_service("sysctl");
            }
            $retval |= rc_update_service("syscons");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
    }
}
function sysctl_tune($mode)
{
    global $config;
    if (!is_array($config['system']['sysctl']['param'])) {
        $config['system']['sysctl']['param'] = array();
    }
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Access"), gettext("Groups"));
if ($_POST) {
    $pconfig = $_POST;
    if ($_POST['apply']) {
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("userdb_group", "userdbgroup_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("userdb");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if ($retval == 0) {
            updatenotify_delete("userdb_group");
        }
    }
}
if (!is_array($config['access']['group'])) {
    $config['access']['group'] = array();
}
array_sort_key($config['access']['group'], "name");
$a_group_conf =& $config['access']['group'];
$a_group = system_get_group_list();
if ($_GET['act'] === "del") {
Пример #10
0
        $input_errors[] = gettext("The new password does not match. Please ensure the passwords match exactly.");
    }
    // Check Webserver document root if auth is required
    if (isset($config['websrv']['enable']) && isset($config['websrv']['authentication']['enable']) && !is_dir($config['websrv']['documentroot'])) {
        $input_errors[] = gettext("Webserver document root is missing.");
    }
    if (empty($input_errors)) {
        $config['system']['password'] = mkpasswd($_POST['password_new']);
        write_config();
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            config_lock();
            $retval |= rc_exec_service("userdb");
            $retval |= rc_exec_service("htpasswd");
            $retval |= rc_exec_service("websrv_htpasswd");
            $retval |= rc_exec_service("fmperm");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
    }
}
include "fbegin.inc";
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
    <td class="tabnavtbl">
      <ul id="tabnav">
      	<li class="tabinact"><a href="system.php"><span><?php 
echo gettext("General");
?>
</span></a></li>
Пример #11
0
 }
 if (empty($input_errors)) {
     $config['system']['email']['server'] = $_POST['server'];
     $config['system']['email']['port'] = $_POST['port'];
     $config['system']['email']['auth'] = isset($_POST['auth']) ? true : false;
     $config['system']['email']['authmethod'] = $_POST['authmethod'];
     $config['system']['email']['security'] = $_POST['security'];
     $config['system']['email']['starttls'] = isset($_POST['starttls']) ? true : false;
     $config['system']['email']['username'] = $_POST['username'];
     $config['system']['email']['password'] = $_POST['password'];
     $config['system']['email']['from'] = $_POST['from'];
     write_config();
     $retval = 0;
     if (!file_exists($d_sysrebootreqd_path)) {
         config_lock();
         $retval |= rc_exec_service("msmtp");
         config_unlock();
     }
     // Send test email.
     if (stristr($_POST['Submit'], gettext("Send test email"))) {
         $subject = sprintf(gettext("Test email from host: %s"), system_get_hostname());
         $message = gettext("This email has been sent to validate your email configuration.");
         $retval = @email_send($config['system']['email']['from'], $subject, $message, $error);
         if (0 == $retval) {
             $savemsg = gettext("Test email successfully sent.");
             write_log(sprintf(gettext("Test email successfully sent to: %s."), $config['system']['email']['from']));
         } else {
             $failmsg = sprintf(gettext("Failed to send test email. Please check the <a href='%s'>log</a> files."), "diag_log.php");
             write_log(sprintf(gettext("Failed to send test email to: %s."), $config['system']['email']['from']));
         }
     } else {
Пример #12
0
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Access"), gettext("Users"));
if ($_POST) {
    $pconfig = $_POST;
    if (isset($_POST['apply']) && $_POST['apply']) {
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("userdb_user", "userdbuser_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("userdb");
            $retval |= rc_exec_service("websrv_htpasswd");
            $retval |= rc_exec_service("fmperm");
            if (isset($config['samba']['enable'])) {
                $retval |= rc_exec_service("passdb");
                $retval |= rc_update_service("samba");
            }
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if ($retval == 0) {
            updatenotify_delete("userdb_user");
        }
    }
}
if (!isset($config['access']['user']) || !is_array($config['access']['user'])) {
    $config['access']['user'] = array();
}
array_sort_key($config['access']['user'], "login");
$a_user =& $config['access']['user'];
Пример #13
0
    		foreach ($rawdata as $line) {
    			echo htmlspecialchars($line)."\n";
    		}
    */
    $handle = popen("{$cmd} 2>&1", "r");
    while (!feof($handle)) {
        $line = fgets($handle);
        echo htmlspecialchars($line);
        ob_flush();
        flush();
    }
    $result = pclose($handle);
    echo '</pre>';
    if ($result == 0) {
        rename("/var/etc/smb4.conf", "{$path}/smb4.conf.created");
        rc_exec_service("resolv");
    }
}
?>
	<div id="remarks">
	  <?php 
html_remark("note", gettext("Note"), sprintf("<div id='enumeration'><ul><li>%s</li><li>%s</li><li>%s</li></ul></div>", gettext("All data in the path is overwritten. To avoid invalid data/permission, using empty UFS directory is recommended."), sprintf(gettext("Check <a href=\"%s\">System|General Setup</a> before initializing."), "system.php"), ""));
?>
	</div>
	<?php 
include "formend.inc";
?>
      </form>
    </td>
  </tr>
</table>
Пример #14
0
        $input_errors[] = gettext("The confimed password does not match. Please ensure the passwords match exactly.");
    }
    // Check Webserver document root if auth is required
    if (isset($config['websrv']['enable']) && isset($config['websrv']['authentication']['enable']) && !is_dir($config['websrv']['documentroot'])) {
        $input_errors[] = gettext("Webserver document root is missing.");
    }
    if (!$input_errors) {
        $config['system']['password'] = $_POST['password_new'];
        write_config();
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            config_lock();
            $retval |= rc_exec_service("userdb");
            $retval |= rc_exec_service("htpasswd");
            $retval |= rc_exec_service("websrv_htpasswd");
            $retval |= rc_exec_service("webfm");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
    }
}
include "fbegin.inc";
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
    <td class="tabnavtbl">
      <ul id="tabnav">
      	<li class="tabinact"><a href="system.php"><span><?php 
echo gettext("General");
?>
</span></a></li>
Пример #15
0
                        if (!isset($config['interfaces'][$ifname]['descr'])) {
                            $config['interfaces'][$ifname]['descr'] = strtoupper($ifname);
                        }
                    }
                }
            }
        }
        write_config();
        touch($d_sysrebootreqd_path);
    }
}
if (isset($_GET['act']) && $_GET['act'] == "del") {
    $id = $_GET['id'];
    $ifn = $config['interfaces'][$id]['if'];
    // Stop interface.
    rc_exec_service("netif stop {$ifn}");
    // Remove ifconfig_xxx and ipv6_ifconfig_xxx entries.
    mwexec("/usr/local/sbin/rconf attribute remove 'ifconfig_{$ifn}'");
    mwexec("/usr/local/sbin/rconf attribute remove 'ipv6_ifconfig_{$ifn}'");
    unset($config['interfaces'][$id]);
    /* delete the specified OPTn */
    /* shift down other OPTn interfaces to get rid of holes */
    $i = substr($id, 3);
    /* the number of the OPTn port being deleted */
    $i++;
    /* look at the following OPTn ports */
    while (isset($config['interfaces']['opt' . $i]) && is_array($config['interfaces']['opt' . $i])) {
        $config['interfaces']['opt' . ($i - 1)] = $config['interfaces']['opt' . $i];
        if ($config['interfaces']['opt' . ($i - 1)]['descr'] == "OPT" . $i) {
            $config['interfaces']['opt' . ($i - 1)]['descr'] = "OPT" . ($i - 1);
        }
        $rsyncclient['options']['xattrs'] = $_POST['xattrs'] ? true : false;
        $rsyncclient['options']['extraoptions'] = $_POST['extraoptions'];
        if (isset($uuid) && FALSE !== $cnid) {
            $a_rsyncclient[$cnid] = $rsyncclient;
            $mode = UPDATENOTIFY_MODE_MODIFIED;
        } else {
            $a_rsyncclient[] = $rsyncclient;
            $mode = UPDATENOTIFY_MODE_NEW;
        }
        updatenotify_set("rsyncclient", $mode, $rsyncclient['uuid']);
        write_config();
        if (stristr($_POST['Submit'], gettext("Execute now"))) {
            $retval = 0;
            // Update scripts and execute it.
            config_lock();
            $retval |= rc_exec_service("rsync_client");
            $retval |= rc_exec_script("/var/run/rsync_client_{$rsyncclient['uuid']}.sh");
            config_unlock();
            $savemsg = get_std_save_message($retval);
        } else {
            header("Location: services_rsyncd_client.php");
            exit;
        }
    }
}
include "fbegin.inc";
?>
<script type="text/javascript">
<!--
function set_selected(name) {
	document.getElementsByName(name)[1].checked = true;
Пример #17
0
            unset($config['system']['hostsacl']['rule']);
            foreach (explode("\n", $_POST['hostsacl']) as $rule) {
                $rule = trim($rule, "\t\n\r");
                if (!empty($rule)) {
                    $config['system']['hostsacl']['rule'][] = $rule;
                }
            }
            write_config();
        }
    }
    if (isset($_POST['apply']) && $_POST['apply'] || isset($_POST['Submit']) && $_POST['Submit']) {
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("hosts", "hosts_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("hosts");
            // Update /etc/hosts
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if ($retval == 0) {
            updatenotify_delete("hosts");
        }
    }
}
if (!isset($config['system']['hosts']) || !is_array($config['system']['hosts'])) {
    $config['system']['hosts'] = array();
}
if (!isset($config['system']['hostsacl']['rule']) || !is_array($config['system']['hostsacl']['rule'])) {
    $config['system']['hostsacl']['rule'] = array();
}
Пример #18
0
        $config['websrv']['authentication']['enable'] = isset($_POST['authentication']) ? true : false;
        $config['websrv']['dirlisting'] = isset($_POST['dirlisting']) ? true : false;
        // Write additional parameters.
        unset($config['websrv']['auxparam']);
        foreach (explode("\n", $_POST['auxparam']) as $auxparam) {
            $auxparam = trim($auxparam, "\t\n\r");
            if (!empty($auxparam)) {
                $config['websrv']['auxparam'][] = $auxparam;
            }
        }
        write_config();
        $retval = 0;
        if (!file_exists($d_sysrebootreqd_path)) {
            $retval |= updatenotify_process("websrvauth", "websrvauth_process_updatenotification");
            config_lock();
            $retval |= rc_exec_service("websrv_htpasswd");
            $retval |= rc_update_service("websrv");
            config_unlock();
        }
        $savemsg = get_std_save_message($retval);
        if (0 == $retval) {
            updatenotify_delete("websrvauth");
        }
    }
}
if (isset($_GET['act']) && $_GET['act'] === "del") {
    updatenotify_set("websrvauth", UPDATENOTIFY_MODE_DIRTY, $_GET['uuid']);
    header("Location: services_websrv.php");
    exit;
}
function websrvauth_process_updatenotification($mode, $data)
Пример #19
0
     // XXX shoud be fixed for more better way
     touch($d_sysrebootreqd_path);
 }
 if ($config['system']['webgui']['certificate'] != $oldcert || $config['system']['webgui']['privatekey'] != $oldkey) {
     touch($d_sysrebootreqd_path);
 }
 $retval = 0;
 if (!file_exists($d_sysrebootreqd_path)) {
     config_lock();
     $retval |= rc_exec_service("rcconf");
     $retval |= rc_exec_service("timezone");
     $retval |= rc_exec_service("resolv");
     $retval |= rc_exec_service("hosts");
     $retval |= rc_restart_service("hostname");
     $retval |= rc_exec_service("userdb");
     $retval |= rc_exec_service("htpasswd");
     $retval |= rc_update_service("ntpdate");
     $retval |= rc_update_service("mdnsresponder");
     $retval |= rc_update_service("bsnmpd");
     $retval |= rc_update_service("cron");
     config_unlock();
 }
 if ($pconfig['systime'] !== "Not Set" && !empty($pconfig['systime'])) {
     $timestamp = strtotime($pconfig['systime']);
     if (FALSE !== $timestamp) {
         $timestamp = strftime("%g%m%d%H%M", $timestamp);
         // The date utility exits 0 on success, 1 if unable to set the date,
         // and 2 if able to set the local date, but unable to set it globally.
         $retval |= mwexec("/bin/date -n {$timestamp}");
         $pconfig['systime'] = "Not Set";
     }