Raspberry on the road

I am trying to simplify the connection of my raspberry to the different wifi networks that I meet in my travels.
I created an ui page in which I can launch my functions (radio, tv and sites consultation). I also created a form that allows me to enter the ssid, the password and the security type to feed a flow that produces a wpa_supplicant.conf file to overwrite the existing one.

My problem is that this flow generates the following error: "EACCES: permission denied; open '/ etc / wpa_supplicant ..."
Of course, I could modify the permissions of the file but I am surprised that node-red which a proiori runs as root, does not have the necessary permissions.
Could someone confirm that for me?

By default if using the service, Node-RED runs as the pi user not root.

If you add a new group (possibly wificonf for example) and add the user the that group, then change the permissions on the file to root:wificonf and allow group members to write to the file then you will be able to edit it from node-red (note, edit not replace). So you would need to modify the script to write to it rather than replace it.
Alternatively you could use an existing group such as adm that the user may already be a member of.

In case you did not realise, if you add the new network to the file rather than completely replacing it then it will automatically connect when you are at that location again.

Thank you for this explanation.
But then, how to do so that all users of the raspberry can access
to the node-red ui of pi (without accessing the flow editor if possible) and execute the commands assigned to the buttons installed in this ui?

Thank you for your explanation.

I will create a group open to "everyone" in writing and in execution (not in reading).
Then I will put the existing users there (me = pi and my daughter = jeanne).

But is there a way so that all the users who will be created later (my son, my wife, guests ...) can be automatically attached to this group during creation?

It is not the user accessing the node-red gui that is important but the user configured to run node red itself. By default that will be which ever user ran the pi install script when node red was installed. That is the user that is running node red, whoever happens to be accessing it via a browser.

Backup a moment. When you are traveling, are you connecting your Pi to a public access point like at a campground, hotel, or store? If so, remember that anyone else on the network could access the pi.

Thank you for this alert.
Indeed in a hotel this poses a problem but I intend to use it most often at the homes of members of my family or my friends (I hope my daughter will do the same!).

Thank you for your response.
However, when I connect to my localhost: 1880 from the account I recently created for my daughter, I do not access the flows created with the user pi. Is it because I created this user recently while using the node-red preinstalled in the Raspberry Pi Imager package?

In fact, things seem to be even more complicated: I created the user for my daughter, I tried to connect to localhost: 1880 (none of my flows present), then to localhost: 1880 / ui (" cannot get ui ").
I then returned to the user pi and there, all my feeds disappeared!

It's as if by creating a second user I deleted all my feeds!

I can't comment on the node red installed in the pi Imager package as I don't even know what that is, but if you use the recommended install script then it will install node red so you can set it to autorun from boot by using
sudo systemctl enable nodered
then it will be the same flows whoever is logged onto the pi.

False alert !!!
the magic of Reboot made it all right!
And the flows are well presented in the editor regardless of the user.
Thank you for all your advices !

NB: I actually use "sudo systemctl enable nodered"

Thanks for all your advice.
Finally, I created the wificonf group, to which I attached root, pi and the user for my daughter.
I also modified the group and the rights of the file wpa_supplicant.
Everything works fine but as soon as I reboot the wpa_supplicant file regains its original group and rights.
Do you have any idea to deal with this problem?

As I said previously, it is only the user running the node-red server that needs to be in the group (that is pi, probably). It doesn't matter who is running the browser. It is the server that writes to the file, not the browser.

Try adding a chown command to change the ownership, into the file /etc/rc.local, before the exit 0 line at the end. That will get run on boot, but you might find it is too early and that the system is changing it after that file is run.

Thanks again.
I will modify the attachments to the wificonf group
As for the rebbot problem, I'll solve it by running the chown from the nodered flow, just when it's needed.
Thanks again for your help.
Subject solved thanks to you !!!

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