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-206-


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-206-gad5c1f5
Date: Sun, 02 May 2010 12:07:26 +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  ad5c1f510e9555267323696692d98282a224b9e1 (commit)
       via  ac734d1129c1df81f4966752bd3f01584f8d9ae8 (commit)
       via  d465c28cee3d4e2efd709a2b0b043702ab0ad1e3 (commit)
      from  df7c9552587fa0774a3c736685a5d95fc7e84422 (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 ad5c1f510e9555267323696692d98282a224b9e1
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun May 2 14:04:46 2010 +0200

    Http path resolution uses `FilesUtility::notDirectory' to save a `stat'

diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 5551af4..423ca64 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -491,8 +491,7 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped,
           if (next >= filenamePathLen)
             break;
 
-          if (mimeLoc || (FilesUtility::nodeExists (curr.c_str ())
-                          && !FilesUtility::isDirectory (curr.c_str ())))
+          if (mimeLoc || FilesUtility::notDirectory (curr.c_str ()))
             {
               td->pathInfo.assign (&(td->filenamePath.c_str ()[next]));
               td->filenamePath.erase (next);



commit ac734d1129c1df81f4966752bd3f01584f8d9ae8
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun May 2 13:31:15 2010 +0200

    Add new method helper method `notDirectory'

diff --git a/myserver/include/base/file/files_utility.h 
b/myserver/include/base/file/files_utility.h
index f8e79b4..988ad6f 100644
--- a/myserver/include/base/file/files_utility.h
+++ b/myserver/include/base/file/files_utility.h
@@ -58,7 +58,12 @@ public:
   static int completePath (string &fileName);
 
   static int isDirectory (const char*);
-  static int isDirectory (const string& dir){return isDirectory (dir.c_str 
());}
+  static int isDirectory (const string& dir)
+  {return isDirectory (dir.c_str ());}
+
+  static bool notDirectory (const char *path);
+  static bool notDirectory (const string &path)
+  {return notDirectory (path.c_str ());}
 
   static int isLink (const char*);
   static int isLink (const string& dir){return isLink (dir.c_str ());}
diff --git a/myserver/src/base/file/files_utility.cpp 
b/myserver/src/base/file/files_utility.cpp
index 090f111..1151a35 100644
--- a/myserver/src/base/file/files_utility.cpp
+++ b/myserver/src/base/file/files_utility.cpp
@@ -210,6 +210,30 @@ int FilesUtility::deleteFile (const char *filename)
   return 0;
 }
 
+
+/*!
+  Return the result of `nodeExists (PATH) && !isDirectory (PATH)' using a
+  single stat.
+
+  \param path Parameter to `stat'.
+ */
+bool FilesUtility::notDirectory (const char *path)
+{
+  struct stat F_Stats;
+  int err = ::stat (path, &F_Stats);
+  if (err < 0)
+    {
+      if (errno == ENOENT || errno == ENOTDIR)
+        return true;
+
+      /* Raise an exception.  */
+      checked::checkError (err);
+    }
+
+  return (S_ISDIR (F_Stats.st_mode)) ? 0 : 1;
+}
+
+
 /*!
  * Returns a non-null value if the path is a directory.
  * \param filename The path to check.



commit d465c28cee3d4e2efd709a2b0b043702ab0ad1e3
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun May 2 01:10:44 2010 +0200

    Move `areSymlinksAllowed' helper function to the class `Http'.

diff --git a/myserver/include/protocol/http/http.h 
b/myserver/include/protocol/http/http.h
index 5d801f2..b3bcdb1 100644
--- a/myserver/include/protocol/http/http.h
+++ b/myserver/include/protocol/http/http.h
@@ -158,6 +158,18 @@ public:
 
   SecurityToken *getSecurityToken (){return &(td->securityToken);}
   HttpProtocol *getStaticData () {return staticData;}
+
+  /* Helper function used in different places.  Probably this is not
+     the best place for it.  */
+  bool areSymlinksAllowed ()
+  {
+    const char *perm = td->securityToken.getData ("symlinks.follow",
+                                                  MYSERVER_VHOST_CONF
+                                                  | MYSERVER_SERVER_CONF,
+                                                  "NO");
+    return strcasecmp (perm, "YES") == 0;
+  }
+
 protected:
   int processDefaultFile (string& uri, int permissions, int onlyHeader);
 
diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index 8018654..3608202 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -36,18 +36,6 @@ using namespace std;
 # include <errno.h>
 #endif
 
-
-/* FIXME: move somewhere else, duplicated in ftp.cpp.  */
-static bool
-areSymlinkAllowed (HttpThreadContext *td)
-{
-  const char *perm = td->securityToken.getData ("symlinks.follow",
-                                                MYSERVER_VHOST_CONF
-                                                | MYSERVER_SERVER_CONF,
-                                                "NO");
-  return strcasecmp (perm, "YES") == 0;
-}
-
 /*!
   Main function to handle the HTTP PUT command.
  */
@@ -68,7 +56,8 @@ int HttpFile::putFile (HttpThreadContext* td, string& 
filename)
         File file;
         try
           {
-            int symFlags = areSymlinkAllowed (td) ? 0 : 
File::NO_FOLLOW_SYMLINK;
+            int symFlags = td->http->areSymlinksAllowed () ? 0
+              : File::NO_FOLLOW_SYMLINK;
             file.openFile (td->filenamePath.c_str (), File::OPEN_IF_EXISTS
                            | File::WRITE | symFlags);
           }
@@ -120,7 +109,8 @@ int HttpFile::putFile (HttpThreadContext* td, string& 
filename)
         File file;
         try
           {
-            int symFlags = areSymlinkAllowed (td) ? 0 : 
File::NO_FOLLOW_SYMLINK;
+            int symFlags = td->http->areSymlinksAllowed () ? 0
+              : File::NO_FOLLOW_SYMLINK;
             file.openFile (td->filenamePath.c_str (), File::FILE_CREATE_ALWAYS
                            | File::WRITE | symFlags);
           }
@@ -285,7 +275,8 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
 
       try
         {
-          int symFlags = areSymlinkAllowed (td) ? 0 : File::NO_FOLLOW_SYMLINK;
+          int symFlags = td->http->areSymlinksAllowed () ? 0
+            : File::NO_FOLLOW_SYMLINK;
           file = Server::getInstance ()->getCachedFiles ()->open (filenamePath,
                                                                   symFlags);
           if (! file)
diff --git a/myserver/src/protocol/ftp/ftp.cpp 
b/myserver/src/protocol/ftp/ftp.cpp
index 59c23b3..3652a61 100644
--- a/myserver/src/protocol/ftp/ftp.cpp
+++ b/myserver/src/protocol/ftp/ftp.cpp
@@ -48,7 +48,7 @@ static DEFINE_THREAD (ReceiveAsciiFile, pParam);
 static DEFINE_THREAD (ReceiveImageFile, pParam);
 
 
-/* FIXME: move somewhere else, duplicated in http_file.cpp.  */
+/* FIXME: move somewhere else.  */
 static bool
 areSymlinkAllowed (SecurityToken *st)
 {

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

Summary of changes:
 myserver/include/base/file/files_utility.h        |    7 +++++-
 myserver/include/protocol/http/http.h             |   12 ++++++++++
 myserver/src/base/file/files_utility.cpp          |   24 +++++++++++++++++++++
 myserver/src/http_handler/http_file/http_file.cpp |   21 +++++-------------
 myserver/src/protocol/ftp/ftp.cpp                 |    2 +-
 myserver/src/protocol/http/http.cpp               |    3 +-
 6 files changed, 50 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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