Certbot - Better Handling of Folder Creation for Windows

Hi All

One of the challenges I have had with running certbot on Windows is that os.geteuid method used in some classes breaks the process

Methods:

make_or_verify_core_dir()
util.make_or_verify_dir()
util.make_or_verify_dirs()

Classes:

main.py
account.py
cert_maanger.py

Error message:

Root Cause:

os.geteuid() is a unix only method

Work Around:

Use find and replace to replace os.getuid() with โ€˜0โ€™

This has to be done in each class (main.py, account.py etc) as the errors are raised in those classes not in the util.py class

e,g, in account.py class

Original Code:

Work around Code:

Suggested Changes:

  1. Use If else statement to differentiate between windows and linux

Reference: https://docs.python.org/3/library/os.html

os.name() is able to differentiate between windows (โ€˜ntโ€™) and linux (โ€˜posix)โ€™

  1. Create new folder creation methods in util.py specifically for windows. This means we can isolate Window folder creation specific issues and write logic to deal with those errors in those methods :smiley:

  2. In methods above Point windows to windows folder creation methods

  3. Point linux to linux folder creation methods

Andrei

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.