home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3454 < prev    next >
Encoding:
Internet Message Format  |  1991-06-07  |  24.9 KB

  1. From: jfh@rpp386.cactus.org (John F Haugh II)
  2. Newsgroups: alt.sources
  3. Subject: Shadow Login Suite, patch 3
  4. Message-ID: <19363@rpp386.cactus.org>
  5. Date: 6 Jun 91 15:06:34 GMT
  6.  
  7.  
  8. Chip Rosenthal has provided me with a large collection of fixes for the
  9. code, and many of them are included here.  I've been working on implementing
  10. the SVR4 "useradd" and "userdel" command, and some of these changes were
  11. required to support those commands.  Patch 4 will include useradd, usermod
  12. and userdel, as well as the documentation for those three commands.  I will
  13. probably do groupadd, groupmod and groupdel for Patch 5 or 6.
  14.  
  15. There is someone down under working on a port to SunOS and I expect those
  16. changes to show up in the next patch or two.
  17. --
  18. Changes -
  19.  
  20. dialup.c 3.4
  21. made code more robust, added support for shell name default to "*"
  22.  
  23. utmp.c 3.7
  24. fixed strncmp and strncpy calls in BSD part of an ifdef
  25.  
  26. README 3.3
  27. added DBM and SYSLOG comments
  28.  
  29. Makefile 3.10
  30. fixed lint flags to get around command bug
  31.  
  32. config.h 3.7
  33. removed NOBLANK option.
  34.  
  35. passwd.c 3.3
  36. don't need to print CHANGING message with -S flag
  37.  
  38. sgroupio.c 3.3
  39. fixed misspelt function calls
  40.  
  41. gshadow.c 3.4
  42. fixed bugs with variable names
  43.  
  44. pwdbm.c 3.5
  45. added pw_dbm_remove function
  46.  
  47. spdbm.c 3.2
  48. added sp_dbm_remove function
  49.  
  50. gpmain.c 3.6
  51. list addition/deletion had bugs
  52.  
  53. *** rel3/dialup.c    Thu May 30 07:02:56 1991
  54. --- dialup.c    Tue Jun  4 08:15:10 1991
  55. ***************
  56. *** 1,5 ****
  57.   /*
  58. !  * Copyright 1989, 1990, John F. Haugh II
  59.    * All rights reserved.
  60.    *
  61.    * Permission is granted to copy and create derivative works for any
  62. --- 1,5 ----
  63.   /*
  64. !  * Copyright 1989, 1990, 1991, John F. Haugh II
  65.    * All rights reserved.
  66.    *
  67.    * Permission is granted to copy and create derivative works for any
  68. ***************
  69. *** 20,26 ****
  70.   #include "dialup.h"
  71.   
  72.   #ifndef    lint
  73. ! static    char    sccsid[] = "@(#)dialup.c    3.3    19:44:20    12/10/90";
  74.   #endif
  75.   
  76.   static    FILE    *dialpwd;
  77. --- 20,26 ----
  78.   #include "dialup.h"
  79.   
  80.   #ifndef    lint
  81. ! static    char    sccsid[] = "@(#)dialup.c    3.4    07:58:44    5/30/91";
  82.   #endif
  83.   
  84.   static    FILE    *dialpwd;
  85. ***************
  86. *** 48,57 ****
  87.   FILE    *fp;
  88.   {
  89.       static    struct    dialup    dialup;    /* static structure to point to */
  90. !     static    char    shell[64];    /* some space for a login shell */
  91. !     static    char    passwd[16];    /* some space for dialup password */
  92.       char    buf[BUFSIZ];
  93.       char    *cp;
  94.   
  95.       if (! fp)
  96.           return 0;
  97. --- 48,58 ----
  98.   FILE    *fp;
  99.   {
  100.       static    struct    dialup    dialup;    /* static structure to point to */
  101. !     static    char    shell[128];    /* some space for a login shell */
  102. !     static    char    passwd[128];    /* some space for dialup password */
  103.       char    buf[BUFSIZ];
  104.       char    *cp;
  105. +     char    *cp2;
  106.   
  107.       if (! fp)
  108.           return 0;
  109. ***************
  110. *** 65,84 ****
  111.       if (feof (fp))
  112.           return ((struct dialup *) 0);
  113.   
  114. !     cp = strchr (buf, ':');
  115.       if (cp - buf > sizeof shell)    /* something is fishy ... */
  116.           return ((struct dialup *) 0);
  117.   
  118. !     (void) strncpy (shell, buf, cp - buf);
  119.       shell[cp - buf] = '\0';
  120.   
  121. !     if (strlen (cp + 1) > sizeof passwd) /* something is REALLY fishy */
  122.           return ((struct dialup *) 0);
  123.   
  124. !     (void) strcpy (passwd, cp + 1);
  125. !     passwd[strlen (passwd) - 1] = '\0';
  126. !     if (cp = strchr (passwd, ':'))
  127. !         *cp = '\0';
  128.   
  129.       dialup.du_shell = shell;
  130.       dialup.du_passwd = passwd;
  131. --- 66,88 ----
  132.       if (feof (fp))
  133.           return ((struct dialup *) 0);
  134.   
  135. !     if (! (cp = strchr (buf, ':')))
  136. !         return ((struct dialup *) 0);
  137.       if (cp - buf > sizeof shell)    /* something is fishy ... */
  138.           return ((struct dialup *) 0);
  139.   
  140. !     *cp++ = '\0';
  141. !     (void) strcpy (shell, buf);
  142.       shell[cp - buf] = '\0';
  143.   
  144. !     if (cp2 = strchr (cp, ':'))
  145. !         *cp2 = '\0';
  146. !     if (strlen (cp) + 1 > sizeof passwd) /* something is REALLY fishy */
  147.           return ((struct dialup *) 0);
  148.   
  149. !     (void) strcpy (passwd, cp);
  150.   
  151.       dialup.du_shell = shell;
  152.       dialup.du_passwd = passwd;
  153. *** rel3/utmp.c    Thu May 30 07:04:51 1991
  154. --- utmp.c    Thu Jun  6 09:32:47 1991
  155. ***************
  156. *** 25,44 ****
  157.   #include "config.h"
  158.   
  159.   #ifndef    lint
  160. ! static    char    sccsid[] = "@(#)utmp.c    3.4    09:08:23    5/28/91";
  161.   #endif
  162.   
  163.   extern    struct    utmp    utent;
  164. - extern    char    name[];
  165.   
  166.   extern    struct    utmp    *getutent();
  167.   extern    void    setutent();
  168.   extern    void    endutent();
  169.   extern    time_t    time();
  170.   extern    char    *ttyname();
  171.   
  172.   #define    NO_UTENT \
  173.       "No utmp entry.  You must exec \"login\" from the lowest level \"sh\""
  174.   
  175.   /*
  176.    * checkutmp - see if utmp file is correct for this process
  177. --- 25,47 ----
  178.   #include "config.h"
  179.   
  180.   #ifndef    lint
  181. ! static    char    sccsid[] = "@(#)utmp.c    3.7    09:49:56    6/5/91";
  182.   #endif
  183.   
  184.   extern    struct    utmp    utent;
  185.   
  186.   extern    struct    utmp    *getutent();
  187. + extern    struct    utmp    *getutline();
  188.   extern    void    setutent();
  189.   extern    void    endutent();
  190.   extern    time_t    time();
  191.   extern    char    *ttyname();
  192. + extern    long    lseek();
  193.   
  194.   #define    NO_UTENT \
  195.       "No utmp entry.  You must exec \"login\" from the lowest level \"sh\""
  196. + #define    NO_TTY \
  197. +     "Unable to determine your tty name."
  198.   
  199.   /*
  200.    * checkutmp - see if utmp file is correct for this process
  201. ***************
  202. *** 47,52 ****
  203. --- 50,60 ----
  204.    *    and requires that a slot for the current process exist.
  205.    *    The utmp file is scanned for an entry with the same process
  206.    *    ID.  If no entry exists the process exits with a message.
  207. +  *
  208. +  *    The "picky" flag is for network and other logins that may
  209. +  *    use special flags.  It allows the pid checks to be overridden.
  210. +  *    This means that getty should never invoke login with any
  211. +  *    command line flags.
  212.    */
  213.   
  214.   void
  215. ***************
  216. *** 53,65 ****
  217.   checkutmp (picky)
  218.   int    picky;
  219.   {
  220. -     struct    utmp    *ut;
  221.       char    *line;
  222.   #ifndef    NDEBUG
  223.       int    pid = getppid ();
  224.   #else
  225.       int    pid = getpid ();
  226.   #endif
  227.       setutent ();
  228.   
  229.   #ifndef    BSD
  230. --- 61,75 ----
  231.   checkutmp (picky)
  232.   int    picky;
  233.   {
  234.       char    *line;
  235. + #ifdef    USG
  236. +     struct    utmp    *ut;
  237.   #ifndef    NDEBUG
  238.       int    pid = getppid ();
  239.   #else
  240.       int    pid = getpid ();
  241.   #endif
  242. + #endif
  243.       setutent ();
  244.   
  245.   #ifndef    BSD
  246. ***************
  247. *** 76,98 ****
  248.           if (ut && utent.ut_pid == pid)
  249.               return;
  250.   
  251. !         puts (NO_UTENT);
  252.           exit (1);
  253.       } else {
  254. !         line = ttyname (0);
  255.           if (strncmp (line, "/dev/", 5) == 0)
  256.               line += 5;
  257.   
  258. !         strncpy (utent.ut_line, line, sizeof utent.ut_line);
  259.           if (ut = getutline (&utent))
  260. !             strncpy (utent.ut_id, ut->ut_id, sizeof ut->ut_id);
  261.   
  262. !         strcpy (utent.ut_user, "LOGIN");
  263.           utent.ut_pid = getpid ();
  264.           utent.ut_type = LOGIN_PROCESS;
  265. !         time (&utent.ut_time);
  266.       }
  267.   #endif
  268.   }
  269.   
  270.   /*
  271. --- 86,126 ----
  272.           if (ut && utent.ut_pid == pid)
  273.               return;
  274.   
  275. !         (void) puts (NO_UTENT);
  276.           exit (1);
  277.       } else {
  278. !         if (! (line = ttyname (0))) {
  279. !             (void) puts (NO_TTY);
  280. !             exit (1);
  281. !         }
  282.           if (strncmp (line, "/dev/", 5) == 0)
  283.               line += 5;
  284.   
  285. !         (void) strncpy (utent.ut_line, line,
  286. !                 (int) sizeof utent.ut_line);
  287.           if (ut = getutline (&utent))
  288. !             (void) strncpy (utent.ut_id, ut->ut_id,
  289. !                     (int) sizeof ut->ut_id);
  290.   
  291. !         (void) strcpy (utent.ut_user, "LOGIN");
  292.           utent.ut_pid = getpid ();
  293.           utent.ut_type = LOGIN_PROCESS;
  294. !         (void) time (&utent.ut_time);
  295. !         return;
  296. !     }
  297. ! #else
  298. !     bzero (&utent, sizeof utent);
  299. !     if (line = ttyname (0)) {
  300. !         if (strncmp (line, "/dev/", 5) == 0)
  301. !             line += 5;
  302. !         (void) strncpy (utent.ut_line, line, (int) sizeof utent.ut_line);
  303. !         (void) time (&utent.ut_time);
  304. !         return;
  305.       }
  306.   #endif
  307. +     (void) puts (NO_TTY);
  308. +     exit (1);
  309.   }
  310.   
  311.   /*
  312. ***************
  313. *** 107,144 ****
  314.   char    *name;
  315.   char    *line;
  316.   {
  317. !     FILE    *wtmp;
  318. !     struct    utmp    utent;
  319.       int    fd;
  320. -     int    i;
  321.       int    found = 0;
  322.   
  323.       if (! (fd = open ("/etc/utmp", O_RDWR)))
  324.           return;
  325.   
  326. !     while (! found && read (fd, &utent, sizeof utent) == sizeof utent) {
  327. !         if (! strncmp (line, utent.ut_line, sizeof utent.ut_line))
  328.               found++;
  329.       }
  330.       if (! found) {
  331. !         bzero (&utent, sizeof utent);
  332. !         strncpy (utent.ut_line, line, sizeof utent.ut_line);
  333.       }
  334. -     (void) strncpy (utent.ut_user, name, sizeof utent.ut_user);
  335.   #ifndef    BSD
  336. !     utent.ut_type = USER_PROCESS;
  337. !     utent.ut_pid = getpid ();
  338.   #endif
  339. !     (void) time (&utent.ut_time);
  340.   
  341.       if (found)
  342. !         lseek (fd, (long) - sizeof utent, 1);
  343.   
  344. !     write (fd, &utent, sizeof utent);
  345. !     close (fd);
  346.   
  347. !     if ((wtmp = fopen (WTMP_FILE, "a+"))) {
  348. !         fwrite ((char *) &utent, sizeof utent, 1, wtmp);
  349. !         fclose (wtmp);
  350.       }
  351.   }
  352. --- 135,173 ----
  353.   char    *name;
  354.   char    *line;
  355.   {
  356. !     struct    utmp    utmp;
  357.       int    fd;
  358.       int    found = 0;
  359.   
  360.       if (! (fd = open ("/etc/utmp", O_RDWR)))
  361.           return;
  362.   
  363. !     while (! found && read (fd, &utmp, sizeof utmp) == sizeof utmp) {
  364. !         if (! strncmp (line, utmp.ut_line, (int) sizeof utmp.ut_line))
  365.               found++;
  366.       }
  367.       if (! found) {
  368. !         (void) bzero (&utmp, sizeof utmp);
  369. !         (void) strncpy (utmp.ut_line, line, (int) sizeof utmp.ut_line);
  370.       }
  371.   #ifndef    BSD
  372. !     (void) strncpy (utmp.ut_user, name, (int) sizeof utmp.ut_user);
  373. !     utmp.ut_type = USER_PROCESS;
  374. !     utmp.ut_pid = getpid ();
  375. ! #else
  376. !     (void) strncpy (utmp.ut_name, name, (int) sizeof utmp.ut_name);
  377.   #endif
  378. !     (void) time (&utmp.ut_time);
  379.   
  380.       if (found)
  381. !         (void) lseek (fd, (long) - sizeof utmp, 1);
  382.   
  383. !     (void) write (fd, &utmp, sizeof utmp);
  384. !     (void) close (fd);
  385.   
  386. !     if ((fd = open (WTMP_FILE, O_WRONLY|O_APPEND)) >= 0) {
  387. !         (void) write (fd, &utmp, sizeof utmp);
  388. !         (void) close (fd);
  389.       }
  390. +     utent = utmp;
  391.   }
  392. *** rel3/README    Thu May 30 07:02:41 1991
  393. --- README    Thu Jun  6 09:32:49 1991
  394. ***************
  395. *** 1,9 ****
  396.   This is the explanatory document for John F. Haugh II's login replacement,
  397. ! release 3.  This document was last updated 11/21/90.
  398.   
  399. ! This software is copyright 1988, 1989, 1990, John F. Haugh II.  All rights
  400. ! reserved.  Use, duplication and disclosure is permitted according to the
  401. ! guidelines listed below.
  402.   
  403.   This software is being provided as a freely redistributable login clone.
  404.   You may distribute this software provided you do not charge for other than
  405. --- 1,11 ----
  406. + [    @(#)README    3.3    08:56:06    5/30/91    ]
  407.   This is the explanatory document for John F. Haugh II's login replacement,
  408. ! release 3.  This document was last updated 5/30/91.
  409.   
  410. ! This software is copyright 1988, 1989, 1990, 1991, John F. Haugh II.  All
  411. ! rights reserved.  Use, duplication and disclosure is permitted according
  412. ! to the guidelines listed below.
  413.   
  414.   This software is being provided as a freely redistributable login clone.
  415.   You may distribute this software provided you do not charge for other than
  416. ***************
  417. *** 27,35 ****
  418.   New for Release 3:
  419.       The objects are being combined into libraries to make maintenance
  420.       easier and to encourage developers to use the modules as the
  421. !     basis for new tools.
  422.   
  423.       New lint rules have been added to make the code easier to lint.
  424.   
  425.   Begin by reading and editing the config.h file.  All options are selected
  426.   by using #define's.  A brief description for each available option appears
  427. --- 29,43 ----
  428.   New for Release 3:
  429.       The objects are being combined into libraries to make maintenance
  430.       easier and to encourage developers to use the modules as the
  431. !     basis for new tools.  New tools are planned based on SVR4 commands.
  432.   
  433.       New lint rules have been added to make the code easier to lint.
  434. +     Files will gradually be fixed so that they lint cleanly.
  435. +     DBM file access has been added to everything that would tolerate
  436. +     it.  The files /etc/passwd, /etc/group, and /etc/shadow all have
  437. +     DBM interfaces.  The new file, /etc/gshadow, has been added to
  438. +     support shadowed group information and it too has a DBM interface.
  439.   
  440.   Begin by reading and editing the config.h file.  All options are selected
  441.   by using #define's.  A brief description for each available option appears
  442. ***************
  443. *** 70,76 ****
  444.   DBM Password Files -
  445.       This option utilizes the DBM database access routines to
  446.       increase the performance of user name and ID lookups in the
  447. !     password file.
  448.   
  449.       Select this option by defining both the DBM and GETPWENT
  450.       macros.  The FGETPWENT macro must also be defined or the
  451. --- 78,85 ----
  452.   DBM Password Files -
  453.       This option utilizes the DBM database access routines to
  454.       increase the performance of user name and ID lookups in the
  455. !     password file.  You may select the NDBM database instead
  456. !     and have DBM-style access to all user information files.
  457.   
  458.       Select this option by defining both the DBM and GETPWENT
  459.       macros.  The FGETPWENT macro must also be defined or the
  460. ***************
  461. *** 94,108 ****
  462.       Additionally, the PASSLENGTH macro must be defined to
  463.       control the minimum length for a legal password.
  464.   
  465. - Mandatory Password Prompting -
  466. -     This option requires all passwords, including null ones,
  467. -     to be prompted for.  Traditionally an account with a
  468. -     password field of '::' does not require prompting for.
  469. -     This option modifies this behavior to require even
  470. -     null passwords be prompted for.
  471. -     Select this option by defining the NOBLANK macro.
  472.   Password Aging Defaults -
  473.       You may select the default number of days during which a
  474.       password is valid.  The pwconv command adds aging
  475. --- 103,108 ----
  476. ***************
  477. *** 169,175 ****
  478.       This option permits you to specify a file which disables
  479.       user logins.  This options permits you to keep normal
  480.       users off of the system while performing maintenance
  481. !     functions.
  482.   
  483.       Select this option by defining NOLOGINS to be the name
  484.       of the file to use.
  485. --- 169,176 ----
  486.       This option permits you to specify a file which disables
  487.       user logins.  This options permits you to keep normal
  488.       users off of the system while performing maintenance
  489. !     functions.  The contents of the file will be displayed if
  490. !     the file exists at login time.
  491.   
  492.       Select this option by defining NOLOGINS to be the name
  493.       of the file to use.
  494. ***************
  495. *** 261,267 ****
  496.   
  497.       Select this option by defining the SULOG macro to
  498.       have the value of the name of the file you want
  499. !     attempts logged to.
  500.   
  501.   Configurable Editing Keys -
  502.       This options allows the erase and kill characters to
  503. --- 262,270 ----
  504.   
  505.       Select this option by defining the SULOG macro to
  506.       have the value of the name of the file you want
  507. !     attempts logged to.  If you enable syslog processing,
  508. !     you may want to define SULOGONLY to prevent multiple
  509. !     records of su(1) usage.  See config.h for more details.
  510.   
  511.   Configurable Editing Keys -
  512.       This options allows the erase and kill characters to
  513. ***************
  514. *** 284,289 ****
  515. --- 287,301 ----
  516.       
  517.       Warning: These values will not apply to processes
  518.       executed by /etc/cron or any of their children.
  519. + Syslog -
  520. +     This option causes the code to log various errors or
  521. +     special conditions to the syslog daemon.  The types of
  522. +     information that are logged security violations, changes
  523. +     to the user database, and program errors.
  524. +     Select syslog processing by defining the USE_SYSLOG
  525. +     macro.
  526.   
  527.   BSD Notes:    Steve Simmons    scs@iti.org
  528.   
  529. *** rel3/Makefile    Thu May 30 07:04:20 1991
  530. --- Makefile    Thu Jun  6 09:32:51 1991
  531. ***************
  532. *** 8,16 ****
  533.   # and conspicuously displayed on all copies of object code or
  534.   # distribution media.
  535.   #
  536. ! #    @(#)Makefile    3.9    09:06:23  - Shadow password system
  537.   #
  538. ! #    @(#)Makefile    3.9    09:06:23    5/28/91
  539.   #
  540.   SHELL = /bin/sh
  541.   
  542. --- 8,16 ----
  543.   # and conspicuously displayed on all copies of object code or
  544.   # distribution media.
  545.   #
  546. ! #    @(#)Makefile    3.10    09:05:50  - Shadow password system
  547.   #
  548. ! #    @(#)Makefile    3.10    09:05:50    5/30/91
  549.   #
  550.   SHELL = /bin/sh
  551.   
  552. ***************
  553. *** 67,73 ****
  554.   LINTFLAGS = $(OS) -Dlint
  555.   
  556.   .c.L:
  557. !     $(LINT) -u $(LINTFLAGS) $*.c > $*.L
  558.   
  559.   LOBJS = lmain.o login.o env.o valid.o setup.o shell.o age.o \
  560.       utmp.o sub.o mail.o motd.o log.o ttytype.o failure.o
  561. --- 67,73 ----
  562.   LINTFLAGS = $(OS) -Dlint
  563.   
  564.   .c.L:
  565. !     $(LINT) -pxu $(LINTFLAGS) $*.c > $*.L
  566.   
  567.   LOBJS = lmain.o login.o env.o valid.o setup.o shell.o age.o \
  568.       utmp.o sub.o mail.o motd.o log.o ttytype.o failure.o
  569. *** rel3/config.h    Thu May 30 07:04:21 1991
  570. --- config.h    Sun Jun  2 16:03:33 1991
  571. ***************
  572. *** 12,18 ****
  573.   /*
  574.    * Configuration file for login.
  575.    *
  576. !  *    @(#)config.h    3.6    09:18:23    5/28/91
  577.    */
  578.   
  579.   /*
  580. --- 12,18 ----
  581.   /*
  582.    * Configuration file for login.
  583.    *
  584. !  *    @(#)config.h    3.7    08:57:09    5/30/91
  585.    */
  586.   
  587.   /*
  588. ***************
  589. *** 53,64 ****
  590.    */
  591.   
  592.   #define    PASSLENGTH    5
  593. - /*
  594. -  * Define NOBLANK if you want all passwords prompted for, including
  595. -  * empty ones.
  596. - #undef    NOBLANK
  597.   
  598.   /*
  599.    * Define MAXDAYS to be the default maximum number of days a password
  600. --- 53,58 ----
  601. *** rel3/passwd.c    Thu May 30 07:04:21 1991
  602. --- passwd.c    Tue Jun  4 09:11:10 1991
  603. ***************
  604. *** 16,22 ****
  605.   #include <signal.h>
  606.   
  607.   #ifndef    lint
  608. ! static    char    sccsid[] = "@(#)passwd.c    3.2    09:06:29    5/28/91";
  609.   #endif
  610.   
  611.   /*
  612. --- 16,22 ----
  613.   #include <signal.h>
  614.   
  615.   #ifndef    lint
  616. ! static    char    sccsid[] = "@(#)passwd.c    3.3    08:50:26    6/4/91";
  617.   #endif
  618.   
  619.   /*
  620. ***************
  621. *** 605,611 ****
  622.        * Let the user know whose password is being changed.
  623.        */
  624.   
  625. !     printf (CHANGING, name);
  626.   
  627.       /*
  628.        * The user name is valid, so let's get the shadow file
  629. --- 605,612 ----
  630.        * Let the user know whose password is being changed.
  631.        */
  632.   
  633. !     if (! Sflg)
  634. !         printf (CHANGING, name);
  635.   
  636.       /*
  637.        * The user name is valid, so let's get the shadow file
  638. *** rel3/sgroupio.c    Thu May 30 07:04:49 1991
  639. --- sgroupio.c    Thu Jun  6 07:23:39 1991
  640. ***************
  641. *** 38,44 ****
  642.   #include "shadow.h"
  643.   
  644.   #ifndef    lint
  645. ! static    char    sccsid[] = "@(#)sgroupio.c    3.2    09:08:11    5/28/91";
  646.   #endif
  647.   
  648.   static    int    islocked;
  649. --- 38,44 ----
  650.   #include "shadow.h"
  651.   
  652.   #ifndef    lint
  653. ! static    char    sccsid[] = "@(#)sgroupio.c    3.3    07:06:36    6/6/91";
  654.   #endif
  655.   
  656.   static    int    islocked;
  657. ***************
  658. *** 66,72 ****
  659.   static    char    sg_filename[BUFSIZ] = SGROUP;
  660.   
  661.   extern    char    *strdup();
  662. ! extern    struct    sgrp    *sgetgsent();
  663.   extern    char    *fgetsx();
  664.   extern    char    *malloc();
  665.   
  666. --- 66,72 ----
  667.   static    char    sg_filename[BUFSIZ] = SGROUP;
  668.   
  669.   extern    char    *strdup();
  670. ! extern    struct    sgrp    *sgetsgent();
  671.   extern    char    *fgetsx();
  672.   extern    char    *malloc();
  673.   
  674. ***************
  675. *** 338,344 ****
  676.   
  677.           sgrf->sgr_changed = 0;
  678.           sgrf->sgr_line = strdup (buf);
  679. !         if ((sgrent = sgetgsent (buf)) && ! (sgrent = sgr_dup (sgrent)))
  680.               return 0;
  681.   
  682.           sgrf->sgr_entry = sgrent;
  683. --- 338,344 ----
  684.   
  685.           sgrf->sgr_changed = 0;
  686.           sgrf->sgr_line = strdup (buf);
  687. !         if ((sgrent = sgetsgent (buf)) && ! (sgrent = sgr_dup (sgrent)))
  688.               return 0;
  689.   
  690.           sgrf->sgr_entry = sgrent;
  691. ***************
  692. *** 421,427 ****
  693.   
  694.           for (sgrf = sgr_head;! errors && sgrf;sgrf = sgrf->sgr_next) {
  695.               if (sgrf->sgr_changed) {
  696. !                 if (putgsent (sgrf->sgr_entry, sgrfp))
  697.                       errors++;
  698.               } else {
  699.                   if (fputsx (sgrf->sgr_line, sgrfp))
  700. --- 421,427 ----
  701.   
  702.           for (sgrf = sgr_head;! errors && sgrf;sgrf = sgrf->sgr_next) {
  703.               if (sgrf->sgr_changed) {
  704. !                 if (putsgent (sgrf->sgr_entry, sgrfp))
  705.                       errors++;
  706.               } else {
  707.                   if (fputsx (sgrf->sgr_line, sgrfp))
  708. *** rel3/gshadow.c    Thu May 30 07:03:27 1991
  709. --- gshadow.c    Thu Jun  6 08:08:00 1991
  710. ***************
  711. *** 1,5 ****
  712.   /*
  713. !  * Copyright 1990, John F. Haugh II
  714.    * All rights reserved.
  715.    *
  716.    * Permission is granted to copy and create derivative works for any
  717. --- 1,5 ----
  718.   /*
  719. !  * Copyright 1990, 1991, John F. Haugh II
  720.    * All rights reserved.
  721.    *
  722.    * Permission is granted to copy and create derivative works for any
  723. ***************
  724. *** 24,31 ****
  725.   #ifdef    NDBM
  726.   #include <ndbm.h>
  727.   #include <fcntl.h>
  728. ! DBM    *sg_dbm;
  729. ! int    sg_dbm_mode;
  730.   static    int    dbmopened;
  731.   static    int    dbmerror;
  732.   #endif
  733. --- 24,31 ----
  734.   #ifdef    NDBM
  735.   #include <ndbm.h>
  736.   #include <fcntl.h>
  737. ! DBM    *sgr_dbm;
  738. ! int    sg_dbm_mode = -1;
  739.   static    int    dbmopened;
  740.   static    int    dbmerror;
  741.   #endif
  742. ***************
  743. *** 32,38 ****
  744.   
  745.   
  746.   #ifndef    lint
  747. ! static    char    sccsid[] = "@(#)gshadow.c    3.3    11:25:55    12/19/90";
  748.   #endif
  749.   
  750.   #define    MAXMEM    1024
  751. --- 32,38 ----
  752.   
  753.   
  754.   #ifndef    lint
  755. ! static    char    sccsid[] = "@(#)gshadow.c    3.4    07:31:22    6/6/91";
  756.   #endif
  757.   
  758.   #define    MAXMEM    1024
  759. ***************
  760. *** 88,101 ****
  761.   
  762.           strcpy (dbmfiles, sgrpfile);
  763.           strcat (dbmfiles, ".pag");
  764. !         if (sg_dbm_mode != -1)
  765. !             mode = O_RDONLY;
  766.           else
  767. !             mode = (sg_dbm_mode == O_RDONLY ||
  768. !                 sg_dbm_mode == O_RDWR) ? sg_dbm_mode:O_RDONLY;
  769.   
  770.           if (access (dbmfiles, 0) ||
  771. !             (! (sg_dbm = dbm_open (sgrpfile, mode, 0))))
  772.               dbmerror = 1;
  773.           else
  774.               dbmopened = 1;
  775. --- 88,101 ----
  776.   
  777.           strcpy (dbmfiles, sgrpfile);
  778.           strcat (dbmfiles, ".pag");
  779. !         if (sg_dbm_mode == -1)
  780. !             mode = O_RDWR;
  781.           else
  782. !             mode = (sg_dbm_mode == O_RDWR) ? O_RDWR:O_RDONLY;
  783.   
  784.           if (access (dbmfiles, 0) ||
  785. !             (! (sgr_dbm = dbm_open (sgrpfile, mode, 0))))
  786.               dbmerror = 1;
  787.           else
  788.               dbmopened = 1;
  789. ***************
  790. *** 111,120 ****
  791.   
  792.       shadow = (FILE *) 0;
  793.   #ifdef    NDBM
  794. !     if (dbmopened && sg_dbm) {
  795. !         dbm_close (sg_dbm);
  796.           dbmopened = 0;
  797. !         sg_dbm = 0;
  798.       }
  799.   #endif
  800.   }
  801. --- 111,120 ----
  802.   
  803.       shadow = (FILE *) 0;
  804.   #ifdef    NDBM
  805. !     if (dbmopened && sgr_dbm) {
  806. !         dbm_close (sgr_dbm);
  807.           dbmopened = 0;
  808. !         sgr_dbm = 0;
  809.       }
  810.   #endif
  811.   }
  812. ***************
  813. *** 204,210 ****
  814.           key.dsize = strlen (name);
  815.           key.dptr = name;
  816.   
  817. !         content = dbm_fetch (sg_dbm, key);
  818.           if (content.dptr != 0) {
  819.               memcpy (sgrbuf, content.dptr, content.dsize);
  820.               sgroup.sg_mem = members;
  821. --- 204,210 ----
  822.           key.dsize = strlen (name);
  823.           key.dptr = name;
  824.   
  825. !         content = dbm_fetch (sgr_dbm, key);
  826.           if (content.dptr != 0) {
  827.               memcpy (sgrbuf, content.dptr, content.dsize);
  828.               sgroup.sg_mem = members;
  829. *** rel3/pwdbm.c    Thu May 30 07:04:47 1991
  830. --- pwdbm.c    Thu Jun  6 09:32:51 1991
  831. ***************
  832. *** 10,16 ****
  833.    */
  834.   
  835.   #ifndef    lint
  836. ! static    char    sccsid[] = "@(#)pwdbm.c    3.4    09:08:00    5/28/91";
  837.   #endif
  838.   
  839.   #ifdef    BSD
  840. --- 10,16 ----
  841.    */
  842.   
  843.   #ifndef    lint
  844. ! static    char    sccsid[] = "@(#)pwdbm.c    3.5    09:29:30    6/6/91";
  845.   #endif
  846.   
  847.   #ifdef    BSD
  848. ***************
  849. *** 92,97 ****
  850. --- 92,152 ----
  851.   #endif
  852.   #ifdef    NDBM
  853.       if (dbm_store (pw_dbm, key, content, DBM_REPLACE))
  854. +         return 0;
  855. + #endif
  856. +     return 1;
  857. + }
  858. + /*
  859. +  * pw_dbm_remove
  860. +  *
  861. +  * Removes the DBM password entry, if it exists.
  862. +  */
  863. + int
  864. + pw_dbm_remove (pw)
  865. + struct    passwd    *pw;
  866. + {
  867. +     datum    key;
  868. +     static    int    once;
  869. +     if (! once) {
  870. + #ifdef    NDBM
  871. +         if (! pw_dbm)
  872. +             setpwent ();
  873. + #else
  874. +         setpwent ();
  875. + #endif
  876. +         once++;
  877. +     }
  878. + #ifdef    DBM
  879. +     strcpy (data, PWDFILE);
  880. +     strcat (data, ".pag");
  881. +     if (access (data, 0))
  882. +         return 0;
  883. + #endif
  884. + #ifdef    NDBM
  885. +     if (! pw_dbm)
  886. +         return 0;
  887. + #endif
  888. +     key.dsize = strlen (pw->pw_name);
  889. +     key.dptr = pw->pw_name;
  890. + #ifdef    DBM
  891. +     if (delete (key))
  892. +         return 0;
  893. + #endif
  894. + #ifdef    NDBM
  895. +     if (dbm_delete (pw_dbm, key))
  896. +         return 0;
  897. + #endif
  898. +     key.dsize = sizeof pw->pw_uid;
  899. +     key.dptr = (char *) &pw->pw_uid;
  900. + #ifdef    DBM
  901. +     if (delete (key))
  902. +         return 0;
  903. + #endif
  904. + #ifdef    NDBM
  905. +     if (dbm_delete (pw_dbm, key))
  906.           return 0;
  907.   #endif
  908.       return 1;
  909. *** rel3/spdbm.c    Thu May 30 07:03:30 1991
  910. --- spdbm.c    Thu Jun  6 09:32:52 1991
  911. ***************
  912. *** 1,5 ****
  913.   /*
  914. !  * Copyright 1990, John F. Haugh II
  915.    * All rights reserved.
  916.    *
  917.    * Use, duplication, and disclosure prohibited without
  918. --- 1,5 ----
  919.   /*
  920. !  * Copyright 1990, 1991, John F. Haugh II
  921.    * All rights reserved.
  922.    *
  923.    * Use, duplication, and disclosure prohibited without
  924. ***************
  925. *** 7,13 ****
  926.    */
  927.   
  928.   #ifndef    lint
  929. ! static    char    sccsid[] = "@(#)spdbm.c    3.1    08:16:16    11/21/90";
  930.   #endif
  931.   
  932.   #include <string.h>
  933. --- 7,13 ----
  934.    */
  935.   
  936.   #ifndef    lint
  937. ! static    char    sccsid[] = "@(#)spdbm.c    3.2    09:29:53    6/6/91";
  938.   #endif
  939.   
  940.   #include <string.h>
  941. ***************
  942. *** 56,61 ****
  943. --- 56,91 ----
  944.       key.dsize = strlen (sp->sp_namp);
  945.       key.dptr = sp->sp_namp;
  946.       if (dbm_store (sp_dbm, key, content, DBM_REPLACE))
  947. +         return 0;
  948. +     return 1;
  949. + }
  950. + /*
  951. +  * sp_dbm_remove
  952. +  *
  953. +  * Updates the DBM password files, if they exist.
  954. +  */
  955. + int
  956. + sp_dbm_remove (user)
  957. + char    *user;
  958. + {
  959. +     datum    key;
  960. +     static    int    once;
  961. +     if (! once) {
  962. +         if (! sp_dbm)
  963. +             setspent ();
  964. +         once++;
  965. +     }
  966. +     if (! sp_dbm)
  967. +         return 0;
  968. +     key.dsize = strlen (user);
  969. +     key.dptr = user;
  970. +     if (dbm_delete (sp_dbm, key))
  971.           return 0;
  972.   
  973.       return 1;
  974. *** rel3/gpmain.c    Thu May 30 07:04:33 1991
  975. --- gpmain.c    Thu Jun  6 09:32:53 1991
  976. ***************
  977. *** 38,44 ****
  978.   #endif
  979.   
  980.   #ifndef    lint
  981. ! static    char    _sccsid[] = "@(#)gpmain.c    3.5    09:07:24    5/28/91";
  982.   #endif
  983.   
  984.   char    name[BUFSIZ];
  985. --- 38,44 ----
  986.   #endif
  987.   
  988.   #ifndef    lint
  989. ! static    char    _sccsid[] = "@(#)gpmain.c    3.6    09:28:18    6/6/91";
  990.   #endif
  991.   
  992.   char    name[BUFSIZ];
  993. ***************
  994. *** 95,116 ****
  995.   char    *member;
  996.   {
  997.       int    i;
  998. -     int    found = 0;
  999.       char    **tmp;
  1000.   
  1001. !     for (i = 0;!found && list[i] != (char *) 0;i++)
  1002.           if (strcmp (list[i], member) == 0)
  1003. !             found++;
  1004.   
  1005. !     tmp = (char **) malloc ((i + 2) * sizeof member);
  1006.   
  1007.       for (i = 0;list[i] != (char *) 0;i++)
  1008.           tmp[i] = list[i];
  1009.   
  1010. !     if (! found)
  1011. !         tmp[i++] = strdup (member);
  1012.       tmp[i] = (char *) 0;
  1013.       return tmp;
  1014.   }
  1015.   
  1016. --- 95,115 ----
  1017.   char    *member;
  1018.   {
  1019.       int    i;
  1020.       char    **tmp;
  1021.   
  1022. !     for (i = 0;list[i] != (char *) 0;i++)
  1023.           if (strcmp (list[i], member) == 0)
  1024. !             return list;
  1025.   
  1026. !     if (! (tmp = (char **) malloc ((i + 2) * sizeof member)))
  1027. !         return 0;
  1028.   
  1029.       for (i = 0;list[i] != (char *) 0;i++)
  1030.           tmp[i] = list[i];
  1031.   
  1032. !     tmp[i++] = strdup (member);
  1033.       tmp[i] = (char *) 0;
  1034.       return tmp;
  1035.   }
  1036.   
  1037. -- 
  1038. John F. Haugh II        | Distribution to  | UUCP: ...!cs.utexas.edu!rpp386!jfh
  1039. Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) |  Domain: jfh@rpp386.cactus.org
  1040. "If liberals interpreted the 2nd Amendment the same way they interpret the
  1041.  rest of the Constitution, gun ownership would be mandatory."
  1042.