home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / elm-2.4-pl20.tar.Z / elm-2.4-pl20.tar / lib / validname.c < prev   
C/C++ Source or Header  |  1993-01-12  |  2KB  |  72 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: validname.c,v 5.3 1992/12/11 01:45:04 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: validname.c,v $
  17.  * Revision 5.3  1992/12/11  01:45:04  syd
  18.  * remove sys/types.h include, it is now included by defs.h
  19.  * and this routine includes defs.h or indirectly includes defs.h
  20.  * From: Syd
  21.  *
  22.  * Revision 5.2  1992/12/07  04:55:16  syd
  23.  * add sys/types include for time_t
  24.  * From: Syd
  25.  *
  26.  * Revision 5.1  1992/10/03  22:41:36  syd
  27.  * Initial checkin as of 2.4 Release at PL0
  28.  *
  29.  *
  30.  ******************************************************************************/
  31.  
  32. #include <stdio.h>
  33. #include "defs.h"
  34.  
  35. #ifndef NOCHECK_VALIDNAME         /* Force a return of valid */
  36. # ifdef PWDINSYS
  37. #  include <sys/pwd.h>
  38. # else
  39. #  include <pwd.h>
  40. # endif
  41. #endif
  42.  
  43. int
  44. valid_name(name)
  45. char *name;
  46. {
  47.     /** Determine whether "name" is a valid logname on this system.
  48.         It is valid if there is a password entry, or if there is
  49.         a mail file in the mail spool directory for "name".
  50.      **/
  51.  
  52. #ifdef NOCHECK_VALIDNAME         /* Force a return of valid */
  53.  
  54.     return(TRUE);
  55.  
  56. #else
  57.  
  58.     char filebuf[SLEN];
  59.     struct passwd *getpwnam();
  60.  
  61.     if(getpwnam(name) != NULL)
  62.       return(TRUE);
  63.  
  64.     sprintf(filebuf,"%s/%s", mailhome, name);
  65.     if (access(filebuf, ACCESS_EXISTS) == 0)
  66.       return(TRUE);
  67.  
  68.     return(FALSE);
  69.  
  70. #endif
  71. }
  72.