home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / npasswd / part01 / checkpasswd / pwck_passwd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-19  |  3.2 KB  |  106 lines

  1.  
  2. /* --------------------------------------------------------------------  */
  3. /*                                                                       */
  4. /*                         Author: Clyde Hoover                          */
  5. /*                          Computation Center                           */
  6. /*                   The University of Texas at Austin                   */
  7. /*                          Austin, Texas 78712                          */
  8. /*                         clyde@emx.utexas.edu                          */
  9. /*                   uunet!cs.utexas.edu!ut-emx!clyde                    */
  10. /*                                                                       */
  11. /*This code may be distributed freely, provided this notice is retained. */
  12. /*                                                                       */
  13. /* --------------------------------------------------------------------  */
  14. /*
  15.  *    pwck_password - Check password candidate against the users' password
  16.  *        file information, or any other information that is publicly
  17.  *        available about this user that a bandit could use as
  18.  *        password guesses.
  19.  *
  20.  *    This code has an option for the User Information Data Base used
  21.  *    at the UT Computation Center.  Here is the place to search 
  22.  *    any local 'finger' database.
  23.  */
  24. #ifndef lint
  25. static char sccsid[] = "@(#)pwck_passwd.c    1.2 6/5/89 (cc.utexas.edu)";
  26. #endif
  27.  
  28. #include "checkpasswd.h"
  29.  
  30. #ifdef    UTEXAS_CC
  31. /*
  32.  *    For UTCC systems
  33.  */
  34. #include <local/userinfo.h>
  35. #define    cname    pwp->ui_name
  36. typedef    userptr    pwptr;
  37. #define    setpwent    setuserent
  38. #define    getpwuid    getuserbyuid
  39.  
  40. #else    /* UTEXAS_CC */
  41.  
  42. #include    <pwd.h>
  43. #define    cname    pwp->pw_name
  44. typedef    struct passwd *pwptr;
  45.  
  46. #endif    /* UTEXAS_CC */
  47.  
  48. pwck_passwd(password, userid, mesg)
  49. char    *password;
  50. int    userid;
  51. char    *mesg;
  52. {
  53.     char    temp[BUFSIZ];    /* Scratch */
  54.     pwptr    pwp;        /* Pointer to user information */
  55.  
  56.     mesg[0] = 0;
  57. #ifdef    DEBUG
  58.     printf("pwck_passwd: \"%s\"\n", password);
  59. #endif
  60.     if (userid < 0)            /* Can't do user checks */
  61.         return(PWCK_FAIL);
  62.  
  63.     pwp = getpwuid(userid);
  64.     if (pwp == (pwptr )0)
  65.         return(PWCK_FAIL);
  66.  
  67.     strcpy(mesg, "Password is part of your passwd information");
  68.     try(password, cname, PWCK_OBVIOUS);    /* Checks 'name' and 'Name' */
  69.  
  70.     (void) strcpy(temp, cname);
  71.     (void) strcat(temp, cname);
  72.     try(password, temp, PWCK_OBVIOUS);    /* Check 'namename' */
  73.  
  74.     (void) strcpy(temp, cname);
  75.     _flipstring(temp);
  76.     try(password, temp, PWCK_OBVIOUS);    /* 'eman' */
  77.  
  78. #ifdef    UTEXAS_CC
  79.     /*
  80.      * Try the rest of the stuff in this userinfo record
  81.      */
  82.     try(password, pwp->ui_rje_cc, PWCK_OBVIOUS);
  83.     try(password, pwp->ui_bill_cc, PWCK_OBVIOUS);
  84.  
  85.     mesg[0] = 0;
  86.     /* Try all 'finger' information */
  87.     mtry(password, pwp->ui_personal_name, PWCK_FINGER);
  88.     mtry(password, pwp->ui_nick_name, PWCK_FINGER);    
  89.     mtry(password, pwp->ui_home_address, PWCK_FINGER);
  90.     mtry(password, pwp->ui_work_address, PWCK_FINGER);
  91.     mtry(password, pwp->ui_home_phone, PWCK_FINGER);
  92.     mtry(password, pwp->ui_work_phone, PWCK_FINGER);
  93.     mtry(password, pwp->ui_birthday, PWCK_FINGER);
  94.     mtry(password, pwp->ui_project, PWCK_FINGER);
  95.     mtry(password, pwp->ui_fellows, PWCK_FINGER);
  96. #else
  97.     /*
  98.      * Try every word in user's GECOS entry
  99.      */
  100.     mesg[0] = 0;
  101.     mtry(password, pwp->pw_gecos, PWCK_FINGER);
  102. #endif
  103.     return(PWCK_OK);
  104. }
  105. /*    End pwck_passwd.c */
  106.