1) I'm struggling to find a secure way to allow new users to create accounts without granting them admin rights to do so. If you already have an account on my system and can work UNIX command line, then you can use programs such as puTTY to access it. I'm currently making a program that lets you visually transfer files back and forth, with a layout similar to dropbox. However, I'd like to add a "Create new user" feature and I'm not sure how to securely do it.
Sure, I can have the program execute something like "sudo adduser jim" and supply the sudo password, but this would require me to include an administrative password within the jar file. I know there are obfuscation programs out there, but it doesn't necessarily make it more secure. I'd prefer to create users with ssh, but I'm open to whatever works and is secure.
2) I just thought of something. What if I created an administrative user with a their sudo ability limited to only creating new users? Does this sound like a reasonably secure solution? If so, how should I go about doing this? If not, what are the cons of this method?
EDIT: This is my solution so far: assuming I have sanitized inputs I'll make a script that will take the first argument as a username, and the second as the password, then set it's permissions (setuid bit) to be non-writable, and when non-root accounts run it, they are allowed to run this and ONLY this with root privileges. Here is the most basic code so far:
adduser --disabled-password --gecos "" "$1"
echo "$1":"$2" | chpasswd
What do you think? How do you think I can improve it?
$1and$2in quotes."$1""$2"