home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3348 / dialchk.c < prev    next >
C/C++ Source or Header  |  1991-05-16  |  1KB  |  66 lines

  1. /*
  2.  * Copyright 1989, 1990, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #include <stdio.h>
  13. #ifdef    BSD
  14. #include <strings.h>
  15. #else
  16. #include <string.h>
  17. #endif
  18. #include "config.h"
  19. #include "dialup.h"
  20.  
  21. #ifndef    lint
  22. static    char    sccsid[] = "@(#)dialchk.c    3.2    19:44:18    12/10/90";
  23. #endif
  24.  
  25. extern    char    *pw_encrypt();
  26.  
  27. /*
  28.  * Check for dialup password
  29.  *
  30.  *    dialcheck tests to see if tty is listed as being a dialup
  31.  *    line.  If so, a dialup password may be required if the shell
  32.  *    is listed as one which requires a second password.
  33.  */
  34.  
  35. int    dialcheck (tty, shell)
  36. char    *tty;
  37. char    *shell;
  38. {
  39.     char    *crypt ();
  40.     char    *getpass ();
  41.     struct    dialup    *dialup;
  42.     char    *pass;
  43.     char    *cp;
  44.  
  45.     setduent ();
  46.  
  47.     if (! isadialup (tty)) {
  48.         endduent ();
  49.         return (1);
  50.     }
  51.     if (! (dialup = getdushell (shell))) {
  52.         endduent ();
  53.         return (1);
  54.     }
  55.     endduent ();
  56.  
  57.     if (dialup->du_passwd[0] == '\0')
  58.         return (1);
  59.  
  60.     if (! (pass = getpass ("Dialup Password:")))
  61.         return (0);
  62.  
  63.     cp = pw_encrypt (pass, dialup->du_passwd);
  64.     return (strcmp (cp, dialup->du_passwd) == 0);
  65. }
  66.