title: Switch to Linux root account in executing C++ binary with password, POSSIBLE?
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>I have tried in C++:</p>
  
  <p><strong>system("su localadmin");</strong> // This prompts for password, but not sure how to pass the password.</p>
  
  <p><strong>setuid(0);</strong> // Again, where do I pass the password to get the account privileges? All I get is an "operation not permitted".</p>
  
  <p>I apologize if this is an easy question. I am just trying to run the commands as localadmin and be done.</p>