Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear sys.argv in python

Tags:

python

argv

When user specify a password in MySQL cli, aka -pXXXXXX, the password parameter is replaced to -p****** in argv array.

So when someone check the process list with ps, they can't see the password.

How can I do the same in Python? This doesn't work obviously

for arg in sys.argv[1:]:
    arg = ""
like image 522
daisy Avatar asked Jan 16 '17 02:01

daisy


1 Answers

sys.argv = [sys.argv[0]]

works and is more efficient and elegant than deleting all but the first element. I can't confirm this would overwrite or erase previous value of sys.argv in memory though.

like image 166
James T. Avatar answered Nov 06 '22 05:11

James T.