Subject: Concerning authentication

From: Wal <[email-masked]>
Date: Thu, 22 Jul 1999 23:59:49 +1000 (EST)

Hello all,

i have a strange problem. I would like to use wuftp however
i need to modify the source code a bit so as i can do the following
with it...
        I have a file that maps usernames into the realuser names
(contained in
the passwd file)
        when a user ftp;s to my server etc...he will login using a given
        username..now the ftpd should check a file which contains a
mapping
        to his "real" user name (the one in the passwd file)..

        So, in source code, i belive all i need to do is to add a function
        that does this before authentication with the passwd file etc..
        i.e..right after the user enters his username and password....
        and before authentication..

Now, my problem is, ive looked at source code etc..for wuftpd 2.5.0 and i
cant seem to find where i should do this...
could someone point me in the right direction as to where i should add
this
bit of extra code?

any help would be greatly appreciated

wal

---

From: Gregory A Lundberg <[email-masked]>
Date: Thu, 22 Jul 1999 10:31:53 -0400

On Thu, Jul 22, 1999 at 11:59:49PM +1000, Wal wrote:

>         (contained in the passwd file) when a user ftp;s to my server
>         etc...he will login using a given username..now the ftpd should
>         check a file which contains a mapping to his "real" user name
>         (the one in the passwd file)..

The attached patch should get you going.  Just add the function
RemapUserName(); return 0 if error, non-0 if OK.  If you want to allow
un-mapped usernames as well, remove the test later in the patch.

-- 

Gregory A Lundberg              WU-FTPD Development Group
1441 Elmdale Drive              [email-masked]
Kettering, OH 45409-1615 USA    1-800-809-2195
Index: src/ftpd.c
===================================================================
RCS file: /cvsroot/wu-ftpd-stable/src/ftpd.c,v
retrieving revision 1.21
diff -c -r1.21 ftpd.c
*** src/ftpd.c	1999/05/20 16:37:40	1.21
--- src/ftpd.c	1999/07/22 14:28:54
***************
*** 1525,1536 ****
  
  void
  #ifdef __STDC__
! user(char *name)
  #else
! user(name)
! char *name;
  #endif
  {
      char *cp;
      char *shell;
      char *getusershell();
--- 1525,1538 ----
  
  void
  #ifdef __STDC__
! user(char *original_name)
  #else
! user(original_name)
! char *original_name;
  #endif
  {
+     char new_name[64]; /* Should be big enough. */
+     char *name;
      char *cp;
      char *shell;
      char *getusershell();
***************
*** 1540,1545 ****
--- 1542,1554 ----
      extern char *start_auth();
  #endif
  
+     extern int RemapUserName (char *to, size_t tolen, const char *from);
+     int RemapStatus = RemapuserName (new_name, sizeof(new_name), original_name);
+     if (RemapStatus)
+         name = new_name;
+     else
+         name = original_name;
+ 
  /* H* fix: if we're logged in at all, we can't log in again. */
      if (logged_in) {
  #ifdef VERBOSE_ERROR_LOGING
***************
*** 1549,1554 ****
--- 1558,1575 ----
  	reply(530, "Already logged in.");
  	return;
      }
+ 
+     if (!RemapStatus) {
+ #ifndef HELP_CRACKERS
+           DenyLoginAfterPassword = 1;
+           syslog(LOG_NOTICE, "FTP LOGIN REFUSED (cannot remap username) FROM %s, %s", remoteident, name);
+ #else
+           reply(530, "User %s access denied.", name);
+           syslog(LOG_NOTICE, "FTP LOGIN REFUSED (cannot remap username) FROM %s, %s", remoteident, name);
+           return;
+ #endif
+     }
+ 
  #ifndef HELP_CRACKERS
      askpasswd = 1;
      DenyLoginAfterPassword = 0;