[node-patches] Change in ovirt-node[ovirt-3.5]: password: Always persist passwd and shadow

fabiand at redhat.com fabiand at redhat.com
Wed Jul 29 13:44:06 UTC 2015


Fabian Deutsch has uploaded a new change for review.

Change subject: password: Always persist passwd and shadow
......................................................................

password: Always persist passwd and shadow

Befor eit could happen that one of the files ended up to be unpersisted,
by catching the exception and putting the persistence in the finaly branch,
we ensure that the files (and the set passwords) are now always persisted.

In the worst case it could have happened that a user can not login anymore,
because the password got unpersisted.

Change-Id: I30d579672c49bd0d07d0b8f73308b3d6238da5d3
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1246117
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirtnode/password.py
1 file changed, 9 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/47/44147/1

diff --git a/src/ovirtnode/password.py b/src/ovirtnode/password.py
index e0eca20..53614bb 100755
--- a/src/ovirtnode/password.py
+++ b/src/ovirtnode/password.py
@@ -39,11 +39,15 @@
     admin = libuser.admin()
     root = admin.lookupUserByName(user)
     passwd = cryptPassword(password)
-    _functions.unmount_config("/etc/shadow")
-    _functions.unmount_config("/etc/passwd")
-    admin.setpassUser(root, passwd, "is_crypted")
-    _functions.ovirt_store_config("/etc/shadow")
-    _functions.ovirt_store_config("/etc/passwd")
+    try:
+        _functions.unmount_config("/etc/shadow")
+        _functions.unmount_config("/etc/passwd")
+        admin.setpassUser(root, passwd, "is_crypted")
+    except:
+        raise
+    finally:
+        _functions.ovirt_store_config("/etc/shadow")
+        _functions.ovirt_store_config("/etc/passwd")
     return True
 
 


-- 
To view, visit https://gerrit.ovirt.org/44147
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I30d579672c49bd0d07d0b8f73308b3d6238da5d3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list