Subject: excluding files from directory listings

From: Richard Goerwitz <[email-masked]>
Date: Sun, 1 Nov 1998 23:35:11 -0500 (EST)

The only obvious solution to the problem of excluding files from directory
listings within WU-FTPd is to replace the system "ls" command in ~ftp/bin
with an "ls" that understands the -I (ignore) option.

Then one adds "lslong", "lsshort", and "lsplain" entries to the ftpaccess
file that exclude the desired directories.

I notice, after some reading, that support for "lslong" and "lsshort" is
already in 2.4.2-BETA-18-VR10, but these only take one argument (plus the
base path).  Adding support for multiple arguments is easy - as is adding
support for overriding the plain /bin/ls command.  Sample diffs are given
below.

Basically, these diffs simply make it possible to put things like:

lslong   /bin/ls -lA -I.AppleDouble -I.AppleDesktop -INetwork*Trash*Folder
lsshort  /bin/ls -lA -I.AppleDouble -I.AppleDesktop -INetwork*Trash*Folder
lsplain  /bin/ls -I.AppleDouble -I.AppleDesktop -INetwork*Trash*Folder

into the ftpaccess file.

(No, I haven't tested my diffs.  They're there for illustration and dis-
cussion.  This just seems the most reasonable approach, given the existence
of "lslong" and "lsshort" support that already exists.)

Richard Goerwitz
Brown University

*** ftpd.c	Sun Nov  1 23:16:16 1998
--- ftpd.c.orig	Sun Nov  1 21:05:11 1998
***************
*** 429,437 ****
  #endif
  
  /* ls program commands and options for lreplies on and off */
! char  ls_long[1024];
! char  ls_short[1024];
! char  ls_plain[1024];
  struct aclmember *entry = NULL;
  
  #ifdef DAEMON
--- 429,436 ----
  #endif
  
  /* ls program commands and options for lreplies on and off */
! char  ls_long[50];
! char  ls_short[50];
  struct aclmember *entry = NULL;
  
  #ifdef DAEMON
***************
*** 514,520 ****
  #ifdef IPTOS_LOWDELAY
      int tos;
  #endif
!     int c, which;
      extern int optopt;
      extern char *optarg;
      struct hostent *shp;
--- 513,519 ----
  #ifdef IPTOS_LOWDELAY
      int tos;
  #endif
!     int c;
      extern int optopt;
      extern char *optarg;
      struct hostent *shp;
***************
*** 1021,1031 ****
  
      entry = (struct aclmember *) NULL;
      if (getaclentry("lslong", &entry) && ARG0 && (int)strlen(ARG0) > 0) {
!         strcpy(ls_long,ARG0);
!         for (which = 1; (which < MAXARGS) && ARG[which]; which++) {
               strcat(ls_long," ");
!              strcat(ls_long,ARG[which]);
!         }
      } else {
  #if defined(SVR4) || defined(ISC)
  #if defined(AIX) || defined(SOLARIS2)
--- 1020,1030 ----
  
      entry = (struct aclmember *) NULL;
      if (getaclentry("lslong", &entry) && ARG0 && (int)strlen(ARG0) > 0) {
!           strcpy(ls_long,ARG0);
!       if (ARG1 && strlen(ARG1)) {
               strcat(ls_long," ");
!          strcat(ls_long,ARG1);
!           }
      } else {
  #if defined(SVR4) || defined(ISC)
  #if defined(AIX) || defined(SOLARIS2)
***************
*** 1041,1051 ****
  
      entry = (struct aclmember *) NULL;
      if (getaclentry("lsshort", &entry) && ARG0 && (int)strlen(ARG0) > 0) {
!         strcpy(ls_short,ARG0);
! 	for (which = 1; (which < MAXARGS) && ARG[which]; which++) {
               strcat(ls_short," ");
!              strcat(ls_short,ARG[which]);
! 	}
      } else {
  #if defined(SVR4) || defined(ISC)
  #if defined(AIX) || defined(SOLARIS2)
--- 1040,1050 ----
  
      entry = (struct aclmember *) NULL;
      if (getaclentry("lsshort", &entry) && ARG0 && (int)strlen(ARG0) > 0) {
!           strcpy(ls_short,ARG0);
!       if (ARG1 && strlen(ARG1)) {
               strcat(ls_short," ");
!              strcat(ls_short,ARG1);
!       }
      } else {
  #if defined(SVR4) || defined(ISC)
  #if defined(AIX) || defined(SOLARIS2)
***************
*** 1060,1076 ****
      }
      strcat(ls_short," %s");
  
-     entry = (struct aclmember *) NULL;
-     if (getaclentry("lsplain", &entry) && ARG0 && (int)strlen(ARG0) > 0) {
-         strcpy(ls_plain,ARG0);
- 	for (which = 1; (which < MAXARGS) && ARG[which]; which++) {
-              strcat(ls_plain," ");
-              strcat(ls_plain,ARG[which]);
- 	}
-     } else
-         strcpy(ls_plain,"/bin/ls");
-     strcat(ls_plain," %s");
- 
    {
    int version_option = 0;
  
--- 1059,1064 ----
***************
*** 5295,5301 ****
               * the user meant. */
              if (dirname[0] == '-' && *dirlist == NULL && transflag == 0) {
                  retrieve_is_data = 0;
!                 retrieve(ls_plain, dirname);
                  retrieve_is_data = 1;
                  goto globfree;
              }
--- 5283,5289 ----
               * the user meant. */
              if (dirname[0] == '-' && *dirlist == NULL && transflag == 0) {
                  retrieve_is_data = 0;
!                 retrieve("/bin/ls %s", dirname);
                  retrieve_is_data = 1;
                  goto globfree;
              }

---

From: Gregory A Lundberg <[email-masked]>
Date: Mon, 2 Nov 1998 07:55:19 -0500 (EST)

> lsplain  /bin/ls -I.AppleDouble -I.AppleDesktop -INetwork*Trash*Folder

lslong and lsshort are already in the daemon source so do NOT apply his
patch unless you're running 2.4; in which case you don't care about
security so this is a non-issue anyway.

-- 

Gregory A Lundberg		Senior Partner, VRnet Company
1441 Elmdale Drive              [email-masked]
Kettering, OH 45409-1615 USA    1-800-809-2195