[Ovirt-devel] [PATCH node] add password.py

Joey Boggs jboggs at redhat.com
Wed Oct 27 01:44:30 UTC 2010


add module for ssh/password configuration
---
 scripts/password.py |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100755 scripts/password.py

diff --git a/scripts/password.py b/scripts/password.py
new file mode 100755
index 0000000..bb8f3ee
--- /dev/null
+++ b/scripts/password.py
@@ -0,0 +1,34 @@
+import ovirtfunctions
+import libuser
+
+def cryptPassword(password):
+    saltlen = 2
+    algo = 'sha512'
+    saltlen = 16
+    saltstr = '$6$'
+    for i in range(saltlen):
+        saltstr = saltstr + random.choice (string.letters +
+                                           string.digits + './')
+    return crypt.crypt (password, saltstr)
+
+def set_root_password(password):
+    user = self.__admin.initUser(root)
+    passwd = cryptPassword()
+    unmount_config("/etc/shadow")
+    user.set(passwd, password)
+    ovirt_store_config("/etc/shadow")
+
+def check_ssh_password_auth(self):
+    password_auth_status = augeas.Augeas("root=/")
+    password_auth_status.get("/files/etc/ssh/sshd_config/PasswordAuthentication")
+    return password_auth_status
+
+def toggle_ssh_access(status):
+    ssh_config = augeas.Augeas("root=/")
+    ssh_config.set("/files/etc/ssh/sshd_config", status)
+    ssh_config.save()
+    ovirt_store_config("/etc/ssh/sshd_config")
+    os.system("service sshd reload")
+
+def set_sasl_password(user, password):
+    os.system("saslpasswd2 -a libvirt -p " + user)
-- 
1.7.2.3




More information about the ovirt-devel mailing list