Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 70a730bfe33418826fd49997b976838edb46f249
Author: Stephen Gallagher <sgallagh(a)redhat.com>
Date: Wed Jan 22 16:03:38 2014 +0100
use local UNIX socket only if URI scheme is unspecified
---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index d00e187..ef83a8a 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -39,6 +39,17 @@ from LMIUtil import lmi_raise_or_dump_exception
from LMIUtil import lmi_get_use_exceptions
from LMIUtil import lmi_set_use_exceptions
+LOCALHOST_VARIANTS = (
+ "localhost",
+ "localhost.localdomain",
+ "localhost4",
+ "localhost4.localdomain4",
+ "localhost6",
+ "localhost6.localdomain6",
+ "127.0.0.1",
+ "::1",
+)
+
def __lmi_raw_input(prompt, use_echo=True):
"""
Reads a string from the standard input.
@@ -131,9 +142,11 @@ def connect(uri, username="", password="",
**kwargs):
logger = logging.getLogger("")
connection = None
- netloc = urlparse.urlparse(uri).netloc
- destination = netloc if netloc else uri
- if os.getuid() == 0 and destination in ("localhost", "127.0.0.1",
"::1") and \
+
+ # If we are running as root and the scheme has not been explicitly set,
+ # we will use the local UNIX socket for higher performance (and skip
+ # authentication).
+ if os.getuid() == 0 and uri in LOCALHOST_VARIANTS and \
os.path.exists("/var/run/tog-pegasus/cimxml.socket") and \
not username and not password:
connection = LMIConnection(uri, None, None, interactive=interactive,