Subject: Two little changes to the 2.4.2-B15 (no bugs)

From: Thorsten Ludewig <[email-masked]>
Date: Mon, 1 Dec 1997 13:43:30 +0100

Hi I've 

made two little changes to the 2.4.2-B15.

1. I've added the keyword  ,,chdir <yes|no> <typelist>''.
   f.e if you like to have some guest or. distribution accounts that
   have access to one directory only.

2. I've added the keyword ,,system'' as an upload root-dir.
   f.e. with the following line in the ftpaccess you can deny
   any upload into the /tmp dir also for real users.

   upload system /tmp* no nodirs

Ciao Thorsten
______________________________________________________________________
  __________
 /___   ___/|
 |__/  /|__|/                                         Thorsten Ludewig
   /  / /  /|
  /__/ /  / /           Home Page: http://www.fh-wolfenbuettel.de/~th/
  |__|/  /_/____                     E-Mail: [email-masked]
     /_________/|                              Phone: +49 5331 939 488
     |_________|/                                FAX: +49 5331 939 482

--- CUT HERE --- --- CUT HERE --- --- CUT HERE --- --- CUT HERE --- --- CUT HERE ---
diff -u -r ../orig/wu-ftpd-2.4.2-beta-15/config.h ./config.h
--- ../orig/wu-ftpd-2.4.2-beta-15/config.h	Fri Sep 12 17:44:00 1997
+++ ./config.h	Mon Dec  1 11:58:57 1997
@@ -12,6 +12,17 @@
 #define UPLOAD
 
 /*
+ * allow "update system" keyword in ftpaccess
+ *
+ * f.e. to deny ,,real'' user to upload to the system /tmp
+ *
+ * upload   system   /tmp*  no  nodirs
+ * 
+ */
+ 
+#define SYSTEM_UPLOAD
+
+/*
  * allow "overwrite" keyword in ftpaccess.
  */
 
diff -u -r ../orig/wu-ftpd-2.4.2-beta-15/src/extensions.c ./src/extensions.c
--- ../orig/wu-ftpd-2.4.2-beta-15/src/extensions.c	Fri Sep 12 17:42:43 1997
+++ ./src/extensions.c	Mon Dec  1 11:59:16 1997
@@ -985,7 +985,7 @@
   char path[BUFSIZ];
   char *sp;
   extern struct passwd *pw;
-
+  
   *valid = 0;
   /* what's our current directory? */
 
@@ -998,8 +998,14 @@
     return(-1);
   }
   while (getaclentry("upload", &entry) && ARG0 && ARG1 && ARG2 != NULL) {
-      if ( (!strcmp(ARG0, pw->pw_dir)) &&
-           ((i = path_compare(ARG1, cwdir)) >= match_value) ) {
+  
+      if ( 
+#ifdef SYSTEM_UPLOAD      
+		( strcmp(ARG0, pw->pw_dir) == 0 || strcmp(ARG0, "system") == 0 ) &&
+#else
+		( strcmp(ARG0, pw->pw_dir) == 0) &&
+#endif
+			((i = path_compare(ARG1, cwdir)) >= match_value) ) {
           match_value = i;
           ap2 = ARG2;
           if (ARG3)  ap3 = ARG3;
@@ -1010,6 +1016,8 @@
           else       ap6 = NULL;
       }
   }
+  
+    
   if ( (ap3 && !strcasecmp(ap3, "nodirs")) ||
        (ap6 && !strcasecmp(ap6, "nodirs")) ) {
       reply(530, "%s: Permission denied. (Upload dirs)", name);
@@ -1068,8 +1076,13 @@
        * value" we have received so far... */
 
       while (getaclentry("upload", &entry) && ARG0 && ARG1 && ARG2 != NULL) {
-          if ( (!strcmp(ARG0, pw->pw_dir)) &&
-		       ((i = path_compare(ARG1, cwdir)) >= match_value) ) {
+          if ( 
+#ifdef SYSTEM_UPLOAD      
+		( strcmp(ARG0, pw->pw_dir) == 0 || strcmp(ARG0, "system") == 0 ) &&
+#else
+		(!strcmp(ARG0, pw->pw_dir)) &&
+#endif
+			((i = path_compare(ARG1, cwdir)) >= match_value) ) {
               match_value = i;
               ap1 = ARG1;
               ap2 = ARG2;
diff -u -r ../orig/wu-ftpd-2.4.2-beta-15/src/ftpd.c ./src/ftpd.c
--- ../orig/wu-ftpd-2.4.2-beta-15/src/ftpd.c	Fri Sep 12 17:42:46 1997
+++ ./src/ftpd.c	Mon Dec  1 11:59:34 1997
@@ -1998,6 +1998,7 @@
 
 #endif /* OVERWRITE */
 
+
 #ifdef UPLOAD
     int open_flags = (O_RDWR | O_CREAT |
 		      ((mode != NULL && *mode == 'a') ? O_APPEND : O_TRUNC));
@@ -2935,7 +2936,15 @@
     struct aclmember *entry = NULL;
     char cdpath[MAXPATHLEN + 1];
 
-    if (chdir(path) < 0) {
+    while (getaclentry("chdir", &entry) && ARG0 && ARG1 != NULL) {
+        if (type_match(ARG1))
+            if (strcmp(ARG0, "yes")) {
+                reply(553, "Permission denied. (chdir)" );
+                return;
+            }
+    }
+
+    if (chdir(path) < 0) {    
         /* alias checking */
         while (getaclentry("alias", &entry) && ARG0 && ARG1 != NULL) {
             if (!strcasecmp(ARG0, path)) {