Skip to content

Conversation

@juliusknorr
Copy link
Member

@juliusknorr juliusknorr commented Nov 13, 2020

This will make sure that we don't attempt to move preview files into trash that are originating on appdata.

image

Fetching the nodes from the user folder will fail anyways afterwards, since the fileid of the app data can't be found in the user home, but this should save some queries and help not running into this code path by accident.

This was reported by ONLYOFFICE but seems to be only triggered due to initializing a user session with an non-existing user id:
https://github.com/ONLYOFFICE/onlyoffice-nextcloud/blob/7bdd9a68de1104292a9b9d4e2d868f4c508224c6/controller/callbackcontroller.php#L448-L450

{
   "reqId":"iuXVLDr0l8c22tVY4hnu",
   "level":3,
   "time":"2020-10-20T11:16:31+00:00",
   "remoteAddr":"172.18.0.4",
   "user":"uid-1603192542829",
   "app":"no app in context",
   "method":"POST",
"url":"/index.php/apps/onlyoffice/track?doc=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOm51bGwsImZpbGVJZCI6MzExLCJmaWxlUGF0aCI6bnVsbCwic2hhcmVUb2tlbiI6IlRwZWF5eG5BTEVxYkZmRyIsImFjdGlvbiI6InRyYWNrIn0.2Y0V5Cf669Nj8krbWq_YaAGrpwbPkxewm-vZmYgf8bI",
   "message":{
      "Exception":"OC\\User\\NoUserException",
      "Message":"Backends provided no user object",
      "Code":0,
      "Trace":[
         {
            "function":"getUserFolder",
            "class":"OC\\Files\\Node\\Root",
            "type":"->",
            "args":[
               "uid-1603192542829"
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/LazyFolder.php",
            "line":66,
            "function":"call_user_func_array",
            "args":[
               [
                  {
                     "__class__":"OC\\Files\\Node\\Root"
                  },
                  "getUserFolder"
               ],
               [
                  "uid-1603192542829"
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/LazyRoot.php",
            "line":41,
            "function":"__call",
            "class":"OC\\Files\\Node\\LazyFolder",
            "type":"->",
            "args":[
               "getUserFolder",
               [
                  "uid-1603192542829"
               ]
            ]
         },
         {
"file":"/var/www/html/apps/files_trashbin/lib/Storage.php",
            "line":141,
            "function":"getUserFolder",
            "class":"OC\\Files\\Node\\LazyRoot",
            "type":"->",
            "args":[
               "uid-1603192542829"
            ]
         },
         {
"file":"/var/www/html/apps/files_trashbin/lib/Storage.php",
            "line":181,
            "function":"shouldMoveToTrash",
            "class":"OCA\\Files_Trashbin\\Storage",
            "type":"->",
            "args":[
               "appdata_ocjh5q8w3asc/preview/9/d/f/c/d/5/e/311"
            ]
         },
         {
"file":"/var/www/html/apps/files_trashbin/lib/Storage.php",
            "line":118,
            "function":"doDelete",
            "class":"OCA\\Files_Trashbin\\Storage",
            "type":"->",
            "args":[
               "appdata_ocjh5q8w3asc/preview/9/d/f/c/d/5/e/311",
               "rmdir"
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/View.php",
            "line":1161,
            "function":"rmdir",
            "class":"OCA\\Files_Trashbin\\Storage",
            "type":"->",
            "args":[
               "appdata_ocjh5q8w3asc/preview/9/d/f/c/d/5/e/311"
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/View.php",
            "line":350,
            "function":"basicOperation",
            "class":"OC\\Files\\View",
            "type":"->",
            "args":[
               "rmdir",
               "/appdata_ocjh5q8w3asc/preview/9/d/f/c/d/5/e/311",
               [
                  "delete"
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/Folder.php",
            "line":402,
            "function":"rmdir",
            "class":"OC\\Files\\View",
            "type":"->",
            "args":[
               "/appdata_ocjh5q8w3asc/preview/9/d/f/c/d/5/e/311"
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/SimpleFS/SimpleFolder.php",
            "line":68,
            "function":"delete",
            "class":"OC\\Files\\Node\\Folder",
            "type":"->",
            "args":[

            ]
         },
         {
"file":"/var/www/html/lib/private/Preview/Watcher.php",
            "line":66,
            "function":"delete",
            "class":"OC\\Files\\SimpleFS\\SimpleFolder",
            "type":"->",
            "args":[

            ]
         },
         {
"file":"/var/www/html/lib/private/Preview/Watcher.php",
            "line":55,
            "function":"deleteNode",
            "class":"OC\\Preview\\Watcher",
            "type":"->",
            "args":[
               "*** sensitive parameter replaced ***"
            ]
         },
         {
"file":"/var/www/html/lib/private/Preview/WatcherConnector.php",
            "line":64,
            "function":"postWrite",
            "class":"OC\\Preview\\Watcher",
            "type":"->",
            "args":[
               "*** sensitive parameter replaced ***"
            ]
         },
         {
            "function":"OC\\Preview\\{closure}",
            "class":"OC\\Preview\\WatcherConnector",
            "type":"->",
            "args":[
               "*** sensitive parameters replaced ***"
            ]
         },
         {
"file":"/var/www/html/lib/private/Hooks/EmitterTrait.php",
            "line":101,
            "function":"call_user_func_array",
            "args":[
               {
                  "__class__":"Closure"
               },
               [
                  "*** sensitive parameter replaced ***"
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Hooks/PublicEmitter.php",
            "line":40,
            "function":"emit",
            "class":"OC\\Hooks\\BasicEmitter",
            "type":"->",
            "args":[
               "\\OC\\Files",
               "postWrite",
               [
                  "*** sensitive parameter replaced ***"
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/Root.php",
            "line":139,
            "function":"emit",
            "class":"OC\\Hooks\\PublicEmitter",
            "type":"->",
            "args":[
               "\\OC\\Files",
               "postWrite",
               [
                  "*** sensitive parameter replaced ***"
               ]
            ]
         },
         {
            "function":"emit",
            "class":"OC\\Files\\Node\\Root",
            "type":"->",
            "args":[
               "\\OC\\Files",
               "postWrite",
               [
                  "*** sensitive parameter replaced ***"
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/LazyFolder.php",
            "line":66,
            "function":"call_user_func_array",
            "args":[
               [
                  {
                     "__class__":"OC\\Files\\Node\\Root"
                  },
                  "emit"
               ],
               [
                  "\\OC\\Files",
                  "postWrite",
                  [
                     "*** sensitive parameter replaced ***"
                  ]
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/LazyFolder.php",
            "line":94,
            "function":"__call",
            "class":"OC\\Files\\Node\\LazyFolder",
            "type":"->",
            "args":[
               "emit",
               [
                  "\\OC\\Files",
                  "postWrite",
                  [
                     "*** sensitive parameter replaced ***"
                  ]
               ]
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/HookConnector.php",
            "line":115,
            "function":"emit",
            "class":"OC\\Files\\Node\\LazyFolder",
            "type":"->",
            "args":[
               "\\OC\\Files",
               "postWrite",
               [
                  "*** sensitive parameter replaced ***"
               ]
            ]
         },
         {
            "file":"/var/www/html/lib/private/legacy/OC_Hook.php",
            "line":110,
            "function":"postWrite",
            "class":"OC\\Files\\Node\\HookConnector",
            "type":"->",
            "args":[
               {
                  "run":true,
                  "path":"/1.docx"
               }
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/View.php",
            "line":1274,
            "function":"emit",
            "class":"OC_Hook",
            "type":"::",
            "args":[
               "OC_Filesystem",
               "post_write",
               {
                  "run":true,
                  "path":"/1.docx"
               }
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/View.php",
            "line":1202,
            "function":"runHooks",
            "class":"OC\\Files\\View",
            "type":"->",
            "args":[
               [
                  "update",
                  "write"
               ],
               "/1.docx",
               true
            ]
         },
         {
            "file":"/var/www/html/lib/private/Files/View.php",
            "line":696,
            "function":"basicOperation",
            "class":"OC\\Files\\View",
            "type":"->",
            "args":[
               "file_put_contents",
               "/admin/files/1.docx",
               [
                  "update",
                  "write"
               ],
               null
            ]
         },
         {
"file":"/var/www/html/lib/private/Files/Node/File.php",
            "line":72,
            "function":"file_put_contents",
            "class":"OC\\Files\\View",
            "type":"->",
            "args":[
               "/admin/files/1.docx",
               null
            ]
         },
         {
"file":"/var/www/html/custom_apps/onlyoffice/controller/callbackcontroller.php",
            "line":527,
            "function":"putContent",
            "class":"OC\\Files\\Node\\File",
            "type":"->",
            "args":[
               null
            ]
         },
         {
"file":"/var/www/html/custom_apps/onlyoffice/controller/callbackcontroller.php",
            "line":747,
            "function":"OCA\\Onlyoffice\\Controller\\{closure}",
"class":"OCA\\Onlyoffice\\Controller\\CallbackController",
            "type":"->",
            "args":[
               "*** sensitive parameters replaced ***"
            ]
         },
         {
"file":"/var/www/html/custom_apps/onlyoffice/controller/callbackcontroller.php",
            "line":528,
            "function":"retryOperation",
"class":"OCA\\Onlyoffice\\Controller\\CallbackController",
            "type":"->",
            "args":[
               {
                  "__class__":"Closure"
               }
            ]
         },
         {
"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
            "line":169,
            "function":"track",
"class":"OCA\\Onlyoffice\\Controller\\CallbackController",
            "type":"->",
            "args":[
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOm51bGwsImZpbGVJZCI6MzExLCJmaWxlUGF0aCI6bnVsbCwic2hhcmVUb2tlbiI6IlRwZWF5eG5BTEVxYkZmRyIsImFjdGlvbiI6InRyYWNrIn0.2Y0V5Cf669Nj8krbWq_YaAGrpwbPkxewm-vZmYgf8bI",
               [
                  "uid-1603192542829"
               ],
               "949206267",
               2,
"http://onlyoffice-document-server/cache/files/949206267_9418/output.docx/output.docx?md5=Vi9FNmsMdSoJkIpsayjMnw&expires=1603193492&disposition=attachment&filename=output.docx",
               null,
               {
                  "serverVersion":"6.0.0",
                  "changes":[
                     {
                        "created":"2020-10-20 11:16:17",
                        "user":{
                           "id":"uid-1603192542829",
                           "name":"Anonymous"
                        }
                     }
                  ]
               },
"http://192.168.0.142/ds-vpath/cache/files/949206267_9418/changes.zip/changes.zip?md5=kTm3rtXz85RD0mRAzQIPYA&expires=1603193492&disposition=attachment&filename=changes.zip"
            ]
         },
         {
"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
            "line":100,
            "function":"executeController",
            "class":"OC\\AppFramework\\Http\\Dispatcher",
            "type":"->",
            "args":[
               {
"__class__":"OCA\\Onlyoffice\\Controller\\CallbackController"
               },
               "track"
            ]
         },
         {
"file":"/var/www/html/lib/private/AppFramework/App.php",
            "line":152,
            "function":"dispatch",
            "class":"OC\\AppFramework\\Http\\Dispatcher",
            "type":"->",
            "args":[
               {
"__class__":"OCA\\Onlyoffice\\Controller\\CallbackController"
               },
               "track"
            ]
         },
         {
            "file":"/var/www/html/lib/private/Route/Router.php",
            "line":308,
            "function":"main",
            "class":"OC\\AppFramework\\App",
            "type":"::",
            "args":[
               "OCA\\Onlyoffice\\Controller\\CallbackController",
               "track",
               {
"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"
               },
               {
                  "action":null,
                  "_route":"onlyoffice.callback.track"
               }
            ]
         },
         {
            "file":"/var/www/html/lib/base.php",
            "line":1009,
            "function":"match",
            "class":"OC\\Route\\Router",
            "type":"->",
            "args":[
               "/apps/onlyoffice/track"
            ]
         },
         {
            "file":"/var/www/html/index.php",
            "line":37,
            "function":"handleRequest",
            "class":"OC",
            "type":"::",
            "args":[

            ]
         }
      ],
      "File":"/var/www/html/lib/private/Files/Node/Root.php",
      "Line":373,
      "CustomMessage":"--"
   },
   "userAgent":"Node.js/6.13",
   "version":"20.0.0.9",
   "id":"5f8ec70fe8dbe"
}

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

@MorrisJobke MorrisJobke merged commit bf23555 into master Nov 19, 2020
@MorrisJobke MorrisJobke deleted the bugfix/noid/trash-appdata branch November 19, 2020 21:29
@MorrisJobke
Copy link
Member

@juliushaertl Backport?

@juliusknorr
Copy link
Member Author

/backport to stable20

@juliusknorr
Copy link
Member Author

/backport to stable19

@juliusknorr
Copy link
Member Author

/backport to stable18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants