I have seen npm adduser, but i can figure it out how to manage this inside mine code.
What i have to do is to create new user from nodejs server code inside linux server, and change chmod and chown of that user and folders it content.
1 Answer
Use child_process.execFile to execute /usr/sbin/adduser, /bin/chmod and /bin/chown
Otherwise you can use exec from npm if your version of nodejs doesn't have child_process.execFile
2 Comments
Rob Raisch
Doing this from a node process assumes the process is running as 'root', which is a bad idea. The proper way would be to add the user under which the process will run to the /etc/sudoers file with the proper magic to only run
useradd as root without a password. See ducea.com/2006/05/19/…Honchar Denys
I agree with @RobRaisch and do what he said, but with exec i cant use sudo, or just cant find how. Without sudo working perfectly