Subject: Re: logins

From: [email-masked] (Andy Church)
Date: Tue, 29 Jul 1997 11:02:11 EDT

>Andy Church wrote:
>> 
>> >I have 700+ people using wuftpd.
>> >
>> >When they login in ,it takes forever to check there password, is this to
>> >do with wuftps or just the size of the password file
>> 
>>      Do you have many (>50 or so) "upload" directives in your ftpaccess
>> file?  That could cause the kind of delay you mentioned, since wu-ftpd has
>> to do a getpwnam() and getgrnam() for each line.
>> 
>>   --Andy Church                  | If Bell Atlantic really is the heart
>>     [email-masked]       | of communication, then it desperately
>>     www.dragonfire.net/~achurch/ | needs a quadruple bypass.
>
>
>Yes I have about 700+, but I don't know how I can reduce this. Does
>wuftpd goto the password file every time it sees a upload directive,
>can't it just skip until it finds the one it needs.
>
>How do I get around this, or do I just pray that we don't get anymore
>accounts on the nachine.

     I ran into this problem myself a while back, and came up with the
patch below; it allows you to specify the user/group in upload lines
numerically, by using the string "%NNN" where NNN is the UID/GID.  For
example:

upload /home/ftp /users/a/achurch/incoming yes %501 %100 0600 nodirs

     The patch below is against beta 13, but should apply more or less
cleanly to most versions; and if it doesn't, the changes are still fairly
straightforward.

  --Andy Church                  | If Bell Atlantic really is the heart
    [email-masked]       | of communication, then it desperately
    www.dragonfire.net/~achurch/ | needs a quadruple bypass.

*** src/extensions.c.old	Mon Mar  3 04:39:54 1997
--- src/extensions.c	Thu Jul 24 17:01:31 1997
***************
*** 809,824 ****
  
      while (getaclentry("upload", &entry) && ARG0 && ARG1 && ARG2 != NULL) {
          if (ARG3 && ARG4) {
!             pwent = getpwnam(ARG3);
!             grent = getgrnam(ARG4);
  
!             if (pwent)  sprintf(buf, "%d", pwent->pw_uid);
!             else        sprintf(buf, "%d", 0);
              ARG3 = (char *) malloc(strlen(buf) + 1);
              strcpy(ARG3, buf);
  
!             if (grent)  sprintf(buf, "%d", grent->gr_gid);
!             else        sprintf(buf, "%d", 0);
              ARG4 = (char *) malloc(strlen(buf) + 1);
              strcpy(ARG4, buf);
  	    endgrent();
--- 809,828 ----
  
      while (getaclentry("upload", &entry) && ARG0 && ARG1 && ARG2 != NULL) {
          if (ARG3 && ARG4) {
!             if (*ARG3 != '%')
!                 pwent = getpwnam(ARG3);
!             if (*ARG4 != '%')
!                 grent = getgrnam(ARG4);
  
!             if (*ARG3 == '%')       sprintf(buf, "%s", ARG3+1);
!             else if (pwent)         sprintf(buf, "%d", pwent->pw_uid);
!             else                    sprintf(buf, "%d", 0);
              ARG3 = (char *) malloc(strlen(buf) + 1);
              strcpy(ARG3, buf);
  
!             if (*ARG4 == '%')       sprintf(buf, "%s", ARG4+1);
!             else if (grent)         sprintf(buf, "%d", grent->gr_gid);
!             else                    sprintf(buf, "%d", 0);
              ARG4 = (char *) malloc(strlen(buf) + 1);
              strcpy(ARG4, buf);
  	    endgrent();