#864 Ensure log output is produced if config file is unreadable
Closed 4 years ago by tkopecek. Opened 6 years ago by rwphillis.

file modified
+7 -2
@@ -387,8 +387,13 @@ 

          configs = koji.config_directory_contents(cfdir)

      else:

          configs = []

-     if cf and os.path.isfile(cf):

-         configs.append(cf)

+     if cf:

+         # Only consider the config file only if it is a readable file

+         if os.path.isfile(cf) and os.access(cf, os.R_OK):

+             configs.append(cf)

+         else:

+             # Log the permissions error if the config file is not readable

+             logger.error('Unable to read configuration file (%s)', cf)

      if configs:

          config = RawConfigParser()

          config.read(configs)

Hi Team,

During a recent test deploy of a new koji-hub host, I discovered that no logging is produced if the main configuration file (/etc/koji-hub/hub.conf) is unreadable.

In my case, an overly restrictive user/group/mode combination rendered the file unreadable by the apache user:

[richard@host:~]# ls -l /etc/koji-hub/hub.conf
-rw------- 1 koji koji 4003 Mar 27 10:17 /etc/koji-hub/hub.conf
[richard@host:~]#

Attempting to connect to this koji-hub instance via koji-client yielded the following error:

ServerOffline: database outage

Due to a lack of logging (and perhaps caffeine), I didn't initially spot the user/group/mode blunder.

This pull request seeks to ensure that suitable logging is produced in the event that the configuration file is not readable. This is particularly important, as koji-hub's default behaviour upon being unable to read the configuration file is to coalesce a number of configuration file parameters, with values that will result in koji-hub failing to operate.

Thanks! :)

I've created issue #865 and PR #866 for consolidating this behaviour through all places. It should satisfy also this case.

Pull-Request has been closed by tkopecek

4 years ago