[27519] in Source-Commits
python-hesiod commit: Implement FSGROUP support correctly
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Wed Oct 30 14:20:03 2013
Date: Wed, 30 Oct 2013 14:19:55 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201310301819.r9UIJtoC008000@drugstore.mit.edu>
To: source-commits@MIT.EDU
https://github.com/mit-athena/python-hesiod/commit/2f01f67f3eaf9ce5fdac0648aad330981693c9d4
commit 2f01f67f3eaf9ce5fdac0648aad330981693c9d4
Author: Jonathan Reed <jdreed@mit.edu>
Date: Mon Oct 28 16:45:47 2013 -0400
Implement FSGROUP support correctly
An FSGROUP can have a single member. We define an FSGROUP response
as something for which all returned records have an integer >= 1 as
the last field.
Technically, the definition of an FSGROUP is "the definition of any
given filesys type which has one additional final field", but that
requires knowing about each filsys type, which is liblocker's job.
hesiod.py | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/hesiod.py b/hesiod.py
index 530575a..0e4475a 100755
--- a/hesiod.py
+++ b/hesiod.py
@@ -33,11 +33,25 @@ class FilsysLookup(Lookup):
Lookup.parseRecords(self)
self.filsys = []
- self.multiRecords = (len(self.results) > 1)
+ # An FSGROUP need not contain multiple members.
+ # We are defining an FSGROUP as "Something for which all
+ # returned records have an integer as the last field"
+
+ self.isFSGroup = True
+ for result in self.results:
+ try:
+ if int(result.rsplit(" ", 1)[1]) < 1:
+ self.isFSGroup = False
+ break
+ except ValueError:
+ self.isFSGroup = False
+ break
+ except IndexError:
+ raise HesiodParseError("No fields found in result '%s'; shouldn't happen" % (result,))
for result in self.results:
priority = 0
- if self.multiRecords:
+ if self.isFSGroup:
result, priority = result.rsplit(" ", 1)
priority = int(priority)