Ejemplo n.º 1
0
/**
 * Added sudoers entries
 *
 * @since 2.0
 * @package facileManager
 *
 * @param string $module_name Module to add line for
 * @param string $sudoers_line Sudo lines
 * @param string $user User with permissions
 */
function addSudoersConfig($module_name, $sudoers_line, $user)
{
    $sudoers_file = findFile('sudoers');
    $sudoers_options[] = "Defaults:{$user}  !requiretty";
    $sudoers_options[] = "Defaults:{$user}  !env_reset";
    $sudoers_line = implode("\n", $sudoers_options) . "\n" . $sudoers_line;
    unset($sudoers_options);
    if (!$sudoers_file) {
        echo fM("  --> It does not appear sudo is installed.  Please install it and add the following to the sudoers file:\n");
        echo fM("\n      {$sudoers_line}\n");
        echo fM("\nInstallation aborted.\n");
        exit(1);
    } else {
        $includedir = getParameterValue('includedir', $sudoers_file, ' ');
        if ($includedir) {
            if (is_dir($includedir)) {
                $sudoers_file = $includedir . '/99_' . $module_name;
            }
        }
        $cmd = "echo '{$sudoers_line}' >> {$sudoers_file} 2>/dev/null";
        if (strpos(file_get_contents($sudoers_file), $sudoers_line) === false) {
            $sudoers_update = system($cmd, $retval);
            if ($retval) {
                echo fM("  --> The sudoers entry cannot be added.\n{$cmd}\n");
            } else {
                echo fM("  --> The sudoers entry has been added.\n");
            }
            @chmod($sudoers_file, 0440);
        } else {
            echo fM("  --> The sudoers entry already exists...skipping\n");
        }
    }
}
Ejemplo n.º 2
0
function detectChrootDir()
{
    switch (PHP_OS) {
        case 'Linux':
            $os = detectOSDistro();
            if (in_array($os, array('Redhat', 'CentOS', 'ClearOS', 'Oracle'))) {
                if ($chroot_dir = getParameterValue('^ROOTDIR', '/etc/sysconfig/named')) {
                    return $chroot_dir;
                }
            }
            if (in_array($os, array('Debian', 'Ubuntu', 'Fubuntu'))) {
                if ($flags = getParameterValue('^OPTIONS', '/etc/default/bind9')) {
                    $flags = explode(' ', $flags);
                    if (in_array('-t', $flags)) {
                        return $flags[array_search('-t', $flags) + 1];
                    }
                }
            }
            break;
        case 'OpenBSD':
            $chroot_dir = '/var/named';
            foreach (array('/etc/rc.conf.local', '/etc/rc.conf') as $rcfile) {
                if ($chroot_dir = getParameterValue('^named_chroot', $rcfile)) {
                    break;
                }
            }
            return $chroot_dir;
        case 'FreeBSD':
            if ($chroot_dir = getParameterValue('^named_chroot', '/etc/rc.conf')) {
                return $chroot_dir;
            }
            if ($flags = getParameterValue('^named_flags', '/etc/rc.conf')) {
                $flags = explode(' ', $flags);
                if (in_array('-t', $flags)) {
                    return $flags[array_search('-t', $flags) + 1];
                }
            }
    }
    return null;
}
Ejemplo n.º 3
0
     //get the current article
     $query = "SELECT * FROM #__content WHERE id=" . $id . " LIMIT 1";
     $db->setQuery($query);
     $current = $db->loadObject();
     HTML_versions::show($rows, $current);
     break;
     //show the list of versions for this document
 //show the list of versions for this document
 default:
     $rows = null;
     $current = null;
     if ($id > 0) {
         $group_id = 0;
         //check that the user is authorized to approve
         if (function_exists('getParameterValue')) {
             $group_id = (int) getParameterValue('approval_user_group');
         }
         if ($group_id > 0) {
             $user =& JFactory::getUser();
             //if they are at or above the selected user group
             if (canAccess($user->gid, $group_id)) {
                 $query = "SELECT * FROM #__version WHERE content_id=" . $id . " AND (autosaved != '1' or autosaved is null) ORDER BY id DESC";
             } else {
                 //no access to staging versions
                 $query = "SELECT * FROM #__version WHERE content_id=" . $id . " AND (stage != '1' or stage is null) AND (autosaved != '1' or autosaved is null) ORDER BY id DESC";
             }
         } else {
             $query = "SELECT * FROM #__version WHERE content_id=" . $id . " AND (autosaved != '1' or autosaved is null) ORDER BY id DESC";
         }
         $db->setQuery($query);
         $rows = $db->loadObjectList();