xml2rfc icon indicating copy to clipboard operation
xml2rfc copied to clipboard

clear-cache removes the whole directory

Open alicerusso opened this issue 2 years ago • 1 comments

Describe the issue

Regarding xml2rfc --clear-cache (xml2rfc 3.15.3), could it be changed to remove the content of the directory rather than the directory itself? Use case: there's a shared reference cache among a group of users. More info below.

From Glen:

When you run --clear-cache, xml2rfc appears to be trying to remove the entire cache directory - the directory itself. It then re-creates it under the control of the user who cleared it, which then potentially prevents other people from using that cache (which was the original problem you encountered, and the reason for the wrong permissions.)

I locked the parent directory, which prevented the cache directory itself from being changed, thus protecting normal operation, but which also, it seems, exposed this behavior.

My opinion is that the behavior of clear-cache is incorrect: It should clear the files IN the directory, but not the directory itself.

% xml2rfc --clear-cache
Traceback (most recent call last):
 File “/usr/local/bin/xml2rfc”, line 11, in <module>
  load_entry_point(‘xml2rfc==3.15.3’, ‘console_scripts’, ‘xml2rfc’)()
 File “/usr/local/lib/python3.9/site-packages/xml2rfc/run.py”, line 413, in main
  xml2rfc.parser.XmlRfcParser(‘’).delete_cache(path=options.cache)
 File “/usr/local/lib/python3.9/site-packages/xml2rfc/parser.py”, line 544, in delete_cache
  self.cachingResolver.delete_cache(path=path)
 File “/usr/local/lib/python3.9/site-packages/xml2rfc/parser.py”, line 126, in delete_cache
  shutil.rmtree(path)
 File “/usr/lib64/python3.9/shutil.py”, line 740, in rmtree
  onerror(os.rmdir, path, sys.exc_info())
 File “/usr/lib64/python3.9/shutil.py”, line 738, in rmtree
  os.rmdir(path)
PermissionError: [Errno 13] Permission denied: ‘/a/cache/xml2rfc/’

Code of Conduct

alicerusso avatar Jan 11 '23 22:01 alicerusso

The suggestion will not work.

If the system is configured such that different users would have different permissions on the cache directory (as is the current case at rfcpa), one user running --clear-cache would encounter errors deleting cache entries that were created when a different user was running xml2rfc.

Instead, at rfcpa, consider creating an xml2rfc group, setgid to that group on execution (since you are installing xml2rfc manually on that machine), and make sure all users of xml2rfc are in the group.

In general we need to revisit the caching mechanic, and better consider many things, including mulituser scenarios, but in particular cache timeouts, and possibly looking for a way for an include source to indicate that cache originating from that source should be flushed.

rjsparks avatar Jan 12 '23 15:01 rjsparks