Fix password file permission

Invalid permission makes file unreadable by owner if he is not root.

Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Sergey Orlov 2020-08-05 16:37:05 +02:00 committed by Rob Crittenden
parent 61db3527e3
commit 07341990d9

View File

@ -34,7 +34,7 @@ class IPAOpenSSHTransport(OpenSSHTransport):
elif self.host.ssh_password:
password_file = os.path.join(self.control_dir.path, "password")
with open(password_file, "w") as f:
os.fchmod(f.fileno(), 600)
os.fchmod(f.fileno(), 0o600)
f.write(self.host.ssh_password)
f.write("\n")
argv = ["sshpass", f"-f{password_file}"] + argv