/**
  * Commit new records.
  *
  * @return void
  */
 public function commit()
 {
     $request = (object) array('pid' => getmypid(), 'threadid' => ZEND_THREAD_SAFE ? zend_thread_id() : null, 'uid' => getmyuid(), 'url' => $this->url->out_as_local_url(false), 'hostname' => gethostname(), 'memory' => memory_get_usage(), 'peakmemory' => memory_get_peak_usage());
     // Not supported on Windows until PHP 7
     if (function_exists('getrusage')) {
         $resourceusage = getrusage();
         $request->numswaps = $resourceusage['ru_nswap'];
         $request->numpagefaults = $resourceusage['ru_majflt'];
         $request->usertime = $resourceusage['ru_utime.tv_usec'];
     }
     $request->id = $this->db->insert_record('telemetry_request', $request);
     foreach ($this->additionalstate as $collector) {
         $table = $collector->get_table();
         $records = $collector->get_records();
         foreach ($records as $record) {
             $record->requestid = $request->id;
         }
         $this->db->insert_records($table, $records);
     }
 }
 /**
  * @param CommandSender $sender
  */
 public function sendPHPInfo(CommandSender $sender)
 {
     $info = ["CWD" => getcwd(), "GID" => getmygid(), "PID" => getmypid(), "UID" => getmyuid(), "Memory-usage" => memory_get_usage(true), "Memory-peak-usage" => memory_get_peak_usage(true), "PHP-version" => phpversion(), "Zend-version" => zend_version()];
     foreach ($info as $key => $value) {
         $sender->sendMessage($key . ": " . $value);
     }
 }
Esempio n. 3
0
function has_different_permissions($file)
{
    if (!file_exists($file)) {
        return false;
    }
    return fileowner($file) != getmyuid();
}
Esempio n. 4
0
 /**
  * Tests mocking a previously mocked function again.
  *
  * @test
  * @depends testMockFunctionWithoutParameters
  */
 public function testRedefine()
 {
     $this->mockFunction(__NAMESPACE__, "getmyuid", function () {
         return 5;
     });
     $this->assertEquals(5, getmyuid());
 }
Esempio n. 5
0
 public function getRuntimeDir($strict = true)
 {
     if ($runtimeDir = getenv('XDG_RUNTIME_DIR')) {
         return $runtimeDir;
     }
     if ($strict) {
         throw new \RuntimeException('XDG_RUNTIME_DIR was not set');
     }
     $fallback = sys_get_temp_dir() . DIRECTORY_SEPARATOR . self::RUNTIME_DIR_FALLBACK . getenv('USER');
     $create = false;
     if (!is_dir($fallback)) {
         mkdir($fallback, 0700, true);
     }
     $st = lstat($fallback);
     # The fallback must be a directory
     if (!$st['mode'] & self::S_IFDIR) {
         rmdir($fallback);
         $create = true;
     } elseif ($st['uid'] != getmyuid() || $st['mode'] & (self::S_IRWXG | self::S_IRWXO)) {
         rmdir($fallback);
         $create = true;
     }
     if ($create) {
         mkdir($fallback, 0700, true);
     }
     return $fallback;
 }
Esempio n. 6
0
File: uid.php Progetto: rhertzog/lcs
 /**
  * Checks the UID of the PHP process to make sure it is above PHPSECINFO_MIN_SAFE_UID
  *
  * @see PHPSECINFO_MIN_SAFE_UID
  */
 function _execTest()
 {
     if (getmyuid() >= PHPSECINFO_MIN_SAFE_UID) {
         return PHPSECINFO_TEST_RESULT_OK;
     }
     return PHPSECINFO_TEST_RESULT_WARN;
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
function trustedFile($file)
{
    // only trust local files owned by ourselves
    if (!eregi("^([a-z]+)://", $file) && fileowner($file) == getmyuid()) {
        return true;
    }
    return false;
}
Esempio n. 9
0
 public function mount()
 {
     $this->runCommand("sudo mount -t tmpfs -o size={$this->getSizeMb()}m tmpfs {$this->ram_disk_path}");
     $uid = getmyuid();
     $gid = getmygid();
     $this->runCommand("sudo chown {$uid}:{$gid} {$this->ram_disk_path}");
     $this->runCommand("chmod 0755 {$this->ram_disk_path}");
 }
Esempio n. 10
0
/**
 * sd_pid_notify_with_fds PHP implementation
 *
 * @param int    $pid FIXME currently not usable!
 * @param bool   $unset_environment
 * @param string $state
 * @param array  $fds
 *
 * @return int
 *
 * @link https://github.com/systemd/systemd/blob/master/src/libsystemd/sd-daemon/sd-daemon.c
 */
function sd_pid_notify_with_fds($pid, $unset_environment, $state, array $fds)
{
    $state = trim($state);
    if ('' === $state) {
        $r = -EINVAL;
        goto finish;
    }
    $e = getenv('NOTIFY_SOCKET');
    if (!$e) {
        return 0;
    }
    /* Must be an abstract socket, or an absolute path */
    if (strlen($e) < 2 || strpos($e, '@') !== 0 && strpos($e, '/') !== 0) {
        $r = -EINVAL;
        goto finish;
    }
    $fd = socket_create(AF_UNIX, SOCK_DGRAM, 0);
    if (!$fd) {
        $r = -1 * socket_last_error();
        goto finish;
    }
    $msghdr = ['name' => ['path' => $e], 'iov' => [$state . "\n"], 'control' => []];
    if (strpos($msghdr['name']['path'], '@') === 0) {
        $msghdr['name'][0] = "";
    }
    $pid = (int) $pid;
    $have_pid = $pid && getmypid() !== $pid;
    if (count($fds) > 0 || $have_pid) {
        if (count($fds)) {
            $msghdr['control'][] = ['level' => SOL_SOCKET, 'type' => SCM_RIGHTS, 'data' => $fds];
        }
        if ($have_pid) {
            $msghdr['control'][] = ['level' => SOL_SOCKET, 'type' => SCM_CREDENTIALS, 'data' => ['pid' => $pid, 'uid' => getmyuid(), 'gid' => getmygid()]];
        }
    }
    /* First try with fake ucred data, as requested */
    if (@socket_sendmsg($fd, $msghdr, MSG_NOSIGNAL) !== false) {
        $r = 1;
        goto finish;
    }
    /* If that failed, try with our own ucred instead */
    if ($have_pid) {
        $msghdr['control'] = [];
        if (@socket_sendmsg($fd, $msghdr, MSG_NOSIGNAL) !== false) {
            $r = 1;
            goto finish;
        }
    }
    $r = -1 * socket_last_error($fd);
    finish:
    if (isset($fd) && $fd) {
        socket_close($fd);
    }
    if ($unset_environment) {
        putenv('NOTIFY_SOCKET');
    }
    return $r;
}
Esempio n. 11
0
 public function url_stat($path)
 {
     $mode = 0666;
     $uid = 0;
     $gid = 0;
     $len = strlen('fiemulate://');
     $type = substr($path, $len, 1);
     switch (substr($path, $len, 1)) {
         case 'u':
             $uid = getmyuid();
             $gid = getmygid() + 1;
             switch (substr($path, $len + 2)) {
                 case 'not_readable':
                     $mode &= ~0400;
                     break;
                 case 'not_writable':
                     $mode &= ~0200;
                     break;
             }
             break;
         case 'g':
             $uid = getmyuid() + 1;
             $gid = getmygid();
             switch (substr($path, $len + 2)) {
                 case 'not_readable':
                     $mode &= ~0440;
                     break;
                 case 'not_writable':
                     $mode &= ~0220;
                     break;
             }
             break;
         case 'o':
             $uid = getmyuid() + 1;
             $gid = getmygid() + 1;
             switch (substr($path, $len + 2)) {
                 case 'not_readable':
                     $mode &= ~0444;
                     break;
                 case 'not_writable':
                     $mode &= ~0222;
                     break;
             }
             break;
         case 'a':
             $uid = getmyuid();
             $gid = getmygid();
             break;
     }
     $keys = array('dev', 'ino', 'mode', 'nlink', 'uid', 'gid', 'rdev', 'size', 'atime', 'mtime', 'ctime', 'blksize', 'blocks');
     $values = array(0, 0, $mode, 0, $uid, $gid, 0, 0, 0, 0, 0, 0, 0);
     foreach ($keys as $index => $key) {
         $values[$key] = $values[$index];
     }
     return $values;
 }
function randomBytes($length = 16, $secure = true, $raw = true, $startEntropy = "", &$rounds = 0, &$drop = 0)
{
    static $lastRandom = "";
    $output = "";
    $length = abs((int) $length);
    $secureValue = "";
    $rounds = 0;
    $drop = 0;
    while (!isset($output[$length - 1])) {
        //some entropy, but works ^^
        $weakEntropy = array(is_array($startEntropy) ? implode($startEntropy) : $startEntropy, serialize(stat(__FILE__)), __DIR__, PHP_OS, microtime(), (string) lcg_value(), (string) PHP_MAXPATHLEN, PHP_SAPI, (string) PHP_INT_MAX . "." . PHP_INT_SIZE, serialize($_SERVER), serialize(get_defined_constants()), get_current_user(), serialize(ini_get_all()), (string) memory_get_usage() . "." . memory_get_peak_usage(), php_uname(), phpversion(), extension_loaded("gmp") ? gmp_strval(gmp_random(4)) : microtime(), zend_version(), (string) getmypid(), (string) getmyuid(), (string) mt_rand(), (string) getmyinode(), (string) getmygid(), (string) rand(), function_exists("zend_thread_id") ? (string) zend_thread_id() : microtime(), var_export(@get_browser(), true), function_exists("getrusage") ? @implode(getrusage()) : microtime(), function_exists("sys_getloadavg") ? @implode(sys_getloadavg()) : microtime(), serialize(get_loaded_extensions()), sys_get_temp_dir(), (string) disk_free_space("."), (string) disk_total_space("."), uniqid(microtime(), true), file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : microtime());
        shuffle($weakEntropy);
        $value = hash("sha512", implode($weakEntropy), true);
        $lastRandom .= $value;
        foreach ($weakEntropy as $k => $c) {
            //mixing entropy values with XOR and hash randomness extractor
            $value ^= hash("sha256", $c . microtime() . $k, true) . hash("sha256", mt_rand() . microtime() . $k . $c, true);
            $value ^= hash("sha512", (string) lcg_value() . $c . microtime() . $k, true);
        }
        unset($weakEntropy);
        if ($secure === true) {
            $strongEntropyValues = array(is_array($startEntropy) ? hash("sha512", $startEntropy[($rounds + $drop) % count($startEntropy)], true) : hash("sha512", $startEntropy, true), file_exists("/dev/urandom") ? fread(fopen("/dev/urandom", "rb"), 64) : str_repeat("", 64), (function_exists("openssl_random_pseudo_bytes") and version_compare(PHP_VERSION, "5.3.4", ">=")) ? openssl_random_pseudo_bytes(64) : str_repeat("", 64), function_exists("mcrypt_create_iv") ? mcrypt_create_iv(64, MCRYPT_DEV_URANDOM) : str_repeat("", 64), $value);
            $strongEntropy = array_pop($strongEntropyValues);
            foreach ($strongEntropyValues as $value) {
                $strongEntropy = $strongEntropy ^ $value;
            }
            $value = "";
            //Von Neumann randomness extractor, increases entropy
            $bitcnt = 0;
            for ($j = 0; $j < 64; ++$j) {
                $a = ord($strongEntropy[$j]);
                for ($i = 0; $i < 8; $i += 2) {
                    $b = ($a & 1 << $i) > 0 ? 1 : 0;
                    if ($b != (($a & 1 << $i + 1) > 0 ? 1 : 0)) {
                        $secureValue |= $b << $bitcnt;
                        if ($bitcnt == 7) {
                            $value .= chr($secureValue);
                            $secureValue = 0;
                            $bitcnt = 0;
                        } else {
                            ++$bitcnt;
                        }
                        ++$drop;
                    } else {
                        $drop += 2;
                    }
                }
            }
        }
        $output .= substr($value, 0, min($length - strlen($output), $length));
        unset($value);
        ++$rounds;
    }
    $lastRandom = hash("sha512", $lastRandom, true);
    return $raw === false ? bin2hex($output) : $output;
}
Esempio n. 13
0
 public static function matchingLetter($file)
 {
     if (fileowner($file) === getmyuid()) {
         return 'u';
     }
     if (filegroup($file) === getmygid()) {
         return 'g';
     }
     return 'o';
 }
Esempio n. 14
0
 public function pull_project()
 {
     if (!is_cli()) {
         echo 'This controller must run from command line interface only.' . PHP_EOL;
         return;
     }
     exec('git pull');
     exec('chown ' . getmyuid() . ':' . getmygid() . ' ' . FCPATH . '.. -R');
     exec('chmod 0777 ' . APPPATH . 'cache');
     exec('chmod 0777 ' . APPPATH . 'logs');
 }
Esempio n. 15
0
 public function __construct()
 {
     $this->config = array('filename' => basename(__FILE__), 'username' => '', 'password' => '', 'interpreter' => 'shell_exec', 'current_user' => get_current_user(), 'hostname' => function_exists('gethostname') ? gethostname() : $_SERVER['HTTP_HOST'], 'server_address' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1', 'server_port' => $_SERVER['SERVER_PORT'], 'request_time' => $_SERVER['REQUEST_TIME'], 'php_owner_uid' => getmyuid(), 'php_owner_gid' => getmygid(), 'php_process_id' => getmypid(), 'inode_script' => getmyinode(), 'last_page_modification' => getlastmod(), 'cwd' => getcwd());
     if (isset($_SESSION['interpreter'])) {
         $this->config['interpreter'] = $_SESSION['interpreter'];
     }
     if (isset($_SESSION['cwd']) && $_SESSION['cwd'] != $this->config['cwd']) {
         chdir($_SESSION['cwd']);
         $this->config['cwd'] = getcwd();
     }
     $this->config['prompt'] = $this->get_prompt();
 }
Esempio n. 16
0
 /**
  * Check that we are being called via HTTPS in favor of HTTP.
  *
  * @return void
  */
 protected function doTest()
 {
     $this->setMessage('Check that the file owner matches the user executing php');
     $request = Request::createFromGlobals();
     $owning = fileowner($request->server->get('SCRIPT_FILENAME'));
     $running = getmyuid();
     if ($owning === $running) {
         $this->markSuccess();
         return;
     }
     $this->markWarning('Script is owned by uid ' . $owning . ' whereas it is being executed by uid ' . $running);
 }
Esempio n. 17
0
 /**
  * Check if path is writable.
  *
  * @param string $path
  * @return bool
  */
 public static function isWritable($path)
 {
     if (!is_writable($path)) {
         return false;
     }
     if (ini_get('safe_mode')) {
         if (ini_get('safe_mode_gid') ? getmygid() != filegroup($path) : getmyuid() != fileowner($path)) {
             return false;
         }
     }
     return true;
 }
Esempio n. 18
0
 public function runProvider()
 {
     $echo = function () {
         echo 'test';
         return true;
     };
     $uid = function () {
         echo getmyuid();
         return true;
     };
     $job = ['closure' => $echo];
     return ['diabled, not run' => [$job + ['enabled' => false], ''], 'normal job, run' => [$job, 'test'], 'wrong host, not run' => [$job + ['runOnHost' => 'something that does not match'], ''], 'current user, run,' => [['closure' => $uid], getmyuid()]];
 }
Esempio n. 19
0
 protected function _init()
 {
     $this->os = new Zend_Environment_Field(array('title' => 'OS', 'info' => 'Host operating system', 'value' => PHP_OS));
     $this->uid = new Zend_Environment_Field(array('title' => 'Script uid', 'info' => 'script user id', 'value' => getmyuid()));
     $this->gid = new Zend_Environment_Field(array('title' => 'Script gid', 'info' => 'script group id', 'value' => getmygid()));
     $this->script_username = new Zend_Environment_Field(array('title' => 'Script username', 'info' => 'username obtained via HTTP authentication', 'value' => get_current_user()));
     $this->memory = new Zend_Environment_Field(array('title' => 'Memory', 'info' => 'Memory used by this script on host'));
     if (function_exists('memory_get_usage')) {
         $this->memory->value = memory_get_usage();
     } else {
         $this->memory->notice = 'memory_get_usage() not enabled';
     }
 }
Esempio n. 20
0
 public function runProvider()
 {
     $echo = function () {
         echo 'test';
         return true;
     };
     $uid = function () {
         echo getmyuid();
         return true;
     };
     $job = ['command' => $echo];
     return ['diabled, not run' => [$job + ['enabled' => false], ''], 'cron schedule, not run' => [$job + ['schedule' => '0 0 1 1 *'], ''], 'date time, not run' => [$job + ['schedule' => date('Y-m-d H:i:s', strtotime('tomorrow'))], ''], 'date time, run' => [$job + ['schedule' => date('Y-m-d H:i:s')], 'test'], 'wrong host, not run' => [$job + ['runOnHost' => 'something that does not match'], ''], 'current user, run,' => [['command' => $uid], getmyuid()]];
 }
 public function stat()
 {
     $time = time();
     if ($this->_getStreamContent() != null) {
         $size = strlen($this->_getStreamContent());
     } else {
         $size = 0;
     }
     $uid = getmyuid();
     $gid = getmygid();
     $mode = octdec(100000 + $this->_getStreamMode());
     $keys = array('dev' => 0, 'ino' => 0, 'mode' => $mode, 'nlink' => 0, 'uid' => $uid, 'gid' => $gid, 'rdev' => 0, 'size' => $size, 'atime' => $time, 'mtime' => $time, 'ctime' => $time, 'blksize' => 0, 'blocks' => 0);
     $return_value = $keys + array_values($keys);
     return $return;
 }
function _WP_Filesystem_bestOption($preference = 'direct')
{
    $tempFile = tempnam('/tmp', 'WPU');
    //Remember, We have to unlink this file.
    switch ($preference) {
        default:
        case 'direct':
            //Likely suPHP or windows.
            if (getmyuid() == fileowner($tempFile)) {
                $method = 'direct';
            }
            break;
        case 'phpext':
            if (extension_loaded('ftp')) {
                $method = 'ftpext';
            }
            break;
        case 'phpsocket':
            if (extension_loaded('sockets')) {
                $method = 'ftpsockets';
            }
            break;
            /*case 'phpstream':
            		if( function_exists('stream_get_transports()') &&
            			in_array('tcp',stream_get_transports()) )
            			$method = 'pemftp';
            		break;*/
    }
    if ($method) {
        unlink($tempFile);
        return $method;
    }
    if (getmyuid() == fileowner($tempFile)) {
        unlink($tempFile);
        return 'direct';
    } else {
        unlink($tempFile);
    }
    if (extension_loaded('ftp')) {
        return 'ftpext';
    }
    if (extension_loaded('sockets')) {
        return 'ftpsockets';
    }
    //if( in_array('tcp',stream_get_transports()) ) return 'pemftp';
    return false;
}
Esempio n. 23
0
 private function setAccessMode()
 {
     // get the user-ID of the user who owns the loaded file
     try {
         $fsFile = new FileSystemFile($this->file);
         $fileOwnerUserId = $fsFile->getFileOwner();
         \DBG::msg('File (FileSystem): ' . $this->file . ' is owned by ' . $fileOwnerUserId);
     } catch (FileSystemFileException $e) {
         \DBG::msg('FileSystemFile: ' . $e->getMessage());
         \DBG::msg('File: CAUTION: ' . $this->file . ' is owned by an unknown user!');
         return false;
     }
     // get the user-ID of the user running the PHP-instance
     if (function_exists('posix_getuid')) {
         $phpUserId = posix_getuid();
     } else {
         $phpUserId = getmyuid();
     }
     \DBG::msg('File (PHP): Script user is ' . $phpUserId);
     // check if the file we're going to work with is owned by the PHP user
     if ($fileOwnerUserId == $phpUserId) {
         $this->accessMode = self::PHP_ACCESS;
         \DBG::msg('File: Using FileSystem access');
         return true;
     }
     // fetch FTP user-ID
     $ftpConfig = \Env::get('ftpConfig');
     $ftpUsername = $ftpConfig['username'];
     if (function_exists('posix_getpwnam')) {
         $ftpUserInfo = posix_getpwnam($ftpUsername);
         $ftpUserId = $ftpUserInfo['uid'];
         \DBG::msg('File (FTP): ' . $this->file . ' is owned by ' . $ftpUserId);
     } else {
         $ftpUserId = null;
     }
     // check if the file we're going to work with is owned by the FTP user
     if ($fileOwnerUserId == $ftpUserId) {
         $this->accessMode = self::FTP_ACCESS;
         \DBG::msg('File: Using FTP access');
         return true;
     }
     // the file to work on is neither owned by the PHP user nor the FTP user
     \DBG::msg('File: CAUTION: ' . $this->file . ' is owned by an unknown user!');
     $this->accessMode = self::UNKNOWN_ACCESS;
     return false;
 }
Esempio n. 24
0
 public function __construct()
 {
     $this->scriptFilename = $this->getServerVar('SCRIPT_FILENAME');
     $this->documentRoot = $this->getServerVar('DOCUMENT_ROOT');
     $this->httpHost = $this->getServerVar('HTTP_HOST');
     $this->adminEmail = $this->getServerVar('SERVER_ADMIN');
     $this->time = date('Y.m.d H:i:s', $this->getServerVar('REQUEST_TIME'));
     $this->serverAddr = $this->getServerVar('SERVER_ADDR');
     $this->serverSoftware = $this->getServerVar('SERVER_SOFTWARE');
     $this->serverGateway = $this->getServerVar('GATEWAY_INTERFACE');
     $this->serverSignature = $this->getServerVar('SERVER_SIGNATURE');
     $this->serverHostname = @php_uname('n');
     $this->serverPlatform = @php_uname('s') . ' ' . @php_uname('r') . ' ' . @php_uname('v');
     $this->serverArchitecture = @php_uname('m');
     $this->username = '******' . @getmyuid() . ', gid: ' . @getmygid();
     $this->pathinfo = getcwd();
     $this->phpinfo = $this->getCompactPhpInfo();
 }
 static function Open()
 {
     // Check if native PHP methods should be used - Test 1
     self::$native = is_writable(DOC_ROOT) && getmyuid() == fileowner(DOC_ROOT) ? true : false;
     // Check if native PHP methods should be used - Test 2
     if (self::$native) {
         // Create temporary file
         $native_check_file = DOC_ROOT . '/native-check' . time();
         $handle = @fopen($native_check_file, 'w');
         @fwrite($handle, 'Native Check');
         // Check if webserver/PHP has filesystem access
         self::$native = fileowner($native_check_file) == getmyuid() ? true : false;
         // Remove temporary file
         @fclose($handle);
         @unlink($native_check_file);
     }
     // Login to server via FTP if PHP doesn't have write access
     if (!self::$native) {
         // Set FTP login settings
         global $settings;
         self::$ftp_hostname = $settings->ftp_hostname;
         self::$ftp_username = $settings->ftp_username;
         self::$ftp_password = $settings->ftp_password;
         self::$ftp_path = $settings->ftp_path;
         self::$ftp_ssl = $settings->ftp_ssl;
         // Connect to FTP host
         if (self::$ftp_ssl) {
             if (!function_exists('ftp_ssl_connect')) {
                 throw new Exception("Your host doesn't support FTP over SSL connections.");
             }
             self::$ftp_stream = @ftp_ssl_connect(self::$ftp_hostname);
         } else {
             self::$ftp_stream = @ftp_connect(self::$ftp_hostname);
         }
         if (!self::$ftp_stream) {
             throw new Exception("Unable to connect to FTP host (" . self::$ftp_hostname . ")");
         }
         // Login with username and password
         if (!@ftp_login(self::$ftp_stream, self::$ftp_username, self::$ftp_password)) {
             throw new Exception("Unable to login to FTP server (Username: '******', Password: '******')");
         }
     }
     return self::$native ? 'native' : 'ftp';
 }
Esempio n. 26
0
 function have_direct_access()
 {
     if (!is_null($this->have_direct_access)) {
         return $this->have_direct_access;
     }
     $this->have_direct_access = false;
     if (!function_exists('getmyuid') || !function_exists('fileowner') || !function_exists('posix_getgroups') || !function_exists('filegroup')) {
         return $this->have_direct_access;
     }
     $temp_file_name = $this->config->root_path . '/temp-write-test-' . time();
     $temp_handle = @fopen($temp_file_name, 'w');
     if ($temp_handle) {
         if (getmyuid() == @fileowner($temp_file_name) || in_array(@filegroup($temp_file_name), posix_getgroups())) {
             $this->have_direct_access = true;
         }
         @fclose($temp_handle);
         @unlink($temp_file_name);
     }
     return $this->have_direct_access;
 }
Esempio n. 27
0
 function needsRemoteAccess()
 {
     if (!function_exists('getmyuid') && !function_exists('fileowner')) {
         return false;
     }
     $fn = DATA_DIR . '/temp-write-test-' . time();
     $f = @fopen($fn, 'w');
     if (!$f) {
         throw new Am_Exception_InternalError("Could not create test file - check if data dir is writeable");
     }
     if (getmyuid() == @fileowner($fn)) {
         return false;
     }
     @fclose($f);
     @unlink($fn);
     return true;
 }
Esempio n. 28
0
echo "<title>_GsC_SheLL_v0.8_By _GsC_</title>";
//Style CSS
echo "<style>\ninput  {\n                background: #b00;\n                color: #fff;\n            }\n\n            input:hover  {\n                background: #000;\n            }\n\n            select  {\n                background: #b00;\n                color: #fff;\n            }\n            \n            select:hover  {\n                background: #000;\n            }\n\n            hr  {     color: red;\n                      background-color: red;\n                      height: 3px;  \n                      width:100%;\n                      border:0;   }\n\n            .footer table { border:1px dashed black\n                    }\n\n            .footer tr { border:1px groove black\n                    }\n\n            .footer td { border:1px groove black\n                    }\n\n            textarea  {\n                background: #b00;\n                color: #fff;\n            }\n\n            textarea:hover  {\n                background: #000;\n            }\n\n            body  {\n                font-family: courier,courier-new,arial;\n                background-color:black;\n                color:white;\n            }\n\n            A:link { text-decoration: none;\n                     color:white\n            }\n\n            A:hover {  \n                     color:red\n            }\n\n            a:visited { text-decoration: none;\n            color: #FFFFFF;\n            }\n\n            A:visited:hover {  \n                     color:red\n            }\n\n            table {border:1px dashed red}\n\n            td {border:1px groove #666666}\n\n            #dropper:hover  {\n                color: #fff;\n            }\n        </style> ";
//Banner
echo "<center><b><a href=\"?\"><font color=\"green\" size=\"8\">_GsC_</font><font color=\"white\" size=\"8\">SheLL_</font><font color=\"red\" size=\"8\">V0.8_</font></a></b></center><br> <br>";
echo "<hr>";
//Applicazioni
echo "<center><b>[<a href=?mode=fakemail>Fake mailer</a>] [<a href=?mode=PHPinfo>PHP info</a>]</center><hr>";
//Info
echo "<center><table border=\"0\"><tr><td><b><font color=red>Ip server:</font></b> " . $_SERVER['SERVER_ADDR'] . "</td><td><b><font color=red>Server Software:</font></b> " . $_SERVER['SERVER_SOFTWARE'] . "</td><td><b><font color=red>Versione PHP:</font></b> " . phpversion() . " </tr><tr>\n<td><b><font color=red>Your ip:</font></b> " . $_SERVER['REMOTE_ADDR'] . "</td><td><b><font color=red>Safe mode:</font></b>";
if (@ini_get("safe_mode") == "1" || @ini_get("safe_mode") == "on") {
    echo "On";
} else {
    echo "Off";
}
echo "</td><td><b><font color=red>id:</font></b> " . get_current_user() . " | uid= " . getmyuid() . " | gid= " . getmygid() . "</td></tr></table></center><br><hr>";
//Variabili Generali
$dir = htmlspecialchars($_GET['dir']);
// Home shell
if (!isset($mode)) {
    $_GET['dir'] == '' ? $dir = @getcwd() : ($dir = htmlspecialchars($_GET['dir']));
    @chdir($dir);
    if (isset($dir)) {
        echo "<form method=get>&nbsp;&nbsp;Dir : <input type=text name=dir value={$dir} size=65%>&nbsp;<input type=submit value=Invia></form>";
    }
    echo "<table width=\"100%\" border=1><tr><td><b>File name</b></td><td><b>Tipo</b></td><td><b>Size (KB)</b></td><td><b>Chmod</b></td><td><b>Azioni</b></td></tr>";
    foreach (glob("*") as $file) {
        $chmod = substr(sprintf('%o', fileperms($file)), -3);
        if (is_dir($file)) {
            if (isset($dir)) {
                echo "\n                    \n                    \n                    <tr>\n                            <td>\n                                <a href=?dir=" . @getcwd() . "/" . $file . ">\n                                    <font color=\"red\">{$file}</font>\n                                </a>\n                            </td>\n                            <td>\n                            Folder\n                            <td>\n                            " . filesize($file) . "\n                            </td>\n                            <td>\n                            {$chmod}\n                            </td>\n                            <td>\n                            [<a href=?mode=rename&file={$dir}/{$file}>R</a>] [<a href=?mode=delete&file={$dir}/{$file}>D</a>] [<a href=?mode=copy&file={$dir}/{$file}>C</a>] [<a href=?mode=chmod&file={$dir}/{$file}&chmod={$chmod}>P</a>] [<a href=?mode=download&file={$dir}/{$file}>D</a>]\n                            </td>\n                        </tr>\n                        ";
Esempio n. 29
0
        $_file .= '/' . $pear_system_config;
    }
    if ($_file == '/') {
        $_file = 'The default config file';
    }
    $config->getMessage();
    $ui->outputData("ERROR: {$_file} is not a valid config file or is corrupted.");
    // We stop, we have no idea where we are :)
    exit;
}
// this is used in the error handler to retrieve a relative path
$_PEAR_PHPDIR = $config->get('php_dir');
$ui->setConfig($config);
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
if (ini_get('safe_mode')) {
    $ui->outputData('WARNING: running in safe mode requires that all files created ' . 'be the same uid as the current script.  PHP reports this script is uid: ' . @getmyuid() . ', and current user is: ' . @get_current_user());
}
$verbose = $config->get("verbose");
$cmdopts = array();
if ($raw) {
    if (!$config->isDefinedLayer('user') && !$config->isDefinedLayer('system')) {
        $found = false;
        foreach ($opts as $opt) {
            if ($opt[0] == 'd' || $opt[0] == 'D') {
                $found = true;
                // the user knows what they are doing, and are setting config values
            }
        }
        if (!$found) {
            // no prior runs, try to install PEAR
            if (strpos(dirname(__FILE__), 'scripts')) {
Esempio n. 30
0
function eZSetupPrvPosixExtension()
{
    $userInfo = array('has_extension' => false);
    if (extension_loaded('posix')) {
        $userInfo['has_extension'] = true;
        $uinfo = posix_getpwuid(posix_getuid());
        $ginfo = posix_getgrgid(posix_getgid());
        $userInfo['user_name'] = $uinfo['name'];
        $userInfo['user_id'] = $uinfo['uid'];
        $userInfo['group_name'] = $ginfo['name'];
        $userInfo['group_id'] = $ginfo['gid'];
        $userInfo['group_members'] = $ginfo['members'];
        $userInfo['script_user_id'] = getmyuid();
        $userInfo['script_group_id'] = getmygid();
    }
    return $userInfo;
}