UIBuilder markweb permissions issue running as dedicated user

On Ubuntu I have created a system user noderedblog and group noderedblog to run node-red. The user does not have a home directory. Node red is running from a folder /home/colinl/noderedblog. Ownership of that folder and all contained folders and files is set to colinl:noderedblog and the files and folders have r/w access for owner and group. Since user noderedblog is in the group noderedblog this means that node red should have write access to all node red files.

In an exec node I have run id and confirmed that user and group are correct.
In an exec mode I can create and write to files in, for example, /home/colinl/noderedblog/uibuilder/.config.

However, when I start node red I get

un 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [debug] Module: node-red-contrib-uibuilder 7.7.4 /home/colinl/noderedblog/node_modules/node-red-contrib-uibuilder
Jun 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [trace] ๐ŸŒ[uibuilder:runtimeSetup] ----------------- global config started -----------------
Jun 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [trace] ๐ŸŒ[uibuilder:runtimeSetup] uibRoot folder is read/write accessible. /home/colinl/noderedblog
Jun 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [trace] ๐ŸŒ[uibuilder:fs.js:setup] Setup completed
Jun 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [trace] ๐ŸŒ[uibuilder[:runtimeSetup] uibRoot folder exists. /home/colinl/noderedblog/uibuilder
Jun 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [trace] ๐ŸŒ[uibuilder[:runtimeSetup] uibRoot folder is read/write accessible. /home/colinl/noderedblog/uibuilder
Jun 19 14:54:50 x201-vps Node-RED[229996]: 19 Jun 14:54:50 - [error] ๐ŸŒ๐Ÿ›‘[uibuilder:runtimeSetup] Master .config folder copy ERROR, path: /home/colinl/noderedblog/node_modules/node-red-contrib-uibuilder/templates. Could not copy '/home/colinl/noderedblog/node_modules/node-red-contrib-uibuilder/templates/.config' to '/home/colinl/noderedblog/uibuilder/.config'. EPERM, Operation not permitted '/home/colinl/noderedblog/uibuilder/.config' [UibFs:copySync]
Jun 19 14:54:50 x201-vps Node-RED[229996]: Error: [uibuilder:runtimeSetup] Failed to set up uibuilder root folder structure correctly. Check log for additional error messages. Root folder: /home/colinl/noderedblog/uibuilder.

@TotallyInformation, before I start debugging it can you suggest any reason? What exactly is uibuilder doing that generates the error?

The above link is where the error comes from.

copySync calls node.js's synchronous copy function. It is a very simple function. If it has failed, it can mean only 1 of a few things:

  1. The source folder does not exist - should be impossible since this is the master template folder within the uibuilder package.
  2. The source folder is not accessible - should also be impossible for the same reason.
  3. The destination is within a parent folder that either:
    a. Is on a drive with insufficient free space.
    b. Does not have permissions for the node-red user to create a new folder.

There might be some other possibilities if your host is using ACL's but this seems unlikely.

So, firstly make sure that in /home/colinl/noderedblog/, the uibuilder/ folder has permissions that allow your node-red user to create new folders and write to them.

Here is the data from a Linux server:
image

The user id running Node-RED must either be home or in the adm group in the example. Any other user or group would not have permissions to create new folders or files.

Obviously, the implication from the trace logs is that it does indeed have the right permissions. I am quite careful to try to make sure that everything can work before proceeding.

After that, check that the drive has sufficient space. It needs around 16k for the .config folder and around 4k for the common folder.

Then run an exec command something like:

cp /home/colinl/noderedblog/node_modules/node-red-contrib-uibuilder/templates/.config /home/colinl/noderedblog/uibuilder/.config

Since that is what node.js is trying to do on your behalf. There are 4 files:

Actually that isn't a valid command, it needs /* on the end of the source, or -r or similar. That did work in an exec node, but I realised the problem. The folder already existed, however I realised that I had lost the group write permission on the .config folder itself. The JS must do something slightly different that caused that to fail. Fixing the permission fixed it.

In fact I have decided I was trying to be too clever running node red like that, as a system user (so without a home folder). I was not following my usual KISS mantra, which would be to create a normal user with a home folder and run it there, giving my usual login group access to folder if necessary. So that is what I am going to do.

Thanks again.

Phew, you had me worried there for a sec! Those kind of things are either something really simple or are a nightmare to work out. :smiley:

Odd though that uibuilder didn't spot the issue - I wonder if I need to add another, deeper check? Though I suppose not, the generated error was the correct one after all - Node-RED couldn't write to that folder.

In fact it could write to the folder, I had tested that in an exec node, though I am not sure that it should have been able to.