From 682f7601150fe6079d804427c3e8f87e333efa38 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Wed, 12 May 2010 11:09:33 +0100 Subject: [PATCH] Convert some ReadFile calls to ReadOneLineFile For passwords we require strict oneliners, we're a bit more lax with pid and uid files. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/hypervisor/hv_kvm.py | 4 ++-- lib/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index fdd117ab3..2f97c8465 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -235,7 +235,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): """ if os.path.exists(uid_file): try: - uid = int(utils.ReadFile(uid_file)) + uid = int(utils.ReadOneLineFile(uid_file)) return uid except EnvironmentError: logging.warning("Can't read uid file", exc_info=True) @@ -634,7 +634,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): vnc_pwd = None if vnc_pwd_file: try: - vnc_pwd = utils.ReadFile(vnc_pwd_file) + vnc_pwd = utils.ReadOneLineFile(vnc_pwd_file, strict=True) except EnvironmentError, err: raise errors.HypervisorError("Failed to open VNC password file %s: %s" % (vnc_pwd_file, err)) diff --git a/lib/utils.py b/lib/utils.py index 84167d289..bcf811a7b 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -601,7 +601,7 @@ def ReadPidFile(pidfile): """ try: - raw_data = ReadFile(pidfile) + raw_data = ReadOneLineFile(pidfile) except EnvironmentError, err: if err.errno != errno.ENOENT: logging.exception("Can't read pid file") -- GitLab