Re: pure-ftpd logging

DervishD <[email protected]> Tue, 3 Jan 2006 23:32:50 +0100
Newsgroups gmane.network.pureftpd.user
Organization DervishD
Message-ID <20060103223250.GA12997@DervishD>
    Hi Jarek :)

 * Jarek <[email protected]> dixit:
> Is it possible to fix? maybe there is a patch for this or maybe I jsut
> missed something in startup script ?

    I finally managed to find the patch. It's attached to this
message ;)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...

---------------------------------------------------------------------
To post a new message, e-mail: [email protected]
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
pure-ftpd.patch (text/plain, 2.6 KB)
diff -Naur pure-ftpd-1.0.20/src/ftpd.c pure-ftpd-1.0.20-dd/src/ftpd.c
--- pure-ftpd-1.0.20/src/ftpd.c	2004-07-17 15:28:22.000000000 +0200
+++ pure-ftpd-1.0.20-dd/src/ftpd.c	2005-11-27 10:53:19.000000000 +0100
@@ -3250,6 +3250,55 @@
     end:
     displayquota(&quota);
 #endif
+
+#if defined(WITH_UPLOAD_SCRIPT)
+    if (do_upload_script!=0)
+    {
+        char *alloca_dirname_real;
+        const size_t sizeof_dirname_real = MAXPATHLEN + VHOST_PREFIX_MAX_LEN + 1U;
+        char *resolved_path;
+        const size_t sizeof_resolved_path = MAXPATHLEN + 1U + 1U;
+
+        if ((resolved_path = malloc(sizeof_resolved_path)) == NULL) {
+            return;
+        }
+        resolved_path[sizeof_resolved_path - 1U] = 0;
+        if (realpath(name, resolved_path) == NULL) {
+            (void) unlink(name);            
+            free(resolved_path);
+            logfile(LOG_ERR, "realpath() failure : [%s] => [%s]",
+                    name, strerror(errno));            
+            return;
+        }
+        if (resolved_path[sizeof_resolved_path - 1U] != 0) {
+            for (;;) {
+                *resolved_path++ = 0;
+            }
+        }
+        if ((alloca_dirname_real = ALLOCA(sizeof_dirname_real)) == NULL) {
+            free(resolved_path);
+            return;
+        }
+# ifdef WITH_VIRTUAL_CHROOT
+        if (SNCHECK(snprintf(alloca_dirname_real, sizeof_dirname_real,
+                             "\001%s/", resolved_path), sizeof_dirname_real)) {
+            goto rp_failure;
+        }        
+# else
+        if (SNCHECK(snprintf(alloca_dirname_real, sizeof_dirname_real,
+                             "\001%s%s/", root_directory,
+                             (*resolved_path == '/' ? resolved_path + 1 :
+                              resolved_path)), sizeof_dirname_real)) {
+            goto rp_failure;
+        }
+# endif
+        upload_pipe_push(account, alloca_dirname_real);
+        
+        rp_failure:
+        free(resolved_path);
+        ALLOCA_FREE(alloca_dirname_real);
+    }
+#endif
 }
 
 void dormd(char *name)
diff -Naur pure-ftpd-1.0.20/src/pure-uploadscript.c pure-ftpd-1.0.20-dd/src/pure-uploadscript.c
--- pure-ftpd-1.0.20/src/pure-uploadscript.c	2004-03-02 21:29:02.000000000 +0100
+++ pure-ftpd-1.0.20-dd/src/pure-uploadscript.c	2005-11-27 10:54:46.000000000 +0100
@@ -379,7 +379,7 @@
     if (script == NULL || *script == 0 ||
         file == NULL || *file == 0 ||
         lstat(file, &st) < 0 ||
-        !S_ISREG(st.st_mode)) {
+        (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))) {
         return -1;
     }
     pid = fork();