Skylar-Tech / node-red-contrib-matrix-chat

Matrix chat server support for Node-RED
GNU General Public License v3.0
31 stars 10 forks source link

Error: EACCES: permission denied, mkdir '/matrix-client-storage' on FreeBSD #37

Closed d-amend closed 2 years ago

d-amend commented 2 years ago

Everytime I try to use one of the Nodes on FreeBSD (TrueNAS jail - TrueNAS-12.0-U7) I get the message "Error: EACCES: permission denied, mkdir '/matrix-client-storage'" in the Debugger.

I use a own Matrix home server, not matrix.org

What I already tried:

  1. Setting up a Linux VM with that package and the same Matrix server: no problem
  2. Using another Matrix client node-red-contrib-matrixbot and same server: no problem
  3. Set up a clean BSD jail with no other packages installed, than the default ones and node-red-contrib-matrix-chat: got the same error

I would guess, that it is a permission problem, that just happens on FreeBSD. My short investigations didn't lead to any success.

Any ideas what I can try or how I can find the bug?

skylord123 commented 2 years ago

Because this package supports e2e encryption we need to store the encryption keys on the machine running Node-RED. It looks like the package is trying to create the directory /matrix-client-storage within the Node-RED folder and it is failing because of permission issues. This folder is where all the e2e data (as well as already received messages, room data, etc) is stored and is required for the bot to function correctly.

node-red-contrib-matrixbot works because it doesn't create this directory. It downloads all the data it needs at run time which is inefficient.

Does the user running Node-RED have access to create/modify files within it's directory?

Also, are you running Node-RED directly on the system or running it in a docker container?

Thanks, Skylar Sadlier

skylord123 commented 2 years ago

@d-amend did you ever get this resolved?

d-amend commented 2 years ago

Good, that you asked. Thank you! Sorry, for my late reply. It is not solved :/

But to answer your questions:

Does the user running Node-RED have access to create/modify files within it's directory? Yes. The folder /var/db/nodered where Node-RED is installed is owned by the user nodered who also runs the server.

Also, are you running Node-RED directly on the system or running it in a docker container? Node-RED is running in a BSD jail which can compare to a chroot on Linux. So I have direct shell access and can try out things, but is isolated from the host system. So there should not be any side effects from other packages.

What I tried: I created the directory /var/db/nodered/matrix-client-storage. This doesn't change anything. It is the right place, though? I checked your code and came to the conclusion that you try to created it exactly there. From the log messages I was not sure because they give no absolute path where the dir should be located. But it doesn't change anything.

Here is screenshot of the nodered dir of my test setup (after I created /matrix-client-storage manually):

Screenshot 2022-01-17 at 15 42 58
skylord123 commented 2 years ago

I think I figured this out. I'm working on another update to fix this. I'll let you know when it's available :)

d-amend commented 2 years ago

Oh, that are really great news!! I am looking forward to it!

skylord123 commented 2 years ago

@d-amend Just released 0.4.6 which should fix this for you. Give it a try and let me know.

Thanks :)

d-amend commented 2 years ago

It works!!! Thank you very much. We will switch to your plugin <3