Exemple #1
0
 /**
  * Determine HOME directory.
  *
  * @return  string                                      Home directory.
  */
 public static function getHome()
 {
     if (($home = getenv('HOME')) === '') {
         $home = posix_getpwuid(posix_getuid())['dir'];
     }
     return $home;
 }
Exemple #2
0
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param \TYPO3\FLOW3\Cache\Frontend\FrontendInterface $cache
  * @return void
  */
 public function setCache(\TYPO3\FLOW3\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
     $pathHash = substr(md5(FLOW3_PATH_WEB . PHP_SAPI . $processUser['name'] . $this->context), 0, 12);
     $this->identifierPrefix = 'FLOW3_' . $pathHash;
 }
 public function __construct()
 {
     $this->opo_search_base = new SearchBase();
     $this->opo_app_config = Configuration::load();
     $this->opo_search_config = Configuration::load($this->opo_app_config->get("search_config"));
     $this->opo_search_indexing_config = Configuration::load($this->opo_search_config->get("search_indexing_config"));
     $this->ops_webserver_user = posix_getpwuid(posix_getuid());
     $this->ops_webserver_user = $this->ops_webserver_user['name'];
     $this->opa_setting_descriptions = array();
     $this->opa_setting_names = array();
     $this->opa_setting_hints = array();
     $this->_initMessages();
     // allow overriding settings from search.conf via constant (usually defined in bootstrap file)
     // this is useful for multi-instance setups which have the same set of config files for multiple instances
     if (defined('__CA_SOLR_URL__') && strlen(__CA_SOLR_URL__) > 0) {
         $this->ops_search_solr_url = __CA_SOLR_URL__;
     } else {
         $this->ops_search_solr_url = $this->opo_search_config->get('search_solr_url');
     }
     if (defined('__CA_SOLR_HOME_DIR__') && strlen(__CA_SOLR_HOME_DIR__) > 0) {
         $this->ops_search_solr_home_dir = __CA_SOLR_HOME_DIR__;
     } else {
         $this->ops_search_solr_home_dir = $this->opo_search_config->get('search_solr_home_dir');
     }
     parent::__construct();
 }
Exemple #4
0
 /**
  * Get the system user of the user of the current process
  *
  * @return string
  */
 protected function getProcessUser()
 {
     // $userInfo = posix_getpwuid(posix_geteuid());
     $userInfo = posix_getpwuid(posix_getuid());
     $userName = $userInfo['name'];
     return $userName;
 }
 public static function getLog()
 {
     if (!self::$log) {
         $path = PhabricatorEnv::getEnvConfig('log.ssh.path');
         $format = PhabricatorEnv::getEnvConfig('log.ssh.format');
         $format = nonempty($format, "[%D]\t%p\t%h\t%r\t%s\t%S\t%u\t%C\t%U\t%c\t%T\t%i\t%o");
         // NOTE: Path may be null. We still create the log, it just won't write
         // anywhere.
         $data = array('D' => date('r'), 'h' => php_uname('n'), 'p' => getmypid(), 'e' => time());
         $sudo_user = PhabricatorEnv::getEnvConfig('phd.user');
         if (strlen($sudo_user)) {
             $data['S'] = $sudo_user;
         }
         if (function_exists('posix_geteuid')) {
             $system_uid = posix_geteuid();
             $system_info = posix_getpwuid($system_uid);
             $data['s'] = idx($system_info, 'name');
         }
         $client = getenv('SSH_CLIENT');
         if (strlen($client)) {
             $remote_address = head(explode(' ', $client));
             $data['r'] = $remote_address;
         }
         $log = id(new PhutilDeferredLog($path, $format))->setFailQuietly(true)->setData($data);
         self::$log = $log;
     }
     return self::$log;
 }
Exemple #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         if (!$input->getOption('allow-root')) {
             $aProcessUser = posix_getpwuid(posix_geteuid());
             if ($aProcessUser['name'] == 'root') {
                 throw new \InvalidArgumentException('You can however run a command with ' . 'sudo using --allow-root option');
             }
         }
         DaemonUtils::configCheck();
         //Check daemons
         $daemons = DaemonUtils::getDaemonsFromConfig();
         foreach ($daemons as $daemon) {
             if (!$daemon instanceof DaemonizerInterface) {
                 throw new \Exception('Invalid [cli-daemonizer.php] file: file contain not-implementer ' . 'DaemonizerInterface class');
             }
             DaemonUtils::checkScheduleItem($daemon->getSchedule(), get_class($daemon));
         }
         $id = mt_rand(1, 100000);
         shell_exec(DAEMON_FILE . " internal:master --id={$id} > /dev/null 2>&1 &");
         $output->writeln("<info>Daemon started</info>");
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }
Exemple #7
0
 /**
  * @param SplFileInfo|null $splFileInfo
  *
  * @return string
  */
 public function formatGroup(SplFileInfo $splFileInfo = null)
 {
     if ($splFileInfo) {
         return posix_getpwuid($splFileInfo->getGroup())['name'];
     }
     return '';
 }
Exemple #8
0
 function listDirectory()
 {
     global $osC_Language, $toC_Json, $osC_MessageStack;
     $directory = OSC_ADMIN_FILE_MANAGER_ROOT_PATH;
     if (isset($_REQUEST['directory']) && !empty($_REQUEST['directory'])) {
         $directory .= '/' . urldecode($_REQUEST['directory']);
     } elseif (isset($_REQUEST['goto']) && !empty($_REQUEST['goto'])) {
         $directory .= '/' . urldecode($_REQUEST['goto']);
     }
     $osC_DirectoryListing = new osC_DirectoryListing($directory);
     $osC_DirectoryListing->setStats(true);
     $records = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $file_owner = function_exists('posix_getpwuid') ? posix_getpwuid($file['user_id']) : '-?-';
         $group_owner = function_exists('posix_getgrgid') ? posix_getgrgid($file['group_id']) : '-?-';
         if ($file['is_directory'] === true) {
             $entry_icon = osc_icon('folder_red.png');
             $action = array(array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         } else {
             $entry_icon = osc_icon('file.png');
             $action = array(array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit')), array('class' => 'icon-download-record', 'qtip' => $osC_Language->get('icon_download')), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         }
         $records[] = array('icon' => $entry_icon, 'file_name' => $file['name'], 'is_directory' => $file['is_directory'], 'size' => number_format($file['size']), 'permission' => osc_get_file_permissions($file['permissions']), 'file_owner' => $file_owner, 'group_owner' => $group_owner, 'writeable' => osc_icon(is_writable($osC_DirectoryListing->getDirectory() . '/' . $file['name']) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'), 'last_modified_date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($file['last_modified']), true), 'action' => $action);
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
 /**
  * Format a command so it executes as the daemon user, if a daemon user is
  * defined. This wraps the provided command in `sudo -u ...`, roughly.
  *
  * @param   PhutilCommandString Command to execute.
  * @return  PhutilCommandString `sudo` version of the command.
  */
 public static function sudoCommandAsDaemonUser($command)
 {
     $user = PhabricatorEnv::getEnvConfig('phd.user');
     if (!$user) {
         // No daemon user is set, so just run this as ourselves.
         return $command;
     }
     // We may reach this method while already running as the daemon user: for
     // example, active and passive synchronization of clustered repositories
     // run the same commands through the same code, but as different users.
     // By default, `sudo` won't let you sudo to yourself, so we can get into
     // trouble if we're already running as the daemon user unless the host has
     // been configured to let the daemon user run commands as itself.
     // Since this is silly and more complicated than doing this check, don't
     // use `sudo` if we're already running as the correct user.
     if (function_exists('posix_getuid')) {
         $uid = posix_getuid();
         $info = posix_getpwuid($uid);
         if ($info && $info['name'] == $user) {
             return $command;
         }
     }
     // Get the absolute path so we're safe against the caller wiping out
     // PATH.
     $sudo = Filesystem::resolveBinary('sudo');
     if (!$sudo) {
         throw new Exception(pht("Unable to find 'sudo'!"));
     }
     // Flags here are:
     //
     //   -E: Preserve the environment.
     //   -n: Non-interactive. Exit with an error instead of prompting.
     //   -u: Which user to sudo to.
     return csprintf('%s -E -n -u %s -- %C', $sudo, $user, $command);
 }
/**
 * Hook a ejecutar antes del paso 5 de la instalación
 * Extrae cuales son las fuentes de datos principales que podría utilizarse
 *
 * @param array &$data  Los datos a utilizar por las plantillas de tipo stepn
 */
function idpinstaller_hook_step5(&$data)
{
    $data['datasources'] = getDataSources();
    $require_mods = array("saml", "idpinstaller", "modinfo", "ldap", "sqlauth", "core", "portal", "sir2skin");
    //Modulos obligatorios
    $ssphpobj = $data['ssphpobj'];
    $modules = SimpleSAML_Module::getModules();
    sort($modules);
    $perms_ko = array();
    $modules_ko = array();
    foreach ($modules as $m) {
        $f = realpath(__DIR__ . '/../../' . $m);
        if (!file_exists($f . '/default-disable') && !file_exists($f . '/default-enable') && in_array($m, $require_mods)) {
            $modules_ko[] = $f;
        } elseif (file_exists($f . '/default-disable') && !is_writable($f . '/default-disable') || file_exists($f . '/default-enable') && !is_writable($f . '/default-enable')) {
            $perms_ko[] = $f;
        } else {
            if (in_array($m, $require_mods)) {
                //PARA LOS QUE SI QUEREMOS ACTIVAR
                if (file_exists($f . '/default-disable')) {
                    @unlink($f . '/default-disable');
                    @touch($f . '/default-enable');
                    if (!file_exists($f . '/default-enable')) {
                        $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
                    }
                }
            } else {
                //PARA LOS QUE QUEREMOS DESACTIVAR
                if (file_exists($f . '/default-enable')) {
                    @unlink($f . '/default-enable');
                    @touch($f . '/default-disable');
                    if (!file_exists($f . '/default-disable')) {
                        $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
                    }
                }
            }
        }
    }
    if (count($modules_ko) > 0) {
        $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
    } elseif (count($perms_ko) > 0) {
        if (function_exists('posix_getgrnam')) {
            $aux = "<br/>" . $ssphpobj->t('{idpinstaller:idpinstaller:step4_perms_ko}');
            $filename = $perms_ko[0];
            $file_owner = posix_getpwuid(fileowner($filename));
            $group = posix_getgrgid(posix_getgid());
            $recursive = is_dir($filename) ? "-R" : "";
            $aux .= "<pre>&gt; chown {$recursive} " . $file_owner['name'] . ":" . $group['name'] . " {$filename}\n&gt; chmod {$recursive} g+w " . $filename . "</pre>";
        }
        $data['errors'][] = $aux;
        $data['errors'][] = $ssphpobj->t("{idpinstaller:idpinstaller:step1_remember_change_perms}");
    }
    if (count($data['errors']) == 0) {
        $data['info'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_all_ok}');
    }
    /*else {
          $data['errors'][] = $ssphpobj->t('{idpinstaller:idpinstaller:step4_error}');
      }*/
    return true;
}
Exemple #11
0
function check_file($f)
{
    echo "\nFile {$f}\n";
    echo '1.' . (file_exists($f) ? ' exists' : ' does NOT exist') . " \n";
    if (!file_exists($f)) {
        echo 'Remaining checks skipped' . " \n";
        return;
    }
    echo '2. is' . (is_file($f) ? '' : ' NOT') . " a file\n";
    echo '3. is' . (is_readable($f) ? '' : ' NOT') . " readable\n";
    echo '4. is' . (is_writable($f) ? '' : ' NOT') . " writable\n";
    echo '5. has permissions ' . substr(sprintf('%o', fileperms($f)), -4) . "\n";
    echo '6. owner id ' . fileowner($f) . " (0 on Windows, blank if not permitted)\n";
    if (function_exists('posix_geteuid')) {
        $details = posix_getpwuid(posix_geteuid());
        echo '6. owner name ' . $details['name'] . " \n";
        echo '6. owner gid ' . $details['gid'] . " \n";
        $details = posix_getgrgid($details['gid']);
        echo '6. group name ' . $details['name'] . " \n";
    }
    echo '7. group id ' . filegroup($f) . " (0 on Windows, blank if not permitted)\n";
    if (function_exists('posix_getegid')) {
        $details = posix_getgrgid(posix_getegid());
        echo '7. group name ' . $details['name'] . " \n";
    }
}
function walkdir($path, $exclusions, &$array)
{
    global $root_length;
    $rs = @opendir($path);
    if (!$rs) {
        exit(3);
    }
    while ($file = readdir($rs)) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $current_path = "{$path}/{$file}";
        if (is_excluded($current_path)) {
            continue;
        }
        $stat = stat($current_path);
        $group_entry = posix_getgrgid($stat['gid']);
        $user_entry = posix_getpwuid($stat['uid']);
        $group = $group_entry['name'];
        $user = $user_entry['name'];
        $relative_path = substr($current_path, $root_length + 1);
        $array[] = $relative_path . ';' . $stat['mode'] . ';' . $stat['nlink'] . ';' . $stat['uid'] . ';' . $user . ';' . $stat['gid'] . ';' . $group . ';' . $stat['size'] . ';' . $stat['atime'] . ';' . $stat['mtime'] . ';' . $stat['ctime'];
        if (is_dir($current_path)) {
            walkdir($current_path, $exclusions, $array);
        }
    }
    closedir($rs);
}
 function paloConfig($directorio, $archivo, $separador = "", $separador_regexp = "", $usuario_proceso = NULL)
 {
     $this->directorio = $directorio;
     $this->archivo = $archivo;
     $this->separador = $separador;
     $this->separador_regexp = $separador_regexp;
     if (!is_null($usuario_proceso)) {
         $this->usuario_proceso = $usuario_proceso;
     } else {
         $arr_user = posix_getpwuid(posix_getuid());
         if (is_array($arr_user) && array_key_exists("name", $arr_user)) {
             $this->usuario_proceso = $arr_user['name'];
         }
     }
     //Debo setear el usuario de sistema y el grupo dependiendo del usuario y grupo propietario del archivo
     $ruta_archivo = $directorio . "/" . $archivo;
     if (file_exists($ruta_archivo)) {
         $arr_usuario = posix_getpwuid(fileowner($ruta_archivo));
         if (is_array($arr_usuario)) {
             $this->usuario_sistema = $arr_usuario['name'];
         }
         $arr_grupo = posix_getgrgid(filegroup($ruta_archivo));
         if (is_array($arr_grupo)) {
             $this->grupo_sistema = $arr_grupo['name'];
         }
     }
     /*
     echo "ruta_archivo=".$ruta_archivo."<br>usuario_sistema=".$this->usuario_sistema."<br>grupo_sistema=".
          $this->grupo_sistema."<br>usuario_proceso= ".$this->usuario_proceso."<br>";
     echo "<script>alert('alto =)');</script>";
     */
 }
 protected function configure()
 {
     parent::configure();
     $info = posix_getpwuid(posix_getuid());
     $home = isset($info['dir']) ? $info['dir'] : '/tmp';
     $this->setName('site:backup')->addOption('directory', null, InputOption::VALUE_REQUIRED, "Target directory where backups should be stored", $home)->setDescription('Backup a site');
 }
 public static function user_home_directory()
 {
     // Gets the system user's home directory
     static $userhome = null;
     if ($userhome == null) {
         if (function_exists('posix_getpwuid') && function_exists('posix_getuid')) {
             $userinfo = posix_getpwuid(posix_getuid());
             $userhome = $userinfo['dir'];
         } else {
             if ($home = pts_client::read_env('HOME')) {
                 $userhome = $home;
             } else {
                 if ($home = pts_client::read_env('HOMEPATH')) {
                     $userhome = pts_client::read_env('HOMEDRIVE') . $home;
                 } else {
                     if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
                         $userhome = PTS_USER_PATH;
                     } else {
                         if (!is_writable('/')) {
                             echo PHP_EOL . 'ERROR: Cannot find home directory.' . PHP_EOL;
                         }
                         $userhome = null;
                     }
                 }
             }
         }
         $userhome = pts_strings::add_trailing_slash($userhome);
     }
     return $userhome;
 }
Exemple #16
0
/**
 * Checks if user can use bug_report plugin
 *
 * @return boolean
 *
 * @since 1.5.1
 *
 */
function bug_report_check_user()
{
    global $username, $bug_report_allow_users, $bug_report_admin_email;
    bug_report_init();
    if (file_exists(SM_PATH . 'plugins/bug_report/admins')) {
        $auths = file(SM_PATH . 'plugins/bug_report/admins');
        array_walk($auths, 'bug_report_array_trim');
        $auth = in_array($username, $auths);
    } else {
        if (file_exists(SM_PATH . 'config/admins')) {
            $auths = file(SM_PATH . 'config/admins');
            array_walk($auths, 'bug_report_array_trim');
            $auth = in_array($username, $auths);
        } else {
            if (($adm_id = fileowner(SM_PATH . 'config/config.php')) && function_exists('posix_getpwuid')) {
                $adm = posix_getpwuid($adm_id);
                $auth = $username == $adm['name'];
            } else {
                $auth = false;
            }
        }
    }
    if (!empty($bug_report_admin_email) && $bug_report_allow_users) {
        $auth = true;
    }
    return $auth;
}
Exemple #17
0
 private function renderRelativeImagePath($imageType, $imageFilename, $imageWidth = 0, $imageHeight = 0, $flagStamp = false)
 {
     $imageFilename = trim($imageFilename);
     $imageWidth = intval($imageWidth);
     $imageHeight = intval($imageHeight);
     if (!is_bool($flagStamp)) {
         $flagStamp = false;
     }
     if (!in_array($imageType, array('orig', 'crop', 'scale')) || !strlen($imageFilename)) {
         return '';
     }
     $postfix = '';
     if ($imageWidth && $imageHeight) {
         $postfix .= '_' . $imageWidth . '_' . $imageHeight;
     }
     if ($flagStamp) {
         $postfix .= '_stamp';
     }
     $path = '/' . $imageType . '/' . substr($imageFilename, 0, 2) . '/' . substr($imageFilename, 2, 2);
     if (!file_exists($this->pathImage . $path)) {
         mkdir($this->pathImage . $path, 0775, true);
         $folderOwnerInfo = posix_getpwuid(fileowner($this->pathImage . $path));
         if ($folderOwnerInfo['name'] == Cfg::FILE_SYSTEM_SUPERUSER) {
             chown($this->pathImage . $path, Cfg::FILE_SYSTEM_USERNAME);
             chgrp($this->pathImage . $path, Cfg::FILE_SYSTEM_USERNAME);
         }
     }
     return $path . '/' . $imageFilename . $postfix . '.jpg';
 }
function renderUGID($uid, $gid)
{
    static $users = array();
    static $groups = array();
    if ($uid === false) {
        $user = '******';
    } else {
        if (!array_key_exists($uid, $users)) {
            if (function_exists('posix_getpwuid')) {
                $uArray = posix_getpwuid($uid);
                $users[$uid] = $uArray['name'];
                //." ($uid)";
            } else {
                $users[$uid] = $uid;
            }
        }
        $user = $users[$uid];
    }
    if ($gid === false) {
        $group = '&mdash;';
    } else {
        if (!array_key_exists($gid, $groups)) {
            if (function_exists('posix_getgrgid')) {
                $gArray = posix_getgrgid($gid);
                $groups[$gid] = $gArray['name'];
                //." ($gid)";
            } else {
                $groups[$gid] = $gid;
            }
        }
        $group = $groups[$gid];
    }
    return "{$user}:{$group}";
}
Exemple #19
0
 /**
  * Make sure there is no existing installation
  *
  * @return boolean True if there is no existing installation
  */
 protected function canInstall()
 {
     $safe_mode = ini_get('safe_mode');
     // Safe mode enabled
     if ($safe_mode != '' && $safe_mode != 0 && $safe_mode != 'Off') {
         return false;
     }
     // Try to create a folder
     if (@mkdir('test') === false) {
         return false;
     } else {
         clearstatcache();
         $self = posix_getpwuid(@fileowner(dirname(__FILE__)));
         $test = posix_getpwuid(@fileowner('test'));
         @rmdir('test');
         if ($self != $test) {
             return false;
         }
     }
     // Try to create a file
     if (@file_put_contents('test.txt', '') === false) {
         return false;
     } else {
         clearstatcache();
         $self = posix_getpwuid(@fileowner(__FILE__));
         $test = posix_getpwuid(@fileowner('test.txt'));
         @unlink('test.txt');
         if ($self != $test) {
             return false;
         }
     }
     return true;
 }
 /**
  * Get the system user.
  *
  * @return string
  */
 protected function getSystemUser()
 {
     if (str_contains(strtolower(php_uname()), 'windows')) {
         return getenv('USERNAME');
     }
     return posix_getpwuid(posix_geteuid())['name'];
 }
Exemple #21
0
/**
 * Check if user has access to administrative functions
 *
 * @return boolean
 */
function adm_check_user()
{
    global $PHP_SELF, $plugins;
    require_once SM_PATH . 'functions/global.php';
    if (!in_array('administrator', $plugins)) {
        return FALSE;
    }
    if (!sqgetGlobalVar('username', $username, SQ_SESSION)) {
        $username = '';
    }
    /* This needs to be first, for all non_options pages */
    if (strpos('options.php', $PHP_SELF)) {
        $auth = FALSE;
    } else {
        if (file_exists(SM_PATH . 'plugins/administrator/admins')) {
            $auths = file(SM_PATH . 'plugins/administrator/admins');
            array_walk($auths, 'adm_array_trim');
            $auth = in_array($username, $auths);
        } else {
            if (file_exists(SM_PATH . 'config/admins')) {
                $auths = file(SM_PATH . 'config/admins');
                array_walk($auths, 'adm_array_trim');
                $auth = in_array($username, $auths);
            } else {
                if (($adm_id = fileowner(SM_PATH . 'config/config.php')) && function_exists('posix_getpwuid')) {
                    $adm = posix_getpwuid($adm_id);
                    $auth = $username == $adm['name'];
                } else {
                    $auth = FALSE;
                }
            }
        }
    }
    return $auth;
}
Exemple #22
0
 /**
  * @see FileBackendStore::__construct()
  * Additional $config params include:
  *   - basePath       : File system directory that holds containers.
  *   - containerPaths : Map of container names to custom file system directories.
  *                      This should only be used for backwards-compatibility.
  *   - fileMode       : Octal UNIX file permissions to use on files stored.
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     // Remove any possible trailing slash from directories
     if (isset($config['basePath'])) {
         $this->basePath = rtrim($config['basePath'], '/');
         // remove trailing slash
     } else {
         $this->basePath = null;
         // none; containers must have explicit paths
     }
     if (isset($config['containerPaths'])) {
         $this->containerPaths = (array) $config['containerPaths'];
         foreach ($this->containerPaths as &$path) {
             $path = rtrim($path, '/');
             // remove trailing slash
         }
     }
     $this->fileMode = isset($config['fileMode']) ? $config['fileMode'] : 0644;
     if (isset($config['fileOwner']) && function_exists('posix_getuid')) {
         $this->fileOwner = $config['fileOwner'];
         $info = posix_getpwuid(posix_getuid());
         $this->currentUser = $info['name'];
         // cache this, assuming it doesn't change
     }
 }
Exemple #23
0
function check_writable_relative($dir)
{
    $uid = posix_getuid();
    $gid = posix_getgid();
    $user_info = posix_getpwuid($uid);
    $user = $user_info['name'];
    $group_info = posix_getgrgid($gid);
    $group = $group_info['name'];
    $fix_cmd = '. ' . _("To fix that, execute following commands as root") . ':<br><br>' . "cd " . getcwd() . "<br>" . "mkdir -p {$dir}<br>" . "chown {$user}:{$group} {$dir}<br>" . "chmod 0700 {$dir}";
    if (!is_dir($dir)) {
        $config_nt = array('content' => _("Required directory " . getcwd() . "{$dir} does not exist") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
    if (!($stat = stat($dir))) {
        $config_nt = array('content' => _("Could not stat configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
    // 2 -> file perms (must be 0700)
    // 4 -> uid (must be the apache uid)
    // 5 -> gid (must be the apache gid)
    if ($stat[2] != 16832 || $stat[4] !== $uid || $stat[5] !== $gid) {
        $config_nt = array('content' => _("Invalid perms for configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
        $nt = new Notification('nt_1', $config_nt);
        $nt->show();
        exit;
    }
}
 /**
  * Initializes the identifier prefix when setting the cache.
  *
  * @param t3lib_cache_frontend_Frontend $cache The frontend for this backend
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function setCache(t3lib_cache_frontend_Frontend $cache)
 {
     parent::setCache($cache);
     $processUser = extension_loaded('posix') ? posix_getpwuid(posix_geteuid()) : array('name' => 'default');
     $pathHash = t3lib_div::shortMD5(PATH_site . $processUser['name'], 12);
     $this->identifierPrefix = 'TYPO3_' . $pathHash;
 }
 public function log($connector, $message, $args, $object_id, $contexts, $user_id = null)
 {
     global $wpdb;
     if (is_null($user_id)) {
         $user_id = get_current_user_id();
     }
     require_once MAINWP_WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
     $user = new WP_User($user_id);
     $roles = get_option($wpdb->get_blog_prefix() . 'user_roles');
     if (!isset($args['author_meta'])) {
         $args['author_meta'] = array('user_email' => $user->user_email, 'display_name' => defined('WP_CLI') && empty($user->display_name) ? 'WP-CLI' : $user->display_name, 'user_login' => $user->user_login, 'user_role_label' => !empty($user->roles) ? $roles[$user->roles[0]]['name'] : null, 'agent' => MainWP_WP_Stream_Author::get_current_agent());
         if (defined('WP_CLI') && function_exists('posix_getuid')) {
             $uid = posix_getuid();
             $user_info = posix_getpwuid($uid);
             $args['author_meta']['system_user_id'] = $uid;
             $args['author_meta']['system_user_name'] = $user_info['name'];
         }
     }
     // Remove meta with null values from being logged
     $meta = array_filter($args, function ($var) {
         return !is_null($var);
     });
     $recordarr = array('object_id' => $object_id, 'site_id' => is_multisite() ? get_current_site()->id : 1, 'blog_id' => apply_filters('blog_id_logged', is_network_admin() ? 0 : get_current_blog_id()), 'author' => $user_id, 'author_role' => !empty($user->roles) ? $user->roles[0] : null, 'created' => current_time('mysql', 1), 'summary' => vsprintf($message, $args), 'parent' => self::$instance->prev_record, 'connector' => $connector, 'contexts' => $contexts, 'meta' => $meta, 'ip' => mainwp_wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP));
     $record_id = MainWP_WP_Stream_DB::get_instance()->insert($recordarr);
     return $record_id;
 }
 function dir_get_infos($dir = '')
 {
     if ($dir == '') {
         return;
     }
     $dir = str_replace('//', '/', $dir . '/');
     foreach (self::glob($dir . '*') as $file) {
         $array = array();
         if (!is_dir($file)) {
             if (self::webos() !== 'Windows') {
                 if (function_exists('posix_getpwuid')) {
                     $tmp = posix_getpwuid(fileowner($file));
                     $array['owner'] = $tmp['name'];
                 }
             }
             $array['md5file'] = md5_file($file);
             $array['file'] = $file;
             $array['filectime'] = filectime($file);
             $array['filemtime'] = filemtime($file);
             $array['isdir'] = false;
             $return[] = $array;
         } else {
             $return[] = array('file' => $file, 'isdir' => true);
         }
     }
     return serialize($return);
 }
 /**
  * SCPlib constructor. Setup main variables.
  *
  * @param	$server the server we will connect to
  * @param	$config optional. path to an ssh_config file
  */
 function SCPlib($server, $config = null)
 {
     if (!ctype_alpha($server)) {
         trigger_error('specified server name has non-alpha characters', E_USER_ERROR);
         return NULL;
     }
     // pre-run error checks
     $old_umask = umask(077);
     $www_user = posix_getuid();
     $info = posix_getpwuid($www_user);
     $home_ssh = $info['dir'] . '/.ssh';
     $known_hosts = $home_ssh . '/known_hosts';
     if (!is_readable($known_hosts)) {
         throw new SCPException(SCPException::KNOWN_HOSTS, $known_hosts);
     }
     $this->_server = $server;
     $this->_scp_cmd = '/usr/bin/scp -o "BatchMode yes"';
     $this->_ssh_cmd = '/usr/bin/ssh -o "BatchMode yes"';
     if ($config !== null) {
         if (!is_file($config)) {
             throw new SCPException(SCPException::CONFIG_NOT_FILE, $config);
         }
         if (!is_readable($config)) {
             throw new SCPException(SCPException::CONFIG_NOT_READABLE, $config);
         }
         $this->_config = $config;
         $this->_scp_cmd .= ' -F ' . escapeshellarg($config);
         $this->_ssh_cmd .= ' -F ' . escapeshellarg($config);
     }
     $this->_rfutil = "~/rfutil";
 }
Exemple #28
0
/**
 * @version $Id: footer.php 107 2008-07-22 17:27:12Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007
 * @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
 * 
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * Shows the About Box!
 */
function show_about()
{
    // footer for html-page
    echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\r\n\t<img src=\"" . _EXT_URL . "/images/MangosWeb_small.png\" align=\"middle\" alt=\"Mangosweb Enhanced Logo\" />\r\n\t<br />\r\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\r\n\t<br />\r\n (<a href=\"http://virtuemart.net/index2.php?option=com_versions&amp;catid=5&amp;myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\r\n\t\r\n\t";
    if (function_exists("disk_free_space")) {
        $size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']);
        $free = parse_file_size($size);
    } elseif (function_exists("diskfreespace")) {
        $size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']);
        $free = parse_file_size($size);
    } else {
        $free = "?";
    }
    echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n";
    if (extension_loaded("posix")) {
        $owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' ';
        if (ext_isFTPMode()) {
            $my_user_info = posix_getpwnam($_SESSION['ftp_login']);
            $my_group_info = posix_getgrgid($my_user_info['gid']);
        } else {
            $my_user_info = posix_getpwuid(posix_geteuid());
            $my_group_info = posix_getgrgid(posix_getegid());
        }
        $owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')';
        echo $owner_info;
    }
    echo "\r\n\t</div>";
}
 private function parseIniFile()
 {
     $settings = array();
     $settingStack = array();
     $open_basedir_restriction = ini_get('open_basedir');
     if (empty($open_basedir_restriction)) {
         $settingStack[] = '/etc/dbc.ini';
         $settingStack[] = '/usr/local/etc/dbc.ini';
         if (function_exists("posix_getpwuid") && function_exists("posix_getuid")) {
             $userData = posix_getpwuid(posix_getuid());
             $settingStack[] = $userData['dir'] . '/.dbc.ini';
         }
     }
     $settingStack[] = dirname(__FILE__) . '/../dbc.ini';
     $settingStack[] = getcwd() . '/dbc.ini';
     foreach ($settingStack as $settingsFile) {
         if (is_readable($settingsFile)) {
             $settings = array_merge(parse_ini_file($settingsFile, true), $settings);
         }
     }
     //merge with default settings
     $settings = array_merge($this->settingsData, $settings);
     if (empty($settings)) {
         throw new Exception('No settings file found. Aborting.');
     }
     if (!isset($settings['dbConn:standard'])) {
         throw new Exception('Mandatory "dbConn:standard" is missing in settings file. Aborting.');
     }
     $this->settingsData = $this->parseValues($settings);
 }
function pleac_Establishing_a_Default_Value()
{
    #-----------------------------
    # use $b if $b is true, else $c
    $a = $b ? $b : $c;
    # set $x to $y unless $x is already true
    $x || ($x = $y);
    #-----------------------------
    # use $b if $b is defined, else $c
    $a = defined($b) ? $b : $c;
    #-----------------------------
    $foo = $bar || ($foo = "DEFAULT VALUE");
    #-----------------------------
    $dir = array_shift($_SERVER['argv']) || ($dir = "/tmp");
    #-----------------------------
    $dir = $_SERVER['argv'][0] || ($dir = "/tmp");
    #-----------------------------
    $dir = defined($_SERVER['argv'][0]) ? array_shift($_SERVER['argv']) : "/tmp";
    #-----------------------------
    $dir = count($_SERVER['argv']) ? $_SERVER['argv'][0] : "/tmp";
    #-----------------------------
    $count[$shell ? $shell : "/bin/sh"]++;
    #-----------------------------
    # find the user name on Unix systems
    $user = $_ENV['USER'] || ($user = $_ENV['LOGNAME'] || ($user = posix_getlogin() || ($user = posix_getpwuid(posix_getuid())[0] || ($user = "******"))));
    #-----------------------------
    $starting_point || ($starting_point = "Greenwich");
    #-----------------------------
    count($a) || ($a = $b);
    # copy only if empty
    $a = count($b) ? $b : $c;
    # assign @b if nonempty, else @c
    #-----------------------------
}