python subprocess.popen - pass passwords securely

时光毁灭记忆、已成空白 提交于 2019-12-25 04:14:10

问题


I did not find a direct answer to this question, so, asking it in this forum. My question is this - I am using python 2.6.6 version, and using subprocess.popen command to call into a script with some arguments. Some of the arguments are passwords. When I directly use this:

args = shlex.split(cmd)
f = open("a.txt", "a+");
proc = subprocess.Popen(args, stderr=f, stdout=f)
proc.communicate()
retcode = proc.returncode

The command gets executed fine, but I see that ps -ef shows the passwords in clear text. Is there a way to handle this in subprocess api? I have multiple passwords to be passed.

Thanks!

来源:https://stackoverflow.com/questions/52989658/python-subprocess-popen-pass-passwords-securely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!