home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume38 / shadow / part13 / entry.c < prev    next >
C/C++ Source or Header  |  1993-08-14  |  2KB  |  89 lines

  1. /*
  2.  * Copyright 1989, 1990, 1991, 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 "config.h"
  13. #include "pwd.h"
  14. #ifndef    BSD
  15. #include <string.h>
  16. #else
  17. #include <strings.h>
  18. #define    strchr    index
  19. #define    strrchr    rindex
  20. #endif
  21. #ifdef    SHADOWPWD
  22. #include "shadow.h"
  23. #endif
  24.  
  25. #ifndef    lint
  26. static    char    sccsid[] = "@(#)entry.c    3.5    11:59:41    28 Dec 1991";
  27. #endif
  28.  
  29. struct    passwd    *fgetpwent ();
  30. char    *malloc ();
  31.  
  32. void    entry (name, pwent)
  33. char    *name;
  34. struct    passwd    *pwent;
  35. {
  36.     struct    passwd    *passwd;
  37. #ifdef    SHADOWPWD
  38.     struct    spwd    *spwd;
  39.     char    *l64a ();
  40. #endif
  41.     char    *cp;
  42.     char    *malloc();
  43.  
  44.     if (! (passwd = getpwnam (name))) {
  45.         pwent->pw_name = (char *) 0;
  46.         return;
  47.     } else  {
  48.         pwent->pw_name = strdup (passwd->pw_name);
  49.         pwent->pw_uid = passwd->pw_uid;
  50.         pwent->pw_gid = passwd->pw_gid;
  51. #ifdef    ATT_COMMENT
  52.         pwent->pw_comment = strdup (passwd->pw_comment);
  53. #endif
  54.         pwent->pw_gecos = strdup (passwd->pw_gecos);
  55.         pwent->pw_dir = strdup (passwd->pw_dir);
  56.         pwent->pw_shell = strdup (passwd->pw_shell);
  57. #if defined(SHADOWPWD) && !defined(AUTOSHADOW)
  58.         setspent ();
  59.         if (spwd = getspnam (name)) {
  60.             pwent->pw_passwd = strdup (spwd->sp_pwdp);
  61. #ifdef    ATT_AGE
  62.             pwent->pw_age = (char *) malloc (5);
  63.  
  64.             if (spwd->sp_max > (63*7))
  65.                 spwd->sp_max = (63*7);
  66.             if (spwd->sp_min > (63*7))
  67.                 spwd->sp_min = (63*7);
  68.  
  69.             pwent->pw_age[0] = i64c (spwd->sp_max / 7);
  70.             pwent->pw_age[1] = i64c (spwd->sp_min / 7);
  71.  
  72.             cp = l64a (spwd->sp_lstchg / 7);
  73.             pwent->pw_age[2] = cp[0];
  74.             pwent->pw_age[3] = cp[1];
  75.  
  76.             pwent->pw_age[4] = '\0';
  77. #endif
  78.             endspent ();
  79.             return;
  80.         }
  81.         endspent ();
  82. #endif
  83.         pwent->pw_passwd = strdup (passwd->pw_passwd);
  84. #ifdef    ATT_AGE
  85.         pwent->pw_age = strdup (passwd->pw_age);
  86. #endif
  87.     }
  88. }
  89.