diff --git a/pywbem-20131121-local_root_auth.patch b/pywbem-20131121-local_root_auth.patch new file mode 100644 index 0000000..ce80f39 --- /dev/null +++ b/pywbem-20131121-local_root_auth.patch @@ -0,0 +1,50 @@ +Index: pywbem-20131121/cim_http.py +=================================================================== +--- pywbem-20131121.orig/cim_http.py ++++ pywbem-20131121/cim_http.py +@@ -42,6 +42,33 @@ class AuthError(Error): + """This exception is raised when an authentication error (401) occurs.""" + pass + ++try: ++ import pwd ++ def get_user_name(uid=None): ++ """Return user name for given uid. ++ :param int uid: User id of user whose name is desired. ++ If not given, current user will be assumed. ++ """ ++ try: ++ if uid is None: ++ uid = os.getuid() ++ return pwd.getpwuid(uid).pw_name ++ except KeyError: ++ pass ++except ImportError: # pwd is available only on *nix ++ def get_user_name(uid=None): ++ """ ++ Return user name of current user. ++ :param int uid: Optional argument. Note that uid may be equal only ++ to current user's id, otherwise an exception will be raised. ++ """ ++ if uid is not None and uid != os.getuid(): ++ raise ValueError("Can not get user name for other user.") ++ try: ++ return getpass.getuser() ++ except KeyError: ++ pass ++ + def parse_url(url): + """Return a tuple of (host, port, ssl) from the URL parameter. + The returned port defaults to 5988 if not specified. SSL supports +@@ -226,10 +253,7 @@ def wbem_request(url, data, creds, heade + local = True + if local: + uid = os.getuid() +- try: +- locallogin = getpass.getuser() +- except KeyError: +- locallogin = None ++ locallogin = get_user_name(uid) + while numTries < tryLimit: + numTries = numTries + 1 + diff --git a/pywbem.spec b/pywbem.spec index b9de240..4683d0b 100644 --- a/pywbem.spec +++ b/pywbem.spec @@ -4,7 +4,7 @@ Name: pywbem Version: 0.7.0 -Release: 24.%{revdate}svn%{svnrev}%{?dist} +Release: 25.%{revdate}svn%{svnrev}%{?dist} Summary: Python WBEM Client and Provider Interface Group: Development/Libraries License: LGPLv2 @@ -23,6 +23,7 @@ Requires: m2crypto Patch0: pywbem-20130411-mof_compiler-import.patch Patch1: pywbem-20131121-ssl_verify_host.patch Patch2: pywbem-20131121-utf_encoding.patch +Patch3: pywbem-20131121-local_root_auth.patch %description A Python library for making CIM (Common Information Model) operations over HTTP @@ -56,6 +57,7 @@ twisted.protocols.http.HTTPClient base class. %patch0 -p1 -b .mofcomp-imports %patch1 -p1 -b .ssl_verify_host %patch2 -p1 -b .utf_encoding +%patch3 -p1 -b .local_root_auth %build # dirty workaround to fix the mof_compiler.py module path @@ -86,6 +88,9 @@ rm -rf %{buildroot} %{python_sitelib}/pywbem/twisted_client.py* %changelog +* Mon Feb 24 2014 Michal Minar 0.7.0-25.20131121svn656 +- Fixed local authentication under root. + * Thu Jan 23 2014 Michal Minar 0.7.0-24.20131121svn656 - Added support for non-ascii strings.