I have this script running as root:
import subprocess
proc = subprocess.Popen(['chpasswd'], stdin=subprocess.PIPE)
proc.stdin.write("username:password")
print("Password updated")
While the script is run as a root user, it works as expected.
However, when I try running it under flask, it prints "Password updated", but it does not actually update the password.  What could be the reason, and how to make it work?
...
@app.route('/')
def some_path():
    if condition:
        proc = subprocess.Popen(['chpasswd'], stdin=subprocess.PIPE)
        proc.stdin.write("username:password")
        print("Password updated")
...
