home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3432 < prev    next >
Internet Message Format  |  1991-05-30  |  73KB

  1. From: jfh@rpp386.cactus.org (John F Haugh II)
  2. Newsgroups: alt.sources
  3. Subject: Shadow Login Suite, release 3 patch 2
  4. Message-ID: <19343@rpp386.cactus.org>
  5. Date: 30 May 91 13:17:31 GMT
  6.  
  7.  
  8. Here are a number of bugs that were found, mostly by Chip Rosenthal, in
  9. the current release of my shadow password and login suite.  I am continuing
  10. to get bug reports, and as soon as they taper off I'll send the final
  11. result to Kent for posting in comp.sources.misc, so please beat this code
  12. up.
  13.  
  14. The changes are of two types.  The first type is to correct a number of
  15. bugs in __STDC__ processing and whatnot, and the second makes the syslog
  16. calls configurable.  It is now possible (in theory ...) to not have
  17. syslog involved in the resultant code.  I did post a syslog thing some
  18. time back, so you may want to look in the archives for a copy of that
  19. code if you are determined to use syslog but didn't get one with your
  20. system.
  21.  
  22. Chip did find a few places where the code wouldn't work (or compile) if
  23. neither DBM nor NDBM were defined.  I think those have all been caught.
  24. I use GNU DBM here, and encourage you to do so as well.  The annoying
  25. "mkpasswd" after the BSD "chfn" and "chsh" commands has been avoided,
  26. so if you didn't like DBM files before, you might be able to tolerate
  27. them now.  You can even use these two commands without using the rest
  28. of the suite.
  29.  
  30. In the area of "future directions", I have purchased a set of SVR4
  31. documentation and will start implementing commands from there.  It is
  32. good to see that AT&T/USO/BZZT are coming out with utilities for
  33. manipulating the password files ...
  34. --
  35. *** rel3/Makefile    Wed May 29 06:27:28 1991
  36. --- Makefile    Tue May 28 09:10:19 1991
  37. ***************
  38. *** 1,5 ****
  39.   #
  40. ! # Copyright 1988,1989,1990, John F. Haugh II
  41.   # All rights reserved.
  42.   #
  43.   # Permission is granted to copy and create derivative works for any
  44. --- 1,5 ----
  45.   #
  46. ! # Copyright 1988,1989,1990,1991, John F. Haugh II
  47.   # All rights reserved.
  48.   #
  49.   # Permission is granted to copy and create derivative works for any
  50. ***************
  51. *** 8,16 ****
  52.   # and conspicuously displayed on all copies of object code or
  53.   # distribution media.
  54.   #
  55. ! #    @(#)Makefile    3.8    18:25:18  - Shadow password system
  56.   #
  57. ! #    @(#)Makefile    3.8    18:25:18    5/19/91
  58.   #
  59.   SHELL = /bin/sh
  60.   
  61. --- 8,16 ----
  62.   # and conspicuously displayed on all copies of object code or
  63.   # distribution media.
  64.   #
  65. ! #    @(#)Makefile    3.9    09:06:23  - Shadow password system
  66.   #
  67. ! #    @(#)Makefile    3.9    09:06:23    5/28/91
  68.   #
  69.   SHELL = /bin/sh
  70.   
  71. ***************
  72. *** 355,373 ****
  73.   
  74.   entry.o: config.h shadow.h pwd.h
  75.   
  76. ! shadow.o: shadow.h config.h
  77. ! shadowio.o: shadow.h
  78. ! grent.o: config.h shadow.h
  79. ! sgroupio.o: shadow.h
  80. ! dialup.o: dialup.h
  81. ! dialchk.o: dialup.h config.h
  82. ! pwdbm.o: config.h pwd.h
  83. ! pwpack.o: config.h pwd.h
  84. ! pwent.o: config.h pwd.h
  85. ! pwio.o: pwd.h
  86. ! getpass.o: config.h
  87. ! encrypt.o: config.h
  88. ! port.o: port.h
  89.   
  90.   valid.o: config.h pwd.h
  91.   
  92. --- 355,373 ----
  93.   
  94.   entry.o: config.h shadow.h pwd.h
  95.   
  96. ! libshadow.a(shadow.o): shadow.h config.h
  97. ! libshadow.a(shadowio.o): shadow.h
  98. ! libshadow.a(grent.o): config.h shadow.h
  99. ! libshadow.a(sgroupio.o): shadow.h
  100. ! libshadow.a(dialup.o): dialup.h
  101. ! libshadow.a(dialchk.o): dialup.h config.h
  102. ! libshadow.a(pwdbm.o): config.h pwd.h
  103. ! libshadow.a(pwpack.o): config.h pwd.h
  104. ! libshadow.a(pwent.o): config.h pwd.h
  105. ! libshadow.a(pwio.o): pwd.h
  106. ! libshadow.a(getpass.o): config.h
  107. ! libshadow.a(encrypt.o): config.h
  108. ! libshadow.a(port.o): port.h
  109.   
  110.   valid.o: config.h pwd.h
  111.   
  112. *** rel3/passwd.c    Sat May 25 10:22:11 1991
  113. --- passwd.c    Tue May 28 09:10:21 1991
  114. ***************
  115. *** 1,5 ****
  116.   /*
  117. !  * Copyright 1989, 1990, John F. Haugh II
  118.    * All rights reserved.
  119.    *
  120.    * Permission is granted to copy and create derivative works for any
  121. --- 1,5 ----
  122.   /*
  123. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  124.    * All rights reserved.
  125.    *
  126.    * Permission is granted to copy and create derivative works for any
  127. ***************
  128. *** 14,23 ****
  129.   #include <stdio.h>
  130.   #include <fcntl.h>
  131.   #include <signal.h>
  132. - #include <syslog.h>
  133.   
  134.   #ifndef    lint
  135. ! static    char    sccsid[] = "@(#)passwd.c    3.1    09:00:47    2/8/91";
  136.   #endif
  137.   
  138.   /*
  139. --- 14,22 ----
  140.   #include <stdio.h>
  141.   #include <fcntl.h>
  142.   #include <signal.h>
  143.   
  144.   #ifndef    lint
  145. ! static    char    sccsid[] = "@(#)passwd.c    3.2    09:06:29    5/28/91";
  146.   #endif
  147.   
  148.   /*
  149. ***************
  150. *** 40,45 ****
  151. --- 39,52 ----
  152.   #include "lastlog.h"
  153.   #include "shadow.h"
  154.   
  155. + #ifdef    USE_SYSLOG
  156. + #include <syslog.h>
  157. + #ifndef    LOG_WARN
  158. + #define    LOG_WARN    LOG_WARNING
  159. + #endif
  160. + #endif
  161.   /*
  162.    * Password aging constants
  163.    *
  164. ***************
  165. *** 93,98 ****
  166. --- 100,106 ----
  167.   #define    NEWPASSMSG \
  168.   "Enter the new password (minimum of 5 characters)\n\
  169.   Please use a combination of upper and lower case letters and numbers.\n"
  170. + #define    CHANGING    "Changing password for %s\n"
  171.   #define NEWPASS        "New Password:"
  172.   #define    NEWPASS2    "Re-enter new password:"
  173.   #define    WRONGPWD    "Incorrect password for %s.\n"
  174. ***************
  175. *** 172,178 ****
  176. --- 180,188 ----
  177.           if (strcmp (cipher, sp->sp_pwdp) != 0) {
  178.               sleep (1);
  179.               fprintf (stderr, WRONGPWD, sp->sp_namp);
  180. + #ifdef    USE_SYSLOG
  181.               syslog (LOG_WARN, WRONGPWD2, sp->sp_namp);
  182. + #endif
  183.               return -1;
  184.           }
  185.           strcpy (orig, clear);
  186. ***************
  187. *** 252,258 ****
  188. --- 262,271 ----
  189.               strcmp (sp->sp_pwdp, "!") == 0 ||
  190.               sp->sp_min > sp->sp_max) {
  191.           fprintf (stderr, CANTCHANGE, sp->sp_namp);
  192. + #ifdef    USE_SYSLOG
  193.           syslog (LOG_WARN, CANTCHANGE2, sp->sp_namp);
  194. +         closelog ();
  195. + #endif
  196.           exit (1);
  197.       }
  198.   
  199. ***************
  200. *** 262,268 ****
  201. --- 275,284 ----
  202.   
  203.       if (sp->sp_min >= 0 && now < (sp->sp_lstchg + sp->sp_min)) {
  204.           fprintf (stderr, TOOSOON, sp->sp_namp);
  205. + #ifdef    USE_SYSLOG
  206.           syslog (LOG_WARN, TOOSOON2, sp->sp_namp);
  207. +         closelog ();
  208. + #endif
  209.           exit (1);
  210.       }
  211.   }
  212. ***************
  213. *** 435,441 ****
  214. --- 451,459 ----
  215.       else
  216.           Prog = argv[0];
  217.   
  218. + #ifdef    USE_SYSLOG
  219.       openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
  220. + #endif
  221.   
  222.       /*
  223.        * Start with the flags which cause another command to be
  224. ***************
  225. *** 463,469 ****
  226. --- 481,490 ----
  227.           }
  228.           sprintf (buf, EXECFAILED, Prog, argv[1]);
  229.           perror (buf);
  230. + #ifdef    USE_SYSLOG
  231.           syslog (LOG_CRIT, EXECFAILED2, argv[1]);
  232. +         closelog ();
  233. + #endif
  234.           exit (1);
  235.       }
  236.   
  237. ***************
  238. *** 546,556 ****
  239. --- 567,582 ----
  240.       if (optind < argc) {
  241.           strncpy (name, argv[optind], sizeof name);
  242.           name[sizeof name - 1] = '\0';
  243. +     } else if (amroot) {
  244. +         strcpy (name, "root");
  245.       } else if (cp = getlogin ()) {
  246.           strncpy (name, cp, sizeof name);
  247.           name[sizeof name - 1] = '\0';
  248.       } else {
  249.           fprintf (stderr, WHOAREYOU, Prog);
  250. + #ifdef    USE_SYSLOG
  251. +         closelog ();
  252. + #endif
  253.           exit (1);
  254.       }
  255.   
  256. ***************
  257. *** 561,575 ****
  258. --- 587,613 ----
  259.   
  260.       if (! (pw = getpwnam (name))) {
  261.           fprintf (stderr, UNKUSER, Prog, name);
  262. + #ifdef    USE_SYSLOG
  263. +         closelog ();
  264. + #endif
  265.           exit (1);
  266.       }
  267.       if (! amroot && pw->pw_uid != getuid ()) {
  268.           fprintf (stderr, NOPERM, name);
  269. + #ifdef    USE_SYSLOG
  270.           syslog (LOG_WARN, NOPERM2, name);
  271. +         closelog ();
  272. + #endif
  273.           exit (1);
  274.       }
  275.   
  276.       /*
  277. +      * Let the user know whose password is being changed.
  278. +      */
  279. +     printf (CHANGING, name);
  280. +     /*
  281.        * The user name is valid, so let's get the shadow file
  282.        * entry.
  283.        */
  284. ***************
  285. *** 591,596 ****
  286. --- 629,637 ----
  287.   
  288.       if (Sflg) {
  289.           print_status (sp);
  290. + #ifdef    USE_SYSLOG
  291. +         closelog ();
  292. + #endif
  293.           exit (0);
  294.       }
  295.   
  296. ***************
  297. *** 609,614 ****
  298. --- 650,658 ----
  299.   
  300.           if (new_password (pw, sp)) {
  301.               fprintf (stderr, UNCHANGED, name);
  302. + #ifdef    USE_SYSLOG
  303. +             closelog ();
  304. + #endif
  305.               exit (1);
  306.           }
  307.       }
  308. ***************
  309. *** 646,652 ****
  310. --- 690,699 ----
  311.       ulimit (2, 30000);
  312.       if (setuid (0)) {
  313.           fprintf (stderr, NOTROOT);
  314. + #ifdef    USE_SYSLOG
  315.           syslog (LOG_ERR, NOTROOT2);
  316. +         closelog ();
  317. + #endif
  318.           exit (1);
  319.       }
  320.       signal (SIGHUP, SIG_IGN);
  321. ***************
  322. *** 667,678 ****
  323. --- 714,731 ----
  324.   
  325.       if (i == 30) {
  326.           fprintf (stderr, SPWDBUSY);
  327. + #ifdef    USE_SYSLOG
  328.           syslog (LOG_WARN, SPWDBUSY2);
  329. +         closelog ();
  330. + #endif
  331.           exit (1);
  332.       }
  333.       if (! spw_open (O_RDWR)) {
  334.           fprintf (stderr, OPNERROR);
  335. + #ifdef    USE_SYSLOG
  336.           syslog (LOG_ERR, OPNERROR2);
  337. +         closelog ();
  338. + #endif
  339.           (void) spw_unlock ();
  340.           exit (1);
  341.       }
  342. ***************
  343. *** 684,690 ****
  344. --- 737,746 ----
  345.   
  346.       if (! spw_update (sp)) {
  347.           fprintf (stderr, UPDERROR);
  348. + #ifdef    USE_SYSLOG
  349.           syslog (LOG_ERR, UPDERROR2);
  350. +         closelog ();
  351. + #endif
  352.           (void) spw_unlock ();
  353.           exit (1);
  354.       }
  355. ***************
  356. *** 691,697 ****
  357. --- 747,756 ----
  358.   #ifdef    NDBM
  359.       if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_update (sp)) {
  360.           fprintf (stderr, DBMERROR);
  361. + #ifdef    USE_SYSLOG
  362.           syslog (LOG_ERR, DBMERROR2);
  363. +         closelog ();
  364. + #endif
  365.           (void) spw_unlock ();
  366.           exit (1);
  367.       }
  368. ***************
  369. *** 704,718 ****
  370. --- 763,786 ----
  371.   
  372.       if (! spw_close ()) {
  373.           fprintf (stderr, CLSERROR);
  374. + #ifdef    USE_SYSLOG
  375.           syslog (LOG_ERR, CLSERROR2);
  376. +         closelog ();
  377. + #endif
  378.           (void) spw_unlock ();
  379.           exit (1);
  380.       }
  381.       if (! spw_unlock ()) {
  382.           fprintf (stderr, UNLKERROR);
  383. + #ifdef    USE_SYSLOG
  384.           syslog (LOG_ERR, UNLKERROR2);
  385. +         closelog ();
  386. + #endif
  387.           exit (1);
  388.       }
  389. + #ifdef    USE_SYSLOG
  390.       syslog (LOG_INFO, CHGPASSWD, name);
  391. +     closelog ();
  392. + #endif
  393.       exit (0);
  394.   }
  395. *** rel3/config.h    Sat May 25 10:22:07 1991
  396. --- config.h    Tue May 28 09:19:21 1991
  397. ***************
  398. *** 1,15 ****
  399.   /*
  400. !  * Copyright 1989, 1990, John F. Haugh II
  401.    * All rights reserved.
  402.    *
  403. !  * Use, duplication, and disclosure prohibited without
  404. !  * the express written permission of the author.
  405.    */
  406.   
  407.   /*
  408.    * Configuration file for login.
  409.    *
  410. !  *    @(#)config.h    3.4    14:43:20    12/18/90
  411.    */
  412.   
  413.   /*
  414. --- 1,18 ----
  415.   /*
  416. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  417.    * All rights reserved.
  418.    *
  419. !  * Permission is granted to copy and create derivative works for any
  420. !  * non-commercial purpose, provided this copyright notice is preserved
  421. !  * in all copies of source code, or included in human readable form
  422. !  * and conspicuously displayed on all copies of object code or
  423. !  * distribution media.
  424.    */
  425.   
  426.   /*
  427.    * Configuration file for login.
  428.    *
  429. !  *    @(#)config.h    3.6    09:18:23    5/28/91
  430.    */
  431.   
  432.   /*
  433. ***************
  434. *** 248,253 ****
  435. --- 251,265 ----
  436.   #define    SPWLOCK "/etc/shadow.lock"
  437.   
  438.   /*
  439. +  * Define USE_SYSLOG if you want to have SYSLOG functions included
  440. +  * in your code.  Define SULOGONLY if you only want SULOG being used
  441. +  * in the SU command.  Some people only want so much diagnostics.
  442. +  */
  443. + #define    USE_SYSLOG
  444. + #undef    SULOGONLY
  445. + /*
  446.    * Wierd stuff follows ...
  447.    *
  448.    *    The following macros exist solely to override stuff ...
  449. ***************
  450. *** 264,269 ****
  451. --- 276,282 ----
  452.   #define    GETPWENT    /* Define if you want my GETPWENT(3) routines */
  453.   #define    GETGRENT    /* Define if you want my GETGRENT(3) routines */
  454.   #define    NEED_AL64    /* Define if library does not include a64l() */
  455. + #undef    NO_STRSTR    /* Define if library does not include strstr() */
  456.   
  457.   /*
  458.    *    These macros control the contents of <pwd.h>.
  459. *** rel3/grent.c    Sat May 25 10:22:53 1991
  460. --- grent.c    Tue May 28 09:10:24 1991
  461. ***************
  462. *** 1,5 ****
  463.   /*
  464. !  * Copyright 1990, John F. Haugh II
  465.    * All rights reserved.
  466.    *
  467.    * Permission is granted to copy and create derivative works for any
  468. --- 1,5 ----
  469.   /*
  470. !  * Copyright 1990, 1991, John F. Haugh II
  471.    * All rights reserved.
  472.    *
  473.    * Permission is granted to copy and create derivative works for any
  474. ***************
  475. *** 32,38 ****
  476.   #endif    /* NDBM */
  477.   
  478.   #ifndef    lint
  479. ! static    char    sccsid[] = "@(#)grent.c    3.7    08:03:08    12/20/90";
  480.   #endif    /* !lint */
  481.   
  482.   #define    NFIELDS    4
  483. --- 32,38 ----
  484.   #endif    /* NDBM */
  485.   
  486.   #ifndef    lint
  487. ! static    char    sccsid[] = "@(#)grent.c    3.8    09:06:40    5/28/91";
  488.   #endif    /* !lint */
  489.   
  490.   #define    NFIELDS    4
  491. ***************
  492. *** 435,441 ****
  493.           }
  494.       }
  495.   #endif    /* AUTOSHADOW */
  496. !     return 0;
  497.   }
  498.   
  499.   /*
  500. --- 435,441 ----
  501.           }
  502.       }
  503.   #endif    /* AUTOSHADOW */
  504. !     return grp;
  505.   }
  506.   
  507.   /*
  508. *** rel3/smain.c    Sat May 25 10:22:21 1991
  509. --- smain.c    Tue May 28 09:10:26 1991
  510. ***************
  511. *** 13,19 ****
  512.   #include <stdio.h>
  513.   
  514.   #ifndef    lint
  515. ! static    char    sccsid[] = "%W%    %U%    %G%";
  516.   #endif
  517.   
  518.   /*
  519. --- 13,19 ----
  520.   #include <stdio.h>
  521.   
  522.   #ifndef    lint
  523. ! static    char    sccsid[] = "@(#)smain.c    3.5    09:06:44    5/28/91";
  524.   #endif
  525.   
  526.   /*
  527. ***************
  528. *** 34,45 ****
  529.   #endif
  530.   
  531.   #include <signal.h>
  532. - #include <syslog.h>
  533.   #include "config.h"
  534.   #include "lastlog.h"
  535.   #include "pwd.h"
  536.   #include "shadow.h"
  537.   
  538.   /*
  539.    * Password aging constants
  540.    *
  541. --- 34,52 ----
  542.   #endif
  543.   
  544.   #include <signal.h>
  545.   #include "config.h"
  546.   #include "lastlog.h"
  547.   #include "pwd.h"
  548.   #include "shadow.h"
  549.   
  550. + #ifdef    USE_SYSLOG
  551. + #include <syslog.h>
  552. + #ifndef    LOG_WARN
  553. + #define    LOG_WARN LOG_WARNING
  554. + #endif    /* !LOG_WARN */
  555. + #endif    /* USE_SYSLOG */
  556.   /*
  557.    * Password aging constants
  558.    *
  559. ***************
  560. *** 66,76 ****
  561.   #endif
  562.   
  563.   #ifndef    PATH
  564. ! #define    PATH    ":/bin:/usr/bin"
  565.   #endif
  566.   
  567.   #ifndef    SUPATH
  568. ! #define    SUPATH    ":/bin:/usr/bin:/etc"
  569.   #endif
  570.   
  571.   /*
  572. --- 73,83 ----
  573.   #endif
  574.   
  575.   #ifndef    PATH
  576. ! #define    PATH    "/bin:/usr/bin:"
  577.   #endif
  578.   
  579.   #ifndef    SUPATH
  580. ! #define    SUPATH    "/bin:/usr/bin:/etc:"
  581.   #endif
  582.   
  583.   /*
  584. ***************
  585. *** 114,119 ****
  586. --- 121,127 ----
  587.   extern    char    *ttyname ();
  588.   extern    char    *getenv ();
  589.   extern    char    *getpass ();
  590. + extern    char    *pw_encrypt();
  591.   extern    struct    passwd    *getpwuid ();
  592.   extern    struct    passwd    *getpwnam ();
  593.   extern    struct    spwd    *getspnam ();
  594. ***************
  595. *** 147,153 ****
  596. --- 155,163 ----
  597.           ioctl (0, TCGETA, &sgtty);
  598.   #endif
  599.       if (killed) {
  600. + #ifdef    USE_SYSLOG
  601.           closelog ();
  602. + #endif
  603.           exit (killed);
  604.       }
  605.   }
  606. ***************
  607. *** 191,197 ****
  608. --- 201,209 ----
  609.       else
  610.           Prog = argv[0];
  611.   
  612. + #ifdef    USE_SYSLOG
  613.       openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
  614. + #endif
  615.   
  616.       /*
  617.        * Get the tty name.  Entries will be logged indicating that
  618. ***************
  619. *** 282,288 ****
  620. --- 294,302 ----
  621.       if (pw = getpwuid (getuid ()))    /* need old user name */
  622.           (void) strcpy (oldname, pw->pw_name);
  623.       else {                /* user ID MUST exist */ 
  624. + #ifdef    USE_SYSLOG
  625.           syslog (LOG_CRIT, "Unknown UID: %d\n", getuid ());
  626. + #endif
  627.           goto failure;
  628.       }
  629.       amroot = getuid () == 0;    /* currently am super user */
  630. ***************
  631. *** 302,308 ****
  632. --- 316,324 ----
  633.               pw->pw_passwd = spwd->sp_pwdp;
  634.       } else {
  635.           (void) fprintf (stderr, "Unknown id: %s\n", name);
  636. + #ifdef    USE_SYSLOG
  637.           closelog ();
  638. + #endif
  639.           exit (1);
  640.       }
  641.       pwent = *pw;
  642. ***************
  643. *** 337,344 ****
  644. --- 353,362 ----
  645.   
  646.       if (! amroot && pwent.pw_passwd[0]) {
  647.           if (! (cp = getpass ("Password:"))) {
  648. + #ifdef    USE_SYSLOG
  649.               syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
  650.                   "Unable to get password for %s\n", name);
  651. + #endif
  652.               goto failure;
  653.           } else
  654.               strncpy (pass, cp, sizeof pass);
  655. ***************
  656. *** 352,365 ****
  657. --- 370,391 ----
  658.       if (! amroot && ((pass[0] != '\0' || pwent.pw_passwd[0] != '\0') &&
  659.               strcmp (pwent.pw_passwd,
  660.                   pw_encrypt (pass, pwent.pw_passwd)) != 0)) {
  661. + #ifdef    USE_SYSLOG
  662.           syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
  663.               "Invalid password for %s\n", name);
  664. + #endif
  665.   failure:    sulog (0);        /* log failed attempt */
  666. + #ifdef    USE_SYSLOG
  667. + #ifndef    SULOGONLY
  668.           syslog (pwent.pw_uid ? LOG_INFO:LOG_CRIT,
  669.               "- %s %s-%s\n", tty ? tty:"???",
  670.               oldname[0] ? oldname:"???", name[0] ? name:"???");
  671. + #endif
  672. + #endif
  673.           puts ("Sorry.");
  674. + #ifdef    USE_SYSLOG
  675.           closelog ();
  676. + #endif
  677.           exit (1);
  678.       }
  679.       signal (SIGQUIT, oldsig);
  680. ***************
  681. *** 373,380 ****
  682. --- 399,408 ----
  683.       if (! amroot) {
  684.           if (spwd) {
  685.               if (isexpired (&pwent, spwd)) {
  686. + #ifdef    USE_SYSLOG
  687.                   syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
  688.                       "Expired account %s\n", name);
  689. + #endif
  690.                   goto failure;
  691.               }
  692.           }
  693. ***************
  694. *** 381,388 ****
  695. --- 409,418 ----
  696.   #ifdef    ATT_AGE
  697.           else if (pwent.pw_age[0] &&
  698.                   isexpired (&pwent, (struct spwd *) 0)) {
  699. + #ifdef    USE_SYSLOG
  700.               syslog (pwent.pw_uid ? LOG_WARN:LOG_CRIT,
  701.                   "Expired account %s\n", name);
  702. + #endif
  703.               goto failure;
  704.           }
  705.   #endif    /* ATT_AGE */
  706. ***************
  707. *** 405,421 ****
  708.       }
  709.   
  710.       sulog (1);            /* save SU information */
  711.       syslog (LOG_INFO, "+ %s %s-%s\n", tty ? tty:"???",
  712.           oldname[0] ? oldname:"???", name[0] ? name:"???");
  713.       if (fakelogin)
  714.           setup (&pwent);        /* set UID, GID, HOME, etc ... */
  715.       else {
  716.           if (setgid (pwent.pw_gid) || setuid (pwent.pw_uid))  {
  717.               perror ("Can't set ID");
  718.               syslog (LOG_CRIT, "Unable to set uid = %d, gid = %d\n",
  719.                   pwent.pw_uid, pwent.pw_gid);
  720.               closelog ();
  721.               exit (1);
  722.           }
  723.       }
  724. --- 435,456 ----
  725.       }
  726.   
  727.       sulog (1);            /* save SU information */
  728. + #ifdef    USE_SYSLOG
  729. + #ifndef    SULOGONLY
  730.       syslog (LOG_INFO, "+ %s %s-%s\n", tty ? tty:"???",
  731.           oldname[0] ? oldname:"???", name[0] ? name:"???");
  732. ! #endif
  733. ! #endif
  734.       if (fakelogin)
  735.           setup (&pwent);        /* set UID, GID, HOME, etc ... */
  736.       else {
  737.           if (setgid (pwent.pw_gid) || setuid (pwent.pw_uid))  {
  738.               perror ("Can't set ID");
  739. + #ifdef    USE_SYSLOG
  740.               syslog (LOG_CRIT, "Unable to set uid = %d, gid = %d\n",
  741.                   pwent.pw_uid, pwent.pw_gid);
  742.               closelog ();
  743. + #endif
  744.               exit (1);
  745.           }
  746.       }
  747. ***************
  748. *** 425,432 ****
  749. --- 460,469 ----
  750.           argv[-1] = pwent.pw_shell;
  751.           (void) execv (pwent.pw_shell, &argv[-1]);
  752.           (void) fprintf (stderr, "No shell\n");
  753. + #ifdef    USE_SYSLOG
  754.           syslog (LOG_WARN, "Cannot execute %s\n", pwent.pw_shell);
  755.           closelog ();
  756. + #endif
  757.           exit (1);
  758.       }
  759.       if (fakelogin) {
  760. ***************
  761. *** 450,456 ****
  762. --- 487,497 ----
  763.   
  764.           shell (pwent.pw_shell, cp);
  765.       }
  766. + #ifdef    USE_SYSLOG
  767.       syslog (LOG_WARN, "Cannot execute %s\n", pwent.pw_shell);
  768. +     closelog ();
  769. + #endif
  770. +     exit (1);
  771.   
  772.       /*NOTREACHED*/
  773.   }
  774. *** rel3/pwconv.c    Sat May 25 10:22:22 1991
  775. --- pwconv.c    Tue May 28 09:10:29 1991
  776. ***************
  777. *** 1,5 ****
  778.   /*
  779. !  * Copyright 1989, 1990, John F. Haugh II
  780.    * All rights reserved.
  781.    *
  782.    * Permission is granted to copy and create derivative works for any
  783. --- 1,5 ----
  784.   /*
  785. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  786.    * All rights reserved.
  787.    *
  788.    * Permission is granted to copy and create derivative works for any
  789. ***************
  790. *** 40,46 ****
  791.   #include "shadow.h"
  792.   
  793.   #ifndef    lint
  794. ! static    char    _sccsid[] = "@(#)pwconv.c    3.2    12:31:11    12/12/90";
  795.   #endif
  796.   
  797.   char    buf[BUFSIZ];
  798. --- 40,46 ----
  799.   #include "shadow.h"
  800.   
  801.   #ifndef    lint
  802. ! static    char    _sccsid[] = "@(#)pwconv.c    3.3    09:06:53    5/28/91";
  803.   #endif
  804.   
  805.   char    buf[BUFSIZ];
  806. ***************
  807. *** 66,72 ****
  808.           exit (1);
  809.       }
  810.       unlink ("npasswd");
  811. !     if ((fd = open ("npasswd", O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0 ||
  812.               ! (npwd = fdopen (fd, "w"))) {
  813.           perror ("npasswd");
  814.           exit (1);
  815. --- 66,72 ----
  816.           exit (1);
  817.       }
  818.       unlink ("npasswd");
  819. !     if ((fd = open ("npasswd", O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0 ||
  820.               ! (npwd = fdopen (fd, "w"))) {
  821.           perror ("npasswd");
  822.           exit (1);
  823. *** rel3/dialup.h    Sat May 25 10:22:54 1991
  824. --- dialup.h    Tue May 28 09:10:30 1991
  825. ***************
  826. *** 1,5 ****
  827.   /*
  828. !  * Copyright 1989, 1990, John F. Haugh II
  829.    * All rights reserved.
  830.    *
  831.    * Permission is granted to copy and create derivative works for any
  832. --- 1,5 ----
  833.   /*
  834. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  835.    * All rights reserved.
  836.    *
  837.    * Permission is granted to copy and create derivative works for any
  838. ***************
  839. *** 23,42 ****
  840.    *    lines.  Each line consists of the last component of the path
  841.    *    name.  The leading "/dev/" string is removed.
  842.    *
  843. !  *    @(#)dialup.h    3.1    19:44:22    12/10/90
  844.    */
  845.   
  846.   #ifndef    _DIALUP_H
  847.   #define    _DIALUP_H
  848.   
  849. - #include <stdio.h>
  850.   struct    dialup {
  851.       char    *du_shell;
  852.       char    *du_passwd;
  853.   };
  854.   
  855. ! #ifdef    __STDC__
  856.   extern    void    setduent ();
  857.   extern    void    endduent ();
  858.   extern    struct    dialup    *fgetduent ();
  859. --- 23,40 ----
  860.    *    lines.  Each line consists of the last component of the path
  861.    *    name.  The leading "/dev/" string is removed.
  862.    *
  863. !  *    @(#)dialup.h    3.2    09:06:55    5/28/91
  864.    */
  865.   
  866.   #ifndef    _DIALUP_H
  867.   #define    _DIALUP_H
  868.   
  869.   struct    dialup {
  870.       char    *du_shell;
  871.       char    *du_passwd;
  872.   };
  873.   
  874. ! #if !__STDC__
  875.   extern    void    setduent ();
  876.   extern    void    endduent ();
  877.   extern    struct    dialup    *fgetduent ();
  878. *** rel3/chage.c    Sat May 25 10:22:28 1991
  879. --- chage.c    Tue May 28 09:10:34 1991
  880. ***************
  881. *** 1,5 ****
  882.   /*
  883. !  * Copyright 1989, 1990, John F. Haugh II
  884.    * All rights reserved.
  885.    *
  886.    * Permission is granted to copy and create derivative works for any
  887. --- 1,5 ----
  888.   /*
  889. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  890.    * All rights reserved.
  891.    *
  892.    * Permission is granted to copy and create derivative works for any
  893. ***************
  894. *** 10,16 ****
  895.    */
  896.   
  897.   #include <sys/types.h>
  898. - #include <syslog.h>
  899.   #include <stdio.h>
  900.   #include <fcntl.h>
  901.   #include <signal.h>
  902. --- 10,15 ----
  903. ***************
  904. *** 18,24 ****
  905.   #include <time.h>
  906.   
  907.   #ifndef    lint
  908. ! static    char    sccsid[] = "%W%    %U%    %G%";
  909.   #endif
  910.   
  911.   /*
  912. --- 17,23 ----
  913.   #include <time.h>
  914.   
  915.   #ifndef    lint
  916. ! static    char    sccsid[] = "@(#)chage.c    3.6    09:06:57    5/28/91";
  917.   #endif
  918.   
  919.   /*
  920. ***************
  921. *** 40,45 ****
  922. --- 39,52 ----
  923.   #include "pwd.h"
  924.   #include "shadow.h"
  925.   
  926. + #ifdef    USE_SYSLOG
  927. + #include <syslog.h>
  928. + #ifndef    LOG_WARN
  929. + #define    LOG_WARN LOG_WARNING
  930. + #endif    /* !LOG_WARN */
  931. + #endif    /* USE_SYSLOG */
  932.   /*
  933.    * Global variables
  934.    */
  935. ***************
  936. *** 115,120 ****
  937. --- 122,144 ----
  938.          [ -I inactive ] [ -E expire ] [ -d last_day ] user\n"
  939.   #define    DBMERROR    "Error updating the DBM password entry.\n"
  940.   #define    DBMERROR2    "error updating DBM shadow entry.\n"
  941. + #define    UNK_USER    "%s: unknown user: %s\n"
  942. + #define    NO_LFLAG    "%s: do no include \"l\" with other flags\n"
  943. + #define    NO_PERM        "%s: permission denied\n"
  944. + #define    NO_PWLOCK    "%s: can't lock password file\n"
  945. + #define    NO_SPLOCK    "%s: can't lock shadow password file\n"
  946. + #define    NO_PWOPEN    "%s: can't open password file\n"
  947. + #define    NO_SPOPEN    "%s: can't open shadow password file\n"
  948. + #define    CHANGE_INFO    "Changing the aging information for %s\n"
  949. + #define    FIELD_ERR    "%s: error changing fields\n"
  950. + #define    NO_PWUPDATE    "%s: can't update password file\n"
  951. + #define    NO_SPUPDATE    "%s: can't update shadow password file\n"
  952. + #define    NO_PWCLOSE    "%s: can't rewrite password file\n"
  953. + #define    NO_SPCLOSE    "%s: can't rewrite shadow password file\n"
  954. + #define    LOCK_FAIL    "failed locking %s\n"
  955. + #define    OPEN_FAIL    "failed opening %s\n"
  956. + #define    WRITE_FAIL    "failed updating %s\n"
  957. + #define    CLOSE_FAIL    "failed rewriting %s\n"
  958.   
  959.   /*
  960.    * usage - print command line syntax and exit
  961. ***************
  962. *** 405,411 ****
  963. --- 429,437 ----
  964.       else
  965.           Prog = argv[0];
  966.   
  967. + #ifdef    USE_SYSLOG
  968.       openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
  969. + #endif
  970.   #ifdef    NDBM
  971.       sp_dbm_mode = O_RDWR;
  972.       pw_dbm_mode = O_RDWR;
  973. ***************
  974. *** 462,469 ****
  975.           usage ();
  976.   
  977.       if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
  978. !         fprintf (stderr, "%s: do not include \"l\" with other flags\n",
  979. !             Prog);
  980.           usage ();
  981.       }
  982.   
  983. --- 488,497 ----
  984.           usage ();
  985.   
  986.       if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
  987. !         fprintf (stderr, NO_LFLAG, Prog);
  988. ! #ifdef    USE_SYSLOG
  989. !         closelog ();
  990. ! #endif
  991.           usage ();
  992.       }
  993.   
  994. ***************
  995. *** 474,480 ****
  996.        */
  997.   
  998.       if (ruid != 0 && ! lflg) {
  999. !         fprintf (stderr, "%s: permission denied\n", Prog);
  1000.           exit (1);
  1001.       }
  1002.   
  1003. --- 502,511 ----
  1004.        */
  1005.   
  1006.       if (ruid != 0 && ! lflg) {
  1007. !         fprintf (stderr, NO_PERM, Prog);
  1008. ! #ifdef    USE_SYSLOG
  1009. !         closelog ();
  1010. ! #endif
  1011.           exit (1);
  1012.       }
  1013.   
  1014. ***************
  1015. *** 485,501 ****
  1016.        */
  1017.   
  1018.       if (! pw_lock ()) {
  1019. !         fprintf (stderr, "%s: can't lock password file\n", Prog);
  1020.           exit (1);
  1021.       }
  1022.       if (! pw_open (ruid != 0 || lflg ? O_RDONLY:O_RDWR)) {
  1023. !         fprintf (stderr, "%s: can't open password file\n", Prog);
  1024.           cleanup (1);
  1025.           exit (1);
  1026.       }
  1027.       if (! (pw = pw_locate (argv[optind]))) {
  1028. !         fprintf (stderr, "%s: unknown user: %s\n", Prog, argv[optind]);
  1029.           cleanup (1);
  1030.           exit (1);
  1031.       }
  1032.   
  1033. --- 516,543 ----
  1034.        */
  1035.   
  1036.       if (! pw_lock ()) {
  1037. !         fprintf (stderr, NO_PWLOCK, Prog);
  1038. ! #ifdef    USE_SYSLOG
  1039. !         syslog (LOG_ERR, LOCK_FAIL, "/etc/passwd");
  1040. !         closelog ();
  1041. ! #endif
  1042.           exit (1);
  1043.       }
  1044.       if (! pw_open (ruid != 0 || lflg ? O_RDONLY:O_RDWR)) {
  1045. !         fprintf (stderr, NO_PWOPEN, Prog);
  1046.           cleanup (1);
  1047. + #ifdef    USE_SYSLOG
  1048. +         syslog (LOG_ERR, OPEN_FAIL, "/etc/passwd");
  1049. +         closelog ();
  1050. + #endif
  1051.           exit (1);
  1052.       }
  1053.       if (! (pw = pw_locate (argv[optind]))) {
  1054. !         fprintf (stderr, UNK_USER, Prog, argv[optind]);
  1055.           cleanup (1);
  1056. + #ifdef    USE_SYSLOG
  1057. +         closelog ();
  1058. + #endif
  1059.           exit (1);
  1060.       }
  1061.   
  1062. ***************
  1063. *** 508,520 ****
  1064.        */
  1065.   
  1066.       if (! spw_lock ()) {
  1067. !         fprintf (stderr, "%s: can't lock shadow file\n", Prog);
  1068.           cleanup (1);
  1069.           exit (1);
  1070.       }
  1071.       if (! spw_open ((ruid != 0 || lflg) ? O_RDONLY:O_RDWR)) {
  1072. !         fprintf (stderr, "%s: can't open shadow file\n", Prog);
  1073.           cleanup (2);
  1074.           exit (1);
  1075.       }
  1076.       if (sp = spw_locate (argv[optind]))
  1077. --- 550,570 ----
  1078.        */
  1079.   
  1080.       if (! spw_lock ()) {
  1081. !         fprintf (stderr, NO_SPLOCK, Prog);
  1082.           cleanup (1);
  1083. + #ifdef    USE_SYSLOG
  1084. +         syslog (LOG_ERR, LOCK_FAIL, "/etc/shadow");
  1085. +         closelog ();
  1086. + #endif
  1087.           exit (1);
  1088.       }
  1089.       if (! spw_open ((ruid != 0 || lflg) ? O_RDONLY:O_RDWR)) {
  1090. !         fprintf (stderr, NO_SPOPEN, Prog);
  1091.           cleanup (2);
  1092. + #ifdef    USE_SYSLOG
  1093. +         syslog (LOG_ERR, OPEN_FAIL, "/etc/shadow");
  1094. +         closelog ();
  1095. + #endif
  1096.           exit (1);
  1097.       }
  1098.       if (sp = spw_locate (argv[optind]))
  1099. ***************
  1100. *** 567,577 ****
  1101.   
  1102.       if (lflg) {
  1103.           if (ruid != 0 && ruid != pw->pw_uid) {
  1104. !             fprintf (stderr, "%s: permission denied\n", Prog);
  1105.               exit (1);
  1106.           }
  1107.           list_fields ();
  1108.           cleanup (2);
  1109.           exit (0);
  1110.       }
  1111.   
  1112. --- 617,633 ----
  1113.   
  1114.       if (lflg) {
  1115.           if (ruid != 0 && ruid != pw->pw_uid) {
  1116. !             fprintf (stderr, NO_PERM, Prog);
  1117. ! #ifdef    USE_SYSLOG
  1118. !             closelog ();
  1119. ! #endif
  1120.               exit (1);
  1121.           }
  1122.           list_fields ();
  1123.           cleanup (2);
  1124. + #ifdef    USE_SYSLOG
  1125. +         closelog ();
  1126. + #endif
  1127.           exit (0);
  1128.       }
  1129.   
  1130. ***************
  1131. *** 581,590 ****
  1132.        */
  1133.   
  1134.       if (! mflg && ! Mflg && ! dflg && ! Wflg && ! Iflg && ! Eflg) {
  1135. !         printf ("Changing the aging information for %s\n", name);
  1136.           if (! new_fields ()) {
  1137. !             fprintf (stderr, "%s: error changing fields\n", Prog);
  1138.               cleanup (2);
  1139.               exit (1);
  1140.           }
  1141.       }
  1142. --- 637,649 ----
  1143.        */
  1144.   
  1145.       if (! mflg && ! Mflg && ! dflg && ! Wflg && ! Iflg && ! Eflg) {
  1146. !         printf (CHANGE_INFO, name);
  1147.           if (! new_fields ()) {
  1148. !             fprintf (stderr, FIELD_ERR, Prog);
  1149.               cleanup (2);
  1150. + #ifdef    USE_SYSLOG
  1151. +             closelog ();
  1152. + #endif
  1153.               exit (1);
  1154.           }
  1155.       }
  1156. ***************
  1157. *** 608,616 ****
  1158.           pwent.pw_age = "";
  1159.   #endif
  1160.           if (! pw_update (&pwent)) {
  1161. !             fprintf (stderr, "%s: can't update password file\n",
  1162. !                 Prog);
  1163.               cleanup (2);
  1164.               exit (1);
  1165.           }
  1166.   #if defined(DBM) || defined(NDBM)
  1167. --- 667,678 ----
  1168.           pwent.pw_age = "";
  1169.   #endif
  1170.           if (! pw_update (&pwent)) {
  1171. !             fprintf (stderr, NO_PWUPDATE, Prog);
  1172.               cleanup (2);
  1173. + #ifdef    USE_SYSLOG
  1174. +             syslog (LOG_ERR, WRITE_FAIL, "/etc/passwd");
  1175. +             closelog ();
  1176. + #endif
  1177.               exit (1);
  1178.           }
  1179.   #if defined(DBM) || defined(NDBM)
  1180. ***************
  1181. *** 633,657 ****
  1182.       sp->sp_expire = expdays;
  1183.   
  1184.       if (! spw_update (sp)) {
  1185. !         fprintf (stderr, "%s: can't update shadow file\n", Prog);
  1186.           cleanup (2);
  1187.           exit (1);
  1188.       }
  1189.   #ifdef    NDBM
  1190.       if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_update (sp)) {
  1191.           fprintf (stderr, DBMERROR);
  1192.           syslog (LOG_ERR, DBMERROR2);
  1193. !         (void) spw_unlock ();
  1194.           exit (1);
  1195.       }
  1196.   #endif    /* NDBM */
  1197.       if (! spw_close ()) {
  1198. !         fprintf (stderr, "%s: can't rewrite shadow file\n", Prog);
  1199.           cleanup (2);
  1200.           exit (1);
  1201.       }
  1202. -     (void) pw_close ();
  1203.       cleanup (2);
  1204.       exit (0);
  1205.       /*NOTREACHED*/
  1206.   }
  1207. --- 695,758 ----
  1208.       sp->sp_expire = expdays;
  1209.   
  1210.       if (! spw_update (sp)) {
  1211. !         fprintf (stderr, NO_SPUPDATE, Prog);
  1212.           cleanup (2);
  1213. + #ifdef    USE_SYSLOG
  1214. +         syslog (LOG_ERR, WRITE_FAIL, "/etc/shadow");
  1215. +         closelog ();
  1216. + #endif
  1217.           exit (1);
  1218.       }
  1219.   #ifdef    NDBM
  1220. +     /*
  1221. +      * See if the shadow DBM file exists and try to update it.
  1222. +      */
  1223.       if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_update (sp)) {
  1224.           fprintf (stderr, DBMERROR);
  1225. +         cleanup (2);
  1226. + #ifdef    USE_SYSLOG
  1227.           syslog (LOG_ERR, DBMERROR2);
  1228. !         closelog ();
  1229. ! #endif
  1230.           exit (1);
  1231.       }
  1232.   #endif    /* NDBM */
  1233. +     /*
  1234. +      * Now close the shadow password file, which will cause all
  1235. +      * of the entries to be re-written.
  1236. +      */
  1237.       if (! spw_close ()) {
  1238. !         fprintf (stderr, NO_SPCLOSE, Prog);
  1239. !         cleanup (2);
  1240. ! #ifdef    USE_SYSLOG
  1241. !         syslog (LOG_ERR, CLOSE_FAIL, "/etc/shadow");
  1242. !         closelog ();
  1243. ! #endif
  1244. !         exit (1);
  1245. !     }
  1246. !     /*
  1247. !      * Close the password file.  If any entries were modified, the
  1248. !      * file will be re-written.
  1249. !      */
  1250. !     if (! pw_close ()) {
  1251. !         fprintf (stderr, NO_PWCLOSE, Prog);
  1252.           cleanup (2);
  1253. + #ifdef    USE_SYSLOG
  1254. +         syslog (LOG_ERR, CLOSE_FAIL, "/etc/passwd");
  1255. +         closelog ();
  1256. + #endif
  1257.           exit (1);
  1258.       }
  1259.       cleanup (2);
  1260. + #ifdef    USE_SYSLOG
  1261. +     closelog ();
  1262. + #endif
  1263.       exit (0);
  1264.       /*NOTREACHED*/
  1265.   }
  1266. *** rel3/chfn.c    Sat May 25 10:22:19 1991
  1267. --- chfn.c    Tue May 28 09:10:37 1991
  1268. ***************
  1269. *** 1,5 ****
  1270.   /*
  1271. !  * Copyright 1989, 1990, John F. Haugh II
  1272.    * All rights reserved.
  1273.    *
  1274.    * Permission is granted to copy and create derivative works for any
  1275. --- 1,5 ----
  1276.   /*
  1277. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  1278.    * All rights reserved.
  1279.    *
  1280.    * Permission is granted to copy and create derivative works for any
  1281. ***************
  1282. *** 10,22 ****
  1283.    */
  1284.   
  1285.   #include <sys/types.h>
  1286. - #include <syslog.h>
  1287.   #include <stdio.h>
  1288.   #include <fcntl.h>
  1289.   #include <signal.h>
  1290.   
  1291.   #ifndef    lint
  1292. ! static    char    sccsid[] = "@(#)chfn.c    3.4    11:23:40    12/19/90";
  1293.   #endif
  1294.   
  1295.   /*
  1296. --- 10,21 ----
  1297.    */
  1298.   
  1299.   #include <sys/types.h>
  1300.   #include <stdio.h>
  1301.   #include <fcntl.h>
  1302.   #include <signal.h>
  1303.   
  1304.   #ifndef    lint
  1305. ! static    char    sccsid[] = "@(#)chfn.c    3.5    09:07:04    5/28/91";
  1306.   #endif
  1307.   
  1308.   /*
  1309. ***************
  1310. *** 36,41 ****
  1311. --- 35,48 ----
  1312.   #include "config.h"
  1313.   #include "pwd.h"
  1314.   
  1315. + #ifdef    USE_SYSLOG
  1316. + #include <syslog.h>
  1317. + #ifndef    LOG_WARN
  1318. + #define    LOG_WARN LOG_WARNING
  1319. + #endif
  1320. + #endif
  1321.   /*
  1322.    * Global variables.
  1323.    */
  1324. ***************
  1325. *** 229,235 ****
  1326. --- 236,244 ----
  1327.       else
  1328.           Progname = argv[0];
  1329.   
  1330. + #ifdef    USE_SYSLOG
  1331.       openlog (Progname, LOG_PID, LOG_AUTH);
  1332. + #endif
  1333.   
  1334.       /* 
  1335.        * The remaining arguments will be processed one by one and
  1336. ***************
  1337. *** 265,270 ****
  1338. --- 274,280 ----
  1339.                       break;
  1340.                   }
  1341.                   fprintf (stderr, NOPERM, Progname);
  1342. +                 closelog ();
  1343.                   exit (1);
  1344.               default:
  1345.                   usage ();
  1346. ***************
  1347. *** 285,290 ****
  1348. --- 295,301 ----
  1349.           pw = getpwnam (user);
  1350.       } else {
  1351.           fprintf (stderr, WHOAREYOU, Progname);
  1352. +         closelog ();
  1353.           exit (1);
  1354.       }
  1355.   
  1356. ***************
  1357. *** 295,300 ****
  1358. --- 306,312 ----
  1359.   
  1360.       if (! pw) {
  1361.           fprintf (stderr, UNKUSER, Progname, user);
  1362. +         closelog ();
  1363.           exit (1);
  1364.       }
  1365.   
  1366. ***************
  1367. *** 306,311 ****
  1368. --- 318,324 ----
  1369.   
  1370.       if (! amroot && pw->pw_uid != getuid ()) {
  1371.           fprintf (stderr, NOPERM, Progname);
  1372. +         closelog ();
  1373.           exit (1);
  1374.       }
  1375.   
  1376. ***************
  1377. *** 384,405 ****
  1378. --- 397,423 ----
  1379.   
  1380.       if (valid_field (fullnm, ":,=")) {
  1381.           fprintf (stderr, INVALID_NAME, Progname, fullnm);
  1382. +         closelog ();
  1383.           exit (1);
  1384.       }
  1385.       if (valid_field (roomno, ":,=")) {
  1386.           fprintf (stderr, INVALID_ROOM, Progname, roomno);
  1387. +         closelog ();
  1388.           exit (1);
  1389.       }
  1390.       if (valid_field (workph, ":,=")) {
  1391.           fprintf (stderr, INVALID_WORKPH, Progname, workph);
  1392. +         closelog ();
  1393.           exit (1);
  1394.       }
  1395.       if (valid_field (homeph, ":,=")) {
  1396.           fprintf (stderr, INVALID_HOMEPH, Progname, homeph);
  1397. +         closelog ();
  1398.           exit (1);
  1399.       }
  1400.       if (valid_field (slop, ":")) {
  1401.           fprintf (stderr, INVALID_OTHER, Progname, slop);
  1402. +         closelog ();
  1403.           exit (1);
  1404.       }
  1405.   
  1406. ***************
  1407. *** 411,416 ****
  1408. --- 429,435 ----
  1409.       if (strlen (fullnm) + strlen (roomno) + strlen (workph) +
  1410.               strlen (homeph) + strlen (slop) > 80) {
  1411.           fprintf (stderr, INVALID_FIELDS, Progname);
  1412. +         closelog ();
  1413.           exit (1);
  1414.       }
  1415.       sprintf (new_gecos, "%s,%s,%s,%s", fullnm, roomno, workph, homeph);
  1416. ***************
  1417. *** 431,437 ****
  1418. --- 450,459 ----
  1419.       ulimit (2, 30000);
  1420.       if (setuid (0)) {
  1421.           fprintf (stderr, NOTROOT);
  1422. + #ifdef    USE_SYSLOG
  1423.           syslog (LOG_ERR, NOTROOT2);
  1424. +         closelog ();
  1425. + #endif
  1426.           exit (1);
  1427.       }
  1428.       signal (SIGHUP, SIG_IGN);
  1429. ***************
  1430. *** 452,464 ****
  1431.   
  1432.       if (i == 30) {
  1433.           fprintf (stderr, PWDBUSY);
  1434.           syslog (LOG_WARN, PWDBUSY2);
  1435.           exit (1);
  1436.       }
  1437.       if (! pw_open (O_RDWR)) {
  1438.           fprintf (stderr, OPNERROR);
  1439. -         syslog (LOG_ERR, OPNERROR2);
  1440.           (void) pw_unlock ();
  1441.           exit (1);
  1442.       }
  1443.   
  1444. --- 474,492 ----
  1445.   
  1446.       if (i == 30) {
  1447.           fprintf (stderr, PWDBUSY);
  1448. + #ifdef    USE_SYSLOG
  1449.           syslog (LOG_WARN, PWDBUSY2);
  1450. +         closelog ();
  1451. + #endif
  1452.           exit (1);
  1453.       }
  1454.       if (! pw_open (O_RDWR)) {
  1455.           fprintf (stderr, OPNERROR);
  1456.           (void) pw_unlock ();
  1457. + #ifdef    USE_SYSLOG
  1458. +         syslog (LOG_ERR, OPNERROR2);
  1459. +         closelog ();
  1460. + #endif
  1461.           exit (1);
  1462.       }
  1463.   
  1464. ***************
  1465. *** 469,483 ****
  1466.   
  1467.       if (! pw_update (pw)) {
  1468.           fprintf (stderr, UPDERROR);
  1469. -         syslog (LOG_ERR, UPDERROR2);
  1470.           (void) pw_unlock ();
  1471.           exit (1);
  1472.       }
  1473.   #if defined(DBM) || defined(NDBM)
  1474.       if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
  1475.           fprintf (stderr, DBMERROR);
  1476. -         syslog (LOG_ERR, DBMERROR2);
  1477.           (void) pw_unlock ();
  1478.           exit (1);
  1479.       }
  1480.   #endif
  1481. --- 497,517 ----
  1482.   
  1483.       if (! pw_update (pw)) {
  1484.           fprintf (stderr, UPDERROR);
  1485.           (void) pw_unlock ();
  1486. + #ifdef    USE_SYSLOG
  1487. +         syslog (LOG_ERR, UPDERROR2);
  1488. +         closelog ();
  1489. + #endif
  1490.           exit (1);
  1491.       }
  1492.   #if defined(DBM) || defined(NDBM)
  1493.       if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
  1494.           fprintf (stderr, DBMERROR);
  1495.           (void) pw_unlock ();
  1496. + #ifdef    USE_SYSLOG
  1497. +         syslog (LOG_ERR, DBMERROR2);
  1498. +         closelog ();
  1499. + #endif
  1500.           exit (1);
  1501.       }
  1502.   #endif
  1503. ***************
  1504. *** 489,504 ****
  1505.   
  1506.       if (! pw_close ()) {
  1507.           fprintf (stderr, CLSERROR);
  1508. -         syslog (LOG_ERR, CLSERROR2);
  1509.           (void) pw_unlock ();
  1510.           exit (1);
  1511.       }
  1512.       if (! pw_unlock ()) {
  1513.           fprintf (stderr, UNLKERROR);
  1514.           syslog (LOG_ERR, UNLKERROR2);
  1515.           exit (1);
  1516.       }
  1517.       syslog (LOG_INFO, CHGGECOS, user);
  1518.       closelog ();
  1519.       exit (0);
  1520.   }
  1521. --- 523,546 ----
  1522.   
  1523.       if (! pw_close ()) {
  1524.           fprintf (stderr, CLSERROR);
  1525.           (void) pw_unlock ();
  1526. + #ifdef    USE_SYSLOG
  1527. +         syslog (LOG_ERR, CLSERROR2);
  1528. +         closelog ();
  1529. + #endif
  1530.           exit (1);
  1531.       }
  1532.       if (! pw_unlock ()) {
  1533.           fprintf (stderr, UNLKERROR);
  1534. + #ifdef    USE_SYSLOG
  1535.           syslog (LOG_ERR, UNLKERROR2);
  1536. +         closelog ();
  1537. + #endif
  1538.           exit (1);
  1539.       }
  1540. + #ifdef    USE_SYSLOG
  1541.       syslog (LOG_INFO, CHGGECOS, user);
  1542.       closelog ();
  1543. + #endif
  1544.       exit (0);
  1545.   }
  1546. *** rel3/chpasswd.c    Sat May 25 10:22:38 1991
  1547. --- chpasswd.c    Tue May 28 09:10:42 1991
  1548. ***************
  1549. *** 1,5 ****
  1550.   /*
  1551. !  * Copyright 1990, John F. Haugh II
  1552.    * All rights reserved.
  1553.    *
  1554.    * Permission is granted to copy and create derivative works for any
  1555. --- 1,5 ----
  1556.   /*
  1557. !  * Copyright 1990, 1991, John F. Haugh II
  1558.    * All rights reserved.
  1559.    *
  1560.    * Permission is granted to copy and create derivative works for any
  1561. ***************
  1562. *** 8,16 ****
  1563.    * and conspicuously displayed on all copies of object code or
  1564.    * distribution media.
  1565.    *
  1566. !  * chpass - update passwords in batch
  1567.    *
  1568. !  *    chpass reads standard input for a list of colon separated
  1569.    *    user names and new passwords.  the appropriate password
  1570.    *    files are updated to reflect the changes.  because the
  1571.    *    changes are made in a batch fashion, the user must run
  1572. --- 8,16 ----
  1573.    * and conspicuously displayed on all copies of object code or
  1574.    * distribution media.
  1575.    *
  1576. !  * chpasswd - update passwords in batch
  1577.    *
  1578. !  *    chpasswd reads standard input for a list of colon separated
  1579.    *    user names and new passwords.  the appropriate password
  1580.    *    files are updated to reflect the changes.  because the
  1581.    *    changes are made in a batch fashion, the user must run
  1582. ***************
  1583. *** 28,34 ****
  1584.   #endif
  1585.   
  1586.   #ifndef    lint
  1587. ! static    char    sccsid[] = "@(#)chpasswd.c    3.2    12:30:30    12/12/90";
  1588.   #endif
  1589.   
  1590.   char    *Prog;
  1591. --- 28,34 ----
  1592.   #endif
  1593.   
  1594.   #ifndef    lint
  1595. ! static    char    sccsid[] = "@(#)chpasswd.c    3.3    09:07:09    5/28/91";
  1596.   #endif
  1597.   
  1598.   char    *Prog;
  1599. ***************
  1600. *** 211,222 ****
  1601.        */
  1602.   
  1603.       if (errors) {
  1604. !         fprintf ("%s: error detected, changes ignored\n", Prog);
  1605.           pw_unlock ();
  1606.           exit (1);
  1607.       }
  1608.       if (! pw_close ()) {
  1609. !         fprintf ("%s: error updating password file\n", Prog);
  1610.           exit (1);
  1611.       }
  1612.       (void) pw_unlock ();
  1613. --- 211,222 ----
  1614.        */
  1615.   
  1616.       if (errors) {
  1617. !         fprintf (stderr, "%s: error detected, changes ignored\n", Prog);
  1618.           pw_unlock ();
  1619.           exit (1);
  1620.       }
  1621.       if (! pw_close ()) {
  1622. !         fprintf (stderr, "%s: error updating password file\n", Prog);
  1623.           exit (1);
  1624.       }
  1625.       (void) pw_unlock ();
  1626. *** rel3/chsh.c    Sat May 25 10:22:20 1991
  1627. --- chsh.c    Tue May 28 09:10:43 1991
  1628. ***************
  1629. *** 1,5 ****
  1630.   /*
  1631. !  * Copyright 1989, 1990, John F. Haugh II
  1632.    * All rights reserved.
  1633.    *
  1634.    * Permission is granted to copy and create derivative works for any
  1635. --- 1,5 ----
  1636.   /*
  1637. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  1638.    * All rights reserved.
  1639.    *
  1640.    * Permission is granted to copy and create derivative works for any
  1641. ***************
  1642. *** 10,22 ****
  1643.    */
  1644.   
  1645.   #include <sys/types.h>
  1646. - #include <syslog.h>
  1647.   #include <stdio.h>
  1648.   #include <fcntl.h>
  1649.   #include <signal.h>
  1650.   
  1651.   #ifndef    lint
  1652. ! static    char    sccsid[] = "@(#)chsh.c    3.3    11:23:29    12/19/90";
  1653.   #endif
  1654.   
  1655.   /*
  1656. --- 10,21 ----
  1657.    */
  1658.   
  1659.   #include <sys/types.h>
  1660.   #include <stdio.h>
  1661.   #include <fcntl.h>
  1662.   #include <signal.h>
  1663.   
  1664.   #ifndef    lint
  1665. ! static    char    sccsid[] = "@(#)chsh.c    3.4    09:07:12    5/28/91";
  1666.   #endif
  1667.   
  1668.   /*
  1669. ***************
  1670. *** 36,41 ****
  1671. --- 35,48 ----
  1672.   #include "config.h"
  1673.   #include "pwd.h"
  1674.   
  1675. + #ifdef    USE_SYSLOG
  1676. + #include <syslog.h>
  1677. + #ifndef    LOG_WARN
  1678. + #define    LOG_WARN LOG_WARNING
  1679. + #endif
  1680. + #endif
  1681.   /*
  1682.    * Global variables.
  1683.    */
  1684. ***************
  1685. *** 209,215 ****
  1686. --- 216,224 ----
  1687.       else
  1688.           Progname = argv[0];
  1689.   
  1690. + #ifdef    USE_SYSLOG
  1691.       openlog (Progname, LOG_PID, LOG_AUTH);
  1692. + #endif
  1693.   
  1694.       /*
  1695.        * There is only one option, but use getopt() anyway to
  1696. ***************
  1697. *** 249,254 ****
  1698. --- 258,266 ----
  1699.           pw = getpwnam (user);
  1700.       } else {
  1701.           fprintf (stderr, WHOAREYOU, Progname);
  1702. + #ifdef    USE_SYSLOG
  1703. +         closelog ();
  1704. + #endif
  1705.           exit (1);
  1706.       }
  1707.   
  1708. ***************
  1709. *** 259,264 ****
  1710. --- 271,279 ----
  1711.   
  1712.       if (! pw) {
  1713.           fprintf (stderr, UNKUSER, Progname, user);
  1714. + #ifdef    USE_SYSLOG
  1715. +         closelog ();
  1716. + #endif
  1717.           exit (1);
  1718.       }
  1719.   
  1720. ***************
  1721. *** 270,276 ****
  1722. --- 285,294 ----
  1723.   
  1724.       if (! amroot && pw->pw_uid != getuid ()) {
  1725.           fprintf (stderr, NOPERM, user);
  1726. + #ifdef    USE_SYSLOG
  1727.           syslog (LOG_WARN, NOPERM2, user);
  1728. +         closelog ();
  1729. + #endif
  1730.           exit (1);
  1731.       }
  1732.   
  1733. ***************
  1734. *** 281,287 ****
  1735. --- 299,308 ----
  1736.   
  1737.       if (! amroot && restricted_shell (pw->pw_shell)) {
  1738.           fprintf (stderr, NOPERM, user);
  1739. + #ifdef    USE_SYSLOG
  1740.           syslog (LOG_WARN, NOPERM2, user);
  1741. +         closelog ();
  1742. + #endif
  1743.           exit (1);
  1744.       }
  1745.   
  1746. ***************
  1747. *** 329,338 ****
  1748. --- 350,365 ----
  1749.   
  1750.       if (valid_field (loginsh, ":,=")) {
  1751.           fprintf (stderr, BADFIELD, Progname, loginsh);
  1752. + #ifdef    USE_SYSLOG
  1753. +         closelog ();
  1754. + #endif
  1755.           exit (1);
  1756.       }
  1757.       if (! check_shell (loginsh)) {
  1758.           fprintf (stderr, BADSHELL, loginsh);
  1759. + #ifdef    USE_SYSLOG
  1760. +         closelog ();
  1761. + #endif
  1762.           exit (1);
  1763.       }
  1764.       pwent.pw_shell = loginsh;
  1765. ***************
  1766. *** 348,354 ****
  1767. --- 375,384 ----
  1768.       ulimit (2, 30000);
  1769.       if (setuid (0)) {
  1770.           fprintf (stderr, NOTROOT);
  1771. + #ifdef    USE_SYSLOG
  1772.           syslog (LOG_ERR, NOTROOT2);
  1773. +         closelog ();
  1774. + #endif
  1775.           exit (1);
  1776.       }
  1777.       signal (SIGHUP, SIG_IGN);
  1778. ***************
  1779. *** 369,381 ****
  1780.   
  1781.       if (i == 30) {
  1782.           fprintf (stderr, PWDBUSY);
  1783.           syslog (LOG_WARN, PWDBUSY2);
  1784.           exit (1);
  1785.       }
  1786.       if (! pw_open (O_RDWR)) {
  1787.           fprintf (stderr, OPNERROR);
  1788. -         syslog (LOG_ERR, OPNERROR2);
  1789.           (void) pw_unlock ();
  1790.           exit (1);
  1791.       }
  1792.   
  1793. --- 399,417 ----
  1794.   
  1795.       if (i == 30) {
  1796.           fprintf (stderr, PWDBUSY);
  1797. + #ifdef    USE_SYSLOG
  1798.           syslog (LOG_WARN, PWDBUSY2);
  1799. +         closelog ();
  1800. + #endif
  1801.           exit (1);
  1802.       }
  1803.       if (! pw_open (O_RDWR)) {
  1804.           fprintf (stderr, OPNERROR);
  1805.           (void) pw_unlock ();
  1806. + #ifdef    USE_SYSLOG
  1807. +         syslog (LOG_ERR, OPNERROR2);
  1808. +         closelog ();
  1809. + #endif
  1810.           exit (1);
  1811.       }
  1812.   
  1813. ***************
  1814. *** 386,400 ****
  1815.   
  1816.       if (! pw_update (pw)) {
  1817.           fprintf (stderr, UPDERROR);
  1818. -         syslog (LOG_ERR, UPDERROR2);
  1819.           (void) pw_unlock ();
  1820.           exit (1);
  1821.       }
  1822.   #if defined(DBM) || defined(NDBM)
  1823.       if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
  1824.           fprintf (stderr, DBMERROR);
  1825. -         syslog (LOG_ERR, DBMERROR2);
  1826.           (void) pw_unlock ();
  1827.           exit (1);
  1828.       }
  1829.   #endif
  1830. --- 422,442 ----
  1831.   
  1832.       if (! pw_update (pw)) {
  1833.           fprintf (stderr, UPDERROR);
  1834.           (void) pw_unlock ();
  1835. + #ifdef    USE_SYSLOG
  1836. +         syslog (LOG_ERR, UPDERROR2);
  1837. +         closelog ();
  1838. + #endif
  1839.           exit (1);
  1840.       }
  1841.   #if defined(DBM) || defined(NDBM)
  1842.       if (access ("/etc/passwd.pag", 0) == 0 && ! pw_dbm_update (pw)) {
  1843.           fprintf (stderr, DBMERROR);
  1844.           (void) pw_unlock ();
  1845. + #ifdef    USE_SYSLOG
  1846. +         syslog (LOG_ERR, DBMERROR2);
  1847. +         closelog ();
  1848. + #endif
  1849.           exit (1);
  1850.       }
  1851.   #endif
  1852. ***************
  1853. *** 406,421 ****
  1854.   
  1855.       if (! pw_close ()) {
  1856.           fprintf (stderr, CLSERROR);
  1857. -         syslog (LOG_ERR, CLSERROR2);
  1858.           (void) pw_unlock ();
  1859.           exit (1);
  1860.       }
  1861.       if (! pw_unlock ()) {
  1862.           fprintf (stderr, UNLKERROR);
  1863.           syslog (LOG_ERR, UNLKERROR2);
  1864.           exit (1);
  1865.       }
  1866.       syslog (LOG_INFO, CHGSHELL, user, pwent.pw_shell);
  1867.       closelog ();
  1868.       exit (0);
  1869.   }
  1870. --- 448,471 ----
  1871.   
  1872.       if (! pw_close ()) {
  1873.           fprintf (stderr, CLSERROR);
  1874.           (void) pw_unlock ();
  1875. + #ifdef    USE_SYSLOG
  1876. +         syslog (LOG_ERR, CLSERROR2);
  1877. +         closelog ();
  1878. + #endif
  1879.           exit (1);
  1880.       }
  1881.       if (! pw_unlock ()) {
  1882.           fprintf (stderr, UNLKERROR);
  1883. + #ifdef    USE_SYSLOG
  1884.           syslog (LOG_ERR, UNLKERROR2);
  1885. +         closelog ();
  1886. + #endif
  1887.           exit (1);
  1888.       }
  1889. + #ifdef    USE_SYSLOG
  1890.       syslog (LOG_INFO, CHGSHELL, user, pwent.pw_shell);
  1891.       closelog ();
  1892. + #endif
  1893.       exit (0);
  1894.   }
  1895. *** rel3/entry.c    Sat May 25 10:22:34 1991
  1896. --- entry.c    Tue May 28 09:10:44 1991
  1897. ***************
  1898. *** 1,5 ****
  1899.   /*
  1900. !  * Copyright 1989, 1990, John F. Haugh II
  1901.    * All rights reserved.
  1902.    *
  1903.    * Permission is granted to copy and create derivative works for any
  1904. --- 1,5 ----
  1905.   /*
  1906. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  1907.    * All rights reserved.
  1908.    *
  1909.    * Permission is granted to copy and create derivative works for any
  1910. ***************
  1911. *** 23,29 ****
  1912.   #endif
  1913.   
  1914.   #ifndef    lint
  1915. ! static    char    sccsid[] = "@(#)entry.c    3.2    12:30:39    12/12/90";
  1916.   #endif
  1917.   
  1918.   struct    passwd    *fgetpwent ();
  1919. --- 23,29 ----
  1920.   #endif
  1921.   
  1922.   #ifndef    lint
  1923. ! static    char    sccsid[] = "@(#)entry.c    3.3    09:07:17    5/28/91";
  1924.   #endif
  1925.   
  1926.   struct    passwd    *fgetpwent ();
  1927. ***************
  1928. *** 38,43 ****
  1929. --- 38,44 ----
  1930.       char    *l64a ();
  1931.   #endif
  1932.       char    *cp;
  1933. +     char    *malloc();
  1934.   
  1935.       if (! (passwd = getpwnam (name))) {
  1936.           pwent->pw_name = (char *) 0;
  1937. ***************
  1938. *** 57,63 ****
  1939.           if (spwd = getspnam (name)) {
  1940.               pwent->pw_passwd = strdup (spwd->sp_pwdp);
  1941.   #ifdef    ATT_AGE
  1942. !             pwent->pw_age = malloc (5);
  1943.   
  1944.               if (spwd->sp_max > (63*7))
  1945.                   spwd->sp_max = (63*7);
  1946. --- 58,64 ----
  1947.           if (spwd = getspnam (name)) {
  1948.               pwent->pw_passwd = strdup (spwd->sp_pwdp);
  1949.   #ifdef    ATT_AGE
  1950. !             pwent->pw_age = (char *) malloc (5);
  1951.   
  1952.               if (spwd->sp_max > (63*7))
  1953.                   spwd->sp_max = (63*7);
  1954. *** rel3/getpass.c    Sat May 25 10:22:17 1991
  1955. --- getpass.c    Tue May 28 09:10:45 1991
  1956. ***************
  1957. *** 1,5 ****
  1958.   /*
  1959. !  * Copyright 1990, John F. Haugh II
  1960.    * All rights reserved.
  1961.    *
  1962.    * Permission is granted to copy and create derivative works for any
  1963. --- 1,5 ----
  1964.   /*
  1965. !  * Copyright 1990, 1991, John F. Haugh II
  1966.    * All rights reserved.
  1967.    *
  1968.    * Permission is granted to copy and create derivative works for any
  1969. ***************
  1970. *** 22,28 ****
  1971.   #endif
  1972.   
  1973.   #ifndef    lint
  1974. ! static    char    sccsid[] = "@(#)getpass.c    3.2    08:19:03    2/5/91";
  1975.   #endif
  1976.   
  1977.   /*
  1978. --- 22,28 ----
  1979.   #endif
  1980.   
  1981.   #ifndef    lint
  1982. ! static    char    sccsid[] = "@(#)getpass.c    3.3    09:09:36    5/28/91";
  1983.   #endif
  1984.   
  1985.   /*
  1986. ***************
  1987. *** 30,36 ****
  1988.    * for password.
  1989.    */
  1990.   
  1991. ! #if defined(__STDC__) || defined(_POSIX_SOURCE)
  1992.   #include <limits.h>
  1993.   #endif
  1994.   
  1995. --- 30,36 ----
  1996.    * for password.
  1997.    */
  1998.   
  1999. ! #if __STDC__ || _POSIX_SOURCE
  2000.   #include <limits.h>
  2001.   #endif
  2002.   
  2003. *** rel3/gpmain.c    Sat May 25 10:22:26 1991
  2004. --- gpmain.c    Tue May 28 09:10:47 1991
  2005. ***************
  2006. *** 1,5 ****
  2007.   /*
  2008. !  * Copyright 1990, John F. Haugh II
  2009.    * All rights reserved.
  2010.    *
  2011.    * Permission is granted to copy and create derivative works for any
  2012. --- 1,5 ----
  2013.   /*
  2014. !  * Copyright 1990, 1991, John F. Haugh II
  2015.    * All rights reserved.
  2016.    *
  2017.    * Permission is granted to copy and create derivative works for any
  2018. ***************
  2019. *** 38,44 ****
  2020.   #endif
  2021.   
  2022.   #ifndef    lint
  2023. ! static    char    _sccsid[] = "@(#)gpmain.c    3.4    12:30:43    12/12/90";
  2024.   #endif
  2025.   
  2026.   char    name[BUFSIZ];
  2027. --- 38,44 ----
  2028.   #endif
  2029.   
  2030.   #ifndef    lint
  2031. ! static    char    _sccsid[] = "@(#)gpmain.c    3.5    09:07:24    5/28/91";
  2032.   #endif
  2033.   
  2034.   char    name[BUFSIZ];
  2035. ***************
  2036. *** 66,71 ****
  2037. --- 66,72 ----
  2038.   extern    long    a64l ();
  2039.   extern    void    entry ();
  2040.   extern    time_t    time ();
  2041. + extern    char    *malloc ();
  2042.   
  2043.   /*
  2044.    * usage - display usage message
  2045. ***************
  2046. *** 156,161 ****
  2047. --- 157,163 ----
  2048.       void    die ();
  2049.       char    *cp;
  2050.       char    *getlogin ();
  2051. +     char    *getpass ();
  2052.       int    amroot;
  2053.       int    retries;
  2054.       int    ruid = getuid();
  2055. *** rel3/groupio.c    Sat May 25 10:22:56 1991
  2056. --- groupio.c    Tue May 28 09:10:48 1991
  2057. ***************
  2058. *** 1,10 ****
  2059.   /*
  2060. !  * Copyright 1990, John F. Haugh II
  2061. !  * An unpublished work.
  2062.    * All rights reserved.
  2063.    *
  2064. !  * Use, duplication, and disclosure prohibited without
  2065. !  * the express written permission of the author.
  2066.    *
  2067.    *    This file implements a transaction oriented group database
  2068.    *    library.  The group file is updated one entry at a time.
  2069. --- 1,12 ----
  2070.   /*
  2071. !  * Copyright 1990, 1991, John F. Haugh II
  2072.    * All rights reserved.
  2073.    *
  2074. !  * Permission is granted to copy and create derivative works for any
  2075. !  * non-commercial purpose, provided this copyright notice is preserved
  2076. !  * in all copies of source code, or included in human readable form
  2077. !  * and conspicuously displayed on all copies of object code or
  2078. !  * distribution media.
  2079.    *
  2080.    *    This file implements a transaction oriented group database
  2081.    *    library.  The group file is updated one entry at a time.
  2082. ***************
  2083. *** 21,26 ****
  2084. --- 23,29 ----
  2085.    *    gr_unlock            -- remove group lock
  2086.    */
  2087.   
  2088. + #include <sys/types.h>
  2089.   #include <sys/stat.h>
  2090.   #include <fcntl.h>
  2091.   #include <errno.h>
  2092. ***************
  2093. *** 33,39 ****
  2094.   #endif
  2095.   
  2096.   #ifndef    lint
  2097. ! static    char    sccsid[] = "@(#)groupio.c    3.6 15:59:12 12/9/90";
  2098.   #endif
  2099.   
  2100.   static    int    islocked;
  2101. --- 36,42 ----
  2102.   #endif
  2103.   
  2104.   #ifndef    lint
  2105. ! static    char    sccsid[] = "@(#)groupio.c    3.7 09:07:28 5/28/91";
  2106.   #endif
  2107.   
  2108.   static    int    islocked;
  2109. ***************
  2110. *** 62,67 ****
  2111. --- 65,72 ----
  2112.   
  2113.   extern    char    *strdup();
  2114.   extern    struct    group    *sgetgrent();
  2115. + extern    char    *malloc();
  2116. + extern    char    *fgetsx();
  2117.   
  2118.   /*
  2119.    * gr_dup - duplicate a group file entry
  2120. *** rel3/lmain.c    Sat May 25 10:22:13 1991
  2121. --- lmain.c    Tue May 28 09:10:51 1991
  2122. ***************
  2123. *** 1,5 ****
  2124.   /*
  2125. !  * Copyright 1989, 1990, John F. Haugh II
  2126.    * All rights reserved.
  2127.    *
  2128.    * Permission is granted to copy and create derivative works for any
  2129. --- 1,5 ----
  2130.   /*
  2131. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  2132.    * All rights reserved.
  2133.    *
  2134.    * Permission is granted to copy and create derivative works for any
  2135. ***************
  2136. *** 16,22 ****
  2137.   #include <utmp.h>
  2138.   #include <time.h>
  2139.   #include <signal.h>
  2140. - #include <syslog.h>
  2141.   #ifndef    BSD
  2142.   #include <string.h>
  2143.   #include <memory.h>
  2144. --- 16,21 ----
  2145. ***************
  2146. *** 36,43 ****
  2147.   #include "faillog.h"
  2148.   #include "shadow.h"
  2149.   
  2150.   #ifndef    lint
  2151. ! static    char    sccsid[] = "%W%    %U%    %G%";
  2152.   #endif
  2153.   
  2154.   #ifndef    ERASECHAR
  2155. --- 35,50 ----
  2156.   #include "faillog.h"
  2157.   #include "shadow.h"
  2158.   
  2159. + #ifdef    USE_SYSLOG
  2160. + #include <syslog.h>
  2161. + #ifndef    LOG_WARN
  2162. + #define    LOG_WARN    LOG_WARNING
  2163. + #endif
  2164. + #endif
  2165.   #ifndef    lint
  2166. ! static    char    sccsid[] = "@(#)lmain.c    3.5    09:07:32    5/28/91";
  2167.   #endif
  2168.   
  2169.   #ifndef    ERASECHAR
  2170. ***************
  2171. *** 258,264 ****
  2172. --- 265,273 ----
  2173.       if (rflg && (hflg || fflg || pflg))
  2174.           usage ();
  2175.   
  2176. + #ifdef    USE_SYSLOG
  2177.       openlog (Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
  2178. + #endif
  2179.   
  2180.       /*
  2181.        * The -r and -f flags both require the real UID to be
  2182. ***************
  2183. *** 266,277 ****
  2184.        * flags, so the user must already be root.
  2185.        */
  2186.   
  2187. !     if ((rflg || fflg) && getuid () != 0)
  2188.           exit (1);        /* only root can use -r or -f */
  2189. !     if (! isatty (0) || ! isatty (1) || ! isatty (2))
  2190.           exit (1);        /* must be a terminal */
  2191.   #ifndef    BSD
  2192.       (void) ioctl (0, TCGETA, &termio); /* get terminal characteristics */
  2193.   
  2194. --- 275,292 ----
  2195.        * flags, so the user must already be root.
  2196.        */
  2197.   
  2198. !     if ((rflg || fflg) && getuid () != 0) {
  2199. ! #ifdef    USE_SYSLOG
  2200. !         closelog ();
  2201. ! #endif
  2202.           exit (1);        /* only root can use -r or -f */
  2203. !     }
  2204. !     if (! isatty (0) || ! isatty (1) || ! isatty (2)) {
  2205. ! #ifdef    USE_SYSLOG
  2206. !         closelog ();
  2207. ! #endif
  2208.           exit (1);        /* must be a terminal */
  2209. !     }
  2210.   #ifndef    BSD
  2211.       (void) ioctl (0, TCGETA, &termio); /* get terminal characteristics */
  2212.   
  2213. ***************
  2214. *** 330,338 ****
  2215.           pass[0] = '\0';
  2216.   
  2217.           if (! name[0]) {    /* need to get a login id */
  2218. !             if (subroot)
  2219.                   exit (1);
  2220.               rflg = fflg = 0;
  2221.               login (name);
  2222.               continue;
  2223. --- 345,356 ----
  2224.           pass[0] = '\0';
  2225.   
  2226.           if (! name[0]) {    /* need to get a login id */
  2227. !             if (subroot) {
  2228. ! #ifdef    USE_SYSLOG
  2229. !                 closelog ();
  2230. ! #endif
  2231.                   exit (1);
  2232. !             }
  2233.               rflg = fflg = 0;
  2234.               login (name);
  2235.               continue;
  2236. ***************
  2237. *** 344,350 ****
  2238. --- 362,372 ----
  2239.   
  2240.           if (pwent.pw_name) {
  2241.               if (! (spwd = getspnam (name)))
  2242. + #ifdef    USE_SYSLOG
  2243.                   syslog (LOG_WARN, NO_SHADOW, name, tty);
  2244. + #else
  2245. +                 ;
  2246. + #endif
  2247.               else
  2248.                   pwent.pw_passwd = spwd->sp_pwdp;
  2249.               failed = 0;    /* hasn't failed validation yet */
  2250. ***************
  2251. *** 374,380 ****
  2252. --- 396,404 ----
  2253.               strncpy (pass, cp, sizeof pass);
  2254.   
  2255.           if (! valid (pass, &pwent)) { /* check encrypted passwords */
  2256. + #ifdef    USE_SYSLOG
  2257.               syslog (LOG_WARN, BAD_PASSWD, name, tty);
  2258. + #endif
  2259.               failed = 1;
  2260.           }
  2261.           bzero (pass, sizeof pass);
  2262. ***************
  2263. *** 390,396 ****
  2264. --- 414,422 ----
  2265.           alarm (30);
  2266.           if (pwent.pw_name && ! dialcheck (tty,
  2267.                   pwent.pw_shell[0] ? pwent.pw_shell:"/bin/sh")) {
  2268. + #ifdef    USE_SYSLOG
  2269.               syslog (LOG_WARN, BAD_DIALUP, name, tty);
  2270. + #endif
  2271.               failed = 1;
  2272.           }
  2273.   #endif    /* DIALUP */
  2274. ***************
  2275. *** 397,403 ****
  2276. --- 423,431 ----
  2277.   #ifdef    PORTTIME
  2278.           if (pwent.pw_name &&
  2279.               ! isttytime (pwent.pw_name, tty, time ((time_t *) 0))) {
  2280. + #ifdef    USE_SYSLOG
  2281.               syslog (LOG_WARN, BAD_TIME, name, tty);
  2282. + #endif
  2283.               failed = 1;
  2284.           }
  2285.   #endif    /* PORTTIME */
  2286. ***************
  2287. *** 420,433 ****
  2288. --- 448,465 ----
  2289.                   if (strcmp (CONSOLE, tty))
  2290.                       failed = 1;
  2291.               }
  2292. + #ifdef    USE_SYSLOG
  2293.               if (failed)
  2294.                   syslog (LOG_CRIT, BAD_ROOT_LOGIN, tty);
  2295. + #endif
  2296.           }
  2297.   #endif    /* CONSOLE */
  2298.   #ifdef    FAILLOG
  2299.           if (pwent.pw_name &&
  2300.               ! failcheck (pwent.pw_uid, &faillog, failed)) {
  2301. + #ifdef    USE_SYSLOG
  2302.               syslog (LOG_CRIT, FAILURE_CNT, name, tty);
  2303. + #endif
  2304.               failed = 1;
  2305.           }
  2306.   #endif    /* FAILLOG */
  2307. ***************
  2308. *** 435,442 ****
  2309.               break;
  2310.   
  2311.           puts ("Login incorrect");
  2312. !         if (rflg || fflg)
  2313.               exit (1);
  2314.   #ifdef    FAILLOG
  2315.           if (pwent.pw_name)    /* don't log non-existent users */
  2316.               failure (pwent.pw_uid, tty, &faillog);
  2317. --- 467,478 ----
  2318.               break;
  2319.   
  2320.           puts ("Login incorrect");
  2321. !         if (rflg || fflg) {
  2322. ! #ifdef    USE_SYSLOG
  2323. !             closelog ();
  2324. ! #endif
  2325.               exit (1);
  2326. +         }
  2327.   #ifdef    FAILLOG
  2328.           if (pwent.pw_name)    /* don't log non-existent users */
  2329.               failure (pwent.pw_uid, tty, &faillog);
  2330. ***************
  2331. *** 458,466 ****
  2332.   
  2333.           failtmp (&failent);
  2334.   #endif /* FTMP */
  2335. !         if (--retries <= 0)    /* only allow so many failures */
  2336.               exit (1);
  2337.           bzero (name, sizeof name);
  2338.           bzero (pass, sizeof pass);
  2339.       }
  2340. --- 494,505 ----
  2341.   
  2342.           failtmp (&failent);
  2343.   #endif /* FTMP */
  2344. !         if (--retries <= 0) {    /* only allow so many failures */
  2345. ! #ifdef    USE_SYSLOG
  2346. !             closelog ();
  2347. ! #endif
  2348.               exit (1);
  2349. !         }
  2350.           bzero (name, sizeof name);
  2351.           bzero (pass, sizeof pass);
  2352.       }
  2353. ***************
  2354. *** 488,493 ****
  2355. --- 527,535 ----
  2356.           } else
  2357.               printf ("\r\nSystem closed for routine maintenance\n");
  2358.   
  2359. + #ifdef    USE_SYSLOG
  2360. +         closelog ();
  2361. + #endif
  2362.           exit (0);
  2363.       }
  2364.   #endif    /* NOLOGINS */
  2365. ***************
  2366. *** 567,575 ****
  2367. --- 609,620 ----
  2368.       endspent ();            /* stop access to shadow passwd file */
  2369.       endsgent ();            /* stop access to shadow group file */
  2370.   
  2371. + #ifdef    USE_SYSLOG
  2372.       if (pwent.pw_uid == 0)
  2373.           syslog (LOG_INFO, ROOT_LOGIN, tty);
  2374.   
  2375. +     closelog ();
  2376. + #endif
  2377.       shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */
  2378.       /*NOTREACHED*/
  2379.   }
  2380. *** rel3/mkpasswd.c    Sat May 25 10:22:14 1991
  2381. --- mkpasswd.c    Tue May 28 09:10:54 1991
  2382. ***************
  2383. *** 1,5 ****
  2384.   /*
  2385. !  * Copyright 1990, John F. Haugh II
  2386.    * All rights reserved.
  2387.    *
  2388.    * Permission is granted to copy and create derivative works for any
  2389. --- 1,5 ----
  2390.   /*
  2391. !  * Copyright 1990, 1991, John F. Haugh II
  2392.    * All rights reserved.
  2393.    *
  2394.    * Permission is granted to copy and create derivative works for any
  2395. ***************
  2396. *** 9,16 ****
  2397. --- 9,35 ----
  2398.    * distribution media.
  2399.    */
  2400.   
  2401. + #ifndef    lint
  2402. + static    char    sccsid[] = "@(#)mkpasswd.c    3.5    09:07:38    5/28/91";
  2403. + static    char    copyright[] = "Copyright 1990, 1991, John F. Haugh II";
  2404. + #endif
  2405.   #include "config.h"
  2406.   #include <stdio.h>
  2407. + #if !defined(DBM) && !defined(NDBM) /*{*/
  2408. + main (argc, argv)
  2409. + int    argc;
  2410. + char    **argv;
  2411. + {
  2412. +     fprintf(stderr, "%s: no DBM database on system - no action performed\n",
  2413. +         argv[0]);
  2414. +     exit(0);
  2415. + }
  2416. + #else /*} defined(DBM) || defined(NDBM) {*/
  2417.   #include <fcntl.h>
  2418.   #include "pwd.h"
  2419.   #ifdef    BSD
  2420. ***************
  2421. *** 39,49 ****
  2422.   DBM    *sgr_dbm;
  2423.   #endif
  2424.   
  2425. - #ifndef    lint
  2426. - static    char    sccsid[] = "@(#)mkpasswd.c    3.4    11:29:08    12/19/90";
  2427. - static    char    copyright[] = "Copyright 1990, John F. Haugh II";
  2428. - #endif
  2429.   char    *CANT_OPEN =    "%s: cannot open file %s\n";
  2430.   char    *CANT_OVERWRITE = "%s: cannot overwrite file %s\n";
  2431.   char    *CANT_CREATE =    "%s: cannot create %s\n";
  2432. --- 58,63 ----
  2433. ***************
  2434. *** 378,380 ****
  2435. --- 392,395 ----
  2436.       exit (1);
  2437.       /*NOTREACHED*/
  2438.   }
  2439. + #endif /*} defined(DBM) || defined(NDBM) */
  2440. *** rel3/newgrp.c    Sat May 25 10:22:05 1991
  2441. --- newgrp.c    Tue May 28 09:10:56 1991
  2442. ***************
  2443. *** 1,5 ****
  2444.   /*
  2445. !  * Copyright 1990, John F. Haugh II
  2446.    * All rights reserved.
  2447.    *
  2448.    * Permission is granted to copy and create derivative works for any
  2449. --- 1,5 ----
  2450.   /*
  2451. !  * Copyright 1990, 1991, John F. Haugh II
  2452.    * All rights reserved.
  2453.    *
  2454.    * Permission is granted to copy and create derivative works for any
  2455. ***************
  2456. *** 21,27 ****
  2457.   #include "config.h"
  2458.   
  2459.   #ifndef    lint
  2460. ! static    char    sccsid[] = "@(#)newgrp.c    3.3    12:30:58    12/12/90";
  2461.   #endif
  2462.   
  2463.   #ifdef    NGROUPS
  2464. --- 21,27 ----
  2465.   #include "config.h"
  2466.   
  2467.   #ifndef    lint
  2468. ! static    char    sccsid[] = "@(#)newgrp.c    3.4    09:07:42    5/28/91";
  2469.   #endif
  2470.   
  2471.   #ifdef    NGROUPS
  2472. ***************
  2473. *** 44,49 ****
  2474. --- 44,52 ----
  2475.   
  2476.   char    *getlogin();
  2477.   char    *crypt();
  2478. + char    *getpass();
  2479. + char    *getenv();
  2480. + char    *pw_encrypt();
  2481.   void    shell();
  2482.   
  2483.   char    *name;
  2484. *** rel3/newusers.c    Sat May 25 10:22:40 1991
  2485. --- newusers.c    Tue May 28 09:10:58 1991
  2486. ***************
  2487. *** 1,5 ****
  2488.   /*
  2489. !  * Copyright 1990, John F. Haugh II
  2490.    * All rights reserved.
  2491.    *
  2492.    * Permission is granted to copy and create derivative works for any
  2493. --- 1,5 ----
  2494.   /*
  2495. !  * Copyright 1990, 1991, John F. Haugh II
  2496.    * All rights reserved.
  2497.    *
  2498.    * Permission is granted to copy and create derivative works for any
  2499. ***************
  2500. *** 26,32 ****
  2501.   #endif
  2502.   
  2503.   #ifndef    lint
  2504. ! static    char    sccsid[] = "@(#)newusers.c    3.2    12:31:02    12/12/90";
  2505.   #endif
  2506.   
  2507.   char    *Prog;
  2508. --- 26,32 ----
  2509.   #endif
  2510.   
  2511.   #ifndef    lint
  2512. ! static    char    sccsid[] = "@(#)newusers.c    3.3    09:07:46    5/28/91";
  2513.   #endif
  2514.   
  2515.   char    *Prog;
  2516. ***************
  2517. *** 273,278 ****
  2518. --- 273,279 ----
  2519.       struct    passwd    *pw;
  2520.       struct    passwd    pwent;
  2521.       static    char    newage[5];
  2522. +     extern    char    *l64a();
  2523.   
  2524.       /*
  2525.        * In the case of regular password files, this is real
  2526. ***************
  2527. *** 581,587 ****
  2528.        */
  2529.   
  2530.       if (errors) {
  2531. !         fprintf ("%s: error detected, changes ignored\n", Prog);
  2532.           (void) gr_unlock ();
  2533.   #ifdef    SHADOWPWD
  2534.           (void) spw_unlock ();
  2535. --- 582,588 ----
  2536.        */
  2537.   
  2538.       if (errors) {
  2539. !         fprintf (stderr, "%s: error detected, changes ignored\n", Prog);
  2540.           (void) gr_unlock ();
  2541.   #ifdef    SHADOWPWD
  2542.           (void) spw_unlock ();
  2543. ***************
  2544. *** 595,601 ****
  2545.       if (! pw_close () || ! gr_close ())
  2546.   #endif
  2547.       {
  2548. !         fprintf ("%s: error updating files\n", Prog);
  2549.           (void) gr_unlock ();
  2550.   #ifdef    SHADOWPWD
  2551.           (void) spw_unlock ();
  2552. --- 596,602 ----
  2553.       if (! pw_close () || ! gr_close ())
  2554.   #endif
  2555.       {
  2556. !         fprintf (stderr, "%s: error updating files\n", Prog);
  2557.           (void) gr_unlock ();
  2558.   #ifdef    SHADOWPWD
  2559.           (void) spw_unlock ();
  2560. *** rel3/obscure.c    Sat May 25 10:22:08 1991
  2561. --- obscure.c    Tue May 28 09:11:00 1991
  2562. ***************
  2563. *** 1,5 ****
  2564.   /*
  2565. !  * Copyright 1989, 1990, John F. Haugh II
  2566.    * All rights reserved.
  2567.    *
  2568.    * Permission is granted to copy and create derivative works for any
  2569. --- 1,5 ----
  2570.   /*
  2571. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  2572.    * All rights reserved.
  2573.    *
  2574.    * Permission is granted to copy and create derivative works for any
  2575. ***************
  2576. *** 21,27 ****
  2577.   #include "config.h"
  2578.   
  2579.   #ifndef    lint
  2580. ! static    char    sccsid[] = "@(#)obscure.c    3.1    11:31:35    12/19/90";
  2581.   #endif
  2582.   
  2583.   /*
  2584. --- 21,52 ----
  2585.   #include "config.h"
  2586.   
  2587.   #ifndef    lint
  2588. ! static    char    sccsid[] = "@(#)obscure.c    3.2    09:07:51    5/28/91";
  2589. ! #endif
  2590. ! #ifdef    NO_STRSTR
  2591. ! /*
  2592. !  * strstr - find substring in string
  2593. !  */
  2594. ! char *
  2595. ! strstr (string, pattern)
  2596. ! char    *string;
  2597. ! char    *pattern;
  2598. ! {
  2599. !     char    *cp;
  2600. !     int    len;
  2601. !     len = strlen (pattern);
  2602. !     for (cp = string;cp = strchr (cp, *pattern);) {
  2603. !         if (strncmp (cp, pattern, len) == 0)
  2604. !             return cp;
  2605. !         cp++;
  2606. !     }
  2607. !     return 0;
  2608. ! }
  2609.   #endif
  2610.   
  2611.   /*
  2612. *** rel3/pwd.h    Sat May 25 10:22:50 1991
  2613. --- pwd.h    Tue May 28 09:11:01 1991
  2614. ***************
  2615. *** 1,5 ****
  2616.   /*
  2617. !  * Copyright 1990, John F. Haugh II and Steve Simmons
  2618.    * All rights reserved.
  2619.    *
  2620.    * Permission is granted to copy and create derivative works for any
  2621. --- 1,5 ----
  2622.   /*
  2623. !  * Copyright 1990, 1991, John F. Haugh II and Steve Simmons
  2624.    * All rights reserved.
  2625.    *
  2626.    * Permission is granted to copy and create derivative works for any
  2627. ***************
  2628. *** 27,33 ****
  2629.   #ifndef    PWD_H
  2630.   #define    PWD_H
  2631.   
  2632. ! #include    <sys/types.h>
  2633.   
  2634.   /*
  2635.    * For now these are defined here.  Later they should be moved to
  2636. --- 27,36 ----
  2637.   #ifndef    PWD_H
  2638.   #define    PWD_H
  2639.   
  2640. ! #ifdef    M_XENIX
  2641. ! typedef int uid_t;
  2642. ! typedef int gid_t;
  2643. ! #endif
  2644.   
  2645.   /*
  2646.    * For now these are defined here.  Later they should be moved to
  2647. ***************
  2648. *** 77,83 ****
  2649.   };
  2650.   #endif
  2651.   
  2652. ! #ifdef    __STDC__
  2653.   
  2654.   extern    struct    passwd    *getpwent( void ) ;
  2655.   extern    struct    passwd    *getpwuid( uid_t user_uid ) ;
  2656. --- 80,86 ----
  2657.   };
  2658.   #endif
  2659.   
  2660. ! #if    __STDC__
  2661.   
  2662.   extern    struct    passwd    *getpwent( void ) ;
  2663.   extern    struct    passwd    *getpwuid( uid_t user_uid ) ;
  2664. ***************
  2665. *** 93,98 ****
  2666.   int    setpwent();
  2667.   int    endpwent();
  2668.   
  2669. ! #endif    /* of ifdef __STDC__ */
  2670.   
  2671.   #endif    /* of ifdef PWD_H */
  2672. --- 96,101 ----
  2673.   int    setpwent();
  2674.   int    endpwent();
  2675.   
  2676. ! #endif    /* of if __STDC__ */
  2677.   
  2678.   #endif    /* of ifdef PWD_H */
  2679. *** rel3/pwdbm.c    Sat May 25 10:22:42 1991
  2680. --- pwdbm.c    Tue May 28 09:11:02 1991
  2681. ***************
  2682. *** 1,5 ****
  2683.   /*
  2684. !  * Copyright 1990, John F. Haugh II
  2685.    * All rights reserved.
  2686.    *
  2687.    * Permission is granted to copy and create derivative works for any
  2688. --- 1,5 ----
  2689.   /*
  2690. !  * Copyright 1990, 1991, John F. Haugh II
  2691.    * All rights reserved.
  2692.    *
  2693.    * Permission is granted to copy and create derivative works for any
  2694. ***************
  2695. *** 10,16 ****
  2696.    */
  2697.   
  2698.   #ifndef    lint
  2699. ! static    char    sccsid[] = "@(#)pwdbm.c    3.3    12:31:13    12/12/90";
  2700.   #endif
  2701.   
  2702.   #ifdef    BSD
  2703. --- 10,16 ----
  2704.    */
  2705.   
  2706.   #ifndef    lint
  2707. ! static    char    sccsid[] = "@(#)pwdbm.c    3.4    09:08:00    5/28/91";
  2708.   #endif
  2709.   
  2710.   #ifdef    BSD
  2711. ***************
  2712. *** 24,29 ****
  2713. --- 24,31 ----
  2714.   #include "pwd.h"
  2715.   #include "config.h"
  2716.   
  2717. + #if defined(DBM) || defined(NDBM) /*{*/
  2718.   #ifdef    DBM
  2719.   #include <dbm.h>
  2720.   #endif
  2721. ***************
  2722. *** 94,96 ****
  2723. --- 96,100 ----
  2724.   #endif
  2725.       return 1;
  2726.   }
  2727. + #endif    /*} defined(NDBM) || defined(DBM) */
  2728. *** rel3/pwio.c    Sat May 25 10:22:37 1991
  2729. --- pwio.c    Tue May 28 09:11:05 1991
  2730. ***************
  2731. *** 1,5 ****
  2732.   /*
  2733. !  * Copyright 1990, John F. Haugh II
  2734.    * All rights reserved.
  2735.    *
  2736.    * Permission is granted to copy and create derivative works for any
  2737. --- 1,5 ----
  2738.   /*
  2739. !  * Copyright 1990, 1991, John F. Haugh II
  2740.    * All rights reserved.
  2741.    *
  2742.    * Permission is granted to copy and create derivative works for any
  2743. ***************
  2744. *** 23,28 ****
  2745. --- 23,29 ----
  2746.    *    pw_unlock            -- remove password lock
  2747.    */
  2748.   
  2749. + #include <sys/types.h>
  2750.   #include <sys/stat.h>
  2751.   #include <fcntl.h>
  2752.   #include <errno.h>
  2753. ***************
  2754. *** 29,36 ****
  2755.   #include "pwd.h"
  2756.   #include <stdio.h>
  2757.   
  2758.   #ifndef lint
  2759. ! static    char    sccsid[] = "@(#)pwio.c    3.6    12:31:19    12/12/90";
  2760.   #endif
  2761.   
  2762.   static    int    islocked;
  2763. --- 30,43 ----
  2764.   #include "pwd.h"
  2765.   #include <stdio.h>
  2766.   
  2767. + #ifdef    BSD
  2768. + # include <strings.h>
  2769. + #else
  2770. + # include <string.h>
  2771. + #endif
  2772.   #ifndef lint
  2773. ! static    char    sccsid[] = "@(#)pwio.c    3.7    09:08:02    5/28/91";
  2774.   #endif
  2775.   
  2776.   static    int    islocked;
  2777. ***************
  2778. *** 58,63 ****
  2779. --- 65,71 ----
  2780.   static    char    pw_filename[BUFSIZ] = PASSWD;
  2781.   
  2782.   extern    char    *strdup();
  2783. + extern    char    *malloc();
  2784.   extern    struct    passwd    *sgetpwent();
  2785.   
  2786.   /*
  2787. *** rel3/pwunconv.c    Sat May 25 10:22:07 1991
  2788. --- pwunconv.c    Tue May 28 09:11:07 1991
  2789. ***************
  2790. *** 1,5 ****
  2791.   /*
  2792. !  * Copyright 1989, 1990, John F. Haugh II
  2793.    * All rights reserved.
  2794.    *
  2795.    * Permission is granted to copy and create derivative works for any
  2796. --- 1,5 ----
  2797.   /*
  2798. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  2799.    * All rights reserved.
  2800.    *
  2801.    * Permission is granted to copy and create derivative works for any
  2802. ***************
  2803. *** 27,33 ****
  2804.   #include "shadow.h"
  2805.   
  2806.   #ifndef    lint
  2807. ! static    char    sccsid[] = "@(#)pwunconv.c    3.2    12:31:26    12/12/90";
  2808.   #endif
  2809.   
  2810.   #ifdef    ITI_AGING
  2811. --- 27,33 ----
  2812.   #include "shadow.h"
  2813.   
  2814.   #ifndef    lint
  2815. ! static    char    sccsid[] = "@(#)pwunconv.c    3.3    09:08:06    5/28/91";
  2816.   #endif
  2817.   
  2818.   #ifdef    ITI_AGING
  2819. ***************
  2820. *** 108,114 ****
  2821.               pw->pw_age = "";
  2822.   #endif    /* ATT_AGE */
  2823.           if (putpwent (pw, npwd)) {
  2824. !             perror (stderr, "pwunconv: write error");
  2825.               exit (1);
  2826.           }
  2827.       }
  2828. --- 108,114 ----
  2829.               pw->pw_age = "";
  2830.   #endif    /* ATT_AGE */
  2831.           if (putpwent (pw, npwd)) {
  2832. !             perror ("pwunconv: write error");
  2833.               exit (1);
  2834.           }
  2835.       }
  2836. *** rel3/setup.c    Sat May 25 10:22:34 1991
  2837. --- setup.c    Tue May 28 09:11:08 1991
  2838. ***************
  2839. *** 12,18 ****
  2840.   #include <sys/types.h>
  2841.   #include <stdio.h>
  2842.   #include <utmp.h>
  2843. - #include <syslog.h>
  2844.   
  2845.   #ifdef    BSD
  2846.   #include <strings.h>
  2847. --- 12,17 ----
  2848. ***************
  2849. *** 25,32 ****
  2850.   #include "config.h"
  2851.   #include "pwd.h"
  2852.   
  2853.   #ifndef    lint
  2854. ! static    char    sccsid[] = "@(#)setup.c    3.3    07:46:41    2/6/91";
  2855.   #endif
  2856.   
  2857.   #ifndef    PATH
  2858. --- 24,39 ----
  2859.   #include "config.h"
  2860.   #include "pwd.h"
  2861.   
  2862. + #ifdef    USE_SYSLOG
  2863. + #include <syslog.h>
  2864. + #ifndef    LOG_WARN
  2865. + #define    LOG_WARN    LOG_WARNING
  2866. + #endif
  2867. + #endif
  2868.   #ifndef    lint
  2869. ! static    char    sccsid[] = "@(#)setup.c    3.4    09:08:08    5/28/91";
  2870.   #endif
  2871.   
  2872.   #ifndef    PATH
  2873. ***************
  2874. *** 87,94 ****
  2875. --- 94,104 ----
  2876.       (void) strcat (strcpy (tty, "/dev/"), utent.ut_line);
  2877.       if (chown (tty, info->pw_uid, info->pw_gid) || chmod (tty, TTYPERM)) {
  2878.           (void) sprintf (buf, "Unable to change tty %s", tty);
  2879. + #ifdef    USE_SYSLOG
  2880.           syslog (LOG_WARN, "unable to change tty `%s' for user `%s'",
  2881.               tty, info->pw_name);
  2882. +         closelog ();
  2883. + #endif
  2884.           perror (buf);
  2885.           exit (errno);
  2886.       }
  2887. ***************
  2888. *** 95,102 ****
  2889. --- 105,115 ----
  2890.   #endif
  2891.       if (chdir (info->pw_dir) == -1) {
  2892.           (void) sprintf (buf, "Unable to cd to \"%s\"", info->pw_dir);
  2893. + #ifdef    USE_SYSLOG
  2894.           syslog (LOG_WARN, "unable to cd to `%s' for user `%s'",
  2895.               info->pw_dir, info->pw_name);
  2896. +         closelog ();
  2897. + #endif
  2898.           perror (buf);
  2899.           exit (errno);
  2900.       }
  2901. ***************
  2902. *** 130,137 ****
  2903. --- 143,153 ----
  2904.   #endif
  2905.       if (setgid (info->pw_gid) == -1) {
  2906.           puts ("Bad group id");
  2907. + #ifdef    USE_SYSLOG
  2908.           syslog (LOG_WARN, "bad group ID `%d' for user `%s'",
  2909.               info->pw_gid, info->pw_name);
  2910. +         closelog ();
  2911. + #endif
  2912.           exit (errno);
  2913.       }
  2914.   #ifndef    BSD
  2915. ***************
  2916. *** 141,148 ****
  2917. --- 157,167 ----
  2918.   #endif
  2919.       {
  2920.           puts ("Bad user id");
  2921. + #ifdef    USE_SYSLOG
  2922.           syslog (LOG_WARN, "bad user ID `%d' for user `%s'",
  2923.               info->pw_uid, info->pw_name);
  2924. +         closelog ();
  2925. + #endif
  2926.           exit (errno);
  2927.       }
  2928.       (void) strcat (strcpy (buf, "HOME="), info->pw_dir);
  2929. *** rel3/sgroupio.c    Sat May 25 10:22:59 1991
  2930. --- sgroupio.c    Tue May 28 09:11:11 1991
  2931. ***************
  2932. *** 1,5 ****
  2933.   /*
  2934. !  * Copyright 1990, John F. Haugh II
  2935.    * All rights reserved.
  2936.    *
  2937.    * Permission is granted to copy and create derivative works for any
  2938. --- 1,5 ----
  2939.   /*
  2940. !  * Copyright 1990, 1991, John F. Haugh II
  2941.    * All rights reserved.
  2942.    *
  2943.    * Permission is granted to copy and create derivative works for any
  2944. ***************
  2945. *** 23,28 ****
  2946. --- 23,29 ----
  2947.    *    sgr_unlock            -- remove shadow group lock
  2948.    */
  2949.   
  2950. + #include <sys/types.h>
  2951.   #include <sys/stat.h>
  2952.   #include <fcntl.h>
  2953.   #include <errno.h>
  2954. ***************
  2955. *** 37,43 ****
  2956.   #include "shadow.h"
  2957.   
  2958.   #ifndef    lint
  2959. ! static    char    sccsid[] = "@(#)sgroupio.c    3.1    08:13:51    12/14/90";
  2960.   #endif
  2961.   
  2962.   static    int    islocked;
  2963. --- 38,44 ----
  2964.   #include "shadow.h"
  2965.   
  2966.   #ifndef    lint
  2967. ! static    char    sccsid[] = "@(#)sgroupio.c    3.2    09:08:11    5/28/91";
  2968.   #endif
  2969.   
  2970.   static    int    islocked;
  2971. ***************
  2972. *** 67,72 ****
  2973. --- 68,74 ----
  2974.   extern    char    *strdup();
  2975.   extern    struct    sgrp    *sgetgsent();
  2976.   extern    char    *fgetsx();
  2977. + extern    char    *malloc();
  2978.   
  2979.   /*
  2980.    * sgr_dup - duplicate a shadow group file entry
  2981. *** rel3/shadowio.c    Sat May 25 10:22:58 1991
  2982. --- shadowio.c    Tue May 28 09:11:16 1991
  2983. ***************
  2984. *** 1,9 ****
  2985.   /*
  2986. !  * Copyright 1990, John F. Haugh II
  2987.    * All rights reserved.
  2988.    *
  2989. !  * Use, duplication, and disclosure prohibited without
  2990. !  * the express written permission of the author.
  2991.    *
  2992.    *    This file implements a transaction oriented password database
  2993.    *    library.  The password file is updated one entry at a time.
  2994. --- 1,12 ----
  2995.   /*
  2996. !  * Copyright 1990, 1991, John F. Haugh II
  2997.    * All rights reserved.
  2998.    *
  2999. !  * Permission is granted to copy and create derivative works for any
  3000. !  * non-commercial purpose, provided this copyright notice is preserved
  3001. !  * in all copies of source code, or included in human readable form
  3002. !  * and conspicuously displayed on all copies of object code or
  3003. !  * distribution media.
  3004.    *
  3005.    *    This file implements a transaction oriented password database
  3006.    *    library.  The password file is updated one entry at a time.
  3007. ***************
  3008. *** 21,29 ****
  3009.    */
  3010.   
  3011.   #ifndef    lint
  3012. ! static    char    sccsid[] = "@(#)shadowio.c    3.4    07:54:20    12/1/90";
  3013.   #endif
  3014.   
  3015.   #include <sys/stat.h>
  3016.   #include <fcntl.h>
  3017.   #include <errno.h>
  3018. --- 24,33 ----
  3019.    */
  3020.   
  3021.   #ifndef    lint
  3022. ! static    char    sccsid[] = "@(#)shadowio.c    3.5    09:08:15    5/28/91";
  3023.   #endif
  3024.   
  3025. + #include <sys/types.h>
  3026.   #include <sys/stat.h>
  3027.   #include <fcntl.h>
  3028.   #include <errno.h>
  3029. ***************
  3030. *** 60,65 ****
  3031. --- 64,70 ----
  3032.   static    char    spw_filename[BUFSIZ] = SHADOW;
  3033.   
  3034.   extern    char    *strdup();
  3035. + extern    char    *malloc();
  3036.   extern    struct    spwd    *sgetspent();
  3037.   
  3038.   /*
  3039. *** rel3/sub.c    Sat May 25 10:22:48 1991
  3040. --- sub.c    Tue May 28 09:11:18 1991
  3041. ***************
  3042. *** 1,5 ****
  3043.   /*
  3044. !  * Copyright 1989, 1990, John F. Haugh II
  3045.    * All rights reserved.
  3046.    *
  3047.    * Permission is granted to copy and create derivative works for any
  3048. --- 1,5 ----
  3049.   /*
  3050. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  3051.    * All rights reserved.
  3052.    *
  3053.    * Permission is granted to copy and create derivative works for any
  3054. ***************
  3055. *** 10,21 ****
  3056.    */
  3057.   
  3058.   #include <sys/types.h>
  3059.   #include <syslog.h>
  3060.   
  3061.   #include "pwd.h"
  3062.   
  3063.   #ifndef    lint
  3064. ! static    char    sccsid[] = "@(#)sub.c    3.2    08:22:12    1/30/91";
  3065.   #endif
  3066.   
  3067.   #define    BAD_SUBROOT    "Invalid root directory \"%s\"\n"
  3068. --- 10,29 ----
  3069.    */
  3070.   
  3071.   #include <sys/types.h>
  3072. + #include "config.h"
  3073. + #ifdef    USE_SYSLOG
  3074.   #include <syslog.h>
  3075.   
  3076. + #ifndef    LOG_WARN
  3077. + #define    LOG_WARN    LOG_WARNING
  3078. + #endif
  3079. + #endif
  3080.   #include "pwd.h"
  3081.   
  3082.   #ifndef    lint
  3083. ! static    char    sccsid[] = "@(#)sub.c    3.3    09:08:19    5/28/91";
  3084.   #endif
  3085.   
  3086.   #define    BAD_SUBROOT    "Invalid root directory \"%s\"\n"
  3087. ***************
  3088. *** 41,47 ****
  3089. --- 49,58 ----
  3090.   
  3091.       if (pw->pw_dir[0] != '/') {
  3092.           printf (BAD_SUBROOT, pw->pw_dir);
  3093. + #ifdef    USE_SYSLOG
  3094.           syslog (LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name);
  3095. +         closelog ();
  3096. + #endif
  3097.           exit (1);
  3098.       }
  3099.   
  3100. ***************
  3101. *** 52,58 ****
  3102. --- 63,72 ----
  3103.   
  3104.       if (chdir (pw->pw_dir) || chroot (pw->pw_dir)) {
  3105.           printf (NO_SUBROOT, pw->pw_dir);
  3106. + #ifdef    USE_SYSLOG
  3107.           syslog (LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name);
  3108. +         closelog ();
  3109. + #endif
  3110.           exit (1);
  3111.       }
  3112.   }
  3113. *** rel3/sulogin.c    Sat May 25 10:22:15 1991
  3114. --- sulogin.c    Tue May 28 09:11:18 1991
  3115. ***************
  3116. *** 1,5 ****
  3117.   /*
  3118. !  * Copyright 1989, 1990, John F. Haugh II
  3119.    * All rights reserved.
  3120.    *
  3121.    * Permission is granted to copy and create derivative works for any
  3122. --- 1,5 ----
  3123.   /*
  3124. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  3125.    * All rights reserved.
  3126.    *
  3127.    * Permission is granted to copy and create derivative works for any
  3128. ***************
  3129. *** 24,30 ****
  3130.   #include "config.h"
  3131.   
  3132.   #ifndef    lint
  3133. ! static    char    sccsid[] = "@(#)sulogin.c    3.3    12:31:35    12/12/90";
  3134.   #endif
  3135.   
  3136.   char    name[BUFSIZ];
  3137. --- 24,30 ----
  3138.   #include "config.h"
  3139.   
  3140.   #ifndef    lint
  3141. ! static    char    sccsid[] = "@(#)sulogin.c    3.4    09:08:21    5/28/91";
  3142.   #endif
  3143.   
  3144.   char    name[BUFSIZ];
  3145. ***************
  3146. *** 65,70 ****
  3147. --- 65,71 ----
  3148.   {
  3149.       char    *getenv ();
  3150.       char    *ttyname ();
  3151. +     char    *getpass ();
  3152.       char    *cp;
  3153.   
  3154.       if (access (PWDFILE, 0) == -1) { /* must be a password file! */
  3155. *** rel3/utmp.c    Sat May 25 10:22:23 1991
  3156. --- utmp.c    Tue May 28 09:11:19 1991
  3157. ***************
  3158. *** 1,5 ****
  3159.   /*
  3160. !  * Copyright 1989, 1990, John F. Haugh II
  3161.    * All rights reserved.
  3162.    *
  3163.    * Permission is granted to copy and create derivative works for any
  3164. --- 1,5 ----
  3165.   /*
  3166. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  3167.    * All rights reserved.
  3168.    *
  3169.    * Permission is granted to copy and create derivative works for any
  3170. ***************
  3171. *** 25,31 ****
  3172.   #include "config.h"
  3173.   
  3174.   #ifndef    lint
  3175. ! static    char    sccsid[] = "%W%    %U%    %G%";
  3176.   #endif
  3177.   
  3178.   extern    struct    utmp    utent;
  3179. --- 25,31 ----
  3180.   #include "config.h"
  3181.   
  3182.   #ifndef    lint
  3183. ! static    char    sccsid[] = "@(#)utmp.c    3.4    09:08:23    5/28/91";
  3184.   #endif
  3185.   
  3186.   extern    struct    utmp    utent;
  3187. ***************
  3188. *** 138,144 ****
  3189.       close (fd);
  3190.   
  3191.       if ((wtmp = fopen (WTMP_FILE, "a+"))) {
  3192. !         fwrite (&utent, sizeof utent, 1, wtmp);
  3193.           fclose (wtmp);
  3194.       }
  3195.   }
  3196. --- 138,144 ----
  3197.       close (fd);
  3198.   
  3199.       if ((wtmp = fopen (WTMP_FILE, "a+"))) {
  3200. !         fwrite ((char *) &utent, sizeof utent, 1, wtmp);
  3201.           fclose (wtmp);
  3202.       }
  3203.   }
  3204. *** rel3/chage.c    Tue May 28 09:14:40 1991
  3205. --- chage.c    Wed May 29 06:35:11 1991
  3206. ***************
  3207. *** 17,23 ****
  3208.   #include <time.h>
  3209.   
  3210.   #ifndef    lint
  3211. ! static    char    sccsid[] = "@(#)chage.c    3.6    09:06:57    5/28/91";
  3212.   #endif
  3213.   
  3214.   /*
  3215. --- 17,23 ----
  3216.   #include <time.h>
  3217.   
  3218.   #ifndef    lint
  3219. ! static    char    sccsid[] = "@(#)chage.c    3.7    06:35:00    5/29/91";
  3220.   #endif
  3221.   
  3222.   /*
  3223. ***************
  3224. *** 320,326 ****
  3225.        */
  3226.   
  3227.       printf ("Last Change:\t\t");
  3228. !     if (changed <= 0) {
  3229.           printf ("Never\n");
  3230.       } else {
  3231.           changed = lastday * SCALE;
  3232. --- 320,326 ----
  3233.        */
  3234.   
  3235.       printf ("Last Change:\t\t");
  3236. !     if (lastday <= 0) {
  3237.           printf ("Never\n");
  3238.       } else {
  3239.           changed = lastday * SCALE;
  3240. ***************
  3241. *** 336,342 ****
  3242.        */
  3243.   
  3244.       printf ("Password Expires:\t");
  3245. !     if (changed <= 0 || maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
  3246.           printf ("Never\n");
  3247.       } else {
  3248.           expires = changed + maxdays * SCALE;
  3249. --- 336,342 ----
  3250.        */
  3251.   
  3252.       printf ("Password Expires:\t");
  3253. !     if (lastday <= 0 || maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
  3254.           printf ("Never\n");
  3255.       } else {
  3256.           expires = changed + maxdays * SCALE;
  3257. ***************
  3258. *** 353,359 ****
  3259.        */
  3260.   
  3261.       printf ("Password Inactive:\t");
  3262. !     if (changed <= 0 || inactdays <= 0 ||
  3263.               maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
  3264.           printf ("Never\n");
  3265.       } else {
  3266. --- 353,359 ----
  3267.        */
  3268.   
  3269.       printf ("Password Inactive:\t");
  3270. !     if (lastday <= 0 || inactdays <= 0 ||
  3271.               maxdays >= 10000*(DAY/SCALE) || maxdays <= 0) {
  3272.           printf ("Never\n");
  3273.       } else {
  3274. -- 
  3275. John F. Haugh II        | Distribution to  | UUCP: ...!cs.utexas.edu!rpp386!jfh
  3276. Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) |  Domain: jfh@rpp386.cactus.org
  3277. "If liberals interpreted the 2nd Amendment the same way they interpret the
  3278.  rest of the Constitution, gun ownership would be mandatory."
  3279.