{"action":"created","issue":{"url":"https://api.github.com/repos/owncloud/core/issues/15017","labels_url":"https://api.github.com/repos/owncloud/core/issues/15017/labels{/name}","comments_url":"https://api.github.com/repos/owncloud/core/issues/15017/comments","events_url":"https://api.github.com/repos/owncloud/core/issues/15017/events","html_url":"https://github.com/owncloud/core/issues/15017","id":62806577,"number":15017,"title":"Swift Object Storage doesn't work with Encryption App on 8.0.2","user":{"login":"rvrangel","id":848006,"avatar_url":"https://avatars.githubusercontent.com/u/848006?v=3","gravatar_id":"","url":"https://api.github.com/users/rvrangel","html_url":"https://github.com/rvrangel","followers_url":"https://api.github.com/users/rvrangel/followers","following_url":"https://api.github.com/users/rvrangel/following{/other_user}","gists_url":"https://api.github.com/users/rvrangel/gists{/gist_id}","starred_url":"https://api.github.com/users/rvrangel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvrangel/subscriptions","organizations_url":"https://api.github.com/users/rvrangel/orgs","repos_url":"https://api.github.com/users/rvrangel/repos","events_url":"https://api.github.com/users/rvrangel/events{/privacy}","received_events_url":"https://api.github.com/users/rvrangel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/owncloud/core/labels/app:files_encryption","name":"app:files_encryption","color":"02d7e1"},{"url":"https://api.github.com/repos/owncloud/core/labels/app:objectstore","name":"app:objectstore","color":"02d7e1"},{"url":"https://api.github.com/repos/owncloud/core/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/11","html_url":"https://github.com/owncloud/core/milestones/backlog","labels_url":"https://api.github.com/repos/owncloud/core/milestones/11/labels","id":697149,"number":11,"title":"backlog","description":"","creator":{"login":"MTRichards","id":1818977,"avatar_url":"https://avatars.githubusercontent.com/u/1818977?v=3","gravatar_id":"","url":"https://api.github.com/users/MTRichards","html_url":"https://github.com/MTRichards","followers_url":"https://api.github.com/users/MTRichards/followers","following_url":"https://api.github.com/users/MTRichards/following{/other_user}","gists_url":"https://api.github.com/users/MTRichards/gists{/gist_id}","starred_url":"https://api.github.com/users/MTRichards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MTRichards/subscriptions","organizations_url":"https://api.github.com/users/MTRichards/orgs","repos_url":"https://api.github.com/users/MTRichards/repos","events_url":"https://api.github.com/users/MTRichards/events{/privacy}","received_events_url":"https://api.github.com/users/MTRichards/received_events","type":"User","site_admin":false},"open_issues":558,"closed_issues":102,"state":"open","created_at":"2014-06-20T19:52:03Z","updated_at":"2015-10-27T16:56:53Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-03-18T21:31:25Z","updated_at":"2015-10-27T19:39:30Z","closed_at":null,"body":"### Steps to reproduce\r\n1. Install owncloud 8.0.2\r\n2. Store files in a Swift Object Storage\r\n3. Enable encryption\r\n\r\n### Expected behaviour\r\nFile should be stored correctly with its key.\r\n\r\n### Actual behaviour\r\nIt seems the files are uploaded, but when owncloud tries to create a temporary fileKey, it fails. I don't understand how owncloud does it, but I believe when the encryption app is disabled, the file is saves directly to the **data** dir, but when using swift it has to create a temporary file and update it afterwards.\r\n\r\nIn this case, it tries to **touch** the file **/tmp/oc_tmp_a6b01e156c7a13a8ee28a6c9f68dbcdf.txt/fileKey**, but the folder **/tmp/oc_tmp_a6b01e156c7a13a8ee28a6c9f68dbcdf.txt/** does not exist and it fails. I believe creating the folder before should solve this issue.\r\n\r\n### Server configuration\r\n**Operating system**: Ubuntu 14.04\r\n\r\n**Web server:** lighttpd\r\n\r\n**Database:** SQLite\r\n\r\n**PHP version:** 5.5.9\r\n\r\n**ownCloud version:** 8.0.2\r\n\r\n**Updated from an older ownCloud or fresh install:** fresh install\r\n\r\n**List of activated apps:** files_encryption\r\n\r\n**The content of config/config.php:** \r\n\r\n```\r\n<?php\r\n$CONFIG = array (\r\n  'instanceid' => 'xxx',\r\n  'passwordsalt' => 'xxx',\r\n  'secret' => 'xxx',\r\n  'trusted_domains' => \r\n  array (\r\n    0 => 'xxx',\r\n  ),\r\n  'datadirectory' => '/var/www/owncloud/data',\r\n  'overwrite.cli.url' => 'https://xxx',\r\n  'dbtype' => 'sqlite3',\r\n  'version' => '8.0.2.0',\r\n  'installed' => true,\r\n  'forcessl' => true,\r\n  \r\n  'objectstore' => array(\r\n    'class' => 'OC\\\\Files\\\\ObjectStore\\\\Swift',\r\n    'arguments' => array(\r\n      'username' => 'xxx',\r\n      'password' => 'xxx',\r\n      'container' => 'xxx',\r\n      'autocreate' => false,\r\n      'region' => 'xxx',\r\n      'url' => 'xxx',\r\n      'tenantName' => 'xxx',\r\n      'serviceName' => 'swift',\r\n    ),\r\n  ),\r\n);\r\n\r\n```\r\n\r\n**Are you using external storage, if yes which one:** swift\r\n\r\n**Are you using encryption:** yes\r\n\r\n**Are you using an external user-backend, if yes which one:** no\r\n\r\n### Client configuration\r\n**Browser:** Firefox 36.0\r\n\r\n**Operating system:** Linux\r\n\r\n### Logs\r\n#### Web server error log\r\n```\r\n2015-03-18 21:05:26: (mod_fastcgi.c.2673) FastCGI-stderr: PHP Warning:  fflush(): 186 is not a valid stream resource in /var/www/owncloud/apps/files_encryption/lib/stream.php on line 540\r\n2015-03-18 21:05:26: (mod_fastcgi.c.2673) FastCGI-stderr: PHP Warning:  fclose(): 186 is not a valid stream resource in /var/www/owncloud/apps/files_encryption/lib/stream.php on line 657\r\n2015-03-18 21:05:26: (mod_fastcgi.c.2673) FastCGI-stderr: PHP Fatal error:  Access to undeclared static property: OC_Log::$enabled in /var/www/owncloud/lib/private/legacy/log.php on line 47\r\n\r\n```\r\n\r\n#### ownCloud log (data/owncloud.log)\r\n```\r\n{\"reqId\":\"d84b5dd97fb8f9f87d8447aeb0a76774\",\"remoteAddr\":\"xxx.xxx.xxx.xxx\",\"app\":\"PHP\",\"message\":\"touch(): Unable to create file \\/tmp\\/oc_tmp_a6b01e156c7a13a8ee28a6c9f68dbcdf.txt\\/fileKey because No such file or directory at \\/var\\/www\\/owncloud\\/lib\\/private\\/tempmanager.php#62\",\"level\":3,\"time\":\"2015-03-18T21:05:25+00:00\"}\r\n{\"reqId\":\"d84b5dd97fb8f9f87d8447aeb0a76774\",\"remoteAddr\":\"xxx.xxx.xxx.xxx\",\"app\":\"PHP\",\"message\":\"fopen(\\/tmp\\/oc_tmp_a6b01e156c7a13a8ee28a6c9f68dbcdf.txt\\/fileKey): failed to open stream: No such file or directory at \\/var\\/www\\/owncloud\\/lib\\/private\\/files\\/stream\\/close.php#23\",\"level\":3,\"time\":\"2015-03-18T21:05:25+00:00\"}\r\n{\"reqId\":\"d84b5dd97fb8f9f87d8447aeb0a76774\",\"remoteAddr\":\"xxx.xxx.xxx.xxx\",\"app\":\"PHP\",\"message\":\"fopen(close:\\/\\/\\/tmp\\/oc_tmp_a6b01e156c7a13a8ee28a6c9f68dbcdf.txt\\/fileKey): failed to open stream: &quot;OC\\\\Files\\\\Stream\\\\Close::stream_open&quot; call failed at \\/var\\/www\\/owncloud\\/lib\\/private\\/files\\/objectstore\\/objectstorestorage.php#280\",\"level\":3,\"time\":\"2015-03-18T21:05:25+00:00\"}\r\n{\"reqId\":\"d84b5dd97fb8f9f87d8447aeb0a76774\",\"remoteAddr\":\"xxx.xxx.xxx.xxx\",\"app\":\"PHP\",\"message\":\"fwrite() expects parameter 1 to be resource, boolean given at \\/var\\/www\\/owncloud\\/lib\\/private\\/files\\/storage\\/common.php#155\",\"level\":3,\"time\":\"2015-03-18T21:05:25+00:00\"}\r\n{\"reqId\":\"d84b5dd97fb8f9f87d8447aeb0a76774\",\"remoteAddr\":\"xxx.xxx.xxx.xxx\",\"app\":\"PHP\",\"message\":\"fclose() expects parameter 1 to be resource, boolean given at \\/var\\/www\\/owncloud\\/lib\\/private\\/files\\/storage\\/common.php#156\",\"level\":3,\"time\":\"2015-03-18T21:05:25+00:00\"}\r\n{\"reqId\":\"7ec022f6340f6369c8380640ab849645\",\"remoteAddr\":\"xxx.xxx.xxx.xxx\",\"app\":\"index\",\"message\":\"Exception: {\\\"Message\\\":\\\"Encryption key not found for \\\\\\\"\\\\\\/rvrangel\\\\\\/files\\\\\\/test.txt\\\\\\\" during attempted read via stream\\\",\\\"Code\\\":0,\\\"Trace\\\":\\\"#0 [internal function]: OCA\\\\\\\\Files_Encryption\\\\\\\\Stream->stream_read(8192)\\\\n#1 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/preview\\\\\\/txt.php(30): stream_get_contents(Resource id #189, 3000)\\\\n#2 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/preview.php(520): OC\\\\\\\\Preview\\\\\\\\TXT->getThumbnail('\\\\\\/test.txt', 36, 36, true, Object(OC\\\\\\\\Files\\\\\\\\View))\\\\n#3 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/preview.php(565): OC\\\\\\\\Preview->getPreview()\\\\n#4 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/core\\\\\\/ajax\\\\\\/preview.php(44): OC\\\\\\\\Preview->showPreview()\\\\n#5 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/route\\\\\\/route.php(135) : runtime-created function(1): require_once('\\\\\\/var\\\\\\/www\\\\\\/ownclo...')\\\\n#6 [internal function]: __lambda_func(Array)\\\\n#7 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/private\\\\\\/route\\\\\\/router.php(250): call_user_func('?lambda_167', Array)\\\\n#8 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/lib\\\\\\/base.php(767): OC\\\\\\\\Route\\\\\\\\Router->match('\\\\\\/core\\\\\\/preview.p...')\\\\n#9 \\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/index.php(36): OC::handleRequest()\\\\n#10 {main}\\\",\\\"File\\\":\\\"\\\\\\/var\\\\\\/www\\\\\\/owncloud\\\\\\/apps\\\\\\/files_encryption\\\\\\/lib\\\\\\/stream.php\\\",\\\"Line\\\":281}\",\"level\":4,\"time\":\"2015-03-18T21:05:26+00:00\"}\r\n\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/owncloud/core/issues/comments/151620403","html_url":"https://github.com/owncloud/core/issues/15017#issuecomment-151620403","issue_url":"https://api.github.com/repos/owncloud/core/issues/15017","id":151620403,"user":{"login":"butonic","id":956847,"avatar_url":"https://avatars.githubusercontent.com/u/956847?v=3","gravatar_id":"","url":"https://api.github.com/users/butonic","html_url":"https://github.com/butonic","followers_url":"https://api.github.com/users/butonic/followers","following_url":"https://api.github.com/users/butonic/following{/other_user}","gists_url":"https://api.github.com/users/butonic/gists{/gist_id}","starred_url":"https://api.github.com/users/butonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/butonic/subscriptions","organizations_url":"https://api.github.com/users/butonic/orgs","repos_url":"https://api.github.com/users/butonic/repos","events_url":"https://api.github.com/users/butonic/events{/privacy}","received_events_url":"https://api.github.com/users/butonic/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T19:39:30Z","updated_at":"2015-10-27T19:39:30Z","body":"The current encryption is considered incompatible with objectstore and has been since it was added: https://doc.owncloud.org/server/9.0/admin_manual/enterprise_external_storage/s3_swift_as_primary_object_store_configuration.html#implications\r\n\r\nTechnically it was working at least in oc7.0, but:\r\n\r\n1. the keys are also stored in the objectstore, which partly defeats the purpose of using encryption with objectstore. \r\n2. Since the keys need to be decrypted with the users password (OC8.2 allows implementing other mechanisms) every file content change needs an additional HTTP trip to the objectstore, which slows things down to a totally sluggish user experience.\r\n\r\nI think we should track the encryption compatibility as an enhancement. Probably in this issue.\r\n\r\nAlso keep in mind that the decision to store the keys in the objectstore was made because, at the time, it was crucial that no data was stored on local disk (which is a moot point I agree, but we still need to be able to have it working this way when tackling this in the future)."}}