myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-167-


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-167-g2dd5e22
Date: Sun, 18 Apr 2010 12:48:58 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  2dd5e22fb5ea6d078f14dd32d5ba62264078c4d9 (commit)
       via  e82ec6a398df9ccf6bf23cf66681343e04bfb751 (commit)
      from  af7a9a097db1f9ca192cd51feea6378057104e77 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 2dd5e22fb5ea6d078f14dd32d5ba62264078c4d9
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Apr 18 14:48:23 2010 +0200

    Log exceptions messages in the HTTP protocol handler

diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 4bcc303..3c8776f 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -141,20 +141,13 @@ int Http::optionsHTTPRESOURCE (string& filename, int 
yetmapped)
         *td->auxiliaryBuffer << "\r\nConnection:" << connection->value->c_str 
() << "\r\n";
       *td->auxiliaryBuffer << "Content-length: 0\r\nAccept-Ranges: bytes\r\n";
       *td->auxiliaryBuffer << "Allow: " << methods << "\r\n\r\n";
-
-      /* Send the HTTP header. */
-      ret = td->connection->socket->send (td->auxiliaryBuffer->getBuffer (),
-                                          td->auxiliaryBuffer->getLength (), 
0);
-      if (ret < 0)
-        {
-          td->connection->host->warningsLogWrite (_("HTTP: socket error"));
-          return 0;
-        }
+      td->connection->socket->send (td->auxiliaryBuffer->getBuffer (),
+                                    td->auxiliaryBuffer->getLength (), 0);
       return 1;
     }
-  catch (...)
+  catch (exception & e)
     {
-      td->connection->host->warningsLogWrite (_("HTTP: internal error"));
+      td->connection->host->warningsLogWrite (_E ("HTTP: internal error"), &e);
       return raiseHTTPError (500);
     };
 }
@@ -202,19 +195,13 @@ int Http::traceHTTPRESOURCE (string& filename, int 
yetmapped)
           return 0;
         }
 
-      /* Send the client request header as the HTTP body.  */
-      ret = td->connection->socket->send (td->buffer->getBuffer (),
-                                          contentLength, 0);
-      if (ret < 0)
-        {
-          td->connection->host->warningsLogWrite (_("HTTP: socket error"));
-          return 0;
-        }
+      /* Send the client request header as the HTTP payload.  */
+      td->connection->socket->send (td->buffer->getBuffer (), contentLength, 
0);
       return 1;
     }
-  catch (...)
+  catch (exception & e)
     {
-      td->connection->host->warningsLogWrite (_("HTTP: internal error"));
+      td->connection->host->warningsLogWrite (_E ("HTTP: internal error"), &e);
       return raiseHTTPError (500);
     };
 }
@@ -268,8 +255,9 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
 {
   try
     {
+      const string *sysdir = &td->connection->host->getSystemRoot ();
       td->securityToken.setServer (Server::getInstance ());
-      td->securityToken.setSysDirectory 
((string*)&(td->connection->host->getSystemRoot ()));
+      td->securityToken.setSysDirectory (sysdir);
 
       td->securityToken.setVhost (td->connection->host);
 
@@ -412,11 +400,11 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
     {
       return raiseHTTPError (404);
     }
-  catch (...)
+  catch (exception & e)
     {
       td->connection->host->warningsLogWrite (
-                                 _("HTTP: cannot get permissions for %s"),
-                                 filename.c_str ());
+                                 _E ("HTTP: cannot get permissions for %s"),
+                                 filename.c_str (), &e);
       return 500;
     }
 
@@ -440,7 +428,8 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
  * \return Return 200 on success.
  * \return Any other value is the HTTP error code.
  */
-int Http::preprocessHttpRequest (string& filename, int yetmapped, int* 
permissions)
+int Http::preprocessHttpRequest (string& filename, int yetmapped,
+                                 int* permissions)
 {
   string directory;
   string file;
@@ -483,7 +472,6 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped, int* permissio
            */
 
           u_long next = td->filenamePath.find ('/', i + 1);
-
           string curr = td->filenamePath.substr (0, next);
 
           mimeLoc = td->connection->host
@@ -519,7 +507,9 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped, int* permissio
       /*
        * PATH_TRANSLATED is the local filesystem mapped version of PATH_INFO.
        */
-      if (td->pathInfo.length () > 1)
+      if (td->pathInfo.length () <= 1)
+        td->pathTranslated.assign ("");
+      else
         {
           int ret;
           /* Omit the first slash character.  */
@@ -529,10 +519,7 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped, int* permissio
           else
             FilesUtility::completePath (td->pathTranslated);
         }
-      else
-        {
-          td->pathTranslated.assign ("");
-        }
+
       FilesUtility::completePath (td->filenamePath);
 
       td->mime = mimeLoc ? mimeLoc : getMIME (td->filenamePath);
@@ -541,6 +528,11 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped, int* permissio
     {
       return 404;
     }
+  catch (exception & e)
+    {
+      td->connection->host->warningsLogWrite (_E ("HTTP: internal error"), &e);
+      return 404;
+    }
   catch (...)
     {
       td->connection->host->warningsLogWrite (_("HTTP: internal error"));
@@ -730,11 +722,11 @@ Http::sendHTTPResource (string& uri, int systemrequest, 
int onlyHeader,
 
       return manager->send (td, td->filenamePath.c_str (), 0, onlyHeader);
     }
-  catch (...)
+  catch (exception & e)
     {
-      td->connection->host->warningsLogWrite (_("HTTP: internal error"));
+      td->connection->host->warningsLogWrite (_E ("HTTP: internal error"), &e);
       return raiseHTTPError (500);
-    };
+    }
 
   return HttpDataHandler::RET_OK;
 }
@@ -811,14 +803,17 @@ int Http::logHTTPaccess ()
        * Request the access to the log file then append the message.
        */
       if (td->connection->host)
-        td->connection->host->accessesLogWrite ("%s", 
td->auxiliaryBuffer->getBuffer ());
+        {
+          const char *msg = td->auxiliaryBuffer->getBuffer ();
+          td->connection->host->accessesLogWrite ("%s", msg);
+        }
 
       td->auxiliaryBuffer->setLength (0);
     }
   catch (...)
     {
       return HttpDataHandler::RET_FAILURE;
-    };
+    }
   return 0;
 }
 



commit e82ec6a398df9ccf6bf23cf66681343e04bfb751
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Apr 18 14:43:24 2010 +0200

    Make const some getters

diff --git a/myserver/include/conf/security/auth_domain.h 
b/myserver/include/conf/security/auth_domain.h
index 1843739..9eb0836 100644
--- a/myserver/include/conf/security/auth_domain.h
+++ b/myserver/include/conf/security/auth_domain.h
@@ -33,7 +33,7 @@ class AuthDomain : public SecurityDomain
 public:
   AuthDomain (SecurityToken*);
   virtual ~AuthDomain ();
-  virtual string *getValue (string &name);
+  virtual const string *getValue (string &name);
 protected:
   string name;
   SecurityToken *securityToken;
diff --git a/myserver/include/conf/security/security_domain.h 
b/myserver/include/conf/security/security_domain.h
index 472ae28..92437c7 100644
--- a/myserver/include/conf/security/security_domain.h
+++ b/myserver/include/conf/security/security_domain.h
@@ -32,7 +32,7 @@ public:
   SecurityDomain (const char* name);
   SecurityDomain (string &name);
   virtual ~SecurityDomain ();
-  virtual string *getValue (string &name);
+  virtual const string *getValue (string &name);
   string& getName (){return name;}
 protected:
   string name;
diff --git a/myserver/include/conf/security/security_token.h 
b/myserver/include/conf/security/security_token.h
index 799795e..1665a93 100644
--- a/myserver/include/conf/security/security_token.h
+++ b/myserver/include/conf/security/security_token.h
@@ -73,17 +73,17 @@ public:
     return &values;
   }
 
-  string *getDirectory ()
+  const string *getDirectory ()
   {
     return directory;
   }
 
-  string *getSysDirectory ()
+  const string *getSysDirectory ()
   {
     return sysdirectory;
   }
 
-  string *getResource ()
+  const string *getResource ()
   {
     return resource;
   }
@@ -139,17 +139,17 @@ public:
     password.assign (pw);
   }
 
-  void setDirectory (string *d)
+  void setDirectory (const string *d)
   {
     directory = d;
   }
 
-  void setSysDirectory (string *sd)
+  void setSysDirectory (const string *sd)
   {
     sysdirectory = sd;
   }
 
-  void setResource (string *r)
+  void setResource (const string *r)
   {
     resource = r;
   }
@@ -222,13 +222,13 @@ private:
   string password;
 
   /*! Directory that the user is in.  */
-  string *directory;
+  const string *directory;
 
   /*! System directory for the host.  */
-  string *sysdirectory;
+  const string *sysdirectory;
 
   /*! Resource that the user tried to access.  */
-  string *resource;
+  const string *resource;
 
   /*! Permission mask.  */
   int mask;
diff --git a/myserver/include/conf/security/validator.h 
b/myserver/include/conf/security/validator.h
index f4d945c..2a3decf 100644
--- a/myserver/include/conf/security/validator.h
+++ b/myserver/include/conf/security/validator.h
@@ -50,7 +50,7 @@ public:
                                      AuthMethod* authMethod);
 
 
-  string *getValue (HashMap<string, SecurityDomain*> *hashedDomains,
+  const string *getValue (HashMap<string, SecurityDomain*> *hashedDomains,
                     string &name);
 protected:
   bool comparePassword (const char *password, const char *savedPassword,
diff --git a/myserver/src/conf/security/auth_domain.cpp 
b/myserver/src/conf/security/auth_domain.cpp
index 7a540ce..579dee5 100644
--- a/myserver/src/conf/security/auth_domain.cpp
+++ b/myserver/src/conf/security/auth_domain.cpp
@@ -36,7 +36,7 @@ AuthDomain::~AuthDomain ()
 /*!
  *\see SecurityDomain::getValue.
  */
-string *AuthDomain::getValue (string &name)
+const string *AuthDomain::getValue (string &name)
 {
   if (!name.compare ("user"))
     return &(securityToken->getUser ());
diff --git a/myserver/src/conf/security/security_domain.cpp 
b/myserver/src/conf/security/security_domain.cpp
index 3a777bd..00c1ea7 100644
--- a/myserver/src/conf/security/security_domain.cpp
+++ b/myserver/src/conf/security/security_domain.cpp
@@ -45,7 +45,7 @@ SecurityDomain::~SecurityDomain ()
 /*!
  *Get the stored value for [name].
  */
-string *SecurityDomain::getValue (string &name)
+const string *SecurityDomain::getValue (string &name)
 {
   return NULL;
 }
diff --git a/myserver/src/conf/security/validator.cpp 
b/myserver/src/conf/security/validator.cpp
index 2b3f09f..690e275 100644
--- a/myserver/src/conf/security/validator.cpp
+++ b/myserver/src/conf/security/validator.cpp
@@ -87,7 +87,8 @@ int Validator::getPermissionMask (SecurityToken* st,
  *Decorate getPermissionMaskImpl.
  */
 int Validator::getPermissionMaskInt (SecurityToken* st,
-                                     HashMap<string, SecurityDomain*> 
*hashedDomains,
+                                     HashMap<string,
+                                             SecurityDomain*> *hashedDomains,
                                      AuthMethod* authMethod)
 {
   int ret = 0;
@@ -108,7 +109,8 @@ int Validator::getPermissionMaskInt (SecurityToken* st,
  *Get the permission mask for the requested resource.
  */
 int Validator::getPermissionMaskImpl (SecurityToken* st,
-                                      HashMap<string, SecurityDomain*> 
*hashedDomains,
+                                      HashMap<string,
+                                      SecurityDomain*> *hashedDomains,
                                       AuthMethod* authMethod)
 {
   return 0;
@@ -120,7 +122,9 @@ int Validator::getPermissionMaskImpl (SecurityToken* st,
  *\param name Variable name.
  *\return The value of the requested variable.
  */
-string *Validator::getValue (HashMap<string, SecurityDomain*> *hashedDomains, 
string &name)
+const string *Validator::getValue (HashMap<string,
+                                           SecurityDomain*> *hashedDomains,
+                                   string &name)
 {
   string domain;
   string var;
diff --git a/myserver/src/conf/security/xml_validator.cpp 
b/myserver/src/conf/security/xml_validator.cpp
index d8ca272..9fdc1cc 100644
--- a/myserver/src/conf/security/xml_validator.cpp
+++ b/myserver/src/conf/security/xml_validator.cpp
@@ -327,8 +327,7 @@ bool XmlValidator::doCondition (xmlNodePtr node,
       attrs = attrs->next;
     }
 
-  string *storedValue = getValue (hashedDomains, name);
-
+  const string *storedValue = getValue (hashedDomains, name);
   if (!storedValue)
     return false;
 
diff --git a/myserver/tests/test_security_domain.cpp 
b/myserver/tests/test_security_domain.cpp
index eaf1dbe..c2cb296 100644
--- a/myserver/tests/test_security_domain.cpp
+++ b/myserver/tests/test_security_domain.cpp
@@ -59,7 +59,8 @@ public:
   void testGetValue ()
   {
     string val ("value");
-    CPPUNIT_ASSERT_EQUAL (securityDomain->getValue (val), (string*)NULL);
+    CPPUNIT_ASSERT_EQUAL (securityDomain->getValue (val),
+                          (const string *) NULL);
   }
 
 };
diff --git a/myserver/tests/test_security_token.cpp 
b/myserver/tests/test_security_token.cpp
index c292bb0..d4e4c39 100644
--- a/myserver/tests/test_security_token.cpp
+++ b/myserver/tests/test_security_token.cpp
@@ -86,21 +86,21 @@ public:
 
   void testDirectory ()
   {
-    string dir ("foo");
+    const string dir ("foo");
     securityToken->setDirectory (&dir);
     CPPUNIT_ASSERT_EQUAL (securityToken->getDirectory (), &dir);
   }
 
   void testSysDirectory ()
   {
-    string sysDir ("foo");
+    const string sysDir ("foo");
     securityToken->setSysDirectory (&sysDir);
     CPPUNIT_ASSERT_EQUAL (securityToken->getSysDirectory (), &sysDir);
   }
 
   void testResource ()
   {
-    string resource ("foo");
+    const string resource ("foo");
     securityToken->setResource (&resource);
     CPPUNIT_ASSERT_EQUAL (securityToken->getResource (), &resource);
   }
diff --git a/myserver/tests/test_validator.cpp 
b/myserver/tests/test_validator.cpp
index e7a571c..b535f7c 100644
--- a/myserver/tests/test_validator.cpp
+++ b/myserver/tests/test_validator.cpp
@@ -56,14 +56,16 @@ public:
   {
     string val ("value");
     HashMap<string, SecurityDomain*> hashedDomains;
-    CPPUNIT_ASSERT_EQUAL (validator->getValue (&hashedDomains, val), 
(string*)NULL);
+    CPPUNIT_ASSERT_EQUAL (validator->getValue (&hashedDomains, val),
+                          (const string*) NULL);
   }
 
   void testGetPermissionMaskImpl ()
   {
     string val ("value");
     SecurityToken secToken;
-    CPPUNIT_ASSERT_EQUAL (validator->getPermissionMaskImpl (&secToken, NULL, 
NULL), 0);
+    CPPUNIT_ASSERT_EQUAL (validator->getPermissionMaskImpl (&secToken, NULL,
+                                                            NULL), NULL);
 
   }
 
diff --git a/myserver/tests/test_xml_validator.cpp 
b/myserver/tests/test_xml_validator.cpp
index c7da1b8..80f664e 100644
--- a/myserver/tests/test_xml_validator.cpp
+++ b/myserver/tests/test_xml_validator.cpp
@@ -57,7 +57,8 @@ public:
     string val ("value");
     HashMap<string, SecurityDomain*> hashedDomains;
 
-    CPPUNIT_ASSERT_EQUAL (xmlValidator->getValue (&hashedDomains, val), 
(string*)NULL);
+    CPPUNIT_ASSERT_EQUAL (xmlValidator->getValue (&hashedDomains, val),
+                          (const string *) NULL);
 
   }
 
@@ -69,7 +70,8 @@ public:
     secToken.setResource (&val);
     secToken.setDirectory (&val);
     secToken.setSysDirectory (&val);
-    CPPUNIT_ASSERT_EQUAL (xmlValidator->getPermissionMaskImpl (&secToken, 
NULL, NULL), 0);
+    CPPUNIT_ASSERT_EQUAL (xmlValidator->getPermissionMaskImpl (&secToken, NULL,
+                                                               NULL), 0);
 
   }
 

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/conf/security/auth_domain.h     |    2 +-
 myserver/include/conf/security/security_domain.h |    2 +-
 myserver/include/conf/security/security_token.h  |   18 +++---
 myserver/include/conf/security/validator.h       |    2 +-
 myserver/src/conf/security/auth_domain.cpp       |    2 +-
 myserver/src/conf/security/security_domain.cpp   |    2 +-
 myserver/src/conf/security/validator.cpp         |   10 ++-
 myserver/src/conf/security/xml_validator.cpp     |    3 +-
 myserver/src/protocol/http/http.cpp              |   69 ++++++++++------------
 myserver/tests/test_security_domain.cpp          |    3 +-
 myserver/tests/test_security_token.cpp           |    6 +-
 myserver/tests/test_validator.cpp                |    6 +-
 myserver/tests/test_xml_validator.cpp            |    6 +-
 13 files changed, 67 insertions(+), 64 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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