myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [3092] A maximum file size can be defined for security


From: Giuseppe Scrivano
Subject: [myserver-commit] [3092] A maximum file size can be defined for security files.
Date: Fri, 22 May 2009 22:00:06 +0000

Revision: 3092
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3092
Author:   gscrivano
Date:     2009-05-22 22:00:04 +0000 (Fri, 22 May 2009)
Log Message:
-----------
A maximum file size can be defined for security files.

Modified Paths:
--------------
    trunk/myserver/documentation/security.texi
    trunk/myserver/include/conf/security/security_cache.h
    trunk/myserver/src/conf/security/security_cache.cpp
    trunk/myserver/src/conf/security/xml_validator.cpp

Modified: trunk/myserver/documentation/security.texi
===================================================================
--- trunk/myserver/documentation/security.texi  2009-05-22 20:21:30 UTC (rev 
3091)
+++ trunk/myserver/documentation/security.texi  2009-05-22 22:00:04 UTC (rev 
3092)
@@ -38,6 +38,14 @@
 The anonymous user is matched inside MyServer with the ``Guest''
 username and an empty password.
 
+The name for the security file can be changed trought the
address@hidden variable.
+The maximum allowed size for a security file can be limited by the
address@hidden variable, by default there is no limit.
+Both @code{security.filename} and @code{security.max_size} can be
+defined in the global configuration file or differently for every
+virtual host.
+
 @section Security file user authentication
 The information used for the first phase of logging is a simple list
 of USER elements.  Any permission is configured by an attribute, if

Modified: trunk/myserver/include/conf/security/security_cache.h
===================================================================
--- trunk/myserver/include/conf/security/security_cache.h       2009-05-22 
20:21:30 UTC (rev 3091)
+++ trunk/myserver/include/conf/security/security_cache.h       2009-05-22 
22:00:04 UTC (rev 3092)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -40,7 +40,8 @@
   void setMaxNodes (int);
   int getMaxNodes ();
 
-  XmlParser* getParser (const string &dir, const string &sys, bool useXpath = 
true, const char* secName = ".security.xml");
+  XmlParser* getParser (const string &dir, const string &sys, bool useXpath = 
true,
+                        const char* secName = ".security.xml", u_long maxSize 
= 0);
        int getSecurityFile (const string &file, const string &sys, string 
&out, const char* secName = ".security.xml");
 
   /////////OLD NASTY AND DISGUSTING.  TEMPORARY SOLUTION TO DON'T BREAK 
APIs////////////////////////////////////

Modified: trunk/myserver/src/conf/security/security_cache.cpp
===================================================================
--- trunk/myserver/src/conf/security/security_cache.cpp 2009-05-22 20:21:30 UTC 
(rev 3091)
+++ trunk/myserver/src/conf/security/security_cache.cpp 2009-05-22 22:00:04 UTC 
(rev 3092)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -164,11 +164,13 @@
  *\param sys The system directory.
  *\param useXpath Specify if XPath will be used on the file.
  *\param secFileName The security file name.
+ *\param maxSize The maximum file size allowed for the security file.
  */
 XmlParser* SecurityCache::getParser (const string &dir, 
                                      const string &sys, 
                                      bool useXpath,
-                                     const char* secFileName)
+                                     const char* secFileName,
+                                     u_long maxSize)
 {
   XmlParser* parser;
   string file;
@@ -186,10 +188,26 @@
     time_t fileModTime;
     /*! If the file was modified reload it. */
     fileModTime = FilesUtility::getLastModTime (file.c_str ());
+
     if ((fileModTime != static_cast<time_t>(-1))  && 
        (parser->getLastModTime () != fileModTime))
     {
       parser->close ();
+
+      /* FIXME:  Don't open the file twice, once to check
+       * and the second time to parse.  */
+      if (maxSize)
+        {
+          File parserFile;
+          if (parserFile.openFile (file.c_str (), File::MYSERVER_OPEN_READ))
+            return NULL;
+
+          if (parserFile.getFileSize () > maxSize)
+            return NULL;
+
+          parserFile.close ();
+        }
+
       if(parser->open (file.c_str (), useXpath) == -1)
       {
         dictionary.remove (file.c_str ());

Modified: trunk/myserver/src/conf/security/xml_validator.cpp
===================================================================
--- trunk/myserver/src/conf/security/xml_validator.cpp  2009-05-22 20:21:30 UTC 
(rev 3091)
+++ trunk/myserver/src/conf/security/xml_validator.cpp  2009-05-22 22:00:04 UTC 
(rev 3092)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2008 Free Software Foundation, Inc.
+Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -68,8 +68,10 @@
   if (!cache)
     return NULL;
 
-  secName = st->getHashedData ("SECURITY_FILE_NAME", MYSERVER_VHOST_CONF | 
MYSERVER_SERVER_CONF, ".security.xml");
+  secName = st->getHashedData ("security.filename", MYSERVER_VHOST_CONF | 
MYSERVER_SERVER_CONF, ".security.xml");
 
+  u_long maxSize = atol (st->getHashedData ("security.max_size", 
MYSERVER_VHOST_CONF | MYSERVER_SERVER_CONF, "0"));
+
   return cache->getParser (*(st->getDirectory ()), *(st->getSysDirectory ()), 
false, secName);
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]