[node-patches] Change in ovirt-node[master]: Clear passwords when rhn_autoinstall exits

rbarry at redhat.com rbarry at redhat.com
Tue Dec 16 21:04:30 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Clear passwords when rhn_autoinstall exits
......................................................................

Clear passwords when rhn_autoinstall exits

Register a function to clear passwords atexit if they're set,
since something is holding/caching the values and re-writes them
to /etc/default/ovirt unless we do this

Also, stop using ovirtfunctions just for things we can easily
pull from elsewhere.

Change-Id: Ia84bdd8197b569cb21e99f34c64bc7a24c307993
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1062541
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M plugins/rhn_autoinstall.py
1 file changed, 19 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/25/36225/1

diff --git a/plugins/rhn_autoinstall.py b/plugins/rhn_autoinstall.py
index 42176d8..531678e 100644
--- a/plugins/rhn_autoinstall.py
+++ b/plugins/rhn_autoinstall.py
@@ -20,15 +20,18 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
 from ovirt.node.utils.console import TransactionProgress
-from ovirt.node.utils.fs import Config
-from ovirt.node.setup.rhn import rhn_model
-import ovirtnode.ovirtfunctions as _functions
+from ovirt.node.config.defaults import NodeConfigFile
+from ovirt.node.utils.fs import Config, File
+from ovirt.node.setup.rhn.rhn_model import RHN
 from ovirt.node.plugins import Changeset
+from ovirt.node.utils import system
+import atexit
 
 RHSM_CONF = "/etc/rhsm/rhsm.conf"
 SYSTEMID = "/etc/sysconfig/rhn/systemid"
+OVIRT_VARS = NodeConfigFile().get_dict()
 
-args = _functions.get_cmdline_args()
+args = system.kernel_cmdline_arguments()
 keys = ["rhn_type", "rhn_url", "rhn_ca_cert", "rhn_username",
         "rhn_profile", "rhn_activationkey", "rhn_org",
         "rhn_proxy", "rhn_proxyuser"]
@@ -44,19 +47,26 @@
                  "rhn_proxyuser": "rhn.proxyuser",
                  }
 
+def clear_passwords():
+    if "OVIRT_RHN_PASSWORD" in OVIRT_VARS or "OVIRT_RHN_PROXYPASSWORD" in OVIRT_VARS:
+        pw_keys = ("OVIRT_RHN_PASSWORD", "OVIRT_RHN_PROXYPASSWORD")
+        RHN().clear(keys=pw_keys)
+
 changes = dict((keys_to_model[key], args[key]) for key in keys if key in args)
+
+atexit.register(clear_passwords)
 
 if __name__ == "__main__":
     cfg = Config()
     if cfg.exists(RHSM_CONF) or cfg.exists(SYSTEMID):
         # skip rerunning again
         exit()
-    rhn = rhn_model.RHN()
+    rhn = RHN()
     cfg = rhn.retrieve()
-    rhn_password = _functions.OVIRT_VARS["OVIRT_RHN_PASSWORD"] \
-                   if "OVIRT_RHN_PASSWORD" in _functions.OVIRT_VARS else ""
-    rhn_proxypassword = _functions.OVIRT_VARS["OVIRT_RHN_PROXYPASSWORD"] \
-                        if "OVIRT_RHN_PROXYPASSWORD" in _functions.OVIRT_VARS \
+    rhn_password = OVIRT_VARS["OVIRT_RHN_PASSWORD"] \
+                   if "OVIRT_RHN_PASSWORD" in OVIRT_VARS else ""
+    rhn_proxypassword = OVIRT_VARS["OVIRT_RHN_PROXYPASSWORD"] \
+                        if "OVIRT_RHN_PROXYPASSWORD" in OVIRT_VARS \
                         else ""
     effective_model = Changeset({
         "rhn.rhntype": cfg['rhntype'],
@@ -76,6 +86,3 @@
         tx = rhn.transaction(password=rhn_password, \
                              proxypass=rhn_proxypassword)
         TransactionProgress(tx, is_dry=False).run()
-        # remove /etc/default/ovirt entries from being persisted
-        pw_keys = ("OVIRT_RHN_PASSWORD", "OVIRT_RHN_PROXYPASSWORD")
-        rhn.clear(keys=pw_keys)


-- 
To view, visit http://gerrit.ovirt.org/36225
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia84bdd8197b569cb21e99f34c64bc7a24c307993
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list