home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2286 / dialchk.c next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  1008 b   |  54 lines

  1. /*
  2.  * Copyright 1989, 1990, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Use, duplication, and disclosure prohibited without
  6.  * the express written permission of the author.
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include "config.h"
  11. #include "dialup.h"
  12.  
  13. #ifndef    lint
  14. static    char    _sccsid[] = "@(#)dialchk.c    2.2    19:23:36    7/29/90";
  15. #endif
  16.  
  17. /*
  18.  * Check for dialup password
  19.  *
  20.  *    dialcheck tests to see if tty is listed as being a dialup
  21.  *    line.  If so, a dialup password may be required if the shell
  22.  *    is listed as one which requires a second password.
  23.  */
  24.  
  25. #ifdef    DIALUP
  26. int    dialcheck (tty, shell)
  27. char    *tty;
  28. char    *shell;
  29. {
  30.     char    *crypt ();
  31.     char    *getpass ();
  32.     struct    dialup    *dialup;
  33.     char    *pass;
  34.     char    *cp;
  35.  
  36.     if (! isadialup (tty))
  37.         return (1);
  38.  
  39.     if (! (dialup = getdushell (shell)))
  40.         return (1);
  41.  
  42.     endduent ();
  43.  
  44.     if (dialup->du_passwd[0] == '\0')
  45.         return (1);
  46.  
  47.     if (! (pass = getpass ("Dialup Password:")))
  48.         return (0);
  49.  
  50.     cp = crypt (pass, dialup->du_passwd);
  51.     return (strcmp (cp, dialup->du_passwd) == 0);
  52. }
  53. #endif
  54.