I would like to build a program which takes a username as parameter and creates the user and its home folder (with some hard-coded specifications like folder, and security checks like username cannot be root or an existing user).
My application needs to create users in order to give SSH access.
The program will be executed using sudo. I've read it should be written in C or C++ instead of scripts because scripts could easily be exploited.
- Can you give me some advices or good practices about how to achieve this?
- Should I use some Pam library? Is there any examples?
- What are the possible security flaws?
I know C/C++, and running Ubuntu Lucid.
Edit:
The user will only have sudo access to run that specific command, I do not want it to be able to run a shell or bypass some programs (by changing PATH environment, for example).
As a result, for example, I will need to override the PATH, what else should I worry about?