Subject: Different classes of guests

From: Brad Waite <[email-masked]>
Date: Wed, 29 Oct 1997 10:38:44 -0700

Does anyone else have a need for separating different guest users?  For
instance, some guests I want to limit to the daytime, other guests to
the night, and they don't come from known IPs.  Or, different guests
should have different upload perms, etc.  Anyone else feel the same way?

-Brad Waite

---

From: "T's Mailing Lists" <[email-masked]>
Date: Wed, 29 Oct 1997 20:49:03 +0000 (GMT)

> should have different upload perms, etc.  Anyone else feel the same way?

Yes, I think that wuold be nice.
*
t

--------------------------------------------------------------------------------
                   Tomas Pospisek's mailing-lists mailbox   
           www.SPIN.ch - Internet Services in Graubuenden/Switzerland
--------------------------------------------------------------------------------
Tom: So far, der winter kommt, ich schaff mir glaub ich noch ein paar
Tom: Zyxel traffos an...
Roli: Aber genug davon nehmen. Wenn die Dinger kapput gehen werden sie 
Roli: nicht mehr warm.

---

From: Brad Waite <[email-masked]>
Date: Fri, 31 Oct 1997 18:50:42 -0700

Okay, folks.  Slapped something together that give a bit more
flexibility in setting up guest access.  I've added a naming function to
the guestgroup keyword in ftpacess, as well as a new 'guestuser'
keyword. The entries would look something like this:

  guestgroup gumbies 	user nobody
  guestgroup gumps	root bin sys
  guestuser gimps	fred barney

  And the corresponding class line would be:

  class   local1   real,gumps,anonymous localhost
  class	local2   gimps,gumbies localhost

You'll notice that the 'guest' variable is still set, and everything
else functions as usual - this just add the capability of refining the
classes.  I'm working on incorporating the guestgroup names into the
rest of the code, but it's a bigger project.

-Brad Waite

---- Cut here ----
(sorry about the cheesy diff - don't have diffutils handy.  And don't
count on the new version's line numbers to be correct - I've done some
other hacking.)

*** ftpd-orig.c Fri Oct 31 18:00:29 1997
--- ftpd.c      Fri Oct 31 18:02:38 1997
***************
*** 247,252 ****
--- 247,253 ----
  
  int anonymous = 1;
  int guest;
+ char guestname[256];                  /* guest group name */
  int type;
  int form;
  int stru;                       /* avoid C keyword */
****************
*** 1252,1258 ***
          /* if user is a member of any of the guestgroups, cause a
chroot() */
          /* after they log in
successfully                                  */
        if (use_accessfile)             /* see above.  _H*/
!             guest = acl_guestgroup(pw);
      }
      if (access_ok(530) < 1) {
          reply(530, "User %s access denied.", name);
--- 1260,1266 ----
          /* if user is a member of any of the guestgroups, cause a
chroot() */
          /* after they log in
successfully                                  */
        if (use_accessfile)             /* see above.  _H*/
!             guest = (acl_guestuser(pw) || acl_guestgroup(pw));
      }
      if (access_ok(530) < 1) {
          reply(530, "User %s access denied.", name);

*** access-orig.c       Fri Oct 31 18:07:54 1997
--- access.c    Fri Oct 31 17:18:58 1997
***************
*** 60,68 ****
  #include <fcntl.h>
  #endif
  
  extern char remotehost[],
    remoteaddr[],
!  *aclbuf;
  extern int nameserved,
    anonymous,
    guest,
--- 60,68 ----
  #include <fcntl.h>
  #endif
  
  extern char remotehost[],
    remoteaddr[],
!  *aclbuf, guestname[];
  extern int nameserved,
    anonymous,
    guest,
***************
*** 262,277 ****
      int which;
      char **member;
  
!     /* guestgroup <group> [<group> ...] */
      while (getaclentry("guestgroup", &entry)) {
!         for (which = 0; (which < MAXARGS) && ARG[which]; which++) {
              if (!(grp = getgrnam(ARG[which])))
                  continue;
!             if (pw->pw_gid == grp->gr_gid)
!                 return (1);
              for (member = grp->gr_mem; *member; member++) {
!                 if (!strcmp(*member, pw->pw_name))
!                     return (1);
              }
          }
      }
--- 268,287 ----
      int which;
      char **member;
  
!     /* guestgroup <groupname> <group> [<group> ...] */
      while (getaclentry("guestgroup", &entry)) {
!         for (which = 1; (which < MAXARGS) && ARG[which]; which++) {
              if (!(grp = getgrnam(ARG[which])))
                  continue;
!             if (pw->pw_gid == grp->gr_gid){
!                                       strcpy(guestname,ARG0);
!                                       return (1);
!                               }
              for (member = grp->gr_mem; *member; member++) {
!                                       if (!strcmp(*member,
pw->pw_name)){
!                                               strcpy(guestname,ARG0);
!                                               return (1);
!                                       }
              }
          }
      }
***************
*** 452,462 ****
              strcpy(classbuf, ARG0);
  
          for (which = 2; (which < MAXARGS) && ARG[which]; which++) {
             if (anonymous && strcasestr(ARG1, "anonymous") &&
                  hostmatch(ARG[which]))
                  return (1);
  
!             if (guest && strcasestr(ARG1, "guest") &&
hostmatch(ARG[which]))
                  return (1);
  
              if (!guest && !anonymous && strcasestr(ARG1, "real") &&
--- 462,472 ----
              strcpy(classbuf, ARG0);
  
          for (which = 2; (which < MAXARGS) && ARG[which]; which++) {
             if (anonymous && strcasestr(ARG1, "anonymous") &&
                  hostmatch(ARG[which]))
!             if (guest && strcasestr(ARG1, guestname) &&
hostmatch(ARG[which]))
                  return (1);
  
              if (!guest && !anonymous && strcasestr(ARG1, "real") &&
***************
*** 910,913 ****
--- 910,945 ----
      }
  
      /* NOTREACHED */
+ }
+
/*************************************************************************/
+ /* FUNCTION  :
acl_guestuser                                             */
+ /* PURPOSE   : If the real user is the same as one of the listed
users,  */
+ /*             return 1.  Otherwise return
0.                            */
+ /* ARGUMENTS : pw, a pointer to the passwd struct for the
user           */
+
/*************************************************************************/
+ 
+ int
+ #ifdef __STDC__
+ acl_guestuser(struct passwd *pw)
+ #else
+ acl_guestuser(pw)
+ struct passwd *pw;
+ #endif
+ {
+     struct aclmember *entry = NULL;
+     int which;
+        char user1[265];
+        char user2[265];
+ 
+     /* guestuser <groupname> <user> [<user> ...] */
+       while (getaclentry("guestuser", &entry)) {
+               for (which = 1; (which < MAXARGS) && ARG[which];
which++) {
+ 
+             if (!strcmp(pw->pw_name, ARG[which])){
+                                       strcpy(guestname,ARG0);
+                                       return (1);
+                               }
+         }
+     }
+     return (0);
  }

return (1);