home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / shadow / patch04c < prev    next >
Encoding:
Text File  |  1992-04-03  |  44.9 KB  |  1,850 lines

  1. Newsgroups: comp.sources.misc
  2. From: jfh@rpp386.cactus.org (John F Haugh II)
  3. Subject:  v29i049:  shadow - Shadow Login Suite, Patch04c/3
  4. Message-ID: <1992Apr3.202853.20042@sparky.imd.sterling.com>
  5. X-Md4-Signature: adc402ff173d60c747f1e21e15663dcb
  6. Date: Fri, 3 Apr 1992 20:28:53 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jfh@rpp386.cactus.org (John F Haugh II)
  10. Posting-number: Volume 29, Issue 49
  11. Archive-name: shadow/patch04c
  12. Environment: UNIX
  13. Patch-To: shadow: Volume 26, Issue 54-64
  14.  
  15. This is the third part of the patch for 3.1.4.
  16. --
  17. Index: Makefile.sun4
  18. *** rel3/Makefile.sun4    Fri Mar 27 10:25:50 1992
  19. --- Makefile.sun4    Fri Mar 27 10:27:12 1992
  20. ***************
  21. *** 1,5 ****
  22.   #
  23. ! # Copyright 1988,1989,1990,1991, John F. Haugh II
  24.   # All rights reserved.
  25.   #
  26.   # Permission is granted to copy and create derivative works for any
  27. --- 1,5 ----
  28.   #
  29. ! # Copyright 1988,1989,1990,1991,1992 John F. Haugh II
  30.   # All rights reserved.
  31.   #
  32.   # Permission is granted to copy and create derivative works for any
  33. ***************
  34. *** 8,16 ****
  35.   # and conspicuously displayed on all copies of object code or
  36.   # distribution media.
  37.   #
  38. ! #    @(#)Makefile.sun4    3.1    19:49:25  - Shadow password system (SunOS 4.1.1 version)
  39.   #
  40. ! #    @(#)Makefile.sun4    3.1    19:49:25    12/28/91
  41.   #
  42.   SHELL = /bin/sh
  43.   
  44. --- 8,16 ----
  45.   # and conspicuously displayed on all copies of object code or
  46.   # distribution media.
  47.   #
  48. ! #    @(#)Makefile.sun4    3.5    11:27:30  - Shadow password system (SunOS 4.1.1 version)
  49.   #
  50. ! #    @(#)Makefile.sun4    3.5    11:27:30    3/19/92
  51.   #
  52.   SHELL = /bin/sh
  53.   
  54. ***************
  55. *** 40,45 ****
  56. --- 40,46 ----
  57.   
  58.   # Configuration Flags
  59.   #
  60. + #    DEST_INCLUDE_DIR - local include files
  61.   #    LIBS - system libraries
  62.   #        -lsocket - needed for TCP/IP and possibly SYSLOG
  63.   #        -ldbm or -lndbm - needed for DBM support
  64. ***************
  65. *** 47,64 ****
  66.   #    CFLAGS - C compiler flags
  67.   #        -DLAI_TCP - needed for SCO Xenix Lachman TCP/IP
  68.   
  69.   # Flags for SunOS 4.1.1
  70. ! CFLAGS = -O2 $(OS)
  71.   LIBS =
  72.   LDFLAGS = 
  73.   
  74.   # Names for root user and group, and bin user and group.  See your
  75. ! # /etc/passwd and /etc/group files.
  76.   RUID = root
  77.   RGID = wheel
  78.   BUID = bin
  79.   BGID = bin
  80.   
  81.   # Rules for .L (lint) files.
  82.   .SUFFIXES: .L
  83.   LINT = lint
  84. --- 48,73 ----
  85.   #    CFLAGS - C compiler flags
  86.   #        -DLAI_TCP - needed for SCO Xenix Lachman TCP/IP
  87.   
  88. + DEST_INCLUDE_DIR = /usr/include
  89.   # Flags for SunOS 4.1.1
  90. ! CFLAGS = -O2 $(OS) $(DEST_INCLUDE_DIR)
  91.   LIBS =
  92.   LDFLAGS = 
  93.   
  94. + # Library for SunOS 4.1.1
  95. + LIBSEC = libsec.a
  96.   # Names for root user and group, and bin user and group.  See your
  97. ! # /etc/passwd and /etc/group files.  This is for SunOS 4.1.1
  98.   RUID = root
  99.   RGID = wheel
  100.   BUID = bin
  101.   BGID = bin
  102.   
  103. + # Where the login.defs file will be copied.  Must agree with config.h
  104. + DEST_LOGIN_DEFS = /etc/login.defs
  105.   # Rules for .L (lint) files.
  106.   .SUFFIXES: .L
  107.   LINT = lint
  108. ***************
  109. *** 157,162 ****
  110. --- 166,174 ----
  111.   FILES9 = groupadd.c groupdel.c groupmod.c tz.c console.c hushed.c getdef.c \
  112.       scologin.c logoutd.c sulog.c getpass.c userdel.c
  113.   
  114. + FILES_SUN4 = Makefile.sun4 README.sun4 config.h.sun4
  115. + FILES_SVR4 = Makefile.svr4 config.h.svr4
  116.   MAN_1 = chage.1 chfn.1 chsh.1 id.1 login.1 newgrp.1 passwd.1 su.1 \
  117.       useradd.1 userdel.1 usermod.1 groupadd.1 groupdel.1 groupmod.1 \
  118.       groups.1
  119. ***************
  120. *** 233,239 ****
  121.       cp chsh /bin
  122.       cp chage /bin
  123.       cp id /bin
  124. !     cp dialup.h shadow.h pwd.h /usr/include
  125.       chown $(RUID) $(LOGINDIR)/login /etc/pwconv /etc/pwunconv /etc/sulogin \
  126.           /bin/su /bin/passwd /bin/gpasswd /bin/newgrp /etc/mkpasswd \
  127.           /bin/dpasswd /bin/chsh /bin/chfn /bin/chage /etc/useradd \
  128. --- 245,251 ----
  129.       cp chsh /bin
  130.       cp chage /bin
  131.       cp id /bin
  132. !     cp dialup.h shadow.h pwd.h $(DEST_INCLUDE_DIR)
  133.       chown $(RUID) $(LOGINDIR)/login /etc/pwconv /etc/pwunconv /etc/sulogin \
  134.           /bin/su /bin/passwd /bin/gpasswd /bin/newgrp /etc/mkpasswd \
  135.           /bin/dpasswd /bin/chsh /bin/chfn /bin/chage /etc/useradd \
  136. ***************
  137. *** 244,253 ****
  138.           /bin/dpasswd /bin/chsh /bin/chfn /bin/chage /etc/useradd \
  139.           /etc/userdel /etc/usermod /etc/groupadd /etc/groupdel \
  140.           /etc/groupmod /etc/logoutd
  141. !     chown $(BUID) /bin/faillog /bin/id /usr/include/shadow.h \
  142. !         /usr/include/dialup.h /usr/include/pwd.h
  143. !     chgrp $(BGID) /bin/faillog /bin/id /usr/include/shadow.h \
  144. !         /usr/include/dialup.h /usr/include/pwd.h
  145.       chmod 700 /etc/pwconv /etc/pwunconv /etc/sulogin /etc/mkpasswd \
  146.           /etc/chpasswd /etc/newusers /bin/dpasswd /bin/chage \
  147.           /etc/useradd /etc/userdel /etc/usermod /etc/groupadd \
  148. --- 256,265 ----
  149.           /bin/dpasswd /bin/chsh /bin/chfn /bin/chage /etc/useradd \
  150.           /etc/userdel /etc/usermod /etc/groupadd /etc/groupdel \
  151.           /etc/groupmod /etc/logoutd
  152. !     chown $(BUID) /bin/faillog /bin/id $(DEST_INCLUDE_DIR)/shadow.h \
  153. !         $(DEST_INCLUDE_DIR)/dialup.h $(DEST_INCLUDE_DIR)/pwd.h
  154. !     chgrp $(BGID) /bin/faillog /bin/id $(DEST_INCLUDE_DIR)/shadow.h \
  155. !         $(DEST_INCLUDE_DIR)/dialup.h $(DEST_INCLUDE_DIR)/pwd.h
  156.       chmod 700 /etc/pwconv /etc/pwunconv /etc/sulogin /etc/mkpasswd \
  157.           /etc/chpasswd /etc/newusers /bin/dpasswd /bin/chage \
  158.           /etc/useradd /etc/userdel /etc/usermod /etc/groupadd \
  159. ***************
  160. *** 255,272 ****
  161.       chmod 4711 $(LOGINDIR)/login /bin/su /bin/passwd /bin/gpasswd \
  162.           /bin/newgrp /bin/chfn /bin/chsh
  163.       chmod 711 /bin/faillog /bin/id
  164. !     chmod 444 /usr/include/shadow.h /usr/include/dialup.h \
  165. !         /usr/include/pwd.h
  166. !     [ -f /etc/login.defs ] || (cp login.defs /etc ; \
  167. !         chown $(RUID) /etc/login.defs ; \
  168. !         chgrp $(RGID) /etc/login.defs ; \
  169. !         chmod 600 /etc/login.defs )
  170.   
  171.   lint:    su.lint login.lint pwconv.lint pwunconv.lint passwd.lint sulogin.lint \
  172.       faillog.lint newgrp.lint gpasswd.lint mkpasswd.lint chfn.lint \
  173.       chsh.lint chage.lint dpasswd.lint id.lint useradd.lint userdel.lint \
  174. !     usermod.lint groupadd.lint groupdel.lint groupmod.lint $(ALLSRCS:.c=.L)
  175. !     logoutd.lint
  176.   
  177.   tags:    $(ALLSRCS)
  178.       $(TAGS) $(ALLSRCS)
  179. --- 267,284 ----
  180.       chmod 4711 $(LOGINDIR)/login /bin/su /bin/passwd /bin/gpasswd \
  181.           /bin/newgrp /bin/chfn /bin/chsh
  182.       chmod 711 /bin/faillog /bin/id
  183. !     chmod 444 $(DEST_INCLUDE_DIR)/shadow.h $(DEST_INCLUDE_DIR)/dialup.h \
  184. !         $(DEST_INCLUDE_DIR)/pwd.h
  185. !     [ -f $(DEST_LOGIN_DEFS) ] || (cp login.defs $(DEST_LOGIN_DEFS) ; \
  186. !         chown $(RUID) $(DEST_LOGIN_DEFS) ; \
  187. !         chgrp $(RGID) $(DEST_LOGIN_DEFS) ; \
  188. !         chmod 600 $(DEST_LOGIN_DEFS) )
  189.   
  190.   lint:    su.lint login.lint pwconv.lint pwunconv.lint passwd.lint sulogin.lint \
  191.       faillog.lint newgrp.lint gpasswd.lint mkpasswd.lint chfn.lint \
  192.       chsh.lint chage.lint dpasswd.lint id.lint useradd.lint userdel.lint \
  193. !     usermod.lint groupadd.lint groupdel.lint groupmod.lint logoutd.lint \
  194. !     $(ALLSRCS:.c=.L)
  195.   
  196.   tags:    $(ALLSRCS)
  197.       $(TAGS) $(ALLSRCS)
  198. ***************
  199. *** 277,282 ****
  200. --- 289,306 ----
  201.   $(DOCS):
  202.       [ -f s.$@ ] && get -t -r$(RELEASE) s.$@
  203.   
  204. + login.defs:
  205. +     [ -f s.login.defs ] && get -t -r$(RELEASE) s.login.defs
  206. + Makefile.sun4:
  207. +     [ -f s.Makefile.sun4 ] && get -t -r$(RELEASE) s.Makefile.sun4
  208. + README.sun4:
  209. +     [ -f s.README.sun4 ] && get -t -r$(RELEASE) s.README.sun4
  210. + config.h.sun4:
  211. +     [ -f s.config.h.sun4 ] && get -t -r$(RELEASE) s.config.h.sun4
  212.   login:    $(LOBJS) libshadow.a
  213.       $(CC) -o login $(LDFLAGS) $(LOBJS) libshadow.a $(LIBS)
  214.   
  215. ***************
  216. *** 380,386 ****
  217.       $(LINT) $(LINTFLAGS) id.c > id.lint
  218.   
  219.   groups: groups.o libshadow.a
  220. -     $(CC) -c $(CFLAGS) groups.o libshadow.a $(LIBS)
  221.       $(CC) -o groups $(LDFLAGS) groups.o libshadow.a $(LIBS)
  222.   
  223.   groups.lint: groups.c
  224. --- 404,409 ----
  225. ***************
  226. *** 429,435 ****
  227.       [ -f s.pwd.h.m4 ] && get -t -r$(RELEASE) s.pwd.h.m4
  228.   
  229.   pwd.h: pwd.h.m4
  230. !     m4 $(OS) pwd.h.m4 >pwd.h
  231.   
  232.   logoutd: logoutd.o libshadow.a
  233.       $(CC) -o logoutd $(LDFLAGS) logoutd.o libshadow.a
  234. --- 452,458 ----
  235.       [ -f s.pwd.h.m4 ] && get -t -r$(RELEASE) s.pwd.h.m4
  236.   
  237.   pwd.h: pwd.h.m4
  238. !     /usr/5bin/m4 $(OS) < pwd.h.m4 > pwd.h
  239.   
  240.   logoutd: logoutd.o libshadow.a
  241.       $(CC) -o logoutd $(LDFLAGS) logoutd.o libshadow.a
  242. ***************
  243. *** 442,448 ****
  244.   susetup.c: setup.c
  245.       cp setup.c susetup.c
  246.   
  247. ! susetup.o: config.h setup.c pwd.h
  248.       $(CC) -c $(CFLAGS) -DSU susetup.c
  249.   
  250.   scologin: scologin.o
  251. --- 465,471 ----
  252.   susetup.c: setup.c
  253.       cp setup.c susetup.c
  254.   
  255. ! susetup.o: config.h susetup.c pwd.h
  256.       $(CC) -c $(CFLAGS) -DSU susetup.c
  257.   
  258.   scologin: scologin.o
  259. ***************
  260. *** 483,489 ****
  261.   groupadd.o: config.h shadow.h
  262.   groupdel.o: config.h shadow.h
  263.   groupmod.o: config.h shadow.h
  264. ! logoutd.o:
  265.   
  266.   libshadow.a(shadow.o): shadow.h config.h
  267.   libshadow.a(shadowio.o): shadow.h
  268. --- 506,513 ----
  269.   groupadd.o: config.h shadow.h
  270.   groupdel.o: config.h shadow.h
  271.   groupmod.o: config.h shadow.h
  272. ! logoutd.o: config.h
  273. ! sulogin.o: config.h
  274.   
  275.   libshadow.a(shadow.o): shadow.h config.h
  276.   libshadow.a(shadowio.o): shadow.h
  277. ***************
  278. *** 493,498 ****
  279. --- 517,525 ----
  280.   libshadow.a(dialchk.o): dialup.h config.h
  281.   libshadow.a(getdef.o): config.h
  282.   libshadow.a(pwdbm.o): config.h pwd.h
  283. + libshadow.a(spdbm.o): config.h shadow.h
  284. + libshadow.a(grdbm.o): config.h
  285. + libshadow.a(gsdbm.o): config.h shadow.h
  286.   libshadow.a(pwpack.o): config.h pwd.h
  287.   libshadow.a(pwent.o): config.h pwd.h
  288.   libshadow.a(pwio.o): pwd.h
  289. ***************
  290. *** 499,507 ****
  291.   libshadow.a(getpass.o): config.h
  292.   libshadow.a(encrypt.o): config.h
  293.   libshadow.a(port.o): port.h
  294.   
  295.   clean:
  296. !     -rm -f susetup.c *.o a.out core npasswd nshadow *.pag *.dir
  297.   
  298.   clobber: clean
  299.       -rm -f $(BINS) *.lint *.L libshadow.a
  300. --- 526,535 ----
  301.   libshadow.a(getpass.o): config.h
  302.   libshadow.a(encrypt.o): config.h
  303.   libshadow.a(port.o): port.h
  304. + libshadow.a(rad64.o): config.h
  305.   
  306.   clean:
  307. !     -rm -f susetup.c *.o a.out core npasswd nshadow *.pag *.dir pwd.h
  308.   
  309.   clobber: clean
  310.       -rm -f $(BINS) *.lint *.L libshadow.a
  311. ***************
  312. *** 515,521 ****
  313.   
  314.   shar:    login.sh.01 login.sh.02 login.sh.03 login.sh.04 login.sh.05 \
  315.       login.sh.06 login.sh.07 login.sh.08 login.sh.09 login.sh.10 \
  316. !     login.sh.11
  317.   
  318.   login.sh.01: $(FILES1) Makefile
  319.       shar -a $(FILES1) > login.sh.01
  320. --- 543,549 ----
  321.   
  322.   shar:    login.sh.01 login.sh.02 login.sh.03 login.sh.04 login.sh.05 \
  323.       login.sh.06 login.sh.07 login.sh.08 login.sh.09 login.sh.10 \
  324. !     login.sh.11 login.sh.12
  325.   
  326.   login.sh.01: $(FILES1) Makefile
  327.       shar -a $(FILES1) > login.sh.01
  328. ***************
  329. *** 549,551 ****
  330. --- 577,582 ----
  331.   
  332.   login.sh.11: $(DOCS2) Makefile
  333.       shar -a $(DOCS2) > login.sh.11
  334. + login.sh.12: $(FILES_SUN4) $(FILES_SVR4) Makefile
  335. +     shar -a $(FILES_SUN4) $(FILES_SVR4) > login.sh.12
  336. Index: config.h.sun4
  337. *** rel3/config.h.sun4    Fri Mar 27 10:25:50 1992
  338. --- config.h.sun4    Fri Mar 27 10:27:14 1992
  339. ***************
  340. *** 12,18 ****
  341.   /*
  342.    * Configuration file for login.
  343.    *
  344. !  *    @(#)config.h.sun4    3.1    19:49:35    12/28/91 (SunOS 4.1.1)
  345.    */
  346.   
  347.   
  348. --- 12,18 ----
  349.   /*
  350.    * Configuration file for login.
  351.    *
  352. !  *    @(#)config.h.sun4    3.2    13:22:32    3/9/92 (SunOS 4.1.1)
  353.    */
  354.   
  355.   
  356. ***************
  357. *** 79,84 ****
  358. --- 79,92 ----
  359.   
  360.   #define RLOGIN
  361.   #define UT_HOST
  362. + /*
  363. +  * Define the "success" code from ruserok().  Most modern systems use 0
  364. +  * for success and -1 for failure, while certain older versions use 1
  365. +  * for success and 0 for failure.  Please check your manpage to be sure.
  366. +  */
  367. + #define       RUSEROK 0
  368.   
  369.   /*
  370.    * Select one of the following
  371. Index: logoutd.c
  372. *** rel3/logoutd.c    Fri Mar 27 10:25:38 1992
  373. --- logoutd.c    Fri Mar 27 10:27:16 1992
  374. ***************
  375. *** 10,16 ****
  376.    */
  377.   
  378.   #ifndef lint
  379. ! static    char    sccsid[] = "@(#)logoutd.c    3.2    11:50:28    12/28/91";
  380.   #endif
  381.   
  382.   #include <sys/types.h>
  383. --- 10,16 ----
  384.    */
  385.   
  386.   #ifndef lint
  387. ! static    char    sccsid[] = "@(#)logoutd.c    3.3    13:22:33    3/9/92";
  388.   #endif
  389.   
  390.   #include <sys/types.h>
  391. ***************
  392. *** 19,24 ****
  393. --- 19,28 ----
  394.   #include <utmp.h>
  395.   #include "config.h"
  396.   
  397. + #ifdef SUN4
  398. + #include <fcntl.h>
  399. + #endif
  400.   main ()
  401.   {
  402.       int    i;
  403. ***************
  404. *** 55,67 ****
  405.   #ifdef    USG_UTMP
  406.               if (utmp.ut_type != USER_PROCESS)
  407.                   continue;
  408.   #endif
  409.   #ifdef BSD_UTMP
  410. !             if (utmp.ut_user[0] == '\0')
  411.                   continue;
  412. ! #endif
  413. !             if (isttytime (utmp.ut_user, utmp.ut_line, time (0)))
  414.                   continue;
  415.   #ifdef    USG_UTMP
  416.               kill (- utmp.ut_pid, SIGHUP);
  417.               sleep (10);
  418. --- 59,73 ----
  419.   #ifdef    USG_UTMP
  420.               if (utmp.ut_type != USER_PROCESS)
  421.                   continue;
  422. +             if (isttytime (utmp.ut_user, utmp.ut_line, time (0)))
  423. +                 continue;
  424.   #endif
  425.   #ifdef BSD_UTMP
  426. !             if (utmp.ut_name[0] == '\0')
  427.                   continue;
  428. !             if (isttytime (utmp.ut_name, utmp.ut_line, time (0)))
  429.                   continue;
  430. + #endif
  431.   #ifdef    USG_UTMP
  432.               kill (- utmp.ut_pid, SIGHUP);
  433.               sleep (10);
  434. Index: usermod.c
  435. *** rel3/usermod.c    Fri Mar 27 10:25:31 1992
  436. --- usermod.c    Fri Mar 27 10:27:21 1992
  437. ***************
  438. *** 1,5 ****
  439.   /*
  440. !  * Copyright 1991, John F. Haugh II
  441.    * All rights reserved.
  442.    *
  443.    * Permission is granted to copy and create derivative works for any
  444. --- 1,5 ----
  445.   /*
  446. !  * Copyright 1991, 1992, John F. Haugh II
  447.    * All rights reserved.
  448.    *
  449.    * Permission is granted to copy and create derivative works for any
  450. ***************
  451. *** 10,16 ****
  452.    */
  453.   
  454.   #ifndef lint
  455. ! static    char    sccsid[] = "@(#)usermod.c    3.8    19:40:17    12/28/91";
  456.   #endif
  457.   
  458.   #include <sys/types.h>
  459. --- 10,16 ----
  460.    */
  461.   
  462.   #ifndef lint
  463. ! static    char    sccsid[] = "@(#)usermod.c    3.11    09:26:21    3/27/92";
  464.   #endif
  465.   
  466.   #include <sys/types.h>
  467. ***************
  468. *** 31,38 ****
  469.   
  470.   #include "config.h"
  471.   #include "shadow.h"
  472. ! #include <faillog.h>
  473. ! #include <lastlog.h>
  474.   
  475.   #ifdef    USE_SYSLOG
  476.   #include <syslog.h>
  477. --- 31,38 ----
  478.   
  479.   #include "config.h"
  480.   #include "shadow.h"
  481. ! #include "faillog.h"
  482. ! #include "lastlog.h"
  483.   
  484.   #ifdef    USE_SYSLOG
  485.   #include <syslog.h>
  486. ***************
  487. *** 46,51 ****
  488. --- 46,59 ----
  489.   #define    NGROUPS_MAX    64
  490.   #endif
  491.   
  492. + #if !defined(MDY_DATE) && !defined(DMY_DATE) && !defined(YMD_DATE)
  493. + #define    MDY_DATE    1
  494. + #endif
  495. + #if (defined (MDY_DATE) && (defined (DMY_DATE) || defined (YMD_DATE))) || \
  496. +     (defined (DMY_DATE) && (defined (MDY_DATE) || defined (YMD_DATE)))
  497. + Error: You must only define one of MDY_DATE, DMY_DATE, or YMD_DATE
  498. + #endif
  499.   #define    VALID(s)    (strcspn (s, ":\n") == strlen (s))
  500.   
  501.   char    user_name[BUFSIZ];
  502. ***************
  503. *** 221,233 ****
  504.       long    total;
  505.   
  506.       /*
  507. !      * start by separating the month, day and year.  this is
  508. !      * a chauvanistic program - it only takes date input in
  509. !      * the standard USA format.
  510.        */
  511.   
  512.       if (sscanf (str, "%d/%d/%d%c", &month, &day, &year, slop) != 3)
  513.           return -1;
  514.   
  515.       /*
  516.        * the month, day of the month, and year are checked for
  517. --- 229,250 ----
  518.       long    total;
  519.   
  520.       /*
  521. !      * start by separating the month, day and year.  the order
  522. !      * is compiled in ...
  523.        */
  524.   
  525. + #ifdef    MDY_DATE
  526.       if (sscanf (str, "%d/%d/%d%c", &month, &day, &year, slop) != 3)
  527.           return -1;
  528. + #endif
  529. + #ifdef    DMY_DATE
  530. +     if (sscanf (str, "%d/%d/%d%c", &day, &month, &year, slop) != 3)
  531. +         return -1;
  532. + #endif
  533. + #ifdef    YMD_DATE
  534. +     if (sscanf (str, "%d/%d/%d%c", &year, &month, &day, slop) != 3)
  535. +         return -1;
  536. + #endif
  537.   
  538.       /*
  539.        * the month, day of the month, and year are checked for
  540. ***************
  541. *** 458,466 ****
  542.           "usage: %s [-u uid [-o]] [-g group] [-G group,...] \n", Prog);
  543.       fprintf (stderr,
  544.           "\t\t[-d home [-m]] [-s shell] [-c comment] [-l new_name]\n");
  545.       fprintf (stderr,
  546. !         "\t\t[-f inactive] [-e expire] name\n");
  547.       exit (2);
  548.   }
  549.   
  550. --- 475,492 ----
  551.           "usage: %s [-u uid [-o]] [-g group] [-G group,...] \n", Prog);
  552.       fprintf (stderr,
  553.           "\t\t[-d home [-m]] [-s shell] [-c comment] [-l new_name]\n");
  554. + #ifdef    MDY_DATE
  555.       fprintf (stderr,
  556. !         "\t\t[-f inactive ] [-e expire mm/dd/yy ] name\n");
  557. ! #endif
  558. ! #ifdef    DMY_DATE
  559. !     fprintf (stderr,
  560. !         "\t\t[-f inactive ] [-e expire dd/mm/yy ] name\n");
  561. ! #endif
  562. ! #ifdef    YMD_DATE
  563. !     fprintf (stderr,
  564. !         "\t\t[-f inactive ] [-e expire yy/mm/dd ] name\n");
  565. ! #endif
  566.       exit (2);
  567.   }
  568.   
  569. ***************
  570. *** 575,590 ****
  571.       }
  572.       if (! gr_open (O_RDWR)) {
  573.           fprintf (stderr, "%s: error opening group file\n", Prog);
  574. !         exit (1);
  575.       }
  576.   #ifdef    SHADOWGRP
  577.       if (! sgr_lock ()) {
  578.           fprintf (stderr, "%s: error locking shadow group file\n", Prog);
  579. !         exit (1);
  580.       }
  581.       if (! sgr_open (O_RDWR)) {
  582.           fprintf (stderr, "%s: error opening shadow group file\n", Prog);
  583. !         exit (1);
  584.       }
  585.   #endif
  586.   
  587. --- 601,616 ----
  588.       }
  589.       if (! gr_open (O_RDWR)) {
  590.           fprintf (stderr, "%s: error opening group file\n", Prog);
  591. !         fail_exit (1);
  592.       }
  593.   #ifdef    SHADOWGRP
  594.       if (! sgr_lock ()) {
  595.           fprintf (stderr, "%s: error locking shadow group file\n", Prog);
  596. !         fail_exit (1);
  597.       }
  598.       if (! sgr_open (O_RDWR)) {
  599.           fprintf (stderr, "%s: error opening shadow group file\n", Prog);
  600. !         fail_exit (1);
  601.       }
  602.   #endif
  603.   
  604. ***************
  605. *** 646,652 ****
  606.           if (! gr_update (grp)) {
  607.               fprintf (stderr, "%s: error adding new group entry\n",
  608.                   Prog);
  609. !             exit (1);
  610.           }
  611.   #ifdef    NDBM
  612.           /*
  613. --- 672,678 ----
  614.           if (! gr_update (grp)) {
  615.               fprintf (stderr, "%s: error adding new group entry\n",
  616.                   Prog);
  617. !             fail_exit (1);
  618.           }
  619.   #ifdef    NDBM
  620.           /*
  621. ***************
  622. *** 656,666 ****
  623.           if (! gr_dbm_update (grp)) {
  624.               fprintf (stderr, "%s: cannot add new dbm group entry\n",
  625.                   Prog);
  626. !             exit (1);
  627.           }
  628. -         endgrent ();
  629.   #endif
  630.       }
  631.   
  632.   #ifdef    SHADOWGRP
  633.       /*
  634. --- 682,694 ----
  635.           if (! gr_dbm_update (grp)) {
  636.               fprintf (stderr, "%s: cannot add new dbm group entry\n",
  637.                   Prog);
  638. !             fail_exit (1);
  639.           }
  640.   #endif
  641.       }
  642. + #ifdef NDBM
  643. +     endgrent ();
  644. + #endif
  645.   
  646.   #ifdef    SHADOWGRP
  647.       /*
  648. ***************
  649. *** 749,755 ****
  650.           if (! sgr_update (sgrp)) {
  651.               fprintf (stderr, "%s: error adding new group entry\n",
  652.                   Prog);
  653. !             exit (1);
  654.           }
  655.   #ifdef    NDBM
  656.           /*
  657. --- 777,783 ----
  658.           if (! sgr_update (sgrp)) {
  659.               fprintf (stderr, "%s: error adding new group entry\n",
  660.                   Prog);
  661. !             fail_exit (1);
  662.           }
  663.   #ifdef    NDBM
  664.           /*
  665. ***************
  666. *** 759,770 ****
  667.           if (! sgr_dbm_update (sgrp)) {
  668.               fprintf (stderr, "%s: cannot add new dbm group entry\n",
  669.                   Prog);
  670. !             exit (1);
  671.           }
  672. -         endsgent ();
  673.   #endif
  674.       }
  675.   #endif
  676.   }
  677.   
  678.   /*
  679. --- 787,800 ----
  680.           if (! sgr_dbm_update (sgrp)) {
  681.               fprintf (stderr, "%s: cannot add new dbm group entry\n",
  682.                   Prog);
  683. !             fail_exit (1);
  684.           }
  685.   #endif
  686.       }
  687. + #ifdef NDBM
  688. +     endsgent ();
  689.   #endif
  690. + #endif
  691.   }
  692.   
  693.   /*
  694. ***************
  695. *** 976,993 ****
  696.   {
  697.       if (! pw_close ()) {
  698.           fprintf (stderr, "%s: cannot rewrite password file\n", Prog);
  699. !         exit (1);
  700.       }
  701.       if (! spw_close ()) {
  702.           fprintf (stderr, "%s: cannot rewrite shadow password file\n",    
  703.               Prog);
  704. !         exit (1);
  705.       }
  706.       if (user_ngroups >= 0) {
  707.           if (! gr_close ()) {
  708.               fprintf (stderr, "%s: cannot rewrite group file\n",
  709.                   Prog);
  710. !             exit (1);
  711.           }
  712.           (void) gr_unlock ();
  713.   #ifdef    SHADOWGRP
  714. --- 1006,1023 ----
  715.   {
  716.       if (! pw_close ()) {
  717.           fprintf (stderr, "%s: cannot rewrite password file\n", Prog);
  718. !         fail_exit (1);
  719.       }
  720.       if (! spw_close ()) {
  721.           fprintf (stderr, "%s: cannot rewrite shadow password file\n",    
  722.               Prog);
  723. !         fail_exit (1);
  724.       }
  725.       if (user_ngroups >= 0) {
  726.           if (! gr_close ()) {
  727.               fprintf (stderr, "%s: cannot rewrite group file\n",
  728.                   Prog);
  729. !             fail_exit (1);
  730.           }
  731.           (void) gr_unlock ();
  732.   #ifdef    SHADOWGRP
  733. ***************
  734. *** 994,1000 ****
  735.           if (! sgr_close ()) {
  736.               fprintf (stderr, "%s: cannot rewrite shadow group file\n",
  737.                   Prog);
  738. !             exit (1);
  739.           }
  740.           (void) sgr_unlock ();
  741.   #endif
  742. --- 1024,1030 ----
  743.           if (! sgr_close ()) {
  744.               fprintf (stderr, "%s: cannot rewrite shadow group file\n",
  745.                   Prog);
  746. !             fail_exit (1);
  747.           }
  748.           (void) sgr_unlock ();
  749.   #endif
  750. ***************
  751. *** 1017,1031 ****
  752.       }
  753.       if (! pw_open (O_RDWR)) {
  754.           fprintf (stderr, "%s: unable to open password file\n", Prog);
  755. !         exit (1);
  756.       }
  757.       if (! spw_lock ()) {
  758. !         fprintf (stderr, "%s: cannot lock shadow password file\n", Prog);
  759. !         exit (1);
  760.       }
  761.       if (! spw_open (O_RDWR)) {
  762. !         fprintf (stderr, "%s: cannot open shadow password file\n", Prog);
  763. !         exit (1);
  764.       }
  765.   }
  766.   
  767. --- 1047,1063 ----
  768.       }
  769.       if (! pw_open (O_RDWR)) {
  770.           fprintf (stderr, "%s: unable to open password file\n", Prog);
  771. !         fail_exit (1);
  772.       }
  773.       if (! spw_lock ()) {
  774. !         fprintf (stderr, "%s: cannot lock shadow password file\n",
  775. !             Prog);
  776. !         fail_exit (1);
  777.       }
  778.       if (! spw_open (O_RDWR)) {
  779. !         fprintf (stderr, "%s: cannot open shadow password file\n",
  780. !             Prog);
  781. !         fail_exit (1);
  782.       }
  783.   }
  784.   
  785. ***************
  786. *** 1056,1079 ****
  787.           if (! pw_update (&pwent)) {
  788.               fprintf (stderr, "%s: error changing password entry\n",
  789.                   Prog);
  790. !             exit (1);
  791.           }
  792.           if (lflg && ! pw_remove (user_name)) {
  793.               fprintf (stderr, "%s: error removing password entry\n",
  794.                   Prog);
  795. !             exit (1);
  796.           }
  797.   #if defined(DBM) || defined(NDBM)
  798.           if (access ("/etc/passwd.pag", 0) == 0) {
  799.               if (! pw_dbm_update (&pwent)) {
  800. !                 fprintf (stderr, "%s: error adding password dbm entry\n",
  801.                       Prog);
  802. !                 exit (1);
  803.               }
  804. !             if (lflg && (pwd = getpwnam (user_name)) && ! pw_dbm_remove (pwd)) {
  805. !                 fprintf (stderr, "%s: error removing passwd dbm entry\n",
  806.                       Prog);
  807. !                 exit (1);
  808.               }
  809.               endpwent ();
  810.           }
  811. --- 1088,1114 ----
  812.           if (! pw_update (&pwent)) {
  813.               fprintf (stderr, "%s: error changing password entry\n",
  814.                   Prog);
  815. !             fail_exit (1);
  816.           }
  817.           if (lflg && ! pw_remove (user_name)) {
  818.               fprintf (stderr, "%s: error removing password entry\n",
  819.                   Prog);
  820. !             fail_exit (1);
  821.           }
  822.   #if defined(DBM) || defined(NDBM)
  823.           if (access ("/etc/passwd.pag", 0) == 0) {
  824.               if (! pw_dbm_update (&pwent)) {
  825. !                 fprintf (stderr,
  826. !                     "%s: error adding password dbm entry\n",
  827.                       Prog);
  828. !                 fail_exit (1);
  829.               }
  830. !             if (lflg && (pwd = getpwnam (user_name)) &&
  831. !                     ! pw_dbm_remove (pwd)) {
  832. !                 fprintf (stderr,
  833. !                     "%s: error removing passwd dbm entry\n",
  834.                       Prog);
  835. !                 fail_exit (1);
  836.               }
  837.               endpwent ();
  838.           }
  839. ***************
  840. *** 1081,1107 ****
  841.       }
  842.       if (lflg || eflg || fflg) {
  843.           if (! spw_update (&spent)) {
  844. !             fprintf (stderr, "%s: error adding new shadow password entry\n",
  845.                   Prog);
  846. !             exit (1);
  847.           }
  848.           if (lflg && ! spw_remove (user_name)) {
  849. !             fprintf (stderr, "%s: error removing shadow password entry\n",
  850.                   Prog);
  851. !             exit (1);
  852.           }
  853.       }
  854.   #ifdef    NDBM
  855.       if (access ("/etc/shadow.pag", 0) == 0) {
  856.           if (! sp_dbm_update (&spent)) {
  857. !             fprintf (stderr, "%s: error updating shadow passwd dbm entry\n",
  858.                   Prog);
  859. !             exit (1);
  860.           }
  861.           if (lflg && ! sp_dbm_remove (user_name)) {
  862. !             fprintf (stderr, "%s: error removing shadow passwd db entry\n",
  863.                   Prog);
  864. !             exit (1);
  865.           }
  866.           endspent ();
  867.       }
  868. --- 1116,1146 ----
  869.       }
  870.       if (lflg || eflg || fflg) {
  871.           if (! spw_update (&spent)) {
  872. !             fprintf (stderr,
  873. !                 "%s: error adding new shadow password entry\n",
  874.                   Prog);
  875. !             fail_exit (1);
  876.           }
  877.           if (lflg && ! spw_remove (user_name)) {
  878. !             fprintf (stderr,
  879. !                 "%s: error removing shadow password entry\n",
  880.                   Prog);
  881. !             fail_exit (1);
  882.           }
  883.       }
  884.   #ifdef    NDBM
  885.       if (access ("/etc/shadow.pag", 0) == 0) {
  886.           if (! sp_dbm_update (&spent)) {
  887. !             fprintf (stderr,
  888. !                 "%s: error updating shadow passwd dbm entry\n",
  889.                   Prog);
  890. !             fail_exit (1);
  891.           }
  892.           if (lflg && ! sp_dbm_remove (user_name)) {
  893. !             fprintf (stderr,
  894. !                 "%s: error removing shadow passwd db entry\n",
  895.                   Prog);
  896. !             fail_exit (1);
  897.           }
  898.           endspent ();
  899.       }
  900. ***************
  901. *** 1126,1132 ****
  902.           if (access (user_newhome, 0) == 0) {
  903.               fprintf (stderr, "%s: directory %s exists\n",
  904.                   Prog, user_newhome);
  905. !             exit (12);
  906.           } else if (rename (user_home, user_newhome)) {
  907.               if (errno == EXDEV) {
  908.                   if (mkdir (user_newhome, sb.st_mode & 0777)) {
  909. --- 1165,1171 ----
  910.           if (access (user_newhome, 0) == 0) {
  911.               fprintf (stderr, "%s: directory %s exists\n",
  912.                   Prog, user_newhome);
  913. !             fail_exit (12);
  914.           } else if (rename (user_home, user_newhome)) {
  915.               if (errno == EXDEV) {
  916.                   if (mkdir (user_newhome, sb.st_mode & 0777)) {
  917. ***************
  918. *** 1147,1153 ****
  919.               fprintf (stderr,
  920.                   "%s: cannot rename directory %s to %s\n",
  921.                   Prog, user_home, user_newhome);
  922. !             exit (12);
  923.           }
  924.       }
  925.       if (uflg || gflg)
  926. --- 1186,1192 ----
  927.               fprintf (stderr,
  928.                   "%s: cannot rename directory %s to %s\n",
  929.                   Prog, user_home, user_newhome);
  930. !             fail_exit (12);
  931.           }
  932.       }
  933.       if (uflg || gflg)
  934. ***************
  935. *** 1191,1196 ****
  936. --- 1230,1251 ----
  937.           }
  938.           close (fd);
  939.       }
  940. + }
  941. + /*
  942. +  * fail_exit - exit with an error code after unlocking files
  943. +  */
  944. + fail_exit (code)
  945. + int    code;
  946. + {
  947. +     (void) gr_unlock ();
  948. + #ifdef    SHADOWGRP
  949. +     (void) sgr_unlock ();
  950. + #endif
  951. +     (void) spw_unlock ();
  952. +     (void) pw_unlock ();
  953. +     exit (code);
  954.   }
  955.   
  956.   /*
  957. Index: useradd.c
  958. *** rel3/useradd.c    Fri Mar 27 10:25:30 1992
  959. --- useradd.c    Fri Mar 27 10:27:24 1992
  960. ***************
  961. *** 1,5 ****
  962.   /*
  963. !  * Copyright 1991, John F. Haugh II
  964.    * All rights reserved.
  965.    *
  966.    * Permission is granted to copy and create derivative works for any
  967. --- 1,5 ----
  968.   /*
  969. !  * Copyright 1991, 1992, John F. Haugh II
  970.    * All rights reserved.
  971.    *
  972.    * Permission is granted to copy and create derivative works for any
  973. ***************
  974. *** 10,16 ****
  975.    */
  976.   
  977.   #ifndef lint
  978. ! static    char    sccsid[] = "@(#)useradd.c    3.8    19:40:07    12/28/91";
  979.   #endif
  980.   
  981.   #include "config.h"
  982. --- 10,16 ----
  983.    */
  984.   
  985.   #ifndef lint
  986. ! static    char    sccsid[] = "@(#)useradd.c    3.9    09:41:30    3/19/92";
  987.   #endif
  988.   
  989.   #include "config.h"
  990. ***************
  991. *** 52,57 ****
  992. --- 52,65 ----
  993.   #define    NGROUPS_MAX    64
  994.   #endif
  995.   
  996. + #if !defined(MDY_DATE) && !defined(DMY_DATE) && !defined(YMD_DATE)
  997. + #define    MDY_DATE    1
  998. + #endif
  999. + #if (defined (MDY_DATE) && (defined (DMY_DATE) || defined (YMD_DATE))) || \
  1000. +     (defined (DMY_DATE) && (defined (MDY_DATE) || defined (YMD_DATE)))
  1001. + Error: You must only define one of MDY_DATE, DMY_DATE, or YMD_DATE
  1002. + #endif
  1003.   #define    VALID(s)    (strcspn (s, ":\n") == strlen (s))
  1004.   
  1005.   char    user_name[BUFSIZ];
  1006. ***************
  1007. *** 221,233 ****
  1008.       long    total;
  1009.   
  1010.       /*
  1011. !      * start by separating the month, day and year.  this is
  1012. !      * a chauvanistic program - it only takes date input in
  1013. !      * the standard USA format.
  1014.        */
  1015.   
  1016.       if (sscanf (str, "%d/%d/%d%c", &month, &day, &year, slop) != 3)
  1017.           return -1;
  1018.   
  1019.       /*
  1020.        * the month, day of the month, and year are checked for
  1021. --- 229,250 ----
  1022.       long    total;
  1023.   
  1024.       /*
  1025. !      * start by separating the month, day and year.  the order
  1026. !      * is compiled in ...
  1027.        */
  1028.   
  1029. + #ifdef    MDY_DATE
  1030.       if (sscanf (str, "%d/%d/%d%c", &month, &day, &year, slop) != 3)
  1031.           return -1;
  1032. + #endif
  1033. + #ifdef    DMY_DATE
  1034. +     if (sscanf (str, "%d/%d/%d%c", &day, &month, &year, slop) != 3)
  1035. +         return -1;
  1036. + #endif
  1037. + #ifdef    YMD_DATE
  1038. +     if (sscanf (str, "%d/%d/%d%c", &year, &month, &day, slop) != 3)
  1039. +         return -1;
  1040. + #endif
  1041.   
  1042.       /*
  1043.        * the month, day of the month, and year are checked for
  1044. ***************
  1045. *** 643,651 ****
  1046.           "usage:\t%s [-u uid [-o]] [-g group] [-G group,...] \n", Prog);
  1047.       fprintf (stderr,
  1048.           "\t\t[-d home] [-s shell] [-c comment] [-m [-k template]]\n");
  1049.       fprintf (stderr,
  1050. !         "\t\t[-f inactive] [-e expire] name\n");
  1051.       fprintf (stderr,
  1052.           "\t%s -D [-g group] [-b base] [-f inactive] [-e expire]\n",
  1053.               Prog);
  1054. --- 660,677 ----
  1055.           "usage:\t%s [-u uid [-o]] [-g group] [-G group,...] \n", Prog);
  1056.       fprintf (stderr,
  1057.           "\t\t[-d home] [-s shell] [-c comment] [-m [-k template]]\n");
  1058. + #ifdef    MDY_DATE
  1059.       fprintf (stderr,
  1060. !         "\t\t[-f inactive ] [-e expire mm/dd/yy ] name\n");
  1061. ! #endif
  1062. ! #ifdef    DMY_DATE
  1063. !     fprintf (stderr,
  1064. !         "\t\t[-f inactive ] [-e expire dd/mm/yy ] name\n");
  1065. ! #endif
  1066. ! #ifdef    YMD_DATE
  1067. !     fprintf (stderr,
  1068. !         "\t\t[-f inactive ] [-e expire yy/mm/dd ] name\n");
  1069. ! #endif
  1070.       fprintf (stderr,
  1071.           "\t%s -D [-g group] [-b base] [-f inactive] [-e expire]\n",
  1072.               Prog);
  1073. ***************
  1074. *** 778,784 ****
  1075.                   Prog);
  1076.               exit (1);
  1077.           }
  1078. -         endgrent ();
  1079.   #endif
  1080.   #ifdef    USE_SYSLOG
  1081.           syslog (LOG_INFO, "add `%s' to group `%s'\n",
  1082. --- 804,809 ----
  1083. ***************
  1084. *** 785,790 ****
  1085. --- 810,818 ----
  1086.               user_name, grp->gr_name);
  1087.   #endif
  1088.       }
  1089. + #ifdef NDBM
  1090. +     endgrent ();
  1091. + #endif
  1092.   
  1093.   #ifdef    SHADOWGRP
  1094.       /*
  1095. ***************
  1096. *** 831,837 ****
  1097.                   Prog);
  1098.               exit (1);
  1099.           }
  1100. -         endsgent ();
  1101.   #endif
  1102.   #ifdef    USE_SYSLOG
  1103.           syslog (LOG_INFO, "add `%s' to shadow group `%s'\n",
  1104. --- 859,864 ----
  1105. ***************
  1106. *** 838,843 ****
  1107. --- 865,873 ----
  1108.               user_name, sgrp->sg_name);
  1109.   #endif
  1110.       }
  1111. + #ifdef NDBM
  1112. +     endsgent ();
  1113. + #endif
  1114.   #endif
  1115.   }
  1116.   
  1117. Index: userdel.c
  1118. *** rel3/userdel.c    Fri Mar 27 10:24:23 1992
  1119. --- userdel.c    Fri Mar 27 10:27:27 1992
  1120. ***************
  1121. *** 1,5 ****
  1122.   /*
  1123. !  * Copyright 1991, John F. Haugh II
  1124.    * All rights reserved.
  1125.    *
  1126.    * Permission is granted to copy and create derivative works for any
  1127. --- 1,5 ----
  1128.   /*
  1129. !  * Copyright 1991, 1992, John F. Haugh II
  1130.    * All rights reserved.
  1131.    *
  1132.    * Permission is granted to copy and create derivative works for any
  1133. ***************
  1134. *** 10,16 ****
  1135.    */
  1136.   
  1137.   #ifndef lint
  1138. ! static    char    sccsid[] = "@(#)userdel.c    3.9    14:38:36    10/27/91";
  1139.   #endif
  1140.   
  1141.   #include <sys/types.h>
  1142. --- 10,16 ----
  1143.    */
  1144.   
  1145.   #ifndef lint
  1146. ! static    char    sccsid[] = "@(#)userdel.c    3.10    09:41:48    3/19/92";
  1147.   #endif
  1148.   
  1149.   #include <sys/types.h>
  1150. ***************
  1151. *** 163,169 ****
  1152.       struct    group    *grp;
  1153.   #ifdef    SHADOWGRP
  1154.       struct    sgrp    *sgrp;
  1155. ! #endif
  1156.   
  1157.       /*
  1158.        * Scan through the entire group file looking for the groups that
  1159. --- 163,169 ----
  1160.       struct    group    *grp;
  1161.   #ifdef    SHADOWGRP
  1162.       struct    sgrp    *sgrp;
  1163. ! #endif    /* SHADOWGRP */
  1164.   
  1165.       /*
  1166.        * Scan through the entire group file looking for the groups that
  1167. ***************
  1168. *** 190,218 ****
  1169.            */
  1170.   
  1171.           grp->gr_mem = del_list (grp->gr_mem, user_name);
  1172. !         if (! gr_update (grp)) {
  1173.               fprintf (stderr, "%s: error updating group entry\n",
  1174.                   Prog);
  1175. !             exit (1);
  1176. !         }
  1177.           /*
  1178.            * Update the DBM group file with the new entry as well.
  1179.            */
  1180.   
  1181.   #ifdef    NDBM
  1182. !         if (! gr_dbm_update (grp)) {
  1183.               fprintf (stderr, "%s: cannot update dbm group entry\n",
  1184.                   Prog);
  1185. -             exit (1);
  1186. -         }
  1187. -         endgrent ();
  1188.   #endif    /* NDBM */
  1189.   #ifdef    USE_SYSLOG
  1190.           syslog (LOG_INFO, "delete `%s' from group `%s'\n",
  1191.               user_name, grp->gr_name);
  1192. ! #endif
  1193.       }
  1194.   #ifdef    SHADOWGRP
  1195.       /*
  1196.        * Scan through the entire shadow group file looking for the groups
  1197. --- 190,216 ----
  1198.            */
  1199.   
  1200.           grp->gr_mem = del_list (grp->gr_mem, user_name);
  1201. !         if (! gr_update (grp))
  1202.               fprintf (stderr, "%s: error updating group entry\n",
  1203.                   Prog);
  1204.           /*
  1205.            * Update the DBM group file with the new entry as well.
  1206.            */
  1207.   
  1208.   #ifdef    NDBM
  1209. !         if (! gr_dbm_update (grp))
  1210.               fprintf (stderr, "%s: cannot update dbm group entry\n",
  1211.                   Prog);
  1212.   #endif    /* NDBM */
  1213.   #ifdef    USE_SYSLOG
  1214.           syslog (LOG_INFO, "delete `%s' from group `%s'\n",
  1215.               user_name, grp->gr_name);
  1216. ! #endif    /* USE_SYSLOG */
  1217.       }
  1218. ! #ifdef    NDBM
  1219. !     endgrent ();
  1220. ! #endif    /* NDBM */
  1221.   #ifdef    SHADOWGRP
  1222.       /*
  1223.        * Scan through the entire shadow group file looking for the groups
  1224. ***************
  1225. *** 247,275 ****
  1226.           if (! group_changed)
  1227.               continue;
  1228.   
  1229. !         if (! sgr_update (sgrp)) {
  1230.               fprintf (stderr, "%s: error updating group entry\n",
  1231.                   Prog);
  1232. -             exit (1);
  1233. -         }
  1234.   #ifdef    NDBM
  1235.           /*
  1236.            * Update the DBM group file with the new entry as well.
  1237.            */
  1238.   
  1239. !         if (! sgr_dbm_update (sgrp)) {
  1240.               fprintf (stderr, "%s: cannot update dbm group entry\n",
  1241.                   Prog);
  1242. !             exit (1);
  1243. !         }
  1244. !         endsgent ();
  1245. ! #endif
  1246.   #ifdef    USE_SYSLOG
  1247.           syslog (LOG_INFO, "delete `%s' from shadow group `%s'\n",
  1248.               user_name, sgrp->sg_name);
  1249. ! #endif
  1250.       }
  1251. ! #endif
  1252.   }
  1253.   
  1254.   /*
  1255. --- 245,271 ----
  1256.           if (! group_changed)
  1257.               continue;
  1258.   
  1259. !         if (! sgr_update (sgrp))
  1260.               fprintf (stderr, "%s: error updating group entry\n",
  1261.                   Prog);
  1262.   #ifdef    NDBM
  1263.           /*
  1264.            * Update the DBM group file with the new entry as well.
  1265.            */
  1266.   
  1267. !         if (! sgr_dbm_update (sgrp))
  1268.               fprintf (stderr, "%s: cannot update dbm group entry\n",
  1269.                   Prog);
  1270. ! #endif    /* NDBM */
  1271.   #ifdef    USE_SYSLOG
  1272.           syslog (LOG_INFO, "delete `%s' from shadow group `%s'\n",
  1273.               user_name, sgrp->sg_name);
  1274. ! #endif    /* USE_SYSLOG */
  1275.       }
  1276. ! #ifdef    NDBM
  1277. !     endsgent ();
  1278. ! #endif    /* NDBM */
  1279. ! #endif    /* SHADOWGRP */
  1280.   }
  1281.   
  1282.   /*
  1283. ***************
  1284. *** 281,307 ****
  1285.   
  1286.   close_files ()
  1287.   {
  1288. !     if (! pw_close ()) {
  1289.           fprintf (stderr, "%s: cannot rewrite password file\n", Prog);
  1290. !         exit (1);
  1291. !     }
  1292. !     if (! spw_close ()) {
  1293.           fprintf (stderr, "%s: cannot rewrite shadow password file\n",    
  1294.               Prog);
  1295. !         exit (1);
  1296. !     }
  1297. !     if (! gr_close ()) {
  1298.           fprintf (stderr, "%s: cannot rewrite group file\n",
  1299.               Prog);
  1300. !         exit (10);
  1301. !     }
  1302.       (void) gr_unlock ();
  1303.   #ifdef    SHADOWGRP
  1304. !     if (! sgr_close ()) {
  1305.           fprintf (stderr, "%s: cannot rewrite shadow group file\n",
  1306.               Prog);
  1307. !         exit (10);
  1308. !     }
  1309.       (void) sgr_unlock ();
  1310.   #endif
  1311.       (void) spw_unlock ();
  1312. --- 277,299 ----
  1313.   
  1314.   close_files ()
  1315.   {
  1316. !     if (! pw_close ())
  1317.           fprintf (stderr, "%s: cannot rewrite password file\n", Prog);
  1318. !     if (! spw_close ())
  1319.           fprintf (stderr, "%s: cannot rewrite shadow password file\n",    
  1320.               Prog);
  1321. !     if (! gr_close ())
  1322.           fprintf (stderr, "%s: cannot rewrite group file\n",
  1323.               Prog);
  1324.       (void) gr_unlock ();
  1325.   #ifdef    SHADOWGRP
  1326. !     if (! sgr_close ())
  1327.           fprintf (stderr, "%s: cannot rewrite shadow group file\n",
  1328.               Prog);
  1329.       (void) sgr_unlock ();
  1330.   #endif
  1331.       (void) spw_unlock ();
  1332. ***************
  1333. *** 322,353 ****
  1334.       }
  1335.       if (! pw_open (O_RDWR)) {
  1336.           fprintf (stderr, "%s: unable to open password file\n", Prog);
  1337. !         exit (1);
  1338.       }
  1339.       if (! spw_lock ()) {
  1340.           fprintf (stderr, "%s: cannot lock shadow password file\n", Prog);
  1341. !         exit (1);
  1342.       }
  1343.       if (! spw_open (O_RDWR)) {
  1344.           fprintf (stderr, "%s: cannot open shadow password file\n", Prog);
  1345. !         exit (1);
  1346.       }
  1347.       if (! gr_lock ()) {
  1348.           fprintf (stderr, "%s: unable to lock group file\n", Prog);
  1349. !         exit (1);
  1350.       }
  1351.       if (! gr_open (O_RDWR)) {
  1352.           fprintf (stderr, "%s: cannot open group file\n", Prog);
  1353. !         exit (1);
  1354.       }
  1355.   #ifdef    SHADOWGRP
  1356.       if (! sgr_lock ()) {
  1357.           fprintf (stderr, "%s: unable to lock shadow group file\n", Prog);
  1358. !         exit (1);
  1359.       }
  1360.       if (! sgr_open (O_RDWR)) {
  1361.           fprintf (stderr, "%s: cannot open shadow group file\n", Prog);
  1362. !         exit (1);
  1363.       }
  1364.   #endif
  1365.   }
  1366. --- 314,345 ----
  1367.       }
  1368.       if (! pw_open (O_RDWR)) {
  1369.           fprintf (stderr, "%s: unable to open password file\n", Prog);
  1370. !         fail_exit (1);
  1371.       }
  1372.       if (! spw_lock ()) {
  1373.           fprintf (stderr, "%s: cannot lock shadow password file\n", Prog);
  1374. !         fail_exit (1);
  1375.       }
  1376.       if (! spw_open (O_RDWR)) {
  1377.           fprintf (stderr, "%s: cannot open shadow password file\n", Prog);
  1378. !         fail_exit (1);
  1379.       }
  1380.       if (! gr_lock ()) {
  1381.           fprintf (stderr, "%s: unable to lock group file\n", Prog);
  1382. !         fail_exit (1);
  1383.       }
  1384.       if (! gr_open (O_RDWR)) {
  1385.           fprintf (stderr, "%s: cannot open group file\n", Prog);
  1386. !         fail_exit (1);
  1387.       }
  1388.   #ifdef    SHADOWGRP
  1389.       if (! sgr_lock ()) {
  1390.           fprintf (stderr, "%s: unable to lock shadow group file\n", Prog);
  1391. !         fail_exit (1);
  1392.       }
  1393.       if (! sgr_open (O_RDWR)) {
  1394.           fprintf (stderr, "%s: cannot open shadow group file\n", Prog);
  1395. !         fail_exit (1);
  1396.       }
  1397.   #endif
  1398.   }
  1399. ***************
  1400. *** 376,383 ****
  1401.               fprintf (stderr,
  1402.                   "%s: error deleting password dbm entry\n",
  1403.                   Prog);
  1404. -         endpwent ();
  1405.       }
  1406.   
  1407.       /*
  1408. --- 368,373 ----
  1409. ***************
  1410. *** 389,395 ****
  1411.       for (pw_rewind (), pwd = pw_next ();pwd;pwd = pw_next ()) {
  1412.           if (pwd->pw_uid == user_id) {
  1413.               pw_dbm_update (pwd);
  1414. -             endpwent ();
  1415.               break;
  1416.           }
  1417.       }
  1418. --- 379,384 ----
  1419. ***************
  1420. *** 401,409 ****
  1421. --- 390,417 ----
  1422.   
  1423.       endspent ();
  1424.   #endif
  1425. + #if defined(DBM) || defined(NDBM)
  1426. +     endpwent ();
  1427. + #endif
  1428.   #ifdef    USE_SYSLOG
  1429.       syslog (LOG_INFO, "delete user `%s'\n", user_name);
  1430.   #endif
  1431. + }
  1432. + /*
  1433. +  * fail_exit - exit with a failure code after unlocking the files
  1434. +  */
  1435. + fail_exit (code)
  1436. + int    code;
  1437. + {
  1438. +     (void) pw_unlock ();
  1439. +     (void) gr_unlock ();
  1440. +     (void) spw_unlock ();
  1441. + #ifdef    SHADOWGRP
  1442. +     (void) sgr_unlock ();
  1443. + #endif
  1444. +     exit (code);
  1445.   }
  1446.   
  1447.   /*
  1448. Index: groupadd.c
  1449. *** rel3/groupadd.c    Fri Mar 27 10:24:11 1992
  1450. --- groupadd.c    Fri Mar 27 10:27:29 1992
  1451. ***************
  1452. *** 1,5 ****
  1453.   /*
  1454. !  * Copyright 1991, John F. Haugh II
  1455.    * All rights reserved.
  1456.    *
  1457.    * Permission is granted to copy and create derivative works for any
  1458. --- 1,5 ----
  1459.   /*
  1460. !  * Copyright 1991, 1992, John F. Haugh II
  1461.    * All rights reserved.
  1462.    *
  1463.    * Permission is granted to copy and create derivative works for any
  1464. ***************
  1465. *** 10,16 ****
  1466.    */
  1467.   
  1468.   #ifndef lint
  1469. ! static    char    sccsid[] = "@(#)groupadd.c    3.3    08:43:44    9/12/91";
  1470.   #endif
  1471.   
  1472.   #include <sys/types.h>
  1473. --- 10,16 ----
  1474.    */
  1475.   
  1476.   #ifndef lint
  1477. ! static    char    sccsid[] = "@(#)groupadd.c    3.4    09:41:21    3/19/92";
  1478.   #endif
  1479.   
  1480.   #include <sys/types.h>
  1481. ***************
  1482. *** 140,146 ****
  1483.   
  1484.       if (! gr_update (&grp)) {
  1485.           fprintf (stderr, "%s: error adding new group entry\n", Prog);
  1486. !         exit (1);
  1487.       }
  1488.   #ifdef    NDBM
  1489.   
  1490. --- 140,146 ----
  1491.   
  1492.       if (! gr_update (&grp)) {
  1493.           fprintf (stderr, "%s: error adding new group entry\n", Prog);
  1494. !         fail_exit (1);
  1495.       }
  1496.   #ifdef    NDBM
  1497.   
  1498. ***************
  1499. *** 150,156 ****
  1500.   
  1501.       if (! gr_dbm_update (&grp)) {
  1502.           fprintf (stderr, "%s: cannot add new dbm group entry\n", Prog);
  1503. !         exit (1);
  1504.       }
  1505.       endgrent ();
  1506.   #endif    /* NDBM */
  1507. --- 150,156 ----
  1508.   
  1509.       if (! gr_dbm_update (&grp)) {
  1510.           fprintf (stderr, "%s: cannot add new dbm group entry\n", Prog);
  1511. !         fail_exit (1);
  1512.       }
  1513.       endgrent ();
  1514.   #endif    /* NDBM */
  1515. ***************
  1516. *** 163,169 ****
  1517.   
  1518.       if (! sgr_update (&sgrp)) {
  1519.           fprintf (stderr, "%s: error adding new group entry\n", Prog);
  1520. !         exit (1);
  1521.       }
  1522.   #ifdef    NDBM
  1523.   
  1524. --- 163,169 ----
  1525.   
  1526.       if (! sgr_update (&sgrp)) {
  1527.           fprintf (stderr, "%s: error adding new group entry\n", Prog);
  1528. !         fail_exit (1);
  1529.       }
  1530.   #ifdef    NDBM
  1531.   
  1532. ***************
  1533. *** 173,179 ****
  1534.   
  1535.       if (! sgr_dbm_update (&sgrp)) {
  1536.           fprintf (stderr, "%s: cannot add new dbm group entry\n", Prog);
  1537. !         exit (1);
  1538.       }
  1539.       endsgent ();
  1540.   #endif    /* NDBM */
  1541. --- 173,179 ----
  1542.   
  1543.       if (! sgr_dbm_update (&sgrp)) {
  1544.           fprintf (stderr, "%s: cannot add new dbm group entry\n", Prog);
  1545. !         fail_exit (1);
  1546.       }
  1547.       endsgent ();
  1548.   #endif    /* NDBM */
  1549. ***************
  1550. *** 215,226 ****
  1551.           if (strcmp (group_name, grp->gr_name) == 0) {
  1552.               fprintf (stderr, "%s: name %s is not unique\n",
  1553.                   Prog, group_name);
  1554. !             exit (1);
  1555.           }
  1556.           if (gflg && group_id == grp->gr_gid) {
  1557.               fprintf (stderr, "%s: gid %d is not unique\n",
  1558.                   Prog, group_id);
  1559. !             exit (1);
  1560.           }
  1561.           if (! gflg && grp->gr_gid >= group_id)
  1562.               group_id = grp->gr_gid + 1;
  1563. --- 215,226 ----
  1564.           if (strcmp (group_name, grp->gr_name) == 0) {
  1565.               fprintf (stderr, "%s: name %s is not unique\n",
  1566.                   Prog, group_name);
  1567. !             fail_exit (1);
  1568.           }
  1569.           if (gflg && group_id == grp->gr_gid) {
  1570.               fprintf (stderr, "%s: gid %d is not unique\n",
  1571.                   Prog, group_id);
  1572. !             fail_exit (1);
  1573.           }
  1574.           if (! gflg && grp->gr_gid >= group_id)
  1575.               group_id = grp->gr_gid + 1;
  1576. ***************
  1577. *** 256,262 ****
  1578.                   if (*end != '\0') {
  1579.                       fprintf (stderr, "%s: invalid group %s\n",
  1580.                           Prog, optarg);
  1581. !                     exit (3);
  1582.                   }
  1583.                   break;
  1584.               case 'o':
  1585. --- 256,262 ----
  1586.                   if (*end != '\0') {
  1587.                       fprintf (stderr, "%s: invalid group %s\n",
  1588.                           Prog, optarg);
  1589. !                     fail_exit (3);
  1590.                   }
  1591.                   break;
  1592.               case 'o':
  1593. ***************
  1594. *** 269,277 ****
  1595.                   usage ();
  1596.           }
  1597.       }
  1598. -     if (! gflg)
  1599. -         find_new_gid ();
  1600.       if (optind == argc - 1)
  1601.           strcpy (group_name, argv[argc - 1]);
  1602.       else
  1603. --- 269,274 ----
  1604. ***************
  1605. *** 289,295 ****
  1606.   {
  1607.       if (! gr_close ()) {
  1608.           fprintf (stderr, "%s: cannot rewrite group file\n", Prog);
  1609. !         exit (1);
  1610.       }
  1611.       (void) gr_unlock ();
  1612.   #ifdef    SHADOWGRP
  1613. --- 286,292 ----
  1614.   {
  1615.       if (! gr_close ()) {
  1616.           fprintf (stderr, "%s: cannot rewrite group file\n", Prog);
  1617. !         fail_exit (1);
  1618.       }
  1619.       (void) gr_unlock ();
  1620.   #ifdef    SHADOWGRP
  1621. ***************
  1622. *** 296,302 ****
  1623.       if (! sgr_close ()) {
  1624.           fprintf (stderr, "%s: cannot rewrite shadow group file\n",
  1625.               Prog);
  1626. !         exit (1);
  1627.       }
  1628.       (void) sgr_unlock ();
  1629.   #endif    /* SHADOWGRP */
  1630. --- 293,299 ----
  1631.       if (! sgr_close ()) {
  1632.           fprintf (stderr, "%s: cannot rewrite shadow group file\n",
  1633.               Prog);
  1634. !         fail_exit (1);
  1635.       }
  1636.       (void) sgr_unlock ();
  1637.   #endif    /* SHADOWGRP */
  1638. ***************
  1639. *** 316,338 ****
  1640.       }
  1641.       if (! gr_open (O_RDWR)) {
  1642.           fprintf (stderr, "%s: unable to open group file\n", Prog);
  1643. !         exit (1);
  1644.       }
  1645.   #ifdef    SHADOWGRP
  1646.       if (! sgr_lock ()) {
  1647.           fprintf (stderr, "%s: unable to lock shadow group file\n",
  1648.               Prog);
  1649. !         exit (1);
  1650.       }
  1651.       if (! sgr_open (O_RDWR)) {
  1652.           fprintf (stderr, "%s: unable to open shadow group file\n",
  1653.               Prog);
  1654. !         exit (1);
  1655.       }
  1656.   #endif    /* SHADOWGRP */
  1657.   }
  1658.   
  1659.   /*
  1660.    * main - useradd command
  1661.    */
  1662.   
  1663. --- 313,349 ----
  1664.       }
  1665.       if (! gr_open (O_RDWR)) {
  1666.           fprintf (stderr, "%s: unable to open group file\n", Prog);
  1667. !         fail_exit (1);
  1668.       }
  1669.   #ifdef    SHADOWGRP
  1670.       if (! sgr_lock ()) {
  1671.           fprintf (stderr, "%s: unable to lock shadow group file\n",
  1672.               Prog);
  1673. !         fail_exit (1);
  1674.       }
  1675.       if (! sgr_open (O_RDWR)) {
  1676.           fprintf (stderr, "%s: unable to open shadow group file\n",
  1677.               Prog);
  1678. !         fail_exit (1);
  1679.       }
  1680.   #endif    /* SHADOWGRP */
  1681.   }
  1682.   
  1683.   /*
  1684. +  * fail_exit - exit with an error code after unlocking files
  1685. +  */
  1686. + fail_exit (code)
  1687. + int    code;
  1688. + {
  1689. +     (void) gr_unlock ();
  1690. + #ifdef    SHADOWGRP
  1691. +     (void) sgr_unlock ();
  1692. + #endif
  1693. +     exit (code);
  1694. + }
  1695. + /*
  1696.    * main - useradd command
  1697.    */
  1698.   
  1699. ***************
  1700. *** 382,387 ****
  1701. --- 393,400 ----
  1702.        */
  1703.   
  1704.       open_files ();
  1705. +     if (! gflg)
  1706. +         find_new_gid ();
  1707.   
  1708.       grp_update ();
  1709.   
  1710. Index: chage.1
  1711. *** rel3/chage.1    Fri Mar 27 10:24:28 1992
  1712. --- chage.1    Fri Mar 27 10:27:34 1992
  1713. ***************
  1714. *** 4,36 ****
  1715.   .\" Use, duplication, and disclosure prohibited without
  1716.   .\" the express written permission of the author.
  1717.   .\"
  1718. ! .\"    @(#)chage.1    3.1    09:34:14    11/21/90
  1719.   .\"
  1720.   .TH CHAGE 1
  1721.   .SH NAME
  1722.   chage \- change user password expirate information
  1723.   .SH SYNOPSIS
  1724. ! \fBchage\fR [ \fB-m \fImindays\fR ] [ \fB-M \fImaxdays\fR ] [ \fB-d \fIlastday\fR ] \fIuser\fR
  1725.   .SH DESCRIPTION
  1726.   \fIchage\f changes the number of days between password changes and the
  1727.   date of the last password change.
  1728.   This information is used by the system to determine when a user must
  1729. ! change their password.
  1730. ! The \fIchage\f command is restricted to the root user.
  1731.   .PP
  1732. ! The value of \fImindays\f is the minimum number of days between
  1733. ! password changes.
  1734.   A value of zero for this field indicates that the user may change
  1735.   her password at any time.
  1736.   .PP
  1737. ! The value of \fImaxdays\f is the maximum number of days during
  1738. ! which a password is valid.
  1739. ! When \fImaxdays\f plus \fIlastday\f is less than the current day,
  1740.   the user will be required to change her password before being
  1741.   able to use her account.
  1742.   .PP
  1743. ! The value of \fIlastday\f is the number of days since January 1st,
  1744. ! 1970 when the password was last changed.
  1745.   .PP
  1746.   All of the above values are stored exactly as days when the shadow
  1747.   password file is used, but are converted to and from weeks when the
  1748. --- 4,67 ----
  1749.   .\" Use, duplication, and disclosure prohibited without
  1750.   .\" the express written permission of the author.
  1751.   .\"
  1752. ! .\"    @(#)chage.1    3.2    10:04:46    3/27/92
  1753.   .\"
  1754.   .TH CHAGE 1
  1755.   .SH NAME
  1756.   chage \- change user password expirate information
  1757.   .SH SYNOPSIS
  1758. ! \fBchage\fR [ \fB-m \fImindays\fR ] [ \fB-M \fImaxdays\fR ]
  1759. ! [ \fB-d \fIlastday\fR ] [ \fB-I \fIinactive\fR ]
  1760. ! [ \fB-E \fIexpiredate\fR ] [ \fB-W \fIwarndays\fR ] \fIuser\fR
  1761. ! .sp 1
  1762. ! \fBchage\fR -l \fIuser\fR
  1763.   .SH DESCRIPTION
  1764.   \fIchage\f changes the number of days between password changes and the
  1765.   date of the last password change.
  1766.   This information is used by the system to determine when a user must
  1767. ! change her password.
  1768. ! The \fIchage\f command is restricted to the root user, except for the
  1769. ! \fB-l\fR option, which may be used by an unprivileged user to determine
  1770. ! when her password or account is due to expire.
  1771.   .PP
  1772. ! With the \fB-m\fR option, the value of \fImindays\f is the minimum number
  1773. ! of days between password changes.
  1774.   A value of zero for this field indicates that the user may change
  1775.   her password at any time.
  1776.   .PP
  1777. ! With the \fB-M\fR option, the value of \fImaxdays\f is the maximum number
  1778. ! of days during which a password is valid.
  1779. ! When \fImaxdays\fR plus \fIlastday\fR is less than the current day,
  1780.   the user will be required to change her password before being
  1781.   able to use her account.
  1782. + This occurance can be planned for in advance by use of the \fB-W\fR option,
  1783. + which provides the user with advance warning.
  1784.   .PP
  1785. ! With the \fB-d\fR option, the value of \fIlastday\f is the number of days
  1786. ! since January 1st, 1970 when the password was last changed.
  1787. ! The date may also be expressed in the format MM/DD/YY (or the format more
  1788. ! commonly used in your area).
  1789. ! .PP
  1790. ! The \fB-E\fR option is used to set a date on which the user's account will
  1791. ! no longer be accessible.
  1792. ! The \fIexpiredate\fR option is the number of days since January 1, 1970 on
  1793. ! which the accounted is locked.
  1794. ! The date may also be expressed in the format MM/DD/YY (or the format more
  1795. ! commonly used in your area).
  1796. ! A user whose account is locked must contact the system administrator before
  1797. ! being able to use the system again.
  1798. ! .PP
  1799. ! The \fB-I\fR option is used to set the number of days of inactivity after
  1800. ! a password has expired before the account is locked.
  1801. ! A user whose account is locked must contact the system administrator before
  1802. ! being able to use the system again.
  1803. ! The \fIinactive\fR option is the number of days of inactivity. A value of
  1804. ! 0 disables this feature.
  1805. ! .PP
  1806. ! The \fB-W\fR option is used to set the number of days of warning before a
  1807. ! password change is required.
  1808. ! The \fIwarndays\fR option is the number of days prior to the password
  1809. ! expiring that a user will be warned her password is about to expire.
  1810.   .PP
  1811.   All of the above values are stored exactly as days when the shadow
  1812.   password file is used, but are converted to and from weeks when the
  1813. -- 
  1814. John F. Haugh II        | Every 56 days.   | UUCP: ...!cs.utexas.edu!rpp386!jfh
  1815. Ma Bell: (512) 251-2151 | Give Blood, often.    | Domain: jfh@rpp386.cactus.org
  1816. "A countryman between two lawyers is like a fish between two cats."
  1817.         -- Benjamin Franklin
  1818.  
  1819. exit 0 # Just in case...
  1820.