Skip to content

Instantly share code, notes, and snippets.

@pgiraud
Created June 9, 2017 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgiraud/a02f9caf53ea6f0a8583cfb440fc9d19 to your computer and use it in GitHub Desktop.
Save pgiraud/a02f9caf53ea6f0a8583cfb440fc9d19 to your computer and use it in GitHub Desktop.
Test effective userid python subprocess
#! /bin/python
import subprocess
import os
print("subprocess.call")
print("Without seteuid")
subprocess.call(['id', '-u'])
print("With seteuid")
os.seteuid(int(os.getenv('USERID')))
subprocess.call(['id', '-u'])
print("Script bash")
subprocess.call(['./script.sh'])
#! /bin/bash
echo `id -u`
@bersace
Copy link

bersace commented Jun 9, 2017

subprocess.call(['sudo', '-u', 'user', 'id', '-u'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment