From c998930e117608d8c5110e233970912be4d7445a Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Mon, 17 Sep 2012 15:22:07 +0200 Subject: [PATCH] daklib/config.py: allow additional configuration files for specific groups --- daklib/config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/daklib/config.py b/daklib/config.py index c79582c2..99b84dd6 100755 --- a/daklib/config.py +++ b/daklib/config.py @@ -28,6 +28,7 @@ Config access class ################################################################################ +import grp import os import apt_pkg import socket @@ -76,6 +77,19 @@ class Config(object): if conffile: apt_pkg.read_config_file_isc(self.Cnf, conffile) + # Read group-specific options + if 'ByGroup' in self.Cnf: + bygroup = self.Cnf.subtree('ByGroup') + groups = set([os.getgid()]) + groups.update(os.getgroups()) + + for group in bygroup.list(): + gid = grp.getgrnam(group).gr_gid + if gid in groups: + if bygroup.get(group): + apt_pkg.read_config_file_isc(self.Cnf, bygroup[group]) + break + # Rebind some functions # TODO: Clean this up self.get = self.Cnf.get -- 2.39.5