nsscache icon indicating copy to clipboard operation
nsscache copied to clipboard

skip the unexcepted line in the cache file

Open orz-nil opened this issue 1 year ago • 0 comments

context

We use Okta as the LDAP source. when we sync Org2Org, some imported groups named: "name + timestamp". Then : exists in the new name. file_formats get error items. The example stderr:

$ sudo nsscache --verbose  update --full
INFO:nss_cache.app:using nss_cache library, version 0.39
INFO:nss_cache.config: Configured maps are: passwd, group, shadow, sshkey
INFO:nss_cache.command:Rebuilding and verifying passwd cache.
INFO:nss_cache.command:Rebuilding and verifying passwd cache.
INFO:nss_cache.command:Rebuilding and verifying group cache.
INFO:nss_cache.command:Rebuilding and verifying group cache.
Traceback (most recent call last):
  File "/usr/sbin/nsscache", line 32, in <module>
    return_value = nsscache_app.Run(sys.argv[1:], os.environ)
  File "/usr/lib/python3/dist-packages/nss_cache/app.py", line 248, in Run
    retval = command_callable().Run(conf=conf, args=args)
  File "/usr/lib/python3/dist-packages/nss_cache/command.py", line 236, in Run
    return self.UpdateMaps(conf,
  File "/usr/lib/python3/dist-packages/nss_cache/command.py", line 316, in UpdateMaps
    retval = updater.UpdateFromSource(source,
  File "/usr/lib/python3/dist-packages/nss_cache/update/updater.py", line 281, in UpdateFromSource
    return self.UpdateCacheFromSource(cache,
  File "/usr/lib/python3/dist-packages/nss_cache/update/map_updater.py", line 80, in UpdateCacheFromSource
    return_val += self.FullUpdateFromMap(cache, source_map, force_write)
  File "/usr/lib/python3/dist-packages/nss_cache/update/map_updater.py", line 146, in FullUpdateFromMap
    return_val = cache.WriteMap(map_data=new_map)
  File "/usr/lib/python3/dist-packages/nss_cache/caches/caches.py", line 229, in WriteMap
    if force_write or self.Verify(entries_written):
  File "/usr/lib/python3/dist-packages/nss_cache/caches/files.py", line 152, in Verify
    cache_data = self.GetMap(self.temp_cache_filename)
  File "/usr/lib/python3/dist-packages/nss_cache/caches/files.py", line 131, in GetMap
    data = self.map_parser.GetMap(cache_file, data)
  File "/usr/lib/python3/dist-packages/nss_cache/util/file_formats.py", line 56, in GetMap
    entry = self._ReadEntry(line)
  File "/usr/lib/python3/dist-packages/nss_cache/util/file_formats.py", line 110, in _ReadEntry
    map_entry.gid = int(line[2])
ValueError: invalid literal for int() with base 10: '03 PM PDT'

what we want

I hope we can skip the unexcepted line when we get ValueError.

orz-nil avatar Dec 28 '23 03:12 orz-nil