Do not load netrc config files

This commit is contained in:
Mike A. 2024-09-17 23:22:06 +02:00 committed by Hugo Osvaldo Barrera
parent 688d6f907f
commit a490544405

View file

@ -1,6 +1,8 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
import os
import platform
import re import re
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from base64 import b64encode from base64 import b64encode
@ -17,6 +19,13 @@ from .utils import expand_path
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
USERAGENT = f"vdirsyncer/{__version__}" USERAGENT = f"vdirsyncer/{__version__}"
# 'hack' to prevent aiohttp from loading the netrc config,
# but still allow it to read PROXY_* env vars.
# Otherwise, if our host is defined in the netrc config,
# aiohttp will overwrite our Authorization header.
# https://github.com/pimutils/vdirsyncer/issues/1138
os.environ["NETRC"] = "NUL" if platform.system() == "Windows" else "/dev/null"
class AuthMethod(ABC): class AuthMethod(ABC):
def __init__(self, username, password): def __init__(self, username, password):