diff options
author | Alexander Sulfrian <asulfrian@zedat.fu-berlin.de> | 2021-06-18 17:07:40 +0200 |
---|---|---|
committer | Alexander Sulfrian <asulfrian@zedat.fu-berlin.de> | 2022-01-30 05:03:22 +0100 |
commit | 161953cb28f356e1aa38f5cf67234f28a19ceb26 (patch) | |
tree | e9fa337b45bea85529387e36017761d2797cff71 /src | |
parent | 6ab8aaff8adefe8fe4b588fac16d3f1c1e0b0715 (diff) | |
download | bcfg2-161953cb28f356e1aa38f5cf67234f28a19ceb26.tar.gz bcfg2-161953cb28f356e1aa38f5cf67234f28a19ceb26.tar.bz2 bcfg2-161953cb28f356e1aa38f5cf67234f28a19ceb26.zip |
debconf: Find extra entries
Extra debconf entries, are entries that were seen but that are not specified in
the configuration.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/Debconf.py | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/Debconf.py b/src/lib/Bcfg2/Client/Tools/Debconf.py index 147d58b4b..4e8797b1c 100644 --- a/src/lib/Bcfg2/Client/Tools/Debconf.py +++ b/src/lib/Bcfg2/Client/Tools/Debconf.py @@ -8,7 +8,7 @@ import Bcfg2.Client.Tools class Debconf(Bcfg2.Client.Tools.Tool): """Debconf Support for Bcfg2.""" name = 'Debconf' - __execs__ = ['/usr/bin/debconf-communicate'] + __execs__ = ['/usr/bin/debconf-communicate', '/usr/bin/debconf-show'] __handles__ = [('Conf', 'debconf')] __req__ = {'Conf': ['name']} @@ -65,20 +65,13 @@ class Debconf(Bcfg2.Client.Tools.Tool): def VerifyConf(self, entry, _modlist): """ Verify the given Debconf entry. """ - (seen, value) = self.debconf_get(entry.get('name')) - if 'value' not in entry.attrib: - if seen == 'true': - return False - else: - if value != entry.get('value'): - return False + (_, value) = self.debconf_get(entry.get('name')) + if value != entry.get('value'): + return False return True def InstallConf(self, entry): """ Install the given Debconf entry. """ - if 'value' not in entry.attrib: - return self.debconf_reset(entry.get('name')) - return self.debconf_set(entry.get('name'), entry.get('value')) def Inventory(self, structures=None): @@ -100,3 +93,21 @@ class Debconf(Bcfg2.Client.Tools.Tool): return result Install.__doc__ = Bcfg2.Client.Tools.Tool.Install.__doc__ + + def FindExtra(self): + specified = [entry.get('name') + for entry in self.getSupportedEntries()] + extra = set() + listowners = self.cmd.run(['/usr/bin/debconf-show', '--listowners']) + if listowners.success: + owners = listowners.stdout.splitlines() + + values = self.cmd.run(['/usr/bin/debconf-show'] + owners) + for line in values.stdout.splitlines(): + if len(line) > 2 and line[0] == '*': + (name, value) = line[2:].split(':', 2) + if name not in specified: + extra.add(name) + return [Bcfg2.Client.XML.Element('Conf', name=name, type='debconf') + for name in list(extra)] + FindExtra.__doc__ = Bcfg2.Client.Tools.Tool.FindExtra.__doc__ |