[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Be more restrictive about unrecognized sections in conf...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv2984/lib/mixminion

Modified Files:
	Common.py Config.py ServerInfo.py 
Log Message:
Be more restrictive about unrecognized sections in config files

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- Common.py	15 Jul 2003 15:30:56 -0000	1.102
+++ Common.py	30 Jul 2003 22:38:03 -0000	1.103
@@ -825,7 +825,7 @@
             self.setMinSeverity(config['Server'].get('LogLevel', "WARN"))
             logfile = config['Server'].get('LogFile')
             if logfile is None:
-                homedir = config['Server']['Homedir']
+                homedir = config['Server'].get('Homedir')
                 if homedir:
                     logfile = os.path.join(homedir, "log")
             self.addHandler(_ConsoleLogHandler(sys.stderr))

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- Config.py	7 Jul 2003 16:49:24 -0000	1.52
+++ Config.py	30 Jul 2003 22:38:03 -0000	1.53
@@ -549,6 +549,8 @@
     _syntax = None
     _restrictFormat = 0
     _restrictKeys = 1
+    #DOCDOC
+    _restrictSections = 1
 
     def __init__(self, filename=None, string=None, assumeValid=0):
         """Create a new _ConfigFile.  If <filename> is set, read from
@@ -607,8 +609,12 @@
             secConfig = self._syntax.get(secName)
 
             if not secConfig:
-                LOG.warn("Skipping unrecognized section %s", secName)
-                continue
+                if self._restrictSections:
+                    raise ConfigError("Skipping unrecognized section %s"
+                                      %secName)
+                else:
+                    LOG.warn("Skipping unrecognized section %s", secName)
+                    continue
 
             # Set entries from the section, searching for bad entries
             # as we go.
@@ -741,6 +747,7 @@
 
 class ClientConfig(_ConfigFile):
     _restrictFormat = 0
+    _restrictKeys = _restrictSections = 1
     _syntax = {
         'Host' : { '__SECTION__' : ('ALLOW', None, None),
                    'ShredCommand': ('ALLOW', _parseCommand, None),
@@ -765,6 +772,8 @@
         }
     def __init__(self, fname=None, string=None):
         _ConfigFile.__init__(self, fname, string)
+
+    #XXXX005 Make  prevalidate check to make sure there's no 'Server' section.
 
     def validate(self, lines, contents):
         _validateHostSection(self['Host'])

Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- ServerInfo.py	13 Jul 2003 03:45:34 -0000	1.51
+++ ServerInfo.py	30 Jul 2003 22:38:03 -0000	1.52
@@ -47,7 +47,7 @@
 
     """A ServerInfo object holds a parsed server descriptor."""
     _restrictFormat = 1
-    _restrictKeys = 0
+    _restrictKeys = _restrictSections = 0
     _syntax = {
         "Server" : { "__SECTION__": ("REQUIRE", None, None),
                      "Descriptor-Version": ("REQUIRE", None, None),
@@ -387,7 +387,7 @@
     # expectedDigest: the 20-byte digest we expect to find in this
     #    directory's header.
     _restrictFormat = 1
-    _restrictKeys = 0
+    _restrictKeys = _restrictSections = 0
     _syntax = {
         'Directory': { "__SECTION__": ("REQUIRE", None, None),
                        "Version": ("REQUIRE", None, None),