title: Executing shell commands as given UID in Python
body: <p>I need a way to execute the os.system() module as different UID's. It would need to behave similar to the following BASH code (note these are not the exact commands I am executing):</p>
  
  <pre><code>su user1
  ls ~
  mv file1
  su user2
  ls ~
  mv file1
  </code></pre>
  
  <p>The target platform is GNU Linux Generic. </p>
  
  <p>Of course I could just pass these to the os.system module, but how to send the password? Of course I could run the script as root, but that's sloppy and insecure.</p>
  
  <p>Preferably I would like to do with without requiring any passwords to be in plain text.</p>