Пример #1
0
 public function __construct(dropr_Client_Storage_Abstract $storage)
 {
     $ipcPath = DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'droprIpc' . DIRECTORY_SEPARATOR;
     $channelName = $ipcPath . hash('sha1', realpath($storage->getDsn()));
     $this->storage = $storage;
     if (!is_dir($ipcPath)) {
         mkdir($ipcPath, 0777, true);
     }
     if (!is_file($channelName)) {
         if (!posix_mknod($channelName, 0666)) {
             throw new Exception("could not mknod {$channelName}!");
         }
     }
     dropr::log("doing ftok({$channelName})", LOG_DEBUG);
     $this->ipcChannel = msg_get_queue(ftok($channelName, '*'));
 }
Пример #2
0
VERIFY(posix_getpgrp());
VERIFY(posix_getpid());
VERIFY(posix_getppid());
$ret = posix_getpwnam("root");
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VS(posix_getpwnam(""), false);
VS(posix_getpwnam(-1), false);
$ret = posix_getpwuid(0);
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VS(posix_getpwuid(-1), false);
$ret = posix_getrlimit();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
VERIFY(posix_getsid(posix_getpid()));
$tmpfifo = tempnam('/tmp', 'vmmkfifotest');
unlink($tmpfifo);
VERIFY(posix_mkfifo($tmpfifo, 0));
$tmpnod = tempnam('/tmp', 'vmmknodtest');
unlink($tmpnod);
VERIFY(posix_mknod($tmpnod, 0));
VERIFY(posix_setpgid(0, 0));
VERIFY(posix_setsid());
VERIFY(strlen(posix_strerror(1)));
$ret = posix_times();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
$ret = posix_uname();
VERIFY($ret != false);
VERIFY(count((array) $ret) != 0);
Пример #3
0
 /**
  * Extract the current entry to which the iterator points.
  *
  * Extract the current entry to which the iterator points, and return true if the current entry is extracted.
  * If the iterator doesn't point to a valid entry, this method returns false.
  *
  * True if the file is extracted correctly, otherwise false.
  *
  * @param string $target
  *        The full path to which the target should be extracted.
  * @param bool $keepExisting
  *        True if the file shouldn't be overwritten if they already exist.
  *        For the opposite behaviour, false should be given.
  *
  * @throws ezcArchiveValueException     if the archive contains invalid values.
  * @throws ezcBaseFileNotFoundException if the link cannot be found.
  *
  * @return bool
  */
 public function extractCurrent($target, $keepExisting = false)
 {
     if ($this->file === null) {
         throw new ezcArchiveException("The archive is closed");
     }
     if (!$this->valid()) {
         return false;
     }
     $isWindows = substr(php_uname('s'), 0, 7) == 'Windows' ? true : false;
     $entry = $this->current();
     $type = $entry->getType();
     $fileName = $target . DIRECTORY_SEPARATOR . $entry->getPath();
     if ($type == ezcArchiveEntry::IS_LINK) {
         $linkName = $target . DIRECTORY_SEPARATOR . $entry->getLink();
         if (!file_exists($linkName)) {
             throw new ezcBaseFileNotFoundException($linkName, "link", "Hard link could not be created.");
         }
     }
     $this->createDefaultDirectory($fileName);
     if (!$keepExisting || !is_link($fileName) && !file_exists($fileName)) {
         if ((file_exists($fileName) || is_link($fileName)) && !is_dir($fileName)) {
             unlink($fileName);
         }
         if (!file_exists($fileName)) {
             switch ($type) {
                 case ezcArchiveEntry::IS_CHARACTER_DEVICE:
                     if (ezcBaseFeatures::hasFunction('posix_mknod')) {
                         posix_mknod($fileName, POSIX_S_IFCHR, $entry->getMajor(), $entry->getMinor());
                     } else {
                         throw new ezcArchiveValueException($type);
                     }
                     break;
                 case ezcArchiveEntry::IS_BLOCK_DEVICE:
                     if (ezcBaseFeatures::hasFunction('posix_mknod')) {
                         posix_mknod($fileName, POSIX_S_IFBLK, $entry->getMajor(), $entry->getMinor());
                     } else {
                         throw new ezcArchiveValueException($type);
                     }
                     break;
                 case ezcArchiveEntry::IS_FIFO:
                     if (ezcBaseFeatures::hasFunction('posix_mknod')) {
                         posix_mknod($fileName, POSIX_S_IFIFO);
                     } else {
                         throw new ezcArchiveValueException($type);
                     }
                     break;
                 case ezcArchiveEntry::IS_SYMBOLIC_LINK:
                     if ($isWindows) {
                         // FIXME.. need to be sure that target file
                         // already extracted before copying it to link destination.
                         $sourcePath = dirname($fileName) . '/' . $entry->getLink();
                         $fileName = str_replace('/', '\\', $fileName);
                         copy($sourcePath, $fileName);
                     } else {
                         symlink($entry->getLink(), $fileName);
                     }
                     break;
                 case ezcArchiveEntry::IS_LINK:
                     if ($isWindows) {
                         copy($target . DIRECTORY_SEPARATOR . $entry->getLink(), $fileName);
                     } else {
                         link($target . DIRECTORY_SEPARATOR . $entry->getLink(), $fileName);
                     }
                     break;
                 case ezcArchiveEntry::IS_DIRECTORY:
                     $permissions = $entry->getPermissions();
                     if ($permissions === null || $permissions === false) {
                         $permissions = '0777';
                     }
                     mkdir($fileName, octdec($permissions), true);
                     break;
                 case ezcArchiveEntry::IS_FILE:
                     $this->writeCurrentDataToFile($fileName);
                     break;
                 default:
                     throw new ezcArchiveValueException($type);
             }
             if ($type == ezcArchiveEntry::IS_SYMBOLIC_LINK && ezcBaseFeatures::hasFunction('posix_geteuid') && posix_geteuid() == 0) {
                 $user = $entry->getUserId();
                 $group = $entry->getGroupId();
                 @lchown($fileName, $user);
                 @lchgrp($fileName, $group);
             }
             // Change the username and group if the filename exists and if
             // the intention is to keep it as a file. A zip archive
             // stores the symlinks in a file; thus don't change these.
             if (file_exists($fileName) && ($type == ezcArchiveEntry::IS_FILE || $type == ezcArchiveEntry::IS_DIRECTORY)) {
                 $group = $entry->getGroupId();
                 $user = $entry->getUserId();
                 $time = $entry->getModificationTime();
                 $perms = octdec($entry->getPermissions());
                 if ($this->options && $this->options->extractCallback) {
                     $this->options->extractCallback->{$type == ezcArchiveEntry::IS_DIRECTORY ? 'createDirectoryCallback' : 'createFileCallback'}($fileName, $perms, $user, $group);
                 }
                 if (ezcBaseFeatures::hasFunction('posix_geteuid') && posix_geteuid() === 0) {
                     @chgrp($fileName, $group);
                     @chown($fileName, $user);
                 }
                 if ($perms != false) {
                     chmod($fileName, $perms);
                 }
                 touch($fileName, $time);
             }
         }
         return true;
     }
     return false;
 }
Пример #4
0
<?php

$file = '/etc/passwd' . chr(0) . 'asdf';
var_dump(posix_access($file));
var_dump(posix_mkfifo($file, 0644));
var_dump(posix_mknod($file, 0644));
Пример #5
0
 public function testAppendToCurrentFifo()
 {
     if (!$this->canWrite) {
         return;
     }
     if (!ezcBaseFeatures::hasFunction('posix_mknod')) {
         return;
     }
     $dir = $this->getTempDir();
     posix_mknod("{$dir}/myfifo", POSIX_S_IFIFO);
     $fifo = "{$dir}/my_fifo.tar";
     $bf = new ezcArchiveBlockFile($fifo, true);
     $archive = ezcArchive::getTarInstance($bf, $this->tarMimeFormat);
     $archive->appendToCurrent("{$dir}/myfifo", "{$dir}");
     $archive->close();
     // Do the same with gnu tar.
     exec("tar -cf {$dir}/gnutar.tar --format=" . $this->tarFormat . " -C {$dir}/ myfifo");
     $this->assertEquals(file_get_contents("{$dir}/gnutar.tar"), file_get_contents($fifo));
     unlink("{$dir}/myfifo");
 }
Пример #6
0
<?php

var_dump(posix_mknod(NULL, NULL, NULL, NULL));