Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log4j-finder will change acces time of a jar file #62

Open
anepieter opened this issue Dec 21, 2021 · 2 comments
Open

log4j-finder will change acces time of a jar file #62

anepieter opened this issue Dec 21, 2021 · 2 comments

Comments

@anepieter
Copy link

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.

@yunzheng
Copy link
Member

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.

@anepieter
Copy link
Author

anepieter commented Dec 22, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants