Subject: Code to Limit Sub-directories

From: "gil vidals" <[email-masked]>
Date: Wed, 22 Apr 1998 07:57:34 -0700

Hi,

Can someone show me what code to add, so that members ftp'ing to our site will ONLY be able to create sub-directories in their root directory? (Every member is in a group guest and is chroot'd to their directory).

In other words, we don't want members creating sub-directories that go deep into their (root) directory. We only want ONE level of sub-directories. 

I know that this is possible to control via ftpaccess; however, it's a hassel to maintain with 1000 of entries, and I think it would be simpler to modify wuftpd. All members   are in the same directory /usr/www/members. 

Gil

********************************** dir_check in extensions.c ******************************************************
dir_check(name,uid,gid,valid)
char *name;
uid_t *uid;
gid_t *gid;
int *valid;
#endif
{
  struct aclmember *entry = NULL;

  int i,
    match_value = -1;
  char *ap2 = NULL,
       *ap3 = NULL,
       *ap4 = NULL,
       *ap6 = NULL;
  char cwdir[BUFSIZ];
  char path[BUFSIZ];
  char *sp;
  extern struct passwd *pw;

  *valid = 0;
  /* what's our current directory? */

  strcpy(path, name);
  if (sp = strrchr(path, '/'))  *sp = '\0';
  else strcpy(path, ".");

  if ((realpath(path, cwdir)) == NULL) {
    perror_reply(553, "Could not determine cwdir");
    return(-1);
  }
  while (getaclentry("upload", &entry) && ARG0 && ARG1 && ARG2 != NULL) {
      if ( (!strcmp(ARG0, pw->pw_dir)) &&
           ((i = path_compare(ARG1, cwdir)) >= match_value) ) {
          match_value = i;
          ap2 = ARG2;
          if (ARG3)  ap3 = ARG3;
          else       ap3 = NULL;
          if (ARG4)  ap4 = ARG4;
          else       ap4 = NULL;
          if (ARG6)  ap6 = ARG6;
          else       ap6 = NULL;
      }
  }
  if ( (ap3 && !strcasecmp(ap3, "nodirs")) ||
       (ap6 && !strcasecmp(ap6, "nodirs")) ) {
      reply(530, "%s: Permission denied. (Upload dirs)", name);
      return(0);
  }
if (ap3)
     *uid = atoi(ap3);    /* the uid  */
  if (ap4) {
     *gid = atoi(ap4);    /* the gid */
     *valid = 1;
   }
  return(1);
}

http://www.truepath.com
<<the cool community for Christians>>
FREE homepages for Christians