home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / shadow / patch06c < prev    next >
Encoding:
Text File  |  1992-10-14  |  52.0 KB  |  2,153 lines

  1. Newsgroups: comp.sources.misc
  2. From: jfh@rpp386.cactus.org (John F Haugh II)
  3. Subject:  v32i100:  shadow - Shadow Login/Password Suite, Patch06c/3
  4. Message-ID: <1992Oct12.152411.12011@sparky.imd.sterling.com>
  5. X-Md4-Signature: 567ee091de9c0e00615e81830cb6fb50
  6. Date: Mon, 12 Oct 1992 15:24:11 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jfh@rpp386.cactus.org (John F Haugh II)
  10. Posting-number: Volume 32, Issue 100
  11. Archive-name: shadow/patch06c
  12. Environment: UNIX
  13. Patch-To: shadow: Volume 26, Issue 54-64
  14.  
  15. This is the third part of a three part patch.  You now have all of the
  16. parts.
  17. --
  18. Index: userdel.c
  19. *** userdel.c.old    Sat Oct 10 11:20:04 1992
  20. --- userdel.c    Sat Oct 10 11:20:03 1992
  21. ***************
  22. *** 7,16 ****
  23.    * in all copies of source code, or included in human readable form
  24.    * and conspicuously displayed on all copies of object code or
  25.    * distribution media.
  26.    */
  27.   
  28.   #ifndef lint
  29. ! static    char    sccsid[] = "@(#)userdel.c    3.10    09:41:48    3/19/92";
  30.   #endif
  31.   
  32.   #include <sys/types.h>
  33. --- 7,19 ----
  34.    * in all copies of source code, or included in human readable form
  35.    * and conspicuously displayed on all copies of object code or
  36.    * distribution media.
  37. +  *
  38. +  * This software is provided on an AS-IS basis and the author makes
  39. +  * no warrantee of any kind.
  40.    */
  41.   
  42.   #ifndef lint
  43. ! static    char    sccsid[] = "@(#)userdel.c    3.13    10:52:23    10/10/92";
  44.   #endif
  45.   
  46.   #include <sys/types.h>
  47. ***************
  48. *** 30,36 ****
  49. --- 33,42 ----
  50.   #endif
  51.   
  52.   #include "config.h"
  53. + #ifdef    SHADOWPWD
  54.   #include "shadow.h"
  55. + #endif
  56. + #include "pwauth.h"
  57.   
  58.   #ifdef    USE_SYSLOG
  59.   #include <syslog.h>
  60. ***************
  61. *** 40,72 ****
  62.   #endif
  63.   #endif
  64.   
  65. - gid_t    default_group;
  66. - char    default_home[BUFSIZ];
  67. - char    default_shell[BUFSIZ];
  68. - long    default_inactive;
  69. - long    default_expire;
  70. - char    default_file[] = "/etc/default/useradd";
  71.   #ifndef    NGROUPS_MAX
  72.   #define    NGROUPS_MAX    64
  73.   #endif
  74.   
  75.   char    user_name[BUFSIZ];
  76.   uid_t    user_id;
  77. - gid_t    user_group;
  78. - char    user_comment[BUFSIZ];
  79.   char    user_home[BUFSIZ];
  80. - char    user_shell[BUFSIZ];
  81. - int    user_ngroups;
  82. - int    user_expire;
  83. - gid_t    user_groups[NGROUPS_MAX];
  84.   
  85.   char    *Prog;
  86.   int    rflg;
  87.   
  88.   #ifdef    NDBM
  89.   extern    int    pw_dbm_mode;
  90.   extern    int    sp_dbm_mode;
  91.   extern    int    gr_dbm_mode;
  92.   #ifdef    SHADOWGRP
  93.   extern    int    sg_dbm_mode;
  94. --- 46,73 ----
  95.   #endif
  96.   #endif
  97.   
  98.   #ifndef    NGROUPS_MAX
  99.   #define    NGROUPS_MAX    64
  100.   #endif
  101.   
  102. + #if defined(DIR_XENIX) || defined(DIR_BSD) || defined(DIR_SYSV)
  103. + #define    DIR_ANY
  104. + #endif
  105.   char    user_name[BUFSIZ];
  106.   uid_t    user_id;
  107.   char    user_home[BUFSIZ];
  108.   
  109.   char    *Prog;
  110. + #ifdef    DIR_ANY
  111.   int    rflg;
  112. + #endif
  113.   
  114.   #ifdef    NDBM
  115.   extern    int    pw_dbm_mode;
  116. + #ifdef    SHADOWPWD
  117.   extern    int    sp_dbm_mode;
  118. + #endif
  119.   extern    int    gr_dbm_mode;
  120.   #ifdef    SHADOWGRP
  121.   extern    int    sg_dbm_mode;
  122. ***************
  123. *** 78,83 ****
  124. --- 79,92 ----
  125.   extern    struct    passwd    *getpwnam();
  126.   extern    struct    passwd    *pw_next();
  127.   
  128. + #ifdef    SHADOWPWD
  129. + extern    int    spw_lock();
  130. + extern    int    spw_unlock();
  131. + extern    int    spw_open();
  132. + extern    int    spw_close();
  133. + extern    struct    spwd    *spw_locate();
  134. + #endif
  135.   #ifdef    SHADOWGRP
  136.   extern    int    sgr_lock();
  137.   extern    int    sgr_unlock();
  138. ***************
  139. *** 145,151 ****
  140. --- 154,164 ----
  141.   
  142.   usage ()
  143.   {
  144. + #ifdef    DIR_ANY
  145.       fprintf (stderr, "usage: %s [-r] name\n", Prog);
  146. + #else
  147. +     fprintf (stderr, "usage: %s name\n", Prog);
  148. + #endif
  149.       exit (2);
  150.   }
  151.   
  152. ***************
  153. *** 253,259 ****
  154.            * Update the DBM group file with the new entry as well.
  155.            */
  156.   
  157. !         if (! sgr_dbm_update (sgrp))
  158.               fprintf (stderr, "%s: cannot update dbm group entry\n",
  159.                   Prog);
  160.   #endif    /* NDBM */
  161. --- 266,272 ----
  162.            * Update the DBM group file with the new entry as well.
  163.            */
  164.   
  165. !         if (! sg_dbm_update (sgrp))
  166.               fprintf (stderr, "%s: cannot update dbm group entry\n",
  167.                   Prog);
  168.   #endif    /* NDBM */
  169. ***************
  170. *** 279,289 ****
  171.   {
  172.       if (! pw_close ())
  173.           fprintf (stderr, "%s: cannot rewrite password file\n", Prog);
  174.       if (! spw_close ())
  175.           fprintf (stderr, "%s: cannot rewrite shadow password file\n",    
  176.               Prog);
  177.       if (! gr_close ())
  178.           fprintf (stderr, "%s: cannot rewrite group file\n",
  179.               Prog);
  180. --- 292,302 ----
  181.   {
  182.       if (! pw_close ())
  183.           fprintf (stderr, "%s: cannot rewrite password file\n", Prog);
  184. ! #ifdef    SHADOWPWD
  185.       if (! spw_close ())
  186.           fprintf (stderr, "%s: cannot rewrite shadow password file\n",    
  187.               Prog);
  188. ! #endif
  189.       if (! gr_close ())
  190.           fprintf (stderr, "%s: cannot rewrite group file\n",
  191.               Prog);
  192. ***************
  193. *** 296,302 ****
  194. --- 309,317 ----
  195.   
  196.       (void) sgr_unlock ();
  197.   #endif
  198. + #ifdef    SHADOWPWD
  199.       (void) spw_unlock ();
  200. + #endif
  201.       (void) pw_unlock ();
  202.   }
  203.   
  204. ***************
  205. *** 316,321 ****
  206. --- 331,337 ----
  207.           fprintf (stderr, "%s: unable to open password file\n", Prog);
  208.           fail_exit (1);
  209.       }
  210. + #ifdef    SHADOWPWD
  211.       if (! spw_lock ()) {
  212.           fprintf (stderr, "%s: cannot lock shadow password file\n", Prog);
  213.           fail_exit (1);
  214. ***************
  215. *** 324,329 ****
  216. --- 340,346 ----
  217.           fprintf (stderr, "%s: cannot open shadow password file\n", Prog);
  218.           fail_exit (1);
  219.       }
  220. + #endif
  221.       if (! gr_lock ()) {
  222.           fprintf (stderr, "%s: unable to lock group file\n", Prog);
  223.           fail_exit (1);
  224. ***************
  225. *** 354,367 ****
  226.   update_user ()
  227.   {
  228.       struct    passwd    *pwd;
  229.   
  230.       if (! pw_remove (user_name))
  231.           fprintf (stderr, "%s: error deleting password entry\n", Prog);
  232.       if (! spw_remove (user_name))
  233.           fprintf (stderr, "%s: error deleting shadow password entry\n",
  234.               Prog);
  235.   #if defined(DBM) || defined(NDBM)
  236.       if (access ("/etc/passwd.pag", 0) == 0) {
  237.           if ((pwd = getpwnam (user_name)) && ! pw_dbm_remove (pwd))
  238. --- 371,424 ----
  239.   update_user ()
  240.   {
  241.       struct    passwd    *pwd;
  242. + #ifdef    SHADOWPWD
  243. +     struct    spwd    *spwd;
  244.   
  245. +     if ((spwd = spw_locate (user_name)) && spwd->sp_pwdp[0] == '@') {
  246. +         if (pw_auth (spwd->sp_pwdp + 1, user_name, PW_DELETE)) {
  247. + #ifdef    USE_SYSLOG
  248. +             syslog (LOG_ERR,
  249. +                 "failed deleting auth `%s' for user `%s'\n",
  250. +                 spwd->sp_pwdp + 1, user_name);
  251. + #endif     /* USE_SYSLOG */
  252. +             fprintf (stderr,
  253. +                 "%s: error deleting authentication\n",
  254. +             Prog);
  255. +         }
  256. + #ifdef    USE_SYSLOG
  257. +         else {
  258. +             syslog (LOG_INFO,
  259. +                 "delete auth `%s' for user `%s'\n",
  260. +                 spwd->sp_pwdp + 1, user_name);
  261. +         }
  262. + #endif    /* USE_SYSLOG */
  263. +     }
  264. + #endif    /* SHADOWPWD */
  265. +     if ((pwd = pw_locate (user_name)) && pwd->pw_passwd[0] == '@') {
  266. +         if (pw_auth (pwd->pw_passwd + 1, user_name, PW_DELETE)) {
  267. + #ifdef    USE_SYSLOG
  268. +             syslog (LOG_ERR,
  269. +                 "failed deleting auth `%s' for user `%s'\n",
  270. +                 pwd->pw_passwd + 1, user_name);
  271. + #endif     /* USE_SYSLOG */
  272. +             fprintf (stderr, "%s: error deleting authentication\n",
  273. +                 Prog);
  274. +         }
  275. + #ifdef    USE_SYSLOG
  276. +         else {
  277. +             syslog (LOG_INFO,
  278. +                 "delete auth `%s' for user `%s'\n",
  279. +                 pwd->pw_passwd + 1, user_name);
  280. +         }
  281. + #endif    /* USE_SYSLOG */
  282. +     }
  283.       if (! pw_remove (user_name))
  284.           fprintf (stderr, "%s: error deleting password entry\n", Prog);
  285. ! #ifdef    SHADOWPWD
  286.       if (! spw_remove (user_name))
  287.           fprintf (stderr, "%s: error deleting shadow password entry\n",
  288.               Prog);
  289. ! #endif
  290.   #if defined(DBM) || defined(NDBM)
  291.       if (access ("/etc/passwd.pag", 0) == 0) {
  292.           if ((pwd = getpwnam (user_name)) && ! pw_dbm_remove (pwd))
  293. ***************
  294. *** 383,389 ****
  295.           }
  296.       }
  297.   #endif
  298. ! #ifdef    NDBM
  299.       if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_remove (user_name))
  300.           fprintf (stderr, "%s: error deleting shadow passwd dbm entry\n",
  301.               Prog);
  302. --- 440,446 ----
  303.           }
  304.       }
  305.   #endif
  306. ! #if defined(NDBM) && defined(SHADOWPWD)
  307.       if (access ("/etc/shadow.pag", 0) == 0 && ! sp_dbm_remove (user_name))
  308.           fprintf (stderr, "%s: error deleting shadow passwd dbm entry\n",
  309.               Prog);
  310. ***************
  311. *** 407,413 ****
  312. --- 464,472 ----
  313.   {
  314.       (void) pw_unlock ();
  315.       (void) gr_unlock ();
  316. + #ifdef    SHADOWPWD
  317.       (void) spw_unlock ();
  318. + #endif
  319.   #ifdef    SHADOWGRP
  320.       (void) sgr_unlock ();
  321.   #endif
  322. ***************
  323. *** 450,456 ****
  324. --- 509,517 ----
  325.       pw_dbm_mode = O_RDWR;
  326.   #endif
  327.   #ifdef    NDBM
  328. + #ifdef    SHADOWPWD
  329.       sp_dbm_mode = O_RDWR;
  330. + #endif
  331.       gr_dbm_mode = O_RDWR;
  332.   #ifdef    SHADOWGRP
  333.       sg_dbm_mode = O_RDWR;
  334. ***************
  335. *** 457,466 ****
  336. --- 518,531 ----
  337.   #endif
  338.   #endif
  339.       while ((arg = getopt (argc, argv, "r")) != EOF)
  340. + #ifdef    DIR_ANY
  341.           if (arg != 'r')
  342.               usage ();
  343.           else
  344.               rflg++;
  345. + #else
  346. +         usage ();
  347. + #endif
  348.       
  349.       if (optind == argc)
  350.           usage ();
  351. ***************
  352. *** 489,498 ****
  353. --- 554,565 ----
  354.       update_user ();
  355.       update_groups ();
  356.   
  357. + #ifdef    DIR_ANY
  358.       if (rflg) {
  359.           if (remove_tree (user_home) || rmdir (user_home))
  360.               errors++;
  361.       }
  362. + #endif
  363.       close_files ();
  364.       exit (errors ? 12:0);
  365.       /*NOTREACHED*/
  366. Index: usermod.1
  367. *** usermod.1.old    Sat Oct 10 11:20:22 1992
  368. --- usermod.1    Sat Oct 10 11:20:21 1992
  369. ***************
  370. *** 1,4 ****
  371. ! .\" Copyright 1991, John F. Haugh II
  372.   .\" All rights reserved.
  373.   .\"
  374.   .\" Permission is granted to copy and create derivative works for any
  375. --- 1,4 ----
  376. ! .\" Copyright 1991, 1992, John F. Haugh II
  377.   .\" All rights reserved.
  378.   .\"
  379.   .\" Permission is granted to copy and create derivative works for any
  380. ***************
  381. *** 7,19 ****
  382.   .\" and conspicuously displayed on all copies of object code or
  383.   .\" distribution media.
  384.   .\"
  385. ! .\"    @(#)usermod.1    3.1    07:46:06    7/13/91
  386.   .\"
  387.   .TH USERMOD 1M
  388.   .SH NAME
  389.   usermod \- Modify a user account
  390.   .SH SYNOPSIS
  391.   .B usermod
  392.   [ \fB-c\fI comment\fR ]
  393.   [ \fB-d\fI home_dir \fR[ \fB-m\fR ] ]
  394.   [ \fB-e\fI expire_date\fR ]
  395. --- 7,23 ----
  396.   .\" and conspicuously displayed on all copies of object code or
  397.   .\" distribution media.
  398.   .\"
  399. ! .\" This software is provided on an AS-IS basis and the author makes
  400. ! .\" no warrantee of any kind.
  401.   .\"
  402. + .\"    @(#)usermod.1    3.3    08:22:15    10/1/92
  403. + .\"
  404.   .TH USERMOD 1M
  405.   .SH NAME
  406.   usermod \- Modify a user account
  407.   .SH SYNOPSIS
  408.   .B usermod
  409. + [ \fB-A\fI method|DEFAULT ]
  410.   [ \fB-c\fI comment\fR ]
  411.   [ \fB-d\fI home_dir \fR[ \fB-m\fR ] ]
  412.   [ \fB-e\fI expire_date\fR ]
  413. ***************
  414. *** 28,33 ****
  415. --- 32,43 ----
  416.   The \fIusermod\fR command modifies the system account files to reflect
  417.   the changes that are specified on the command line.
  418.   The options which apply to the \fIusermod\fR command are
  419. + .IP "\fB-A \fImethod\fR|\fBDEFAULT\fR"
  420. + The new value of the user's authentication method.
  421. + The authentication method is the name of a program which is responsible
  422. + for validating the user's identity.
  423. + The string \fBDEFAULT\fR may be used to change the user's authentication
  424. + method to the standard system password method.
  425.   .IP "\fB-c \fIcomment\fR"
  426.   The new value of the user's password file comment field.
  427.   It is normally modified using the \fBchfn(1)\fR utility.
  428. Index: usermod.c
  429. *** usermod.c.old    Sat Oct 10 11:20:39 1992
  430. --- usermod.c    Sat Oct 10 11:20:37 1992
  431. ***************
  432. *** 7,16 ****
  433.    * in all copies of source code, or included in human readable form
  434.    * and conspicuously displayed on all copies of object code or
  435.    * distribution media.
  436.    */
  437.   
  438.   #ifndef lint
  439. ! static    char    sccsid[] = "@(#)usermod.c    3.12    15:28:40    5/14/92";
  440.   #endif
  441.   
  442.   #include <sys/types.h>
  443. --- 7,19 ----
  444.    * in all copies of source code, or included in human readable form
  445.    * and conspicuously displayed on all copies of object code or
  446.    * distribution media.
  447. +  *
  448. +  * This software is provided on an AS-IS basis and the author makes
  449. +  * no warrantee of any kind.
  450.    */
  451.   
  452.   #ifndef lint
  453. ! static    char    sccsid[] = "@(#)usermod.c    3.15    10:52:28    10/10/92";
  454.   #endif
  455.   
  456.   #include <sys/types.h>
  457. ***************
  458. *** 35,40 ****
  459. --- 38,44 ----
  460.   #endif
  461.   #include "faillog.h"
  462.   #include "lastlog.h"
  463. + #include "pwauth.h"
  464.   
  465.   #ifdef    USE_SYSLOG
  466.   #include <syslog.h>
  467. ***************
  468. *** 48,53 ****
  469. --- 52,61 ----
  470.   #define    NGROUPS_MAX    64
  471.   #endif
  472.   
  473. + #if defined(DIR_XENIX) || defined(DIR_BSD) || defined(DIR_SYSV)
  474. + #define    DIR_ANY
  475. + #endif
  476.   #if !defined(MDY_DATE) && !defined(DMY_DATE) && !defined(YMD_DATE)
  477.   #define    MDY_DATE    1
  478.   #endif
  479. ***************
  480. *** 60,81 ****
  481. --- 68,97 ----
  482.   
  483.   char    user_name[BUFSIZ];
  484.   char    user_newname[BUFSIZ];
  485. + char    user_auth[BUFSIZ];
  486. + char    user_newauth[BUFSIZ];
  487.   uid_t    user_id;
  488.   uid_t    user_newid;
  489.   gid_t    user_gid;
  490. + gid_t    user_newgid;
  491.   char    user_comment[BUFSIZ];
  492.   char    user_home[BUFSIZ];
  493.   char    user_newhome[BUFSIZ];
  494.   char    user_shell[BUFSIZ];
  495. + #ifdef    SHADOWPWD
  496.   long    user_expire;
  497.   long    user_inactive;
  498. + #endif
  499.   int    user_ngroups = -1;
  500.   gid_t    user_groups[NGROUPS_MAX];
  501.   struct    passwd    user_pwd;
  502. + #ifdef    SHADOWPWD
  503.   struct    spwd    user_spwd;
  504. + #endif
  505.   
  506.   char    *Prog;
  507.   
  508. + int    Aflg;    /* specify user defined authentication method                 */
  509.   int    uflg;    /* specify user ID for new account                            */
  510.   int    oflg;    /* permit non-unique user ID to be specified with -u          */
  511.   int    gflg;    /* primary group ID  for new account                          */
  512. ***************
  513. *** 90,96 ****
  514. --- 106,114 ----
  515.   
  516.   #ifdef    NDBM
  517.   extern    int    pw_dbm_mode;
  518. + #ifdef    SHADOWPWD
  519.   extern    int    sp_dbm_mode;
  520. + #endif
  521.   extern    int    gr_dbm_mode;
  522.   #ifdef    SHADOWGRP
  523.   extern    int    sg_dbm_mode;
  524. ***************
  525. *** 126,135 ****
  526. --- 144,155 ----
  527.   extern    int    pw_rewind();
  528.   extern    int    pw_open();
  529.   
  530. + #ifdef    SHADOWPWD
  531.   extern    int    spw_lock();
  532.   extern    int    spw_unlock();
  533.   extern    int    spw_open();
  534.   extern    struct    spwd    *spw_locate();
  535. + #endif
  536.   
  537.   #define    DAY    (24L*3600L)
  538.   #define    WEEK    (7*DAY)
  539. ***************
  540. *** 525,533 ****
  541.       if (gflg) {
  542.   #ifdef    USE_SYSLOG
  543.           syslog (LOG_INFO, "change user `%s' GID from `%d' to `%d'\n",
  544. !             pwent->pw_name, pwent->pw_gid, user_gid);
  545.   #endif
  546. !         pwent->pw_gid = user_gid;
  547.       }
  548.       if (cflg)
  549.           pwent->pw_gecos = strdup (user_comment);
  550. --- 545,553 ----
  551.       if (gflg) {
  552.   #ifdef    USE_SYSLOG
  553.           syslog (LOG_INFO, "change user `%s' GID from `%d' to `%d'\n",
  554. !             pwent->pw_name, pwent->pw_gid, user_newgid);
  555.   #endif
  556. !         pwent->pw_gid = user_newgid;
  557.       }
  558.       if (cflg)
  559.           pwent->pw_gecos = strdup (user_comment);
  560. ***************
  561. *** 815,821 ****
  562.            * Update the DBM group file with the new entry as well.
  563.            */
  564.   
  565. !         if (! sgr_dbm_update (sgrp)) {
  566.               fprintf (stderr, "%s: cannot add new dbm group entry\n",
  567.                   Prog);
  568.   #ifdef    USE_SYSLOG
  569. --- 835,841 ----
  570.            * Update the DBM group file with the new entry as well.
  571.            */
  572.   
  573. !         if (! sg_dbm_update (sgrp)) {
  574.               fprintf (stderr, "%s: cannot add new dbm group entry\n",
  575.                   Prog);
  576.   #ifdef    USE_SYSLOG
  577. ***************
  578. *** 906,917 ****
  579.       }
  580.   #endif
  581.   #ifdef    SHADOWPWD
  582. !     while ((arg = getopt (argc, argv, "u:og:G:d:s:c:mf:e:l:")) != EOF)
  583.   #else
  584. !     while ((arg = getopt (argc, argv, "u:og:G:d:s:c:ml:")) != EOF)
  585.   #endif
  586.       {
  587.           switch (arg) {
  588.               case 'c':
  589.                   if (! VALID (optarg)) {
  590.                       fprintf (stderr,
  591. --- 926,955 ----
  592.       }
  593.   #endif
  594.   #ifdef    SHADOWPWD
  595. !     while ((arg = getopt (argc, argv, "A:u:og:G:d:s:c:mf:e:l:")) != EOF)
  596.   #else
  597. !     while ((arg = getopt (argc, argv, "A:u:og:G:d:s:c:ml:")) != EOF)
  598.   #endif
  599.       {
  600.           switch (arg) {
  601. +             case 'A':
  602. +                 if (! VALID (optarg) || (optarg[0] != '/' &&
  603. +                     strcmp (optarg, "DEFAULT") != 0) ||
  604. +                         strlen (optarg) > 256) {
  605. +                     fprintf (stderr,
  606. +                         "%s: invalid field `%s'\n",
  607. +                         Prog, optarg);
  608. +                     exit (3);
  609. +                 }
  610. +                 if (strcmp (optarg, "DEFAULT") == 0) {
  611. +                     user_auth[0] = '!';
  612. +                     user_auth[1] = '\0';
  613. +                 } else {
  614. +                     strcpy (user_auth, "@");
  615. +                     strcat (user_auth, optarg);
  616. +                 }
  617. +                 Aflg++;
  618. +                 break;
  619.               case 'c':
  620.                   if (! VALID (optarg)) {
  621.                       fprintf (stderr,
  622. ***************
  623. *** 958,964 ****
  624.                           Prog, optarg);
  625.                       exit (1);
  626.                   }
  627. !                 user_gid = grp->gr_gid;
  628.                   gflg++;
  629.                   break;
  630.               case 'G':
  631. --- 996,1002 ----
  632.                           Prog, optarg);
  633.                       exit (1);
  634.                   }
  635. !                 user_newgid = grp->gr_gid;
  636.                   gflg++;
  637.                   break;
  638.               case 'G':
  639. ***************
  640. *** 1136,1142 ****
  641. --- 1174,1183 ----
  642.       struct    spwd    spent;
  643.       struct    spwd    *spwd;
  644.   #endif
  645. +     char    old_auth[BUFSIZ];
  646.   
  647. +     old_auth[0] = '\0';
  648.       pwd = pw_locate (user_name);
  649.       pwent = *pwd;
  650.       new_pwent (&pwent);
  651. ***************
  652. *** 1145,1152 ****
  653.       spwd = spw_locate (user_name);
  654.       spent = *spwd;
  655.       new_spent (&spent);
  656.   #endif
  657. !     if (lflg || uflg || gflg || cflg || dflg || sflg) {
  658.           if (! pw_update (&pwent)) {
  659.               fprintf (stderr, "%s: error changing password entry\n",
  660.                   Prog);
  661. --- 1186,1238 ----
  662.       spwd = spw_locate (user_name);
  663.       spent = *spwd;
  664.       new_spent (&spent);
  665. +     if (spent.sp_pwdp[0] == '@')
  666. +         strcpy (old_auth, spent.sp_pwdp + 1);
  667. + #else
  668. +     if (pwent.pw_passwd[0] == '@')
  669. +         strcpy (old_auth, pwent.pw_passwd + 1);
  670. + #endif
  671. +     if (lflg || (Aflg && strcmp (old_auth, user_auth + 1) != 0)) {
  672. + #ifdef    USE_SYSLOG
  673. +         if (Aflg)
  674. +             syslog (LOG_INFO, "remove auth `%s' for user `%s'\n",
  675. +                 old_auth[0] ? old_auth:"password", user_name);
  676.   #endif
  677. !         if (old_auth[0] && pw_auth (old_auth, user_name, PW_DELETE)) {
  678. !             fprintf (stderr,
  679. !                 "%s: error deleting authentication method\n",
  680. !                 Prog);
  681. ! #ifdef    USE_SYSLOG
  682. !             syslog (LOG_ERR, "error deleting auth for `%s'\n",
  683. !                 user_name);
  684. ! #endif
  685. !             fail_exit (1);
  686. !         }
  687. ! #ifdef    USE_SYSLOG
  688. !         if (Aflg)
  689. !             syslog (LOG_INFO, "add auth `%s' for user `%s'\n",
  690. !                 user_auth[0] != '@' ? "password":user_auth + 1,
  691. !                 lflg ? user_newname:user_name);
  692. ! #endif
  693. !         if (user_auth[0] == '@' && pw_auth (user_auth + 1,
  694. !                 lflg ? user_newname:user_name, PW_ADD)) {
  695. !             fprintf (stderr,
  696. !                 "%s: error adding authentication method\n",
  697. !                 Prog);
  698. ! #ifdef    USE_SYSLOG
  699. !             syslog (LOG_ERR, "error adding auth for `%s'\n",
  700. !                 lflg ? user_newname:user_name);
  701. ! #endif
  702. !             fail_exit (1);
  703. !         }
  704. ! #ifdef    SHADOWPWD
  705. !         spent.sp_pwdp = user_auth;
  706. ! #else
  707. !         pwent.pw_passwd = user_auth;
  708. ! #endif
  709. !     }
  710. !     if (lflg || uflg || gflg || cflg || dflg || sflg || Aflg) {
  711.           if (! pw_update (&pwent)) {
  712.               fprintf (stderr, "%s: error changing password entry\n",
  713.                   Prog);
  714. ***************
  715. *** 1176,1182 ****
  716.   #endif
  717.       }
  718.   #ifdef    SHADOWPWD
  719. !     if (lflg || eflg || fflg) {
  720.           if (! spw_update (&spent)) {
  721.               fprintf (stderr,
  722.                   "%s: error adding new shadow password entry\n",
  723. --- 1262,1268 ----
  724.   #endif
  725.       }
  726.   #ifdef    SHADOWPWD
  727. !     if (lflg || eflg || fflg || Aflg) {
  728.           if (! spw_update (&spent)) {
  729.               fprintf (stderr,
  730.                   "%s: error adding new shadow password entry\n",
  731. ***************
  732. *** 1235,1249 ****
  733.                           "%s: can't create %s\n",
  734.                           Prog, user_newhome);
  735.                   }
  736. !                 chown (user_newhome, sb.st_uid, sb.st_gid);
  737.                   if (copy_tree (user_home, user_newhome,
  738. !                         -1, -1) == 0 &&
  739.                       remove_tree (user_home) == 0 &&
  740.                           rmdir (user_home) == 0)
  741.                       return;
  742.   
  743. !                 remove_tree (user_newhome);
  744. !                 rmdir (user_newhome);
  745.               }
  746.               fprintf (stderr,
  747.                   "%s: cannot rename directory %s to %s\n",
  748. --- 1321,1347 ----
  749.                           "%s: can't create %s\n",
  750.                           Prog, user_newhome);
  751.                   }
  752. !                 if (chown (user_newhome,
  753. !                         sb.st_uid, sb.st_gid)) {
  754. !                     fprintf (stderr, "%s: can't chown %s\n",
  755. !                         Prog, user_newhome);
  756. !                     rmdir (user_newhome);
  757. !                     fail_exit (12);
  758. !                 }
  759. ! #ifdef    DIR_ANY
  760.                   if (copy_tree (user_home, user_newhome,
  761. !                         uflg ? user_newid:-1,
  762. !                         gflg ? user_newgid:-1,
  763. !                         user_id, user_gid) == 0 &&
  764.                       remove_tree (user_home) == 0 &&
  765.                           rmdir (user_home) == 0)
  766.                       return;
  767.   
  768. !                 (void) remove_tree (user_newhome);
  769. !                 (void) rmdir (user_newhome);
  770. ! #else
  771. !                 return;
  772. ! #endif
  773.               }
  774.               fprintf (stderr,
  775.                   "%s: cannot rename directory %s to %s\n",
  776. ***************
  777. *** 1252,1258 ****
  778.           }
  779.       }
  780.       if (uflg || gflg)
  781. !         chown (dflg ? user_newhome:user_home, user_id, user_gid);
  782.   }
  783.   
  784.   /*
  785. --- 1350,1358 ----
  786.           }
  787.       }
  788.       if (uflg || gflg)
  789. !         chown (dflg ? user_newhome:user_home,
  790. !             uflg ? user_newid:user_id,
  791. !             gflg ? user_newgid:user_gid);
  792.   }
  793.   
  794.   /*
  795. Index: utmp.c
  796. *** utmp.c.old    Sat Oct 10 11:20:55 1992
  797. --- utmp.c    Sat Oct 10 11:20:54 1992
  798. ***************
  799. *** 7,16 ****
  800. --- 7,26 ----
  801.    * in all copies of source code, or included in human readable form
  802.    * and conspicuously displayed on all copies of object code or
  803.    * distribution media.
  804. +  *
  805. +  * This software is provided on an AS-IS basis and the author makes
  806. +  * no warrantee of any kind.
  807.    */
  808.   
  809. + #ifdef    SVR4
  810. + #include <stdlib.h>
  811. + #include <utmpx.h>
  812. + extern    int    gettimeofday (struct timeval *tp);
  813. + #else
  814.   #include <sys/types.h>
  815.   #include <utmp.h>
  816. + #endif    /* SVR4 */
  817.   #include <fcntl.h>
  818.   #ifndef    BSD
  819.   #include <string.h>
  820. ***************
  821. *** 41,51 ****
  822.   #endif    /* SUN || BSD */
  823.   
  824.   #ifndef    lint
  825. ! static    char    sccsid[] = "@(#)utmp.c    3.15    23:57:02    3/7/92";
  826.   #endif
  827.   
  828.   extern    struct    utmp    utent;
  829.   
  830.   extern    struct    utmp    *getutent();
  831.   extern    struct    utmp    *getutline();
  832.   extern    void    setutent();
  833. --- 51,66 ----
  834.   #endif    /* SUN || BSD */
  835.   
  836.   #ifndef    lint
  837. ! static    char    sccsid[] = "@(#)utmp.c    3.16    13:02:55    7/27/92";
  838.   #endif
  839.   
  840. + #ifdef    SVR4
  841. + extern    struct    utmpx    utent;
  842. + #else
  843.   extern    struct    utmp    utent;
  844. + #endif
  845.   
  846. + #ifndef    SVR4
  847.   extern    struct    utmp    *getutent();
  848.   extern    struct    utmp    *getutline();
  849.   extern    void    setutent();
  850. ***************
  851. *** 53,58 ****
  852. --- 68,74 ----
  853.   extern    time_t    time();
  854.   extern    char    *ttyname();
  855.   extern    long    lseek();
  856. + #endif    /* SVR4 */
  857.   
  858.   #define    NO_UTENT \
  859.       "No utmp entry.  You must exec \"login\" from the lowest level \"sh\""
  860. ***************
  861. *** 79,99 ****
  862.   {
  863.       char    *line;
  864.   #ifdef    USG
  865.       struct    utmp    *ut;
  866.   #ifndef    NDEBUG
  867.       int    pid = getppid ();
  868.   #else
  869.       int    pid = getpid ();
  870. ! #endif
  871. ! #endif
  872.   
  873.   #if !defined(SUN) && !defined(SUN4)
  874.       setutent ();
  875. ! #endif    /* SUN */
  876.   
  877.   #ifdef    USG
  878.       if (picky) {
  879.           while (ut = getutent ())
  880.               if (ut->ut_pid == pid)
  881.                   break;
  882.   
  883. --- 95,127 ----
  884.   {
  885.       char    *line;
  886.   #ifdef    USG
  887. + #ifdef    SVR4
  888. +     struct    utmpx    *ut;
  889. + #else
  890.       struct    utmp    *ut;
  891. + #endif    /* SVR4 */
  892.   #ifndef    NDEBUG
  893.       int    pid = getppid ();
  894.   #else
  895.       int    pid = getpid ();
  896. ! #endif    /* !NDEBUG */
  897. ! #endif    /* USG */
  898.   
  899.   #if !defined(SUN) && !defined(SUN4)
  900. + #ifdef    SVR4
  901. +     setutxent ();
  902. + #else
  903.       setutent ();
  904. ! #endif
  905. ! #endif    /* !SUN */
  906.   
  907.   #ifdef    USG
  908.       if (picky) {
  909. + #ifdef    SVR4
  910. +         while (ut = getutxent ())
  911. + #else
  912.           while (ut = getutent ())
  913. + #endif
  914.               if (ut->ut_pid == pid)
  915.                   break;
  916.   
  917. ***************
  918. *** 100,107 ****
  919.           if (ut)
  920.               utent = *ut;
  921.   
  922.           endutent ();
  923.           if (! ut) {
  924.                (void) puts (NO_UTENT);
  925.               exit (1);
  926. --- 128,138 ----
  927.           if (ut)
  928.               utent = *ut;
  929.   
  930. + #ifdef    SVR4
  931. +         endutxent ();
  932. + #else
  933.           endutent ();
  934. ! #endif
  935.           if (! ut) {
  936.                (void) puts (NO_UTENT);
  937.               exit (1);
  938. ***************
  939. *** 116,122 ****
  940.            */
  941.   
  942.           if (utent.ut_line[0] == '\0')
  943. ! #endif
  944.           {
  945.               if (! (line = ttyname (0))) {
  946.                   (void) puts (NO_TTY);
  947. --- 147,153 ----
  948.            */
  949.   
  950.           if (utent.ut_line[0] == '\0')
  951. ! #endif    /* !UNIXPC */
  952.           {
  953.               if (! (line = ttyname (0))) {
  954.                   (void) puts (NO_TTY);
  955. ***************
  956. *** 137,143 ****
  957. --- 168,178 ----
  958.   
  959.            (void) strncpy (utent.ut_line, line,
  960.                             (int) sizeof utent.ut_line);
  961. + #ifdef    SVR4
  962. +         if (ut = getutline (&utent))
  963. + #else
  964.           if (ut = getutline (&utent))
  965. + #endif
  966.                (void) strncpy (utent.ut_id, ut->ut_id,
  967.                        (int) sizeof ut->ut_id);
  968.   
  969. ***************
  970. *** 180,186 ****
  971.   #ifdef SVR4
  972.       struct    utmp    utmp;
  973.       struct    utmpx    *utmpx, utxline;
  974. -     extern int gettimeofday (struct timeval *tp);
  975.   
  976.       /*
  977.        * Update utmpx.  We create an empty entry in case there is
  978. --- 215,220 ----
  979. ***************
  980. *** 192,199 ****
  981.       strncpy (utxline.ut_line, line, sizeof utxline.ut_line);
  982.       utmpx = getutxline (&utxline);
  983.   
  984. !     if (!utmpx)
  985. !         utmpx = &utxline;
  986.   
  987.       /*
  988.        * Fill in the fields in the utmpx entry and write it out.
  989. --- 226,256 ----
  990.       strncpy (utxline.ut_line, line, sizeof utxline.ut_line);
  991.       utmpx = getutxline (&utxline);
  992.   
  993. !     /*
  994. !      * If the entry matching `line' cannot be found, create a new
  995. !      * entry with the device name in it.
  996. !      */
  997. !     if (! utmpx) {
  998. !         /*
  999. !          * Try appending /dev/ and looking again for the device.
  1000. !          */
  1001. !         setutxent ();
  1002. !         strcpy (utxline.ut_line, "/dev/");
  1003. !         strnccat (utxline.ut_line, line, sizeof utxline.ut_line);
  1004. !         if (! (utmpx = getutxline (&utxline)) {
  1005. !             /*
  1006. !              * That didn't do it.  Just use the original
  1007. !              * terminal name.
  1008. !              */
  1009. !             
  1010. !             strncpy (utxline.ut_line, line, sizeof utxline.ut_line);
  1011. !             utmpx = &utxline;
  1012. !         }
  1013. !     }
  1014.   
  1015.       /*
  1016.        * Fill in the fields in the utmpx entry and write it out.
  1017. ***************
  1018. *** 203,208 ****
  1019. --- 260,266 ----
  1020.       utmpx->ut_pid = getpid ();
  1021.       utmpx->ut_type = USER_PROCESS;
  1022.       gettimeofday (&(utmpx->ut_tv));
  1023. +     strncpy (utmpx->ut_host, utent.ut_host, sizeof utmpx->ut_host);
  1024.   
  1025.       pututxline (utmpx);
  1026.   
  1027. ***************
  1028. *** 223,231 ****
  1029.        */
  1030.   
  1031.       updwtmpx(WTMPX_FILE, utmpx);
  1032. !     endutxent();
  1033.   
  1034. !      utent = utmp;
  1035.   #else /* !SVR4 */
  1036.       struct    utmp    utmp;
  1037.       int    fd;
  1038. --- 281,289 ----
  1039.        */
  1040.   
  1041.       updwtmpx(WTMPX_FILE, utmpx);
  1042. !     utent = *utmpx;
  1043.   
  1044. !     endutxent();
  1045.   #else /* !SVR4 */
  1046.       struct    utmp    utmp;
  1047.       int    fd;
  1048. Index: pwauth.c
  1049. *** /dev/null    Sat Oct 10 11:18:23 1992
  1050. --- pwauth.c    Sat Oct 10 11:21:06 1992
  1051. ***************
  1052. *** 0 ****
  1053. --- 1,256 ----
  1054. + /*
  1055. +  * Copyright 1992, John F. Haugh II
  1056. +  * All rights reserved.
  1057. +  *
  1058. +  * Permission is granted to copy and create derivative works for any
  1059. +  * non-commercial purpose, provided this copyright notice is preserved
  1060. +  * in all copies of source code, or included in human readable form
  1061. +  * and conspicuously displayed on all copies of object code or
  1062. +  * distribution media.
  1063. +  *
  1064. +  * This software is provided on an AS-IS basis and the author makes
  1065. +  * not warrantee of any kind.
  1066. +  */
  1067. + #include <signal.h>
  1068. + #include <fcntl.h>
  1069. + #include "config.h"
  1070. + #include "pwauth.h"
  1071. + #ifndef    lint
  1072. + static    char    sccsid[] = "@(#)pwauth.c    3.3    10:52:13    10/10/92";
  1073. + #endif
  1074. + /*
  1075. +  * pw_auth - perform alternate password authentication
  1076. +  *
  1077. +  *    pw_auth executes the alternate password authentication method
  1078. +  *    described in the user's password entry.  _pw_auth does the real
  1079. +  *    work, pw_auth splits the authentication string into individual
  1080. +  *    command names.
  1081. +  */
  1082. + static int
  1083. + _pw_auth (command, user, reason, input)
  1084. + char    *command;
  1085. + char    *user;
  1086. + int    reason;
  1087. + char    *input;
  1088. + {
  1089. +     SIGTYPE (*sigint)();
  1090. +     SIGTYPE (*sigquit)();
  1091. + #ifdef    SIGTSTP
  1092. +     SIGTYPE    (*sigtstp)();
  1093. + #endif
  1094. +     int    pid;
  1095. +     int    status;
  1096. +     int    i;
  1097. +     char    *argv[5];
  1098. +     int    argc = 0;
  1099. +     int    pipes[2];
  1100. +     /*
  1101. +      * Start with a quick sanity check.  ALL command names must
  1102. +      * be fully-qualified path names.
  1103. +      */
  1104. +     if (command[0] != '/')
  1105. +         return -1;
  1106. +     /*
  1107. +      * Set the keyboard signals to be ignored.  When the user kills
  1108. +      * the child we don't want the parent dying as well.
  1109. +      */
  1110. +     sigint = signal (SIGINT, SIG_IGN);
  1111. +     sigquit = signal (SIGQUIT, SIG_IGN);
  1112. + #ifdef    SIGTSTP
  1113. +     sigtstp = signal (SIGTSTP, SIG_IGN);
  1114. + #endif
  1115. +     /* 
  1116. +      * FTP and REXEC reasons don't give the program direct access
  1117. +      * to the user.  This means that the program can only get input
  1118. +      * from this function.  So we set up a pipe for that purpose.
  1119. +      */
  1120. +     if (reason == PW_FTP || reason == PW_REXEC)
  1121. +         if (pipe (pipes))
  1122. +             return -1;
  1123. +     /*
  1124. +      * The program will be forked off with the parent process waiting
  1125. +      * on the child to tell it how successful it was.
  1126. +      */
  1127. +     switch (pid = fork ()) {
  1128. +         /*
  1129. +          * The fork() failed completely.  Clean up as needed and
  1130. +          * return to the caller.
  1131. +          */
  1132. +         case -1:
  1133. +             if (reason == PW_FTP || reason == PW_REXEC) {
  1134. +                 close (pipes[0]);
  1135. +                 close (pipes[1]);
  1136. +             }
  1137. +             return -1;
  1138. +         case 0:
  1139. +             /*
  1140. +              * Let the child catch the SIGINT and SIGQUIT
  1141. +              * signals.  The parent, however, will continue
  1142. +              * to ignore them.
  1143. +              */
  1144. +             signal (SIGINT, SIG_DFL);
  1145. +             signal (SIGQUIT, SIG_DFL);
  1146. +             /*
  1147. +              * Set up the command line.  The first argument is
  1148. +              * the name of the command being executed.  The
  1149. +              * second is the command line option for the reason,
  1150. +              * and the third is the user name.
  1151. +              */
  1152. +             argv[argc++] = command;
  1153. +             switch (reason) {
  1154. +                 case PW_SU:    argv[argc++] = "-s"; break;
  1155. +                 case PW_LOGIN:    argv[argc++] = "-l"; break;
  1156. +                 case PW_ADD:    argv[argc++] = "-a"; break;
  1157. +                 case PW_CHANGE:    argv[argc++] = "-c"; break;
  1158. +                 case PW_DELETE:    argv[argc++] = "-d"; break;
  1159. +                 case PW_TELNET:    argv[argc++] = "-t"; break;
  1160. +                 case PW_RLOGIN:    argv[argc++] = "-r"; break;
  1161. +                 case PW_FTP:    argv[argc++] = "-f"; break;
  1162. +                 case PW_REXEC:    argv[argc++] = "-x"; break;
  1163. +             }
  1164. +             argv[argc++] = user;
  1165. +             argv[argc] = (char *) 0;
  1166. +             /*
  1167. +              * The FTP and REXEC reasons use a pipe to communicate
  1168. +              * with the parent.  The other standard I/O descriptors
  1169. +              * are closed and re-opened as /dev/null.
  1170. +              */
  1171. +             if (reason == PW_FTP || reason == PW_REXEC) {
  1172. +                 close (0);
  1173. +                 close (1);
  1174. +                 close (2);
  1175. +                 if (dup (pipes[0]) != 0)
  1176. +                     exit (1);
  1177. +                 close (pipes[0]);
  1178. +                 close (pipes[1]);
  1179. +                 if (open ("/dev/null", O_WRONLY) != 1)
  1180. +                     exit (1);
  1181. +                 if (open ("/dev/null", O_WRONLY) != 2)
  1182. +                     exit (1);
  1183. +             }
  1184. +             /*
  1185. +              * Now we execute the command directly.
  1186. +              */
  1187. +             execv (command, argv);
  1188. +             _exit (255);
  1189. +             /*NOTREACHED*/
  1190. +         default:
  1191. +             /* 
  1192. +              * FTP and REXEC cause a single line of text to be
  1193. +              * sent to the child over a pipe that was set up
  1194. +              * earlier.
  1195. +              */
  1196. +             if (reason == PW_FTP || reason == PW_REXEC) {
  1197. +                 close (pipes[0]);
  1198. +                 if (input)
  1199. +                     write (pipes[1], input, strlen (input));
  1200. +                 write (pipes[1], "\n", 1);
  1201. +                 close (pipes[1]);
  1202. +             }
  1203. +             /*
  1204. +              * Wait on the child to die.  When it does you will
  1205. +              * get the exit status and use that to determine if
  1206. +              * the authentication program was successful.
  1207. +              */
  1208. +             while ((i = wait (&status)) != pid && i != -1)
  1209. +                 ;
  1210. +             /*
  1211. +              * Re-set the signals to their earlier values.
  1212. +              */
  1213. +             signal (SIGINT, sigint);
  1214. +             signal (SIGQUIT, sigquit);
  1215. + #ifdef    SIGTSTP
  1216. +             signal (SIGTSTP, sigtstp);
  1217. + #endif
  1218. +             /*
  1219. +              * Make sure we found the right process!
  1220. +              */
  1221. +             if (i == -1)
  1222. +                 return -1;
  1223. +             if (status == 0)
  1224. +                 return 0;
  1225. +             else
  1226. +                 return -1;
  1227. +     }
  1228. +     /*NOTREACHED*/
  1229. + }
  1230. + /*
  1231. +  * This function does the real work.  It splits the list of program names
  1232. +  * up into individual programs and executes them one at a time.
  1233. +  */
  1234. + int
  1235. + /*VARARGS3*/
  1236. + pw_auth (command, user, reason, input)
  1237. + char    *command;
  1238. + char    *user;
  1239. + int    reason;
  1240. + char    *input;
  1241. + {
  1242. +     char    buf[256];
  1243. +     char    *cmd, *end;
  1244. +     int    rc;
  1245. +     /* 
  1246. +      * Quick little sanity check ...
  1247. +      */
  1248. +     if (strlen (command) >= sizeof buf)
  1249. +         return -1;
  1250. +     strcpy (buf, command);
  1251. +     /*
  1252. +      * Find each command and make sure it is NUL-terminated.  Then
  1253. +      * invoke _pw_auth to actually run the program.  The first
  1254. +      * failing program ends the whole mess.
  1255. +      */
  1256. +     for (cmd = buf;cmd;cmd = end) {
  1257. +         if (end = strchr (cmd, ';'))
  1258. +             *end++ = '\0';
  1259. +         if (rc = _pw_auth (cmd, user, reason, input))
  1260. +             return rc;
  1261. +     }
  1262. +     return 0;
  1263. + }
  1264. Index: pwauth.h
  1265. *** /dev/null    Sat Oct 10 11:18:23 1992
  1266. --- pwauth.h    Sat Oct 10 11:21:16 1992
  1267. ***************
  1268. *** 0 ****
  1269. --- 1,36 ----
  1270. + /*
  1271. +  * Copyright 1992, John F. Haugh II
  1272. +  * All rights reserved.
  1273. +  *
  1274. +  * Permission is granted to copy and create derivative works for any
  1275. +  * non-commercial purpose, provided this copyright notice is preserved
  1276. +  * in all copies of source code, or included in human readable form
  1277. +  * and conspicuously displayed on all copies of object code or
  1278. +  * distribution media.
  1279. +  *
  1280. +  * This software is provided on an AS-IS basis and the author makes
  1281. +  * not warrantee of any kind.
  1282. +  *
  1283. +  *    @(#)pwauth.h    3.1    14:53:17    7/27/92
  1284. +  */
  1285. + #if    __STDC__
  1286. + int    pw_auth (char * program, char * user, int flag);
  1287. + #else
  1288. + int    pw_auth ();
  1289. + #endif
  1290. + #define    PW_SU        1
  1291. + #define    PW_LOGIN    2
  1292. + #define    PW_ADD        3
  1293. + #define    PW_CHANGE    4
  1294. + #define    PW_DELETE    5
  1295. + /*
  1296. +  * Network access
  1297. +  */
  1298. + #define    PW_TELNET    6
  1299. + #define    PW_RLOGIN    7
  1300. + #define    PW_FTP        8
  1301. + #define    PW_REXEC    9
  1302. Index: gpmain.c
  1303. *** gpmain.c.old    Sat Oct 10 11:21:31 1992
  1304. --- gpmain.c    Sat Oct 10 11:21:30 1992
  1305. ***************
  1306. *** 1,5 ****
  1307.   /*
  1308. !  * Copyright 1990, 1991, John F. Haugh II
  1309.    * All rights reserved.
  1310.    *
  1311.    * Permission is granted to copy and create derivative works for any
  1312. --- 1,5 ----
  1313.   /*
  1314. !  * Copyright 1990, 1991, 1992, John F. Haugh II
  1315.    * All rights reserved.
  1316.    *
  1317.    * Permission is granted to copy and create derivative works for any
  1318. ***************
  1319. *** 7,12 ****
  1320. --- 7,15 ----
  1321.    * in all copies of source code, or included in human readable form
  1322.    * and conspicuously displayed on all copies of object code or
  1323.    * distribution media.
  1324. +  *
  1325. +  * This software is provided on an AS-IS basis and the author makes
  1326. +  * no warrantee of any kind.
  1327.    */
  1328.   
  1329.   #include <sys/types.h>
  1330. ***************
  1331. *** 39,45 ****
  1332.   #endif
  1333.   
  1334.   #ifndef    lint
  1335. ! static    char    _sccsid[] = "@(#)gpmain.c    3.12    19:39:50    12/28/91";
  1336.   #endif
  1337.   
  1338.   char    name[BUFSIZ];
  1339. --- 42,48 ----
  1340.   #endif
  1341.   
  1342.   #ifndef    lint
  1343. ! static    char    _sccsid[] = "@(#)gpmain.c    3.13    11:31:54    7/28/92";
  1344.   #endif
  1345.   
  1346.   char    name[BUFSIZ];
  1347. ***************
  1348. *** 524,530 ****
  1349.       }
  1350.       endgrent ();
  1351.   #ifdef    SHADOWGRP
  1352. !     if (access ("/etc/gshadow.pag", 0) == 0 && ! sgr_dbm_update (&sgent)) {
  1353.           fprintf (stderr, "%s: can't update DBM shadow files\n", Prog);
  1354.           exit (1);
  1355.       }
  1356. --- 527,533 ----
  1357.       }
  1358.       endgrent ();
  1359.   #ifdef    SHADOWGRP
  1360. !     if (access ("/etc/gshadow.pag", 0) == 0 && ! sg_dbm_update (&sgent)) {
  1361.           fprintf (stderr, "%s: can't update DBM shadow files\n", Prog);
  1362.           exit (1);
  1363.       }
  1364. Index: groupadd.c
  1365. *** groupadd.c.old    Sat Oct 10 11:21:46 1992
  1366. --- groupadd.c    Sat Oct 10 11:21:45 1992
  1367. ***************
  1368. *** 7,16 ****
  1369.    * in all copies of source code, or included in human readable form
  1370.    * and conspicuously displayed on all copies of object code or
  1371.    * distribution media.
  1372.    */
  1373.   
  1374.   #ifndef lint
  1375. ! static    char    sccsid[] = "@(#)groupadd.c    3.4    09:41:21    3/19/92";
  1376.   #endif
  1377.   
  1378.   #include <sys/types.h>
  1379. --- 7,19 ----
  1380.    * in all copies of source code, or included in human readable form
  1381.    * and conspicuously displayed on all copies of object code or
  1382.    * distribution media.
  1383. +  *
  1384. +  * This software is provided on an AS-IS basis and the author makes
  1385. +  * no warrantee of any kind.
  1386.    */
  1387.   
  1388.   #ifndef lint
  1389. ! static    char    sccsid[] = "@(#)groupadd.c    3.5    11:32:01    7/28/92";
  1390.   #endif
  1391.   
  1392.   #include <sys/types.h>
  1393. ***************
  1394. *** 171,177 ****
  1395.        * Update the DBM group file with the new entry as well.
  1396.        */
  1397.   
  1398. !     if (! sgr_dbm_update (&sgrp)) {
  1399.           fprintf (stderr, "%s: cannot add new dbm group entry\n", Prog);
  1400.           fail_exit (1);
  1401.       }
  1402. --- 174,180 ----
  1403.        * Update the DBM group file with the new entry as well.
  1404.        */
  1405.   
  1406. !     if (! sg_dbm_update (&sgrp)) {
  1407.           fprintf (stderr, "%s: cannot add new dbm group entry\n", Prog);
  1408.           fail_exit (1);
  1409.       }
  1410. Index: groupdel.c
  1411. *** groupdel.c.old    Sat Oct 10 11:22:01 1992
  1412. --- groupdel.c    Sat Oct 10 11:22:00 1992
  1413. ***************
  1414. *** 1,5 ****
  1415.   /*
  1416. !  * Copyright 1991, John F. Haugh II
  1417.    * All rights reserved.
  1418.    *
  1419.    * Permission is granted to copy and create derivative works for any
  1420. --- 1,5 ----
  1421.   /*
  1422. !  * Copyright 1991, 1992, John F. Haugh II
  1423.    * All rights reserved.
  1424.    *
  1425.    * Permission is granted to copy and create derivative works for any
  1426. ***************
  1427. *** 7,16 ****
  1428.    * in all copies of source code, or included in human readable form
  1429.    * and conspicuously displayed on all copies of object code or
  1430.    * distribution media.
  1431.    */
  1432.   
  1433.   #ifndef lint
  1434. ! static    char    sccsid[] = "@(#)groupdel.c    3.5    19:39:55    12/28/91";
  1435.   #endif
  1436.   
  1437.   #include <sys/types.h>
  1438. --- 7,19 ----
  1439.    * in all copies of source code, or included in human readable form
  1440.    * and conspicuously displayed on all copies of object code or
  1441.    * distribution media.
  1442. +  *
  1443. +  * This software is provided on an AS-IS basis and the author makes
  1444. +  * no warrantee of any kind.
  1445.    */
  1446.   
  1447.   #ifndef lint
  1448. ! static    char    sccsid[] = "@(#)groupdel.c    3.6    11:32:05    7/28/92";
  1449.   #endif
  1450.   
  1451.   #include <sys/types.h>
  1452. ***************
  1453. *** 114,120 ****
  1454.        */
  1455.   
  1456.       if (access ("/etc/gshadow.pag", 0) == 0) {
  1457. !         if (! sgr_dbm_remove (group_name)) {
  1458.               fprintf (stderr,
  1459.                   "%s: error removing shadow group dbm entry\n",
  1460.                   Prog);
  1461. --- 117,123 ----
  1462.        */
  1463.   
  1464.       if (access ("/etc/gshadow.pag", 0) == 0) {
  1465. !         if (! sg_dbm_remove (group_name)) {
  1466.               fprintf (stderr,
  1467.                   "%s: error removing shadow group dbm entry\n",
  1468.                   Prog);
  1469. Index: groupmod.c
  1470. *** groupmod.c.old    Sat Oct 10 11:22:16 1992
  1471. --- groupmod.c    Sat Oct 10 11:22:16 1992
  1472. ***************
  1473. *** 1,5 ****
  1474.   /*
  1475. !  * Copyright 1991, John F. Haugh II
  1476.    * All rights reserved.
  1477.    *
  1478.    * Permission is granted to copy and create derivative works for any
  1479. --- 1,5 ----
  1480.   /*
  1481. !  * Copyright 1991, 1992, John F. Haugh II
  1482.    * All rights reserved.
  1483.    *
  1484.    * Permission is granted to copy and create derivative works for any
  1485. ***************
  1486. *** 7,16 ****
  1487.    * in all copies of source code, or included in human readable form
  1488.    * and conspicuously displayed on all copies of object code or
  1489.    * distribution media.
  1490.    */
  1491.   
  1492.   #ifndef lint
  1493. ! static    char    sccsid[] = "@(#)groupmod.c    3.3    08:43:51    9/12/91";
  1494.   #endif
  1495.   
  1496.   #include <sys/types.h>
  1497. --- 7,19 ----
  1498.    * in all copies of source code, or included in human readable form
  1499.    * and conspicuously displayed on all copies of object code or
  1500.    * distribution media.
  1501. +  *
  1502. +  * This software is provided on an AS-IS basis and the author makes
  1503. +  * no warrantee of any kind.
  1504.    */
  1505.   
  1506.   #ifndef lint
  1507. ! static    char    sccsid[] = "@(#)groupmod.c    3.4    11:32:10    7/28/92";
  1508.   #endif
  1509.   
  1510.   #include <sys/types.h>
  1511. ***************
  1512. *** 190,202 ****
  1513.        */
  1514.   
  1515.       if (access ("/etc/gshadow.pag", 0) == 0) {
  1516. !         if (! sgr_dbm_update (&sgrp)) {
  1517.               fprintf (stderr,
  1518.                   "%s: cannot add new dbm shadow group entry\n",
  1519.                   Prog);
  1520.               exit (1);
  1521.           }
  1522. !         if (nflg && ! sgr_dbm_remove (group_name)) {
  1523.               fprintf (stderr,
  1524.                   "%s: error removing shadow group dbm entry\n",
  1525.                   Prog);
  1526. --- 193,205 ----
  1527.        */
  1528.   
  1529.       if (access ("/etc/gshadow.pag", 0) == 0) {
  1530. !         if (! sg_dbm_update (&sgrp)) {
  1531.               fprintf (stderr,
  1532.                   "%s: cannot add new dbm shadow group entry\n",
  1533.                   Prog);
  1534.               exit (1);
  1535.           }
  1536. !         if (nflg && ! sg_dbm_remove (group_name)) {
  1537.               fprintf (stderr,
  1538.                   "%s: error removing shadow group dbm entry\n",
  1539.                   Prog);
  1540. Index: gsdbm.c
  1541. *** gsdbm.c.old    Sat Oct 10 11:22:31 1992
  1542. --- gsdbm.c    Sat Oct 10 11:22:30 1992
  1543. ***************
  1544. *** 1,5 ****
  1545.   /*
  1546. !  * Copyright 1990, 1991, John F. Haugh II
  1547.    * All rights reserved.
  1548.    *
  1549.    * Permission is granted to copy and create derivative works for any
  1550. --- 1,5 ----
  1551.   /*
  1552. !  * Copyright 1990, 1991, 1992, John F. Haugh II
  1553.    * All rights reserved.
  1554.    *
  1555.    * Permission is granted to copy and create derivative works for any
  1556. ***************
  1557. *** 7,16 ****
  1558.    * in all copies of source code, or included in human readable form
  1559.    * and conspicuously displayed on all copies of object code or
  1560.    * distribution media.
  1561.    */
  1562.   
  1563.   #ifndef    lint
  1564. ! static    char    sccsid[] = "@(#)gsdbm.c    3.5    08:45:49    9/12/91";
  1565.   #endif
  1566.   
  1567.   #include <string.h>
  1568. --- 7,19 ----
  1569.    * in all copies of source code, or included in human readable form
  1570.    * and conspicuously displayed on all copies of object code or
  1571.    * distribution media.
  1572. +  *
  1573. +  * This software is provided on an AS-IS basis and the author makes
  1574. +  * no warrantee of any kind.
  1575.    */
  1576.   
  1577.   #ifndef    lint
  1578. ! static    char    sccsid[] = "@(#)gsdbm.c    3.6    11:32:14    7/28/92";
  1579.   #endif
  1580.   
  1581.   #include <string.h>
  1582. ***************
  1583. *** 20,37 ****
  1584.   
  1585.   #ifdef    NDBM
  1586.   #include <ndbm.h>
  1587. ! DBM    *sgr_dbm;
  1588.   
  1589.   #define    GRP_FRAG    256
  1590.   
  1591.   /*
  1592. !  * sgr_dbm_update
  1593.    *
  1594.    * Updates the DBM password files, if they exist.
  1595.    */
  1596.   
  1597.   int
  1598. ! sgr_dbm_update (sgr)
  1599.   struct    sgrp    *sgr;
  1600.   {
  1601.       datum    key;
  1602. --- 23,40 ----
  1603.   
  1604.   #ifdef    NDBM
  1605.   #include <ndbm.h>
  1606. ! DBM    *sg_dbm;
  1607.   
  1608.   #define    GRP_FRAG    256
  1609.   
  1610.   /*
  1611. !  * sg_dbm_update
  1612.    *
  1613.    * Updates the DBM password files, if they exist.
  1614.    */
  1615.   
  1616.   int
  1617. ! sg_dbm_update (sgr)
  1618.   struct    sgrp    *sgr;
  1619.   {
  1620.       datum    key;
  1621. ***************
  1622. *** 45,56 ****
  1623.       static    int    once;
  1624.   
  1625.       if (! once) {
  1626. !         if (! sgr_dbm)
  1627.               setsgent ();
  1628.   
  1629.           once++;
  1630.       }
  1631. !     if (! sgr_dbm)
  1632.           return 0;
  1633.   
  1634.       len = sgr_pack (sgr, data);
  1635. --- 48,59 ----
  1636.       static    int    once;
  1637.   
  1638.       if (! once) {
  1639. !         if (! sg_dbm)
  1640.               setsgent ();
  1641.   
  1642.           once++;
  1643.       }
  1644. !     if (! sg_dbm)
  1645.           return 0;
  1646.   
  1647.       len = sgr_pack (sgr, data);
  1648. ***************
  1649. *** 61,67 ****
  1650.   
  1651.           key.dsize = strlen (sgr->sg_name);
  1652.           key.dptr = sgr->sg_name;
  1653. !         if (dbm_store (sgr_dbm, key, content, DBM_REPLACE))
  1654.               return 0;
  1655.       } else {
  1656.           content.dsize = sizeof cnt;
  1657. --- 64,70 ----
  1658.   
  1659.           key.dsize = strlen (sgr->sg_name);
  1660.           key.dptr = sgr->sg_name;
  1661. !         if (dbm_store (sg_dbm, key, content, DBM_REPLACE))
  1662.               return 0;
  1663.       } else {
  1664.           content.dsize = sizeof cnt;
  1665. ***************
  1666. *** 70,76 ****
  1667.   
  1668.           key.dsize = strlen (sgr->sg_name);
  1669.           key.dptr = sgr->sg_name;
  1670. !         if (dbm_store (sgr_dbm, key, content, DBM_REPLACE))
  1671.               return 0;
  1672.   
  1673.           for (cp = data, i = 0;i < cnt;i++) {
  1674. --- 73,79 ----
  1675.   
  1676.           key.dsize = strlen (sgr->sg_name);
  1677.           key.dptr = sgr->sg_name;
  1678. !         if (dbm_store (sg_dbm, key, content, DBM_REPLACE))
  1679.               return 0;
  1680.   
  1681.           for (cp = data, i = 0;i < cnt;i++) {
  1682. ***************
  1683. *** 83,89 ****
  1684.               key.dptr = sgrpkey;
  1685.               memcpy (sgrpkey, (char *) &i, sizeof i);
  1686.               strcpy (sgrpkey + sizeof i, sgr->sg_name);
  1687. !             if (dbm_store (sgr_dbm, key, content, DBM_REPLACE))
  1688.                   return 0;
  1689.           }
  1690.       }
  1691. --- 86,92 ----
  1692.               key.dptr = sgrpkey;
  1693.               memcpy (sgrpkey, (char *) &i, sizeof i);
  1694.               strcpy (sgrpkey + sizeof i, sgr->sg_name);
  1695. !             if (dbm_store (sg_dbm, key, content, DBM_REPLACE))
  1696.                   return 0;
  1697.           }
  1698.       }
  1699. ***************
  1700. *** 91,103 ****
  1701.   }
  1702.   
  1703.   /*
  1704. !  * sgr_dbm_remove
  1705.    *
  1706.    * Deletes the DBM shadow group file entries, if they exist.
  1707.    */
  1708.   
  1709.   int
  1710. ! sgr_dbm_remove (name)
  1711.   char    *name;
  1712.   {
  1713.       datum    key;
  1714. --- 94,106 ----
  1715.   }
  1716.   
  1717.   /*
  1718. !  * sg_dbm_remove
  1719.    *
  1720.    * Deletes the DBM shadow group file entries, if they exist.
  1721.    */
  1722.   
  1723.   int
  1724. ! sg_dbm_remove (name)
  1725.   char    *name;
  1726.   {
  1727.       datum    key;
  1728. ***************
  1729. *** 109,125 ****
  1730.       static    int    once;
  1731.   
  1732.       if (! once) {
  1733. !         if (! sgr_dbm)
  1734.               setsgent ();
  1735.   
  1736.           once++;
  1737.       }
  1738. !     if (! sgr_dbm)
  1739.           return 0;
  1740.   
  1741.       key.dsize = strlen (name);
  1742.       key.dptr = name;
  1743. !     content = dbm_fetch (sgr_dbm, key);
  1744.       if (content.dptr == 0)
  1745.           ++errors;
  1746.       else {
  1747. --- 112,128 ----
  1748.       static    int    once;
  1749.   
  1750.       if (! once) {
  1751. !         if (! sg_dbm)
  1752.               setsgent ();
  1753.   
  1754.           once++;
  1755.       }
  1756. !     if (! sg_dbm)
  1757.           return 0;
  1758.   
  1759.       key.dsize = strlen (name);
  1760.       key.dptr = name;
  1761. !     content = dbm_fetch (sg_dbm, key);
  1762.       if (content.dptr == 0)
  1763.           ++errors;
  1764.       else {
  1765. ***************
  1766. *** 131,141 ****
  1767.                   key.dptr = grpkey;
  1768.                   memcpy (grpkey, (char *) &i, sizeof i);
  1769.                   strcpy (grpkey + sizeof i, name);
  1770. !                 if (dbm_delete (sgr_dbm, key))
  1771.                       ++errors;
  1772.               }
  1773.           } else {
  1774. !             if (dbm_delete (sgr_dbm, key))
  1775.                   ++errors;
  1776.           }
  1777.       }
  1778. --- 134,144 ----
  1779.                   key.dptr = grpkey;
  1780.                   memcpy (grpkey, (char *) &i, sizeof i);
  1781.                   strcpy (grpkey + sizeof i, name);
  1782. !                 if (dbm_delete (sg_dbm, key))
  1783.                       ++errors;
  1784.               }
  1785.           } else {
  1786. !             if (dbm_delete (sg_dbm, key))
  1787.                   ++errors;
  1788.           }
  1789.       }
  1790. Index: mkpasswd.c
  1791. *** mkpasswd.c.old    Sat Oct 10 11:22:46 1992
  1792. --- mkpasswd.c    Sat Oct 10 11:22:45 1992
  1793. ***************
  1794. *** 1,5 ****
  1795.   /*
  1796. !  * Copyright 1990, 1991, John F. Haugh II
  1797.    * All rights reserved.
  1798.    *
  1799.    * Permission is granted to copy and create derivative works for any
  1800. --- 1,5 ----
  1801.   /*
  1802. !  * Copyright 1990, 1991, 1992, John F. Haugh II
  1803.    * All rights reserved.
  1804.    *
  1805.    * Permission is granted to copy and create derivative works for any
  1806. ***************
  1807. *** 7,17 ****
  1808.    * in all copies of source code, or included in human readable form
  1809.    * and conspicuously displayed on all copies of object code or
  1810.    * distribution media.
  1811.    */
  1812.   
  1813.   #ifndef    lint
  1814. ! static    char    sccsid[] = "@(#)mkpasswd.c    3.9    07:44:14    9/17/91";
  1815. ! static    char    copyright[] = "Copyright 1990, 1991, John F. Haugh II";
  1816.   #endif
  1817.   
  1818.   #include "config.h"
  1819. --- 7,20 ----
  1820.    * in all copies of source code, or included in human readable form
  1821.    * and conspicuously displayed on all copies of object code or
  1822.    * distribution media.
  1823. +  *
  1824. +  * This software is provided on an AS-IS basis and the author makes
  1825. +  * no warrantee of any kind.
  1826.    */
  1827.   
  1828.   #ifndef    lint
  1829. ! static    char    sccsid[] = "@(#)mkpasswd.c    3.10    11:32:18    7/28/92";
  1830. ! static    char    copyright[] = "Copyright 1990, 1991, 1992, John F. Haugh II";
  1831.   #endif
  1832.   
  1833.   #include "config.h"
  1834. ***************
  1835. *** 51,57 ****
  1836.   DBM    *pw_dbm;
  1837.   DBM    *gr_dbm;
  1838.   DBM    *sp_dbm;
  1839. ! DBM    *sgr_dbm;
  1840.   char    *fgetsx();
  1841.   #endif
  1842.   
  1843. --- 54,60 ----
  1844.   DBM    *pw_dbm;
  1845.   DBM    *gr_dbm;
  1846.   DBM    *sp_dbm;
  1847. ! DBM    *sg_dbm;
  1848.   char    *fgetsx();
  1849.   #endif
  1850.   
  1851. ***************
  1852. *** 92,98 ****
  1853.   extern    struct    sgrp    *sgetsgent();
  1854.   extern    int    sp_dbm_update();
  1855.   extern    int    gr_dbm_update();
  1856. ! extern    int    sgr_dbm_update();
  1857.   #endif
  1858.   
  1859.   /*
  1860. --- 95,101 ----
  1861.   extern    struct    sgrp    *sgetsgent();
  1862.   extern    int    sp_dbm_update();
  1863.   extern    int    gr_dbm_update();
  1864. ! extern    int    sg_dbm_update();
  1865.   #endif
  1866.   
  1867.   /*
  1868. ***************
  1869. *** 278,284 ****
  1870.       }
  1871.       if (gflg) {
  1872.           if (sflg)
  1873. !             sgr_dbm = dbm;
  1874.           else
  1875.               gr_dbm = dbm;
  1876.       } else {
  1877. --- 281,287 ----
  1878.       }
  1879.       if (gflg) {
  1880.           if (sflg)
  1881. !             sg_dbm = dbm;
  1882.           else
  1883.               gr_dbm = dbm;
  1884.       } else {
  1885. ***************
  1886. *** 364,370 ****
  1887.               fprintf (stderr, ADD_REC_ERR,
  1888.                   Progname, group->gr_name);
  1889.   
  1890. !         if (sflg && gflg && ! sgr_dbm_update (gshadow))
  1891.               fprintf (stderr, ADD_REC_ERR,
  1892.                   Progname, gshadow->sg_name);
  1893.   #endif
  1894. --- 367,373 ----
  1895.               fprintf (stderr, ADD_REC_ERR,
  1896.                   Progname, group->gr_name);
  1897.   
  1898. !         if (sflg && gflg && ! sg_dbm_update (gshadow))
  1899.               fprintf (stderr, ADD_REC_ERR,
  1900.                   Progname, gshadow->sg_name);
  1901.   #endif
  1902. Index: pwauth.3
  1903. *** /dev/null    Sat Oct 10 11:18:23 1992
  1904. --- pwauth.3    Sat Oct 10 11:22:56 1992
  1905. ***************
  1906. *** 0 ****
  1907. --- 1,124 ----
  1908. + .\" Copyright 1992, John F. Haugh II
  1909. + .\" All rights reserved.
  1910. + .\"
  1911. + .\" Permission is granted to copy and create derivative works for any
  1912. + .\" non-commercial purpose, provided this copyright notice is preserved
  1913. + .\" in all copies of source code, or included in human readable form
  1914. + .\" and conspicuously displayed on all copies of object code or
  1915. + .\" distribution media.
  1916. + .\"
  1917. + .\" This software is provided on an AS-IS basis and the author makes
  1918. + .\" no warrantee of any kind.
  1919. + .\"
  1920. + .\"    @(#)pwauth.3    3.1    08:30:31    10/1/92
  1921. + .\"
  1922. + .TH PWAUTH 3
  1923. + .SH NAME
  1924. + pwauth \- administrator defined password authentication routines
  1925. + .SH Syntax
  1926. + .IP "" .5i
  1927. + #include <pwauth.h>
  1928. + .IP "" .5i
  1929. + int pw_auth (char *command, char *user, int reason, ...);
  1930. + .SH DESCRIPTION
  1931. + .I pw_auth
  1932. + invokes the administrator defined functions for a given user.
  1933. + .PP
  1934. + \fIcommand\fR is the name of the authentication program.
  1935. + It is retrieved from the user's password file information.
  1936. + The string contains one or more executable file names, delimited by
  1937. + semi-colons.
  1938. + Each program will be executed in the order given.
  1939. + The command line arguments are given for each of the reasons listed
  1940. + below.
  1941. + .PP
  1942. + \fIuser\fR is the name of the user to be authenticated, as given
  1943. + in the \fB/etc/passwd\fR file.
  1944. + User entries are indexed by username.
  1945. + This allows non-unique user IDs to be present and for each different
  1946. + username associated with that user ID to have a different
  1947. + authentication program and information.
  1948. + .PP
  1949. + Each of the permissible authentication reasons is handled in a
  1950. + potentially differenent manner.
  1951. + Unless otherwise mentioned, the standard file descriptors 0, 1, and
  1952. + 2 are available for communicating with the user.
  1953. + The real user ID may be used to determine the identity of the user
  1954. + making the authentication request.
  1955. + \fIreason\fR is one of
  1956. + .IP PW_SU 1i
  1957. + Perform authentication for the current real user ID attempting to
  1958. + switch real user ID to the named user.
  1959. + The authentication program will be invoked with a \fB-s\fR option, followed
  1960. + by the username.
  1961. + .IP PW_LOGIN 1i
  1962. + Perform authentication for the named user creating a new login session.
  1963. + The authentication program will be invoked with a \fB-l\fR option, followed
  1964. + by the username.
  1965. + .IP PW_ADD 1i
  1966. + Create a new entry for the named user.
  1967. + This allows an authentication program to initialize storage for a new
  1968. + user.
  1969. + The authentication program will be invoked with a \fB-a\fR option, followed
  1970. + by the username.
  1971. + .IP PW_CHANGE 1i
  1972. + Alter an existing entry for the named user.
  1973. + This allows an authentication program to alter the authentication
  1974. + information for an existing user.
  1975. + The authentication program will be invoked with a \fB-c\fR option, followed
  1976. + by the username.
  1977. + .IP PW_DELETE 1i
  1978. + Delete authentication information for the named user.
  1979. + This allows an authentication program to reclaim storage for a user which
  1980. + is no longer authenticated using the authentication program.
  1981. + The authentication program will be invoked with a \fB-d\fR option, followed
  1982. + by the username.
  1983. + .IP PW_TELNET 1i
  1984. + Authenticate a user who is connecting to the system using the \fItelnet\fR
  1985. + command.
  1986. + The authentication program will be invoked with a \fB-t\fR option, followed
  1987. + by the username.
  1988. + .IP PW_RLOGIN 1i
  1989. + Authenticate a user who is connecting to the system using the \fIrlogin\fR
  1990. + command.
  1991. + The authentication program will be invoked with a \fB-r\fR option, followed
  1992. + by the username.
  1993. + .IP PW_FTP 1i
  1994. + Authenticate a user who is connecting to the system using the \fIftp\fR
  1995. + command.
  1996. + The authentication program will be invoked with a \fR-f\fR option, followed
  1997. + by the username.
  1998. + The standard file descriptors are not available for communicating with the
  1999. + user.
  2000. + The standard input file descriptor will be connected to the parent process,
  2001. + while the other two output file descriptors will be connected to
  2002. + \fB/dev/null\fR.
  2003. + The \fIpw_auth\fR function will pipe a single line of data to the
  2004. + authentication program using file descriptor 0.
  2005. + .IP PW_REXEC 1i
  2006. + Authenticate a user who is connecting to the system using the \fIrexec\fR
  2007. + command.
  2008. + The authentication program will be invoked with a \fB-x\fR option, followed
  2009. + by the username.
  2010. + The standard file descriptors are not available for communicating with the
  2011. + remote user.
  2012. + The standard input file descriptor will be connected to the parent process,
  2013. + while the other two output file descriptors will be connected to
  2014. + \fB/dev/null\fR.
  2015. + The \fIpw_auth\fR function will pipe a single line of data to the
  2016. + authentication program using file descriptor 0.
  2017. + .PP
  2018. + The last optional argument is the authentication data which is used by the
  2019. + PW_FTP and PW_REXEC reasons.
  2020. + It is treated as a single line of text which is piped to the authentication
  2021. + program.
  2022. + .SH CAVEATS
  2023. + This function does not create the actual session.
  2024. + It only indicates if the user should be allowed to create the session.
  2025. + .PP
  2026. + The network options are untested at this time.
  2027. + .SH DIAGNOSTICS
  2028. + The \fIpw_auth\fR function returns 0 if the authentication program exited
  2029. + with a 0 exit code, and a non-zero value otherwise.
  2030. + .SH SEE ALSO
  2031. + login(1), passwd(1), su(1), useradd(1), userdel(1), usermod(1)
  2032. Index: pwauth.8
  2033. *** /dev/null    Sat Oct 10 11:18:23 1992
  2034. --- pwauth.8    Sat Oct 10 11:23:06 1992
  2035. ***************
  2036. *** 0 ****
  2037. --- 1,44 ----
  2038. + .\" Copyright 1992, John F. Haugh II
  2039. + .\" All rights reserved.
  2040. + .\"
  2041. + .\" Permission is granted to copy and create derivative works for any
  2042. + .\" non-commercial purpose, provided this copyright notice is preserved
  2043. + .\" in all copies of source code, or included in human readable form
  2044. + .\" and conspicuously displayed on all copies of object code or
  2045. + .\" distribution media.
  2046. + .\"
  2047. + .\" This software is provided on an AS-IS basis and the author makes
  2048. + .\" no warrantee of any kind.
  2049. + .\"
  2050. + .\"    @(#)pwauth.8    3.1    08:30:40    10/1/92
  2051. + .\"
  2052. + .TH PWAUTH 8
  2053. + .SH NAME
  2054. + pwauth \- administrator defined password authentication
  2055. + .SH DESCRIPTION
  2056. + The system administrator is able to define a list of programs which
  2057. + are used to validate a user's identity.
  2058. + These programs are given in place of the encrypted password
  2059. + information which is present in either the \fB/etc/passwd\fR or
  2060. + \fB/etc/shadow\fR files.
  2061. + The utilities which administer user accounts examine the encrypted
  2062. + password field and determine if the user has an administrator defined
  2063. + authentication program.
  2064. + The \fIpw_auth\fR function will be invoked whenever one of these
  2065. + administration programs determines that a user which is being altered
  2066. + has authentication programs defined.
  2067. + .PP
  2068. + The initial entry is created with the \fIuseradd\fR command.
  2069. + Alterations, such as changing authentication information or deleting
  2070. + the user account, will cause the \fIpw_auth\fR function to be invoked.
  2071. + This keeps the authentication information up to date for each user
  2072. + account.
  2073. + .PP
  2074. + The authentication programs do not create the actual login or network
  2075. + sessions. 
  2076. + The exit code from the authentication program is taken as an
  2077. + indication that the action is to be permitted.
  2078. + The calling process must have the appropriate priviledges to create
  2079. + the login or network session itself.
  2080. + .SH SEE ALSO
  2081. + login(1), passwd(1), su(1), useradd(1), userdel(1), usermod(1), pwauth(3)
  2082. -- 
  2083. John F. Haugh II                  [  TSAKC  ] !'s: ...!cs.utexas.edu!rpp386!jfh
  2084. Ma Bell: (512) 251-2151           [ DoF #17 ]        @'s: jfh@rpp386.cactus.org
  2085.  
  2086. exit 0 # Just in case...
  2087.