google / nsscache

asynchronously synchronise local NSS databases with remote directory services
GNU General Public License v2.0
143 stars 56 forks source link

skip the unexcepted line in the cache file #210

Open orz-nil opened 10 months ago

orz-nil commented 10 months ago

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 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.