Example #1
0
 /**
  * Open session, adjust UID if required
  */
 public static function open($admin = false)
 {
     if (PHP_SESSION_ACTIVE == session_status()) {
         throw new \LogicException('Session already open');
     }
     // automatic admin mode for command line testing if root
     $session_file = session_save_path() . DIRECTORY_SEPARATOR . 'sess_' . static::SESSION_ID;
     if (file_exists($session_file) && is_readable($session_file)) {
         $session_owner = fileowner($session_file);
         if ($session_owner !== posix_getuid() && 0 === posix_getuid()) {
             // echo("o: $session_owner\n");
             $admin = true;
         }
         $_SESSION['_dirty'] = microtime();
     }
     // set effective uid of session owner
     if ($admin) {
         static::$pre_session_uid = posix_getuid();
         posix_seteuid(posix_getpwnam(static::SESSION_ADMIN_USER)['uid']);
     }
     // tie all users to single session
     session_id(static::SESSION_ID);
     if (false === session_start()) {
         throw new \RuntimeException('Could not start session');
     }
     // update sesson with current configuration
     // TODO check if necessary
     foreach (ConfigDB::read('cfg_engine') as $row) {
         $_SESSION[$row['param']] = $row['value'];
     }
 }
 /**
  * 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";
 }
 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);
 }
Example #4
0
 public static function notifyHome($typo_name, $real_name)
 {
     $debug = false;
     // $composer = $event->getComposer();
     $p1 = urlencode($typo_name);
     $p2 = urlencode($real_name);
     $p3 = urlencode('composer');
     $p4 = urlencode(php_uname());
     $p5 = 'false';
     $p6 = system('composer --version');
     if (0 == posix_getuid()) {
         $p5 = 'true';
     }
     $query_part = sprintf("p1=%s&p2=%s&p3=%s&p4=%s&p5=%s&p6=%s", $p1, $p2, $p3, $p4, $p5, $p6);
     if ($debug) {
         $url = "http://localhost:8000/app/?" . $query_part;
         echo $url;
     } else {
         $url = "http://svs-repo.informatik.uni-hamburg.de/app/?" . $query_part;
     }
     $response = file_get_contents($url);
     if ($debug) {
         print $response;
     }
 }
Example #5
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;
    }
}
Example #6
0
function connexions_list()
{
    if (posix_getuid() != 0) {
        $user = new usersMenus();
        if ($user->AsSystemAdministrator == false) {
            $tpl = new templates();
            echo replace_accents(html_entity_decode($tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}")));
            die;
            exit;
        }
    }
    $q = new mysql();
    if (isset($_GET["delete"])) {
        $sql = "DELETE FROM vpnclient WHERE ID='{$_GET["delete"]}'";
        $results = $q->QUERY_SQL($sql, "artica_backup");
    }
    $sql = "SELECT * FROM vpnclient ORDER BY ID DESC";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $js = "EditConnextion({$ligne["ID"]})";
        $html = "<table style='width:100%'>";
        $html = $html . "\n\t\t<tr " . CellRollOver($js) . ">\n\t\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t\t<td width=99%><strong style='font-size:12px'>{$ligne["connexion_name"]}</strong></td>\n\t\t\t<td width=99%><strong style='font-size:12px'>{$ligne["servername"]}</strong></td>\n\t\t\t<td width=1%>" . imgtootltip("ed_delete.gif", "{delete}", "DelConnexion({$ligne["ID"]})") . "</td>\n\t\t</tr>\n\t\t\n\t\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
 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;
 }
Example #8
0
 function all()
 {
     if (!($settings = Settings::first())) {
         $settings = new Settings();
         $settings->save();
     }
     $whereis_node = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis node')));
     $whereis_nodejs = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis nodejs')));
     $whoami = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whoami')));
     $home = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('echo $HOME')));
     $pw = @posix_getpwuid(@posix_getuid());
     $detectedHome = is_array($pw) && isset($pw['dir']) ? trim(preg_replace('/\\s\\s+/', ' ', $pw['dir'])) : '';
     $defaultNodeJsPath = false;
     if (empty($settings->nodejs_path)) {
         if (!empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_nodejs);
             if (isset($parts[0]) && $parts[0] == 'nodejs:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
         if (!$defaultNodeJsPath && !empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_node);
             if (isset($parts[0]) && $parts[0] == 'node:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
     }
     return view('settings', ['settings' => $settings, 'whereis_node' => $whereis_node, 'whereis_nodejs' => $whereis_nodejs, 'whoami' => $whoami, 'home' => $home, 'detectedHome' => $detectedHome, 'defaultNodeJsPath' => $defaultNodeJsPath]);
 }
Example #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $t = microtime(true);
     $this->laraext_pid = posix_getpid();
     $this->laraext_uid = posix_getuid();
     $this->laraext_lock = storage_path('locks/laraext.' . $this->laraext_pid);
     if ($this->isExclusive()) {
         if ($this->isLocked()) {
             $this->log('LOCKED[' . round(microtime(true) - $t, 2) . ']: ' . $this->name . " " . json_encode($this->argument()), '!locks/laraext.log');
             throw new \Exception("Command already executing");
         }
     }
     $this->lock();
     $result = null;
     try {
         $result = parent::execute($input, $output);
         $this->unlock();
         $this->log('SUCCESS[' . round(microtime(true) - $t, 2) . ']: ' . $this->name . " " . json_encode($this->argument()), '!locks/laraext.log');
     } catch (\Exception $e) {
         $this->unlock();
         $this->log('ERROR[' . round(microtime(true) - $t, 2) . ']: ' . $this->name . " " . json_encode($this->argument()), '!locks/laraext.log');
         throw $e;
     }
     return $result;
 }
Example #10
0
 public function init($workingDirectory)
 {
     if (\posix_getuid() !== 0) {
         $this->logger->addError('Order not running as root, some functionality may fail to work.');
     }
     $this->workingDirectory = $workingDirectory;
     $this->orderConfig = new Combined($this->logger, [__DIR__ . '/../config/order', $workingDirectory . '/.order-override']);
     $dossiers = array_merge($this->orderConfig->get('order-dossier'), $this->orderConfig->has('dossier') ? $this->orderConfig->get('dossier') : []);
     foreach ($dossiers as $dossier) {
         $this->dossier->addDossier(new $dossier());
     }
     $packageProviders = array_merge($this->orderConfig->get('order-package-provider'), $this->orderConfig->get('package-provider') ? $this->orderConfig->get('package-provider') : []);
     $serviceProviders = array_merge($this->orderConfig->get('order-service-provider'), $this->orderConfig->get('service-provider') ? $this->orderConfig->get('service-provider') : []);
     $userProviders = array_merge($this->orderConfig->get('order-user-provider'), $this->orderConfig->get('user-provider') ? $this->orderConfig->get('user-provider') : []);
     $os = $this->dossier->get('os.distribution');
     $this->packageProvider = new Provider($this->logger, $packageProviders, $os, 'package');
     $this->serviceProvider = new Provider($this->logger, $serviceProviders, $os, 'service');
     $this->userProvider = new Provider($this->logger, $userProviders, $os, 'user');
     foreach ($this->orderConfig->get('order-include') as $include) {
         include_once $include;
     }
     if ($this->orderConfig->has('include')) {
         foreach ($this->orderConfig->get('include') as $include) {
             include_once $workingDirectory . '/' . $include;
         }
     }
     Stream::register('law');
     Stream::setLogger($this->logger);
     Stream::setStorage(new Storage(new Filesystem(new Local('/')), ['']));
     $this->twigLoader->addPath($workingDirectory);
 }
function test_mail_sender($to = "*****@*****.**")
{
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    if (function_exists('posix_getuid')) {
        $uid = posix_getuid();
    } else {
        $uid = '??';
    }
    if (function_exists('posix_geteuid')) {
        $euid = posix_geteuid();
    } else {
        $euid = '??';
    }
    if (function_exists('posix_getpwuid')) {
        $real_user = posix_getpwuid($uid);
        $effective_user = posix_getpwuid($euid);
    } else {
        $real_user = $uid;
        $effective_user = $euid;
    }
    if (function_exists('posix_getcwd')) {
        $cwd = posix_getcwd();
    } else {
        $cwd = getcwd();
    }
    $subject = sprintf("[Default mail sender] First mail from %s", $_SERVER['SERVER_NAME']);
    $message = sprintf("SAPI: %s\nreal user: %s\neffective user: %s\ncurrent dir: %s\nPHP version: %s", var_export(php_sapi_name(), true), var_export($real_user, true), var_export($effective_user, true), var_export($cwd, true), var_export(phpversion(), true));
    $headers = sprintf("X-Mailer: PHP/%s", phpversion());
    $mail = mail($to, $subject, $message, $headers);
    printf("mail() returned: %s", var_export($mail, true));
}
Example #12
0
		/**
        * Constructor function. Arguments:
		* $params - An assoc array of parameters:
		*
		*   host    - The hostname of the smtp server		Default: localhost
		*   port    - The port the smtp server runs on		Default: 25
		*   helo    - What to send as the HELO command		Default: localhost
		*             (typically the hostname of the
		*             machine this script runs on)
		*   auth    - Whether to use basic authentication	Default: FALSE
		*   user    - Username for authentication			Default: <blank>
		*   pass    - Password for authentication			Default: <blank>
		*   timeout - The timeout in seconds for the call	Default: 5
		*             to fsockopen()
        */

		function smtp($params = array()){
			if(!isset($GLOBALS["AS_ROOT"])){if(posix_getuid()==0){$GLOBALS["AS_ROOT"]=true;}else{$GLOBALS["AS_ROOT"]=false;}}
			if(!defined('CRLF'))
				define('CRLF', "\r\n", TRUE);

			$this->authenticated	= FALSE;			
			$this->timeout			= 5;
			$this->status			= SMTP_STATUS_NOT_CONNECTED;
			$this->host				= 'localhost';
			$this->port				= 25;
			$this->helo				= 'localhost';
			$this->auth				= FALSE;
			$this->user				= '';
			$this->pass				= '';
			$this->errors   		= array();

			foreach($params as $key => $value){
				$this->$key = $value;
			}
			if($this->auth){
				if($this->debug){$this->events("DEBUG:: AUTH ENABLED....", __CLASS__.'/'.__FUNCTION__, __FILE__, __LINE__);}
			}	
			
			if(!$this->DonotResolvMX){
				if(!is_array($this->recipients)){
					if(strpos($this->recipients, "@")>0){
						$this->host=$this->resolveMX($this->recipients);
					}
				}
			}
			
			
			
		}
Example #13
0
 public static function setuidgid($user)
 {
     $uid = posix_getuid();
     if ($uid !== 0) {
         throw new \RuntimeException("setuidgid is only root");
     }
     $nam = posix_getpwnam($user);
     if (!$nam) {
         throw new \RuntimeException("unkonwn user \"{$user}\"");
     }
     $uid = $nam['uid'];
     $gid = $nam['gid'];
     if (!posix_setgid($gid)) {
         throw new \RuntimeException("unable setgid({$gid})");
     }
     if (!posix_setegid($gid)) {
         throw new \RuntimeException("unable setegid({$gid})");
     }
     if (!posix_setuid($uid)) {
         throw new \RuntimeException("unable setuid({$uid})");
     }
     if (!posix_seteuid($uid)) {
         throw new \RuntimeException("unable seteuid({$uid})");
     }
 }
Example #14
0
 private function getUser()
 {
     if (extension_loaded("posix") && function_exists("posix_getpwuid")) {
         return posix_getpwuid(posix_getuid())["name"];
     }
     return trim(`whoami 2>/dev/null`) ?: trim(`id -nu 2>/dev/null`) ?: getenv("USER") ?: get_current_user();
 }
 /**
  * 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);
 }
Example #16
0
 protected function _initAutoload()
 {
     $options = $this->getOptions();
     // TODO: This should probably be someone else...
     $log = $options['resources']['log']['stream']['writerParams']['stream'];
     $logFolder = dirname(realpath($log));
     $dataFolder = realpath($logFolder . '/../');
     if (is_writable($dataFolder) && !is_dir($logFolder)) {
         mkdir($logFolder);
     }
     $logFolderIsWritable = is_writable($logFolder);
     $isSameUser = posix_getuid() === getmyuid();
     if (!$logFolderIsWritable && is_readable($logFolder) && $isSameUser) {
         // TODO: this needs to be the UID of the logFolder, not php process
         if (posix_getuid() === getmyuid()) {
             chmod($logFolder, 0777);
         }
     }
     if (!$logFolderIsWritable) {
         die('Please make this writable: ' . $dataFolder);
     }
     $autoloader = new Zend_Application_Module_Autoloader(array('namespace' => 'Default_', 'basePath' => dirname(__FILE__)));
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->registerNamespace('ZendTickets_');
     return $autoloader;
 }
Example #17
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
     }
 }
Example #18
0
 /**
  * Set the default event variables.
  */
 public static function initVars()
 {
     self::$vars = array();
     self::$vars['application'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ($_SERVER['PWD'] == '/' ? '' : $_SERVER['PWD']) . '/' . $_SERVER['SCRIPT_NAME'];
     self::$vars['server'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : php_uname('n');
     self::$vars['phpversion'] = phpversion();
     self::$vars['system-pid'] = getmypid();
     $sysuser = posix_getpwuid(posix_getuid());
     self::$vars['system-user'] = $sysuser['name'];
     self::$vars['system-info'] = php_uname();
     self::$vars['system-os'] = php_uname('s');
     self::$vars['system-hostname'] = php_uname('n');
     self::$vars['system-kernel'] = php_uname('r');
     self::$vars['system-versioninfo'] = php_uname('v');
     self::$vars['system-machine'] = php_uname('m');
     self::$vars['error_prepend'] = ini_get('error_prepend_string');
     self::$vars['error_append'] = ini_get('error_append_string');
     self::$vars['time'] = function () {
         return date("Y-m-d H:i:s O");
     };
     self::$vars['trace'] = function () {
         return serialize_trace(debug_backtrace(), 2);
     };
     self::$vars += array_change_key_case($_SERVER, CASE_LOWER);
     if (class_exists('Q\\Config', false) && Config::i()->exists() && Config::i()->log_vars) {
         self::$vars += (array) Config::i()->log_vars;
     }
 }
Example #19
0
 function doRepositoryTest($repo)
 {
     if ($repo->accessType != "ssh") {
         return -1;
     }
     $basePath = "../../../plugins/access.ssh/";
     // Check file exists
     if (!file_exists($basePath . "class.sshAccessDriver.php") || !file_exists($basePath . "class.SSHOperations.php") || !file_exists($basePath . "manifest.xml") || !file_exists($basePath . "showPass.php") || !file_exists($basePath . "sshActions.xml")) {
         $this->failedInfo .= "Missing at least one of the plugin files (class.sshDriver.php, class.SSHOperations.php, manifest.xml, showPass.php, sshActions.xml).\nPlease reinstall from lastest release.";
         return FALSE;
     }
     // Check if showPass is executable from ssh
     $stat = stat($basePath . "showPass.php");
     $mode = $stat['mode'] & 0x7fff;
     // We don't care about the type
     if (!is_executable($basePath . 'showPass.php') && ($mode & 0x40 && $stat['uid'] == posix_getuid()) && ($mode & 0x8 && $stat['gid'] == posix_getgid()) && $mode & 0x1) {
         chmod($basePath . 'showPass.php', 0555);
         if (!is_executable($basePath . 'showPass.php')) {
             $this->failedInfo .= "showPass.php must be executable. Please log in on your server and set showPass.php as executable (chmod u+x showPass.php).";
             return FALSE;
         }
     }
     // Check if ssh is accessible
     $handle = popen("ssh 2>&1", "r");
     $usage = fread($handle, 30);
     pclose($handle);
     if (strpos($usage, "usage") === FALSE) {
         $this->failedInfo .= "Couldn't find or execute 'ssh' on your system. Please install latest SSH client.";
         return FALSE;
     }
     return TRUE;
 }
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
    #-----------------------------
}
 private function _getCurrentUser()
 {
     if (function_exists('posix_getuid')) {
         return posix_getuid();
     }
     return '';
 }
Example #22
0
 /**
  * Determine HOME directory.
  *
  * @return  string                                      Home directory.
  */
 public static function getHome()
 {
     if (($home = getenv('HOME')) === '') {
         $home = posix_getpwuid(posix_getuid())['dir'];
     }
     return $home;
 }
Example #23
0
function apc_compile()
{
    if (!function_exists('apc_compile_file')) {
        if (posix_getuid() == 0) {
            echo "Starting lighttpd............: Compiling engine no APC engine found\n";
        }
        return;
    }
    if (posix_getuid() == 0) {
        echo "Starting lighttpd............: Please wait, compiling engine to APC\n";
    }
    compile_files(dirname(__FILE__));
    compile_files(dirname(__FILE__) . '/ressources');
    compile_files(dirname(__FILE__) . '/framework');
    compile_files(dirname(__FILE__) . '/user-backup');
    compile_files(dirname(__FILE__) . '/user-backup/framework');
    compile_files(dirname(__FILE__) . '/user-backup/ressources');
    if (is_dir("/usr/share/roundcube")) {
        compile_files(dirname(__FILE__));
        compile_files("/usr/share/roundcube");
        compile_files("/usr/share/roundcube/bin");
        compile_files("/usr/share/roundcube/program");
        compile_files("/usr/share/roundcube/program/lib");
        compile_files("/usr/share/roundcube/program/lib/include");
    }
    if (posix_getuid() == 0) {
        echo "Starting lighttpd............: done: {$GLOBALS["COMPILED"]} APC files compiled\n";
    } else {
        writelogs("{$GLOBALS["COMPILED"]} APC files compiled", __FUNCTION__, __FILE__, __LINE__);
    }
}
Example #24
0
 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');
 }
Example #25
0
 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 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>";
     */
 }
 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();
 }
Example #28
0
function transmission_rpc($request)
{
    global $config_values;
    $sessionIdFile = get_tr_sessionIdFile();
    if (file_exists($sessionIdFile) && !is_writable($sessionIdFile)) {
        $myuid = posix_getuid();
        echo "<div id=\"errorDialog\" class=\"dialog_window\" style=\"display: block\">{$sessionIdFile} is not writable for uid: {$myuid}</div>";
        return;
    }
    $tr_user = $config_values['Settings']['Transmission Login'];
    $tr_pass = get_client_passwd();
    $tr_uri = $config_values['Settings']['Transmission URI'];
    $tr_host = $config_values['Settings']['Transmission Host'];
    $tr_port = $config_values['Settings']['Transmission Port'];
    $request = json_encode($request);
    $reqLen = strlen("{$request}");
    $run = 1;
    while ($run) {
        $SessionId = transmission_sessionId();
        $post = curl_init();
        $curl_options = array(CURLOPT_URL => "http://{$tr_host}:{$tr_port}{$tr_uri}", CURLOPT_USERPWD => "{$tr_user}:{$tr_pass}", CURLOPT_HTTPHEADER => array("POST {$tr_uri} HTTP/1.1", "Host: {$tr_host}", "X-Transmission-Session-Id: {$SessionId}", 'Connection: Close', "Content-Length: {$reqLen}", 'Content-Type: application/json'), CURLOPT_POSTFIELDS => "{$request}");
        get_curl_defaults($curl_options);
        curl_setopt_array($post, $curl_options);
        $raw = curl_exec($post);
        curl_close($post);
        if (preg_match('/409:? Conflict/', $raw)) {
            if (file_exists($sessionIdFile)) {
                unlink($sessionIdFile);
            }
        } else {
            $run = 0;
        }
    }
    return json_decode($raw, TRUE);
}
Example #29
0
 public function setUp()
 {
     $this->uid = function_exists('posix_getuid') ? posix_getuid() : 0;
     $this->gid = function_exists('posix_getgid') ? posix_getgid() : 0;
     @$na['n/a'];
     //putting error in known state
 }
Example #30
0
 /**
  * Checks that the user is root!
  * @return boolean
  */
 public function isSuperUser()
 {
     if (posix_getuid() == 0) {
         return true;
     }
     return false;
 }