group creation + adding users without root permission
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
group creation + adding users without root permission
I have a PHP script that creates directories (and files) according to user input and from a user root directory.
These users belong to a small group of about 20 (let's call these "main users")
The main users need to allow other users (selected by each main user) to write files to these directories by way of HTML textarea.
Main user needs to create a group for each directory created and add to it users that are accepted, there is a need to do this without "root" intervention (through scripts) and to make the files written to these directories RO after they have been written.
It looks like ACL could be the solution but it's only executable by root as I understand.
I can't get it to work.
I have run visudo and the /etc/sudoers file has these 2 lines:
root ALL=(ALL) ALL
www-data ALL=(ALL) ALL
(Apache2 runs as www-data:www-data)
I added these 2 lines in the php script and tried some other variations that didn't work.
exec('sudo chown($name,chair)');
exec('sudo chgrp($name,meetings)');
What's the correct way of doing this?
Thank you for the assistance.
It's been a while since I did something like this but I think that you also need to add the NOPASSWD tag, so that you have something like the following in your sudoers file:
www-data ALL = NOPASSWD: useradd, groupadd
you may wish to add more commands, and you may need to add the full path.
do be aware that this solution will mean a vulnerable or malicious php or cgi script can probably root your machine; even if you restrict its sudo privileges to the commands useradd and groupadd, it's hard to say that those commands have no dangerous combination of arguments (e.g., can useradd add a user with uid 0?)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.