[SSSD] [PATCHES] util: Continue if setlocale fails

Nikolai Kondrashov Nikolai.Kondrashov at redhat.com
Wed Oct 21 16:48:46 UTC 2015


On 10/21/2015 07:28 PM, Michal Židek wrote:
> Nick asked me to provide some explanation on the
> issue so I put it here, please correct me if I
> say something wrong.
>
> The problem seems to be that the nss client code only
> checks validity of the memcache when the
> memcache context is created. Long living
> application only check the validity once and
> then use file descriptor to manipulate the
> cache until they are finished. Pytest is
> one such application. If we use the python
> pwd and grp wrappers, we initialize memcache
> context in Pytest. If we later remove
> the memcache files as part of teardown
> and create new memcache files for new
> tests, Pytest still uses the old file descriptors
> so calls to pwd and grp wrappers will
> work with the deleted memcache files.

Thanks, Michal!

However, how come there is a difference when the test has/doesn't have the
LDAP enumeration before clearing the cache?

See the last message in "intg: Add more LDAP tests" thread.

Nick

P.S. I tried not removing the cache file and it doesn't seem to help much -
      now it passes sometimes, but still fails most of the time. You can try
      the test in the message mentioned above. This is the addition I made for
      keeping the cache:

diff --git a/src/tests/intg/ldap_test.py b/src/tests/intg/ldap_test.py
index cdd8c8d..86d0854 100644
--- a/src/tests/intg/ldap_test.py
+++ b/src/tests/intg/ldap_test.py
@@ -30,6 +30,7 @@ import ldap
  import pytest
  import ds_openldap
  import ldap_ent
+import re
  from util import *

  LDAP_BASE_DN = "dc=example,dc=com"
@@ -191,7 +192,8 @@ def cleanup_sssd_process():
          pass
      subprocess.call(["sss_cache", "-E"])
      for path in os.listdir(config.DB_PATH):
-        os.unlink(config.DB_PATH + "/" + path)
+        if re.match("^cache_.*\\.ldb$", path) is None:
+            os.unlink(config.DB_PATH + "/" + path)
      for path in os.listdir(config.MCACHE_PATH):
          os.unlink(config.MCACHE_PATH + "/" + path)


More information about the sssd-devel mailing list