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

Certbot should not touch pre-existing files unless needed #6726

Open
hlieberman opened this issue Jan 31, 2019 · 11 comments
Open

Certbot should not touch pre-existing files unless needed #6726

hlieberman opened this issue Jan 31, 2019 · 11 comments
Labels
area: debian / ubuntu priority: unplanned Work that we believe should be done, but does not have a higher priority.

Comments

@hlieberman
Copy link
Member

From downstream Debian bug 920565.

Currently, certbot will run mkdir on /etc/letsencrypt and /var/log/letsencrypt, whether or not the files currently exist, or whether any files are being changed. This causes the timestamps to be updated unnecessarily. It would be good to check whether or not the files exist rather than checking for the error condition on the mkdir.

@ohemorange
Copy link
Contributor

It is more Pythonic and more threadsafe to do it this way; is it a problem to have the timestamps updated unnecessarily?

@ohemorange
Copy link
Contributor

@jwpemail
Copy link

Yes, it is problematic. Security systems that monitor file systems will repeatedly report directory modifcations for a directory that shouldn't be changing unecessarily.

@basak
Copy link
Contributor

basak commented Feb 5, 2019

@ohemorange I understand the Pythonic principle you're applying here, and I prefer this style myself. However, I'd say that this preference should go out of the window if there are side effects, as there are here. "Pythonic-ness", in my view, only applies to the right way to structure code for a particular desired behaviour.

I don't think that code style preferences are valid as an argument for not changing undesired behaviour. The moment someone complains about undesired externally visible behaviour, and we agree that the behaviour is unnecessary, my view is that the desire for "Pythonicness" must immediately give way.

@basak
Copy link
Contributor

basak commented Feb 5, 2019

Having said that, it might be argued that os.makedirs shouldn't be touching the directory, and that's a bug in stdlib. The docs don't define it to do that.

@adferrand
Copy link
Collaborator

adferrand commented Feb 5, 2019

For an example of how this could be implemented, with minimal overhead, one can check my ongoing PR #6497, on https://github.com/adferrand/certbot/blob/windows-files-permissions/certbot/compat/os.py.

It is to improve some os methods toward security on Windows for Certbot, and in particular os.makedirs, to apply proper permissions on created directory. With this kind of approach, another logic can be added to avoid to touch files that already exists.

@stale
Copy link

stale bot commented Feb 7, 2020

We've made a lot of changes to Certbot since this issue was opened. If you still have this issue with an up-to-date version of Certbot, can you please add a comment letting us know? This helps us to better see what issues are still affecting our users. If there is no activity in the next 30 days, this issue will be automatically closed.

@stale stale bot added the needs-update label Feb 7, 2020
@hlieberman
Copy link
Member Author

hlieberman commented Feb 7, 2020 via email

@stale stale bot removed the needs-update label Feb 7, 2020
@jwpemail
Copy link

jwpemail commented Feb 7, 2020

certbot v0.28.0-1~deb9u2 (Debian oldstable) is still affected by this

certbot v0.31.0-1 (debian stable) is also still affected by this.

To be clear, simply running 'certbot renew' will modify the timestamp of the directory /etc/letsencrypt to the current time.

@bmw bmw added priority: unplanned Work that we believe should be done, but does not have a higher priority. and removed unplanned labels Mar 20, 2020
@github-actions
Copy link

We've made a lot of changes to Certbot since this issue was opened. If you still have this issue with an up-to-date version of Certbot, can you please add a comment letting us know? This helps us to better see what issues are still affecting our users. If there is no activity in the next 30 days, this issue will be automatically closed.

@jwpemail
Copy link

jwpemail commented May 18, 2023

Yes, the problem still exits. Here's how you can verify this on a system with certbot installed.


$  date
$  ls -ald /etc/letsencrypt  <- This will be the datetime of the last run of 'certbot renew'
$  certbot renew 
$  date
$  ls -ald /etc/letsencrypt  <- This will now be the same as the current time

This happens for me on Debian bullseye (certbot v1.12.0-2) and bookworm (certbot v2.1.0-4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: debian / ubuntu priority: unplanned Work that we believe should be done, but does not have a higher priority.
Projects
None yet
Development

No branches or pull requests

6 participants