I am trying to copy some files to a root user from a user with very low (almost no privileges). I need to allow someone with access to the low account copy some files onto the higher account. I have thought about using a bin/Bash script, but I don't want any password in the file to be viewed.
I decided to create a C++ application that has the password of the account I would like pass to the su/setuid commands. I do know the password can be viewed in the binary, but is not a concern. The password not in plain text is sufficient.
My problem is that I cannot figure out how to "login" as the user I need to update files for a service running in that account. I have the user account name, which is localadmin, and the password for that account. But how do I pass these to Linux to copy the files to the localadmin account home/subdirectory from the C++ application?
I have tried in C++:
system("su localadmin"); // This prompts for password, but not sure how to pass the password.
setuid(0); // Again, where do I pass the password to get the account privileges? All I get is an "operation not permitted".
I apologize if this is an easy question. I am just trying to run the commands as localadmin and be done.