wanstreet
Posts: 40
Joined: Fri Jun 01, 2018 5:28 am

Can nodejs modify raspberry pi files

Tue Jun 26, 2018 12:39 pm

I am thinking of running an Access Point webserver using nodejs,
the admin who will connect to the AP can login and change the AP ssid and password
To do this I need to make the changes in the hostapd.conf file, which is a system file.
So can I do this entire thing in nodejs?
Sorry if the question sounds silly, but I kinda need to know

User avatar
topguy
Posts: 6617
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Can nodejs modify raspberry pi files

Tue Jun 26, 2018 1:15 pm

You have two approaches for this.
- Either give the node.js process higher access rights ( run as root/super user )
- Reduce the security of the hostapd.conf file.

I would definitely prefer the last option. It depends on that "hostapd" is not very fuzzy about the security of its config file.

wanstreet
Posts: 40
Joined: Fri Jun 01, 2018 5:28 am

Re: Can nodejs modify raspberry pi files

Tue Jun 26, 2018 2:32 pm

so it can be done on nodejs.
not just hostapd.conf
but i think if i further proceed with the webserver task, then there might be a point where i have to change the wpa_supplicant file too.

wanstreet
Posts: 40
Joined: Fri Jun 01, 2018 5:28 am

Re: Can nodejs modify raspberry pi files

Tue Jun 26, 2018 2:33 pm

if these changes can be done using nodejs, then thanks for the info. :D

User avatar
The Traveler
Posts: 363
Joined: Sat Oct 21, 2017 3:48 pm

Re: Can nodejs modify raspberry pi files

Tue Jun 26, 2018 2:38 pm

node.js is a javascript runtime. Reading, writing, modifying system files depends on how your javascript is coded and permissions are configured.

If node.js javascripts are running "sandboxed" for security then you would not be able to change the files you want.

Cheers.
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

wanstreet
Posts: 40
Joined: Fri Jun 01, 2018 5:28 am

Re: Can nodejs modify raspberry pi files

Tue Jul 03, 2018 10:21 am

Ok, understood.
thanks a lot guys

Return to “Networking and servers”