Setting access rights with `file out`

How can I set the access mode (like '0640') when creating files with file out?

I tried a few ways, these two not very elegant options seem to work:

[{"id":"be891798285c7b2b","type":"inject","z":"117fb44a.f7cc54","name":"msg.filename=/home/pi/outputfile1","props":[{"p":"payload"},{"p":"filename","v":"/home/pi/outputfile1","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":190,"y":80,"wires":[["25b5bf7f4935539f","b2f18653481fc387"]]},{"id":"4adf0e528feff296","type":"file","z":"117fb44a.f7cc54","name":"Output to msg.filename","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":570,"y":140,"wires":[[]]},{"id":"25b5bf7f4935539f","type":"exec","z":"117fb44a.f7cc54","command":"umask 0077 && touch","addpay":"filename","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"umask 0077 && touch msg.filename","x":790,"y":80,"wires":[[],[],[]]},{"id":"b2f18653481fc387","type":"delay","z":"117fb44a.f7cc54","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":370,"y":140,"wires":[["4adf0e528feff296"]]},{"id":"c4767db87a366c3b","type":"exec","z":"117fb44a.f7cc54","command":"chmod 642","addpay":"filename","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"chmod 642 msg.filename","x":750,"y":220,"wires":[[],[],[]]},{"id":"5ce0ede37a00953b","type":"inject","z":"117fb44a.f7cc54","name":"msg.filename=/home/pi/outputfile2","props":[{"p":"payload"},{"p":"filename","v":"/home/pi/outputfile2","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":200,"y":220,"wires":[["275dcdcdf654f83f"]]},{"id":"275dcdcdf654f83f","type":"file","z":"117fb44a.f7cc54","name":"Output to msg.filename","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":490,"y":220,"wires":[["c4767db87a366c3b"]]}]

Thanks for your sample flows, here. The first seem to fail, when used with temporarily unavailable hard-mounted network file systems, the second exposes the file content to others for a short period of time.

Perhaps the functionality could be added as a property to the file out? It is provided from fs.createWriteStream()

I've added it to the backlog: Trello

1 Like

Surely the ability and scope of the node-red user to set access will be limited by the operating system. Not sure how the ui could cope with just permitted options.

It would be no different to if the user set a file path to a directory they don't have permission to write to today. The write will fail.

The node won't force the user to specify file permissions - but for a user who knows what they need, they will be able to do so.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.