From: Ansgar Burchardt Date: Mon, 17 Sep 2012 13:22:07 +0000 (+0200) Subject: daklib/config.py: allow additional configuration files for specific groups X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=c998930e117608d8c5110e233970912be4d7445a;p=dak.git daklib/config.py: allow additional configuration files for specific groups --- 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