from functools import partial
from http import HTTPStatus
from pathlib import Path
+from pwd import getpwuid
from time import time
from typing import Any, Dict, List, Literal, Optional, Set, Union, cast
from aiohttp.web_response import json_response
from aiohttp.web_runner import AppRunner, TCPSite, UnixSite
-from knot_resolver.constants import CONFIG_FILE
+from knot_resolver.constants import CONFIG_FILE, USER
from knot_resolver.controller import get_best_controller_implementation
from knot_resolver.controller.exceptions import SubprocessControllerExecException
from knot_resolver.controller.registered_workers import command_single_registered_worker
# Block signals during initialization to force their processing once everything is ready
signal.pthread_sigmask(signal.SIG_BLOCK, Server.all_handled_signals())
+ # Check if we are running under the intended user, if not, log a warning message
+ pw_username = getpwuid(os.getuid()).pw_name
+ if pw_username != USER:
+ logger.warning(
+ f"Knot Resolver does not run as the default '{USER}' user, but as '{pw_username}' instead."
+ " This may or may not affect the configuration validation and the proper functioning of the resolver."
+ )
+
# before starting server, initialize the subprocess controller, config store, etc. Any errors during inicialization
# are fatal
try: