aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/security
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-01-20 20:34:34 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2015-01-26 16:58:52 +0100
commit5ba19ba7fcda12e21fe37e8686218122936c9a68 (patch)
tree12b22f6dd3421bc674be128626ed688f9580b2a8 /lib/private/security
parent67da1f7e5ac9fc5472b6041dcfdc81a4b8428379 (diff)
downloadnextcloud-server-5ba19ba7fcda12e21fe37e8686218122936c9a68.tar.gz
nextcloud-server-5ba19ba7fcda12e21fe37e8686218122936c9a68.zip
certificate manager should always use a \OC\Files\View otherwise we will get problems for different primary storages
Diffstat (limited to 'lib/private/security')
-rw-r--r--lib/private/security/certificatemanager.php32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/private/security/certificatemanager.php b/lib/private/security/certificatemanager.php
index 0744546177f..7bc83766365 100644
--- a/lib/private/security/certificatemanager.php
+++ b/lib/private/security/certificatemanager.php
@@ -21,10 +21,17 @@ class CertificateManager implements ICertificateManager {
protected $uid;
/**
+ * @var \OC\Files\View
+ */
+ protected $view;
+
+ /**
* @param string $uid
+ * @param \OC\Files\View $view relative zu data/
*/
- public function __construct($uid) {
+ public function __construct($uid, \OC\Files\View $view) {
$this->uid = $uid;
+ $this->view = $view;
}
/**
@@ -34,18 +41,18 @@ class CertificateManager implements ICertificateManager {
*/
public function listCertificates() {
$path = $this->getPathToCertificates() . 'uploads/';
- if (!is_dir($path)) {
+ if (!$this->view->is_dir($path)) {
return array();
}
$result = array();
- $handle = opendir($path);
+ $handle = $this->view->opendir($path);
if (!is_resource($handle)) {
return array();
}
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
try {
- $result[] = new Certificate(file_get_contents($path . $file), $file);
+ $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
} catch(\Exception $e) {}
}
}
@@ -60,10 +67,10 @@ class CertificateManager implements ICertificateManager {
$path = $this->getPathToCertificates();
$certs = $this->listCertificates();
- $fh_certs = fopen($path . '/rootcerts.crt', 'w');
+ $fh_certs = $this->view->fopen($path . '/rootcerts.crt', 'w');
foreach ($certs as $cert) {
$file = $path . '/uploads/' . $cert->getName();
- $data = file_get_contents($file);
+ $data = $this->view->file_get_contents($file);
if (strpos($data, 'BEGIN CERTIFICATE')) {
fwrite($fh_certs, $data);
fwrite($fh_certs, "\r\n");
@@ -87,17 +94,14 @@ class CertificateManager implements ICertificateManager {
}
$dir = $this->getPathToCertificates() . 'uploads/';
- if (!file_exists($dir)) {
- //path might not exist (e.g. non-standard OC_User::getHome() value)
- //in this case create full path using 3rd (recursive=true) parameter.
- //note that we use "normal" php filesystem functions here since the certs need to be local
- mkdir($dir, 0700, true);
+ if (!$this->view->file_exists($dir)) {
+ $this->view->mkdir($dir);
}
try {
$file = $dir . $name;
$certificateObject = new Certificate($certificate, $name);
- file_put_contents($file, $certificate);
+ $this->view->file_put_contents($file, $certificate);
$this->createCertificateBundle();
return $certificateObject;
} catch (\Exception $e) {
@@ -117,8 +121,8 @@ class CertificateManager implements ICertificateManager {
return false;
}
$path = $this->getPathToCertificates() . 'uploads/';
- if (file_exists($path . $name)) {
- unlink($path . $name);
+ if ($this->view->file_exists($path . $name)) {
+ $this->view->unlink($path . $name);
$this->createCertificateBundle();
}
return true;