fox-it/log4j-finder

log4j-finder will change acces time of a jar file

anepieter opened this issue · 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.

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.

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.