log4j-finder icon indicating copy to clipboard operation
log4j-finder copied to clipboard

log4j-finder will change acces time of a jar file

Open anepieter opened this issue 3 years ago • 2 comments

I know that acces time of a file only gives a mere indication but ik could help a little bit. On linux (and aix) you could use the touch command to save the timestamp in a temporary file. And restore it afterwards. like:

save_command = "touch -r '{}' /tmp/timestamp.save"
rest_command = "touch -r /tmp/timestamp.save '{}'"

run(save_command.format(<jar_file>))
<do the check>
run(rest_command.format(<jar_file>))

I tried to patch the code with this but I can't. And I don't really now if it is a good idea to do that anyway FYI i wrote a run function in python.

anepieter avatar Dec 21 '21 11:12 anepieter

Python has an API called os.utime that can set access time on files I believe, of course you will need to have the correct user permissions on the file to be able to do that. This is better than calling subprocesses.

yunzheng avatar Dec 22 '21 09:12 yunzheng

True. Your solution is also more portable. My solution has another problem. The /tmp/ filesystem may be mounted with the noaitme option on AIX. This prevents updating the atime from a file in the filesystem. I don't know if touch will update the atime in this case. linux should have a similar option I suppose.

anepieter avatar Dec 22 '21 09:12 anepieter