Subject: missing chown on mkdir

From: Lee McLoughlin <[email-masked]>
Date: Fri, 25 Jul 1997 21:40:25 +0100

While trying to figure out why a user of SunSITE couldn't do uploads I
found the problem was that any directories they were creating were still
owned by ftp and not the user specified in the ftpaccess upload line.

On checking I found that after files are created fchown() is called to
set the user and group correctly.  This currently is not done after a
mkdir().

The attached patch fixes the problem.

It would also be useful to be able to specify the modes of directories
created by users.  At the moment I tell them to run a chmod after any
mkdir.  This works OK but shouldn't really be necessary.

--
Lee McLoughlin.                         Phone: +44 171 594 8388
IC-Parc, Imperial College,              Fax:   +44 171 594 8432
South Kensington, London. SW7 2BZ. UK.  Email: [email-masked]

*** wu-ftpd-2.4.2-beta-13-ORIG/src/ftpd.c	Mon Mar  3 09:39:56 1997
--- wu-ftpd-2.4.2-beta-13/src/ftpd.c	Fri Jul 25 21:27:47 1997
***************
*** 2956,2961 ****
--- 3153,3159 ----
  char *name;
  #endif
  {
+     uid_t oldid;
  	uid_t uid;
  	gid_t gid;
  	int   valid;
***************
*** 2979,2984 ****
--- 3177,3192 ----
              perror_reply(550, name);
  	return;
      }
+ 
+     oldid = geteuid();
+     (void) seteuid((uid_t) 0);
+     if ((chown(name, uid, gid)) < 0) {
+         (void) seteuid(oldid);
+         perror_reply(550, "chown");
+         return;
+     }
+     (void) seteuid(oldid);
+ 
      reply(257, "MKD command successful.");
  }