Home | History | Annotate | Download | only in in.ftpd
      1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
      2 
      3 /****************************************************************************
      4 
      5   Copyright (c) 1999,2000 WU-FTPD Development Group.
      6   All rights reserved.
      7 
      8   Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
      9     The Regents of the University of California.
     10   Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
     11   Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
     12   Portions Copyright (c) 1989 Massachusetts Institute of Technology.
     13   Portions Copyright (c) 1998 Sendmail, Inc.
     14   Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P.  Allman.
     15   Portions Copyright (c) 1997 by Stan Barber.
     16   Portions Copyright (c) 1997 by Kent Landfield.
     17   Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
     18     Free Software Foundation, Inc.
     19 
     20   Use and distribution of this software and its source code are governed
     21   by the terms and conditions of the WU-FTPD Software License ("LICENSE").
     22 
     23   If you did not receive a copy of the license, it may be obtained online
     24   at http://www.wu-ftpd.org/license.html.
     25 
     26   $Id: authenticate.c,v 1.9 2000/07/01 18:17:38 wuftpd Exp $
     27 
     28 ****************************************************************************/
     29 #include "config.h"
     30 #include <stdio.h>
     31 #include <string.h>
     32 #include "authuser.h"
     33 #include "authenticate.h"
     34 #include "proto.h"
     35 
     36 #define AUTHNAMESIZE 100
     37 
     38 char authuser[AUTHNAMESIZE];
     39 int authenticated;
     40 
     41 extern int disable_rfc931;
     42 extern unsigned int timeout_rfc931;
     43 
     44 /*
     45  * Ideally more authentication schemes would be called from here, with the
     46  * strongest called first.  One possible double-check would be to verify that
     47  * the results of all authentication calls (returning identical data!) are
     48  * checked against each other.
     49  */
     50 int wu_authenticate(void)
     51 {
     52     char *user;
     53 #if USE_A_RFC931
     54     unsigned long in;
     55     unsigned short local, remote;
     56 #endif /* USE_A_RFC931 */
     57 
     58     authenticated = 0;		/* this is a bitmask, one bit per method */
     59 
     60     user = "*";
     61 
     62 #if USE_A_RFC931
     63     if (disable_rfc931 || (timeout_rfc931 == 0))
     64 	user = "*";
     65     else if (auth_fd(0, &in, &local, &remote) == -1)
     66 	user = "?";		/* getpeername/getsockname failure */
     67     else {
     68 	if (!(user = auth_tcpuser(in, local, remote)))
     69 	    user = "*";		/* remote host doesn't support RFC 931 */
     70 	else
     71 	    authenticated |= A_RFC931;
     72     }
     73 #endif /* USE_A_RFC931 */
     74 
     75     strncpy(authuser, user, sizeof(authuser));
     76     authuser[AUTHNAMESIZE - 1] = '\0';
     77     return (0);
     78 }
     79