sudo: initial README.md
This commit is contained in:
20
sudo/README.md
Normal file
20
sudo/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## `whoreallyami.py`
|
||||
```
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
chown +x whoreallyami.py
|
||||
sudo ./whoreallyami.py
|
||||
'''
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
# SUDO_USER: 원래 sudo를 실행한 사용자
|
||||
print("SUDO_USER:", os.environ.get('SUDO_USER'))
|
||||
|
||||
# USER: 현재 프로세스의 유효 사용자 (sudo 실행 시 'root')
|
||||
print("USER:", os.environ.get('USER'))
|
||||
|
||||
# whoami: 현재 프로세스의 실제 사용자 ID (sudo 실행 시 'root')
|
||||
print("whoami:", os.popen('whoami').read().strip())
|
||||
```
|
||||
Reference in New Issue
Block a user