ioBroker / ioBroker.javascript

Script engine for JavaScript and Blockly
MIT License
320 stars 119 forks source link

fs.writeFileSync cause "Error: Permission denied" #1581

Closed sir0drake closed 1 month ago

sir0drake commented 1 month ago

I'm sure that

Script type

Javascript

The problem

const fs = require('fs'); fs.writeFileSync("/opt/iobroker/iobroker-data/files/tvh.html", aHTML); Error: Permission denied

This happen after Updated the JavaScript-Instance to 8.3.1 Also Update to 8.4.0 do not fix this Problem.

linux-console: pi@pi4-iob:/opt/iobroker/iobroker-data/files $ ls -ld drwxrwxr-x+ 49 iobroker iobroker 4096 May 24 12:33 .

Does User iobroker do not have anymore write-rights to this specific folder ?

thanks for any Help in advance

iobroker.current.log (in debug mode!)

javascript.0 2024-05-27 14:26:49.811 error May not read /opt/iobroker/iobroker-data/files/tvh.html - use writeFile instead
javascript.0 2024-05-27 14:26:33.462 error May not read /opt/iobroker/iobroker-data/files/tvh.html - use writeFile instead

Version of nodejs

v18.20.3

Version of ioBroker js-controller

5.0.19

Version of adapter

8.3.1 + 8.4.0

mcm1957 commented 1 month ago

Hast du dir vor dem Update einer MAJOR Release den Changelog angesehen? Wahrscheinlich nicht, denn dort ist klar dokumentiert, dass REQUEST nicht mehr standardmäig verfügbar ist:

https://github.com/ioBroker/ioBroker.javascript/blob/master/CHANGELOG_OLD.md#800-2024-04-05

Zitat: (klein0r) Breaking change: Removed support for binary states (deprecated since v6.2.0) (klein0r) Breaking change: Protected filesystem (iobroker-data/files) to prevent direct file writes (klein0r) Breaking change: request property has been removed of the sandbox (require the module if still needed)

Das Verhalten ist also ein dokumentierter breaking change und kein Bug. Direkte Schreibvorgänge in ioBroker Verzeichnisse sind nicht zulässig.

klein0r commented 1 month ago

Does User iobroker do not have anymore write-rights to this specific folder ?

That is a protected folder which shouldn't be used to save files directly...

mcm1957 commented 1 month ago

Siehe auch die sehr umfangreichen Erläuterungen und Ankündigunge die klein0r im Forum veröffentlicht hat: https://forum.iobroker.net/topic/74606/javascript-8-3-0-log-trigger-file-events-und-warnungen

sir0drake commented 1 month ago

sry, you are right. thanks !