home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume26 / shadow / part11 < prev    next >
Encoding:
Text File  |  1991-11-24  |  47.0 KB  |  1,772 lines

  1. Newsgroups: comp.sources.misc
  2. From: jfh@rpp386.Cactus.ORG (John F Haugh II)
  3. Subject:  v26i064:  shadow - Shadow Password Suite, Part11/11
  4. Message-ID: <1991Nov24.185332.20763@sparky.imd.sterling.com>
  5. X-Md4-Signature: fd04797535c13517f2938233ee8e6477
  6. Date: Sun, 24 Nov 1991 18:53:32 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jfh@rpp386.Cactus.ORG (John F Haugh II)
  10. Posting-number: Volume 26, Issue 64
  11. Archive-name: shadow/part11
  12. Environment: UNIX
  13. Supersedes: shadow-2: Volume 06, Issue 22-24
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  chfn.1 chsh.1 dialchk.c dialup.h dpasswd.8 encrypt.c
  21. #   faillog.4 faillog.h fields.c groupadd.1 groupdel.1 groupmod.1
  22. #   groups.1 grpack.c id.1 lastlog.h log.c logoutd.8 logoutd.c mail.c
  23. #   mkrmdir.c motd.c newgrp.1 pwconv.8 pwunconv.8 spdbm.c sulog.c tz.c
  24. #   userdel.1
  25. # Wrapped by kent@sparky on Sun Nov 24 11:03:44 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 11 (of 11)."'
  29. if test -f 'chfn.1' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'chfn.1'\"
  31. else
  32.   echo shar: Extracting \"'chfn.1'\" \(1598 characters\)
  33.   sed "s/^X//" >'chfn.1' <<'END_OF_FILE'
  34. X.\" Copyright 1990, John F. Haugh II
  35. X.\" All rights reserved.
  36. X.\"
  37. X.\" Use, duplication, and disclosure prohibited without
  38. X.\" the express written permission of the author.
  39. X.\"
  40. X.\"    @(#)chfn.1    3.1    09:34:16    11/21/90
  41. X.\"
  42. X.TH CHFN 1
  43. X.SH NAME
  44. Xchfn \- change user name and information
  45. X.SH SYNOPSIS
  46. X\fBchfn\fR [ \fB-f \fIfull_name\fR ] [ \fB-r \fIroom_no\fR ]
  47. X.br
  48. X[ \fB-w \fIwork_ph\fR ] [ \fB-h \fIhome_ph\fR ] [ \fB-o \fIother\fR ]
  49. X[ \fIuser\fR ]
  50. X.SH DESCRIPTION
  51. X\fIchfn\f changes user fullname, office number, office extension, and home
  52. Xphone number information for a user's account. 
  53. XThis information is typically printed by \fIfinger(1)\f and similiar
  54. Xprograms.
  55. XA normal user may only change the fields for their own account,
  56. Xthe super user may change the fields for any account.
  57. XAlso, only the super user may use the \fB-o\f option to change the
  58. Xundefined portions of the GCOS field.
  59. X.PP
  60. XThe only restrictions placed on the contents of the fields is that no
  61. Xcontrol characters may be present, nor any of comma, colon, or equal sign.
  62. XThe \fIother\f field does not have this restriction, and is used to
  63. Xstore accounting information used by other applications.
  64. X.PP
  65. XIf none of the options are selected, \fIchfn\f operates in an interactive
  66. Xfashion, prompting the user with the current values for all of the fields.
  67. XEnter the new value to change the field, or leave the line blank to use
  68. Xthe current value.
  69. XThe current value is displayed between a pair of \fB[ ]\f marks.
  70. XWithout options, chfn prompts for the current user account.
  71. X.SH Files
  72. X/etc/passwd \- user account information
  73. X.SH See Also
  74. Xpasswd(4)
  75. END_OF_FILE
  76.   if test 1598 -ne `wc -c <'chfn.1'`; then
  77.     echo shar: \"'chfn.1'\" unpacked with wrong size!
  78.   fi
  79.   # end of 'chfn.1'
  80. fi
  81. if test -f 'chsh.1' -a "${1}" != "-c" ; then 
  82.   echo shar: Will not clobber existing file \"'chsh.1'\"
  83. else
  84.   echo shar: Extracting \"'chsh.1'\" \(1475 characters\)
  85.   sed "s/^X//" >'chsh.1' <<'END_OF_FILE'
  86. X.\" Copyright 1990, John F. Haugh II
  87. X.\" All rights reserved.
  88. X.\"
  89. X.\" Use, duplication, and disclosure prohibited without
  90. X.\" the express written permission of the author.
  91. X.\"
  92. X.\"    @(#)chsh.1    3.1    09:34:17    11/21/90
  93. X.\"
  94. X.TH CHSH 1
  95. X.SH NAME
  96. Xchsh \- change login shell
  97. X.SH SYNOPSIS
  98. X\fBchsh\fR [ \fB-s \fIlogin_shell\fR ] [ \fIuser\fR ]
  99. X.SH DESCRIPTION
  100. X\fIchsh\f changes the user login shell.
  101. XThis determines the name of the user's initial login command.
  102. XA normal user may only change the login shell for their own account,
  103. Xthe super user may change the login shell for any account.
  104. X.PP
  105. XThe only restrictions placed on the login shell is that the
  106. Xcommand name must be listed in \fB/etc/shells\fR, unless the
  107. Xinvoker is the super-user, and then any value may be added.
  108. XAn account with a restricted login shell may not change
  109. Xtheir login shell.
  110. XFor this reason, placing \fB/bin/rsh\fR in \fB/etc/shells\fR
  111. Xis discouraged since accidentally changing to a restricted
  112. Xshell would prevent the user from every changing their login
  113. Xshell back to its original value.
  114. X.PP
  115. XIf the \fB-s\fR option is not selected, \fIchsh\f operates in an interactive
  116. Xfashion, prompting the user with the current login shell.
  117. XEnter the new value to change the field, or leave the line blank to use
  118. Xthe current value.
  119. XThe current value is displayed between a pair of \fB[ ]\f marks.
  120. X.SH Files
  121. X/etc/passwd \- user account information
  122. X.br
  123. X/etc/shells \- list of valid login shells
  124. X.SH See Also
  125. Xchfn(1),
  126. Xpasswd(4)
  127. END_OF_FILE
  128.   if test 1475 -ne `wc -c <'chsh.1'`; then
  129.     echo shar: \"'chsh.1'\" unpacked with wrong size!
  130.   fi
  131.   # end of 'chsh.1'
  132. fi
  133. if test -f 'dialchk.c' -a "${1}" != "-c" ; then 
  134.   echo shar: Will not clobber existing file \"'dialchk.c'\"
  135. else
  136.   echo shar: Extracting \"'dialchk.c'\" \(1427 characters\)
  137.   sed "s/^X//" >'dialchk.c' <<'END_OF_FILE'
  138. X/*
  139. X * Copyright 1989, 1990, 1991, John F. Haugh II
  140. X * All rights reserved.
  141. X *
  142. X * Permission is granted to copy and create derivative works for any
  143. X * non-commercial purpose, provided this copyright notice is preserved
  144. X * in all copies of source code, or included in human readable form
  145. X * and conspicuously displayed on all copies of object code or
  146. X * distribution media.
  147. X */
  148. X
  149. X#include <stdio.h>
  150. X#ifdef    BSD
  151. X#include <strings.h>
  152. X#else
  153. X#include <string.h>
  154. X#endif
  155. X#include "config.h"
  156. X#include "dialup.h"
  157. X
  158. X#ifndef    lint
  159. Xstatic    char    sccsid[] = "@(#)dialchk.c    3.3    08:54:38    7/10/91";
  160. X#endif
  161. X
  162. Xextern    char    *pw_encrypt();
  163. X
  164. X/*
  165. X * Check for dialup password
  166. X *
  167. X *    dialcheck tests to see if tty is listed as being a dialup
  168. X *    line.  If so, a dialup password may be required if the shell
  169. X *    is listed as one which requires a second password.
  170. X */
  171. X
  172. Xint    dialcheck (tty, shell)
  173. Xchar    *tty;
  174. Xchar    *shell;
  175. X{
  176. X    char    *crypt ();
  177. X    char    *getpass ();
  178. X    struct    dialup    *dialup;
  179. X    char    *pass;
  180. X    char    *cp;
  181. X
  182. X    setduent ();
  183. X
  184. X    if (! isadialup (tty)) {
  185. X        endduent ();
  186. X        return (1);
  187. X    }
  188. X    if (! (dialup = getdushell (shell))) {
  189. X        endduent ();
  190. X        return (1);
  191. X    }
  192. X    endduent ();
  193. X
  194. X    if (dialup->du_passwd[0] == '\0')
  195. X        return (1);
  196. X
  197. X    if (! (pass = getpass ("Dialup Password:")))
  198. X        return (0);
  199. X
  200. X    cp = pw_encrypt (pass, dialup->du_passwd);
  201. X#if defined(USG)
  202. X    memset (pass, 0, strlen (pass));
  203. X#else
  204. X    bzero (pass, strlen (pass));
  205. X#endif
  206. X    return (strcmp (cp, dialup->du_passwd) == 0);
  207. X}
  208. END_OF_FILE
  209.   if test 1427 -ne `wc -c <'dialchk.c'`; then
  210.     echo shar: \"'dialchk.c'\" unpacked with wrong size!
  211.   fi
  212.   # end of 'dialchk.c'
  213. fi
  214. if test -f 'dialup.h' -a "${1}" != "-c" ; then 
  215.   echo shar: Will not clobber existing file \"'dialup.h'\"
  216. else
  217.   echo shar: Extracting \"'dialup.h'\" \(1581 characters\)
  218.   sed "s/^X//" >'dialup.h' <<'END_OF_FILE'
  219. X/*
  220. X * Copyright 1989, 1990, 1991, John F. Haugh II
  221. X * All rights reserved.
  222. X *
  223. X * Permission is granted to copy and create derivative works for any
  224. X * non-commercial purpose, provided this copyright notice is preserved
  225. X * in all copies of source code, or included in human readable form
  226. X * and conspicuously displayed on all copies of object code or
  227. X * distribution media.
  228. X */
  229. X
  230. X/*
  231. X * Structure of the /etc/d_passwd file
  232. X *
  233. X *    The d_passwd file contains the names of login shells which require
  234. X *    dialup passwords.  Each line contains the fully qualified path name
  235. X *    for the shell, followed by an optional password.  Each field is
  236. X *    separated by a ':'.
  237. X *
  238. X * Structure of the /etc/dialups file
  239. X *
  240. X *    The dialups file contains the names of ports which may be dialup
  241. X *    lines.  Each line consists of the last component of the path
  242. X *    name.  The leading "/dev/" string is removed.
  243. X *
  244. X *    @(#)dialup.h    3.2    09:06:55    5/28/91
  245. X */
  246. X
  247. X#ifndef    _DIALUP_H
  248. X#define    _DIALUP_H
  249. X
  250. Xstruct    dialup {
  251. X    char    *du_shell;
  252. X    char    *du_passwd;
  253. X};
  254. X
  255. X#if !__STDC__
  256. Xextern    void    setduent ();
  257. Xextern    void    endduent ();
  258. Xextern    struct    dialup    *fgetduent ();
  259. Xextern    struct    dialup    *getduent ();
  260. Xextern    struct    dialup    *getdushell ();
  261. Xextern    int    putduent ();
  262. Xextern    int    isadialup ();
  263. X#else
  264. Xextern    void    setduent (void);
  265. Xextern    void    endduent (void);
  266. Xextern    struct    dialup    *fgetduent (FILE *);
  267. Xextern    struct    dialup    *getduent (void);
  268. Xextern    struct    dialup    *getdushell (char *);
  269. Xextern    int    putduent (struct dialup *, FILE *);
  270. Xextern    int    isadialup (char *);
  271. X#endif
  272. X
  273. X#define    DIALPWD    "/etc/d_passwd"
  274. X#define    DIALUPS    "/etc/dialups"
  275. X
  276. X#endif
  277. END_OF_FILE
  278.   if test 1581 -ne `wc -c <'dialup.h'`; then
  279.     echo shar: \"'dialup.h'\" unpacked with wrong size!
  280.   fi
  281.   # end of 'dialup.h'
  282. fi
  283. if test -f 'dpasswd.8' -a "${1}" != "-c" ; then 
  284.   echo shar: Will not clobber existing file \"'dpasswd.8'\"
  285. else
  286.   echo shar: Extracting \"'dpasswd.8'\" \(997 characters\)
  287.   sed "s/^X//" >'dpasswd.8' <<'END_OF_FILE'
  288. X.\" Copyright 1991, John F. Haugh II
  289. X.\" All rights reserved.
  290. X.\"
  291. X.\" Permission is granted to copy and create derivative works for any
  292. X.\" non-commercial purpose, provided this copyright notice is preserved
  293. X.\" in all copies of source code, or included in human readable form
  294. X.\" and conspicuously displayed on all copies of object code or
  295. X.\" distribution media.
  296. X.\"
  297. X.\"    @(#)dpasswd.8    3.1    17:36:06    8/4/91
  298. X.\"
  299. X.TH DPASSWD 8
  300. X.SH NAME
  301. X\fBdpasswd\fR - change dialup password
  302. X.SH SYNOPSIS
  303. X\fBdpasswd\fR
  304. X[ \fI-(a|d)\fR ] \fIshell\fR
  305. X.SH DESCRIPTION
  306. X\fBdpasswd\fR adds, deletes, and updates dialup passwords for user
  307. Xlogin shells.
  308. XThe dialup password is prompted for after a user's password has been
  309. Xauthenticated whenever the user logs in over a dialup line.
  310. X\fBdpasswd\fR will prompt for the new password twice to insure it
  311. Xhas been entered correctly.
  312. X.PP
  313. XThe \fIshell\fR argument must be the complete pathname of the login
  314. Xprogram.
  315. X.SH FILES
  316. X.br
  317. X/etc/d_passwd
  318. X.br
  319. X/etc/dialups
  320. X.SH SEE ALSO
  321. Xlogin(1)
  322. END_OF_FILE
  323.   if test 997 -ne `wc -c <'dpasswd.8'`; then
  324.     echo shar: \"'dpasswd.8'\" unpacked with wrong size!
  325.   fi
  326.   # end of 'dpasswd.8'
  327. fi
  328. if test -f 'encrypt.c' -a "${1}" != "-c" ; then 
  329.   echo shar: Will not clobber existing file \"'encrypt.c'\"
  330. else
  331.   echo shar: Extracting \"'encrypt.c'\" \(1287 characters\)
  332.   sed "s/^X//" >'encrypt.c' <<'END_OF_FILE'
  333. X/*
  334. X * Copyright 1990, John F. Haugh II
  335. X * All rights reserved.
  336. X *
  337. X * Permission is granted to copy and create derivative works for any
  338. X * non-commercial purpose, provided this copyright notice is preserved
  339. X * in all copies of source code, or included in human readable form
  340. X * and conspicuously displayed on all copies of object code or
  341. X * distribution media.
  342. X */
  343. X
  344. X#include <string.h>
  345. X#include "config.h"
  346. X
  347. X#ifndef lint
  348. Xstatic    char    sccsid[] = "@(#)encrypt.c    3.4    19:44:23    12/10/90";
  349. X#endif
  350. X
  351. Xextern    char    *crypt();
  352. X
  353. Xchar *
  354. Xpw_encrypt (clear, salt)
  355. Xchar    *clear;
  356. Xchar    *salt;
  357. X{
  358. X    static    char    cipher[32];
  359. X    static    int    count;
  360. X    char    newsalt[2];
  361. X    char    *cp;
  362. X    long    now;
  363. X
  364. X    /*
  365. X     * See if a new salt is needed and get a few random
  366. X     * bits of information.  The amount of randomness is
  367. X     * probably not all that crucial since the salt only
  368. X     * serves to thwart a dictionary attack.
  369. X     */
  370. X
  371. X    if (salt == (char *) 0) {
  372. X        now = time ((long *) 0) + count++;
  373. X        now ^= clock ();
  374. X        now ^= getpid ();
  375. X        now = ((now >> 12) ^ (now)) & 07777;
  376. X        newsalt[0] = i64c ((now >> 6) & 077);
  377. X        newsalt[1] = i64c (now & 077);
  378. X        salt = newsalt;
  379. X    }
  380. X    cp = crypt (clear, salt);
  381. X    strcpy (cipher, cp);
  382. X
  383. X#ifdef    DOUBLESIZE
  384. X    if (strlen (clear) > 8) {
  385. X        cp = crypt (clear + 8, salt);
  386. X        strcat (cipher, cp + 2);
  387. X    }
  388. X#endif
  389. X    return cipher;
  390. X}
  391. END_OF_FILE
  392.   if test 1287 -ne `wc -c <'encrypt.c'`; then
  393.     echo shar: \"'encrypt.c'\" unpacked with wrong size!
  394.   fi
  395.   # end of 'encrypt.c'
  396. fi
  397. if test -f 'faillog.4' -a "${1}" != "-c" ; then 
  398.   echo shar: Will not clobber existing file \"'faillog.4'\"
  399. else
  400.   echo shar: Extracting \"'faillog.4'\" \(969 characters\)
  401.   sed "s/^X//" >'faillog.4' <<'END_OF_FILE'
  402. X.\" Copyright 1989, 1990, John F. Haugh II
  403. X.\" All rights reserved.
  404. X.\"
  405. X.\" Use, duplication, and disclosure prohibited without
  406. X.\" the express written permission of the author.
  407. X.\"
  408. X.\"    @(#)faillog.4    3.1    09:34:18    11/21/90
  409. X.\"
  410. X.TH FAILLOG 4
  411. X.SH NAME
  412. Xfaillog \- Login failure logging file
  413. X.SH DESCRIPTION
  414. X.I faillog
  415. Xmaintains a count of login failures and the limits for each account.
  416. XThe file is fixed length record, indexed by numerical UID.
  417. XEach record contains the count of login failures since the last
  418. Xsuccessful login;
  419. Xthe maximum number of failures before the account is disabled;
  420. Xthe line the last login failure occured on;
  421. Xand the date the last login failure occured.
  422. X.PP
  423. XThe structure of the file is
  424. X.DS
  425. X
  426. X        struct    faillog {
  427. X                short   fail_cnt;
  428. X                short   fail_max;
  429. X                char    fail_line[12];
  430. X                time_t  fail_time;
  431. X        };
  432. X
  433. X.DE
  434. X.SH Files
  435. X/usr/adm/faillog \- login failure log
  436. X.SH See Also
  437. Xfaillog(8)
  438. END_OF_FILE
  439.   if test 969 -ne `wc -c <'faillog.4'`; then
  440.     echo shar: \"'faillog.4'\" unpacked with wrong size!
  441.   fi
  442.   # end of 'faillog.4'
  443. fi
  444. if test -f 'faillog.h' -a "${1}" != "-c" ; then 
  445.   echo shar: Will not clobber existing file \"'faillog.h'\"
  446. else
  447.   echo shar: Extracting \"'faillog.h'\" \(715 characters\)
  448.   sed "s/^X//" >'faillog.h' <<'END_OF_FILE'
  449. X/*
  450. X * Copyright 1989, 1990, John F. Haugh II
  451. X * All rights reserved.
  452. X *
  453. X * Use, duplication, and disclosure prohibited without
  454. X * the express written permission of the author.
  455. X */
  456. X
  457. X/*
  458. X * faillog.h - login failure logging file format
  459. X *
  460. X *    @(#)faillog.h    2.2    19:23:46    7/29/90
  461. X *
  462. X * The login failure file is maintained by login(1) and fail(1L)
  463. X * Each record in the file represents a separate UID and the file
  464. X * is indexed in that fashion.
  465. X */
  466. X
  467. X#define    FAILFILE    "/usr/adm/faillog"
  468. X
  469. Xstruct    faillog {
  470. X    short    fail_cnt;    /* failures since last success */
  471. X    short    fail_max;    /* failures before turning account off */
  472. X    char    fail_line[12];    /* last failure occured here */
  473. X    time_t    fail_time;    /* last failure occured then */
  474. X};
  475. END_OF_FILE
  476.   if test 715 -ne `wc -c <'faillog.h'`; then
  477.     echo shar: \"'faillog.h'\" unpacked with wrong size!
  478.   fi
  479.   # end of 'faillog.h'
  480. fi
  481. if test -f 'fields.c' -a "${1}" != "-c" ; then 
  482.   echo shar: Will not clobber existing file \"'fields.c'\"
  483. else
  484.   echo shar: Extracting \"'fields.c'\" \(1230 characters\)
  485.   sed "s/^X//" >'fields.c' <<'END_OF_FILE'
  486. X/*
  487. X * Copyright 1990, John F. Haugh II
  488. X * All rights reserved.
  489. X *
  490. X * Use, duplication, and disclosure prohibited without
  491. X * the express written permission of the author.
  492. X */
  493. X
  494. X#include <ctype.h>
  495. X#include <string.h>
  496. X#include <stdio.h>
  497. X
  498. X#ifndef    lint
  499. Xstatic    char    sccsid[] = "@(#)fields.c    3.2    08:26:23    11/26/90";
  500. X#endif
  501. X
  502. Xextern    char    *Progname;
  503. X
  504. X/*
  505. X * valid_field - insure that a field contains all legal characters
  506. X *
  507. X * The supplied field is scanned for non-printing and other illegal
  508. X * characters.  If any illegal characters are found, valid_field
  509. X * returns -1.  Zero is returned for success.
  510. X */
  511. X
  512. Xint
  513. Xvalid_field (field, illegal)
  514. Xchar    *field;
  515. Xchar    *illegal;
  516. X{
  517. X    char    *cp;
  518. X
  519. X    for (cp = field;*cp && isprint (*cp) && ! strchr (illegal, *cp);cp++)
  520. X        ;
  521. X
  522. X    if (*cp)
  523. X        return -1;
  524. X    else
  525. X        return 0;
  526. X}
  527. X
  528. X/*
  529. X * change_field - change a single field if a new value is given.
  530. X *
  531. X * prompt the user with the name of the field being changed and the
  532. X * current value.
  533. X */
  534. X
  535. Xvoid
  536. Xchange_field (buf, prompt)
  537. Xchar    *buf;
  538. Xchar    *prompt;
  539. X{
  540. X    char    new[BUFSIZ];
  541. X    char    *cp;
  542. X
  543. X    printf ("\t%s [%s]: ", prompt, buf);
  544. X    if (fgets (new, BUFSIZ, stdin) != new)
  545. X        return;
  546. X
  547. X    if (cp = strchr (new, '\n'))
  548. X        *cp = '\0';
  549. X    else
  550. X        return;
  551. X
  552. X    if (new[0])
  553. X        strcpy (buf, new);
  554. X}
  555. END_OF_FILE
  556.   if test 1230 -ne `wc -c <'fields.c'`; then
  557.     echo shar: \"'fields.c'\" unpacked with wrong size!
  558.   fi
  559.   # end of 'fields.c'
  560. fi
  561. if test -f 'groupadd.1' -a "${1}" != "-c" ; then 
  562.   echo shar: Will not clobber existing file \"'groupadd.1'\"
  563. else
  564.   echo shar: Extracting \"'groupadd.1'\" \(1349 characters\)
  565.   sed "s/^X//" >'groupadd.1' <<'END_OF_FILE'
  566. X.\" Copyright 1991, John F. Haugh II
  567. X.\" All rights reserved.
  568. X.\"
  569. X.\" Permission is granted to copy and create derivative works for any
  570. X.\" non-commercial purpose, provided this copyright notice is preserved
  571. X.\" in all copies of source code, or included in human readable form
  572. X.\" and conspicuously displayed on all copies of object code or
  573. X.\" distribution media.
  574. X.\"
  575. X.\"    @(#)groupadd.1    3.1    13:28:00    7/13/91
  576. X.\"
  577. X.TH GROUPADD 1M
  578. X.SH NAME
  579. Xgroupadd \- Create a new group
  580. X.SH SYNOPSIS
  581. X.B groupadd
  582. X[ \fB-g\fI gid \fR[ \fB-o\fR ] ]
  583. X.I group
  584. X.SH DESCRIPTION
  585. XThe \fIgroupadd\fR command
  586. Xcreates a new group account using the values specified on the
  587. Xcommand line and the default values from the system.
  588. XThe new group will be entered into the system files as needed.
  589. XThe options which apply to the \fIgroupadd\fR command are
  590. X.IP "\fB-g \fIgid\fR"
  591. XThe numerical value of the group's ID.
  592. XThis value must be unique, unless the \fI-o\fR option is used.
  593. XThe value must be non-negative.
  594. XThe default is to use the smallest ID value greater than 99 and
  595. Xgreater than every other group.
  596. XValues between 0 and 99 are typically reserved for system accounts.
  597. X.SH Files
  598. X/etc/group \- group account information
  599. X.br
  600. X/etc/gshadow \- secure group account information
  601. X.SH SEE ALSO
  602. X\fBchfn(1), chsh(1), useradd(1M), userdel(1M), usermod(1M),
  603. Xpasswd(1), groupdel(1M), groupmod(1M)
  604. END_OF_FILE
  605.   if test 1349 -ne `wc -c <'groupadd.1'`; then
  606.     echo shar: \"'groupadd.1'\" unpacked with wrong size!
  607.   fi
  608.   # end of 'groupadd.1'
  609. fi
  610. if test -f 'groupdel.1' -a "${1}" != "-c" ; then 
  611.   echo shar: Will not clobber existing file \"'groupdel.1'\"
  612. else
  613.   echo shar: Extracting \"'groupdel.1'\" \(969 characters\)
  614.   sed "s/^X//" >'groupdel.1' <<'END_OF_FILE'
  615. X.\" Copyright 1991, John F. Haugh II
  616. X.\" All rights reserved.
  617. X.\"
  618. X.\" Permission is granted to copy and create derivative works for any
  619. X.\" non-commercial purpose, provided this copyright notice is preserved
  620. X.\" in all copies of source code, or included in human readable form
  621. X.\" and conspicuously displayed on all copies of object code or
  622. X.\" distribution media.
  623. X.\"
  624. X.\"    @(#)groupdel.1    3.1    13:28:12    7/13/91
  625. X.\"
  626. X.TH GROUPDEL 1M
  627. X.SH NAME
  628. Xgroupdel \- Delete a group
  629. X.SH SYNOPSIS
  630. X.B groupdel
  631. X.I group
  632. X.SH DESCRIPTION
  633. XThe \fIgroupdel\fR command modifies the system account files, deleting
  634. Xall entries that refer to \fIgroup\fR.
  635. XThe named group must exist.
  636. X.PP
  637. XYou must manually check all filesystems to insure that no files remain
  638. Xwith the named group as the file group ID.
  639. X.SH Files
  640. X/etc/group \- group information
  641. X.br
  642. X/etc/gshadow \- secure group information
  643. X.SH SEE ALSO
  644. X\fBchfn(1), chsh(1), useradd(1M), userdel(1M), usermod(1M),
  645. Xpasswd(1), groupadd(1M), groupmod(1M)
  646. END_OF_FILE
  647.   if test 969 -ne `wc -c <'groupdel.1'`; then
  648.     echo shar: \"'groupdel.1'\" unpacked with wrong size!
  649.   fi
  650.   # end of 'groupdel.1'
  651. fi
  652. if test -f 'groupmod.1' -a "${1}" != "-c" ; then 
  653.   echo shar: Will not clobber existing file \"'groupmod.1'\"
  654. else
  655.   echo shar: Extracting \"'groupmod.1'\" \(1383 characters\)
  656.   sed "s/^X//" >'groupmod.1' <<'END_OF_FILE'
  657. X.\" Copyright 1991, John F. Haugh II
  658. X.\" All rights reserved.
  659. X.\"
  660. X.\" Permission is granted to copy and create derivative works for any
  661. X.\" non-commercial purpose, provided this copyright notice is preserved
  662. X.\" in all copies of source code, or included in human readable form
  663. X.\" and conspicuously displayed on all copies of object code or
  664. X.\" distribution media.
  665. X.\"
  666. X.\"    @(#)groupmod.1    3.1    13:28:27    7/13/91
  667. X.\"
  668. X.TH GROUPMOD 1M
  669. X.SH NAME
  670. Xgroupmod \- Modify a group
  671. X.SH SYNOPSIS
  672. X.B groupmod
  673. X[ \fB-g\fI gid \fR[ \fB-o\fR ] ]
  674. X[ \fB-n\fI group_name \fR ]
  675. X.I group
  676. X.SH DESCRIPTION
  677. XThe \fIgroupmod\fR command modifies the system account files to reflect
  678. Xthe changes that are specified on the command line.
  679. XThe options which apply to the \fIgroupmod\fR command are
  680. X.IP "\fB-g \fIgid\fR"
  681. XThe numerical value of the group's ID.
  682. XThis value must be unique, unless the \fI-o\fR option is used.
  683. XThe value must be non-negative.
  684. XValues between 0 and 99 are typically reserved for system groups.
  685. XAny files which the old group ID is the file group ID
  686. Xmust have the file group ID changed manually.
  687. X.IP "\fB-n \fIgroup_name\fR"
  688. XThe name of the group will be changed from \fIgroup\fR to
  689. X\fIgroup_name\fR.
  690. X.SH Files
  691. X/etc/group \- group information
  692. X.br
  693. X/etc/gshadow \- secure group information
  694. X.SH SEE ALSO
  695. X\fBchfn(1), chsh(1), useradd(1M), userdel(1M), usermod(1M),
  696. Xpasswd(1), groupadd(1M), groupdel(1M)
  697. END_OF_FILE
  698.   if test 1383 -ne `wc -c <'groupmod.1'`; then
  699.     echo shar: \"'groupmod.1'\" unpacked with wrong size!
  700.   fi
  701.   # end of 'groupmod.1'
  702. fi
  703. if test -f 'groups.1' -a "${1}" != "-c" ; then 
  704.   echo shar: Will not clobber existing file \"'groups.1'\"
  705. else
  706.   echo shar: Extracting \"'groups.1'\" \(1092 characters\)
  707.   sed "s/^X//" >'groups.1' <<'END_OF_FILE'
  708. X.\" Copyright 1991, John F. Haugh II
  709. X.\" All rights reserved.
  710. X.\"
  711. X.\" Permission is granted to copy and create derivative works for any
  712. X.\" non-commercial purpose, provided this copyright notice is preserved
  713. X.\" in all copies of source code, or included in human readable form
  714. X.\" and conspicuously displayed on all copies of object code or
  715. X.\" distribution media.
  716. X.\"
  717. X.\"    @(#)groups.1    3.1    08:50:54    11/3/91
  718. X.\"
  719. X.TH ID 1
  720. X.SH NAME
  721. Xgroups \- Display current group ID names
  722. X.SH SYNOPSIS
  723. X.B groups
  724. X[
  725. X.I user
  726. X]
  727. X.SH DESCRIPTION
  728. X.I groups
  729. Xdisplays the current group ID names
  730. Xor values.
  731. XIf the value does not have a corresponding entry in
  732. X\fB/etc/group\fR, the value will be displayed as the numerical group value.
  733. XThe optional \fIuser\fR parameter will display the groups for the named
  734. X\fIuser\R.
  735. X.SH Note
  736. XSystems which do not support concurrent group sets will have the information
  737. Xfrom \fB/etc/group\fR reported.
  738. XThe user must use \fInewgrp\fR to change their current real and effective
  739. Xgroup ID.
  740. X.SH Files
  741. X/etc/group \- group information
  742. X.SH See Also
  743. Xnewgrp(1), getuid(2), getgid(2), getgroups(2)
  744. END_OF_FILE
  745.   if test 1092 -ne `wc -c <'groups.1'`; then
  746.     echo shar: \"'groups.1'\" unpacked with wrong size!
  747.   fi
  748.   # end of 'groups.1'
  749. fi
  750. if test -f 'grpack.c' -a "${1}" != "-c" ; then 
  751.   echo shar: Will not clobber existing file \"'grpack.c'\"
  752. else
  753.   echo shar: Extracting \"'grpack.c'\" \(1511 characters\)
  754.   sed "s/^X//" >'grpack.c' <<'END_OF_FILE'
  755. X/*
  756. X * Copyright 1990, John F. Haugh II
  757. X * All rights reserved.
  758. X *
  759. X * Use, duplication, and disclosure prohibited without
  760. X * the express written permission of the author.
  761. X *
  762. X * Duplication is permitted for non-commercial [ profit making ]
  763. X * purposes provided this and other copyright notices remain
  764. X * intact.
  765. X */
  766. X
  767. X#include <stdio.h>
  768. X#include <grp.h>
  769. X#ifdef    BSD
  770. X#include <strings.h>
  771. X#else
  772. X#include <string.h>
  773. X#endif
  774. X
  775. X#ifndef    lint
  776. Xstatic    char    sccsid[] = "@(#)grpack.c    3.3    08:45:46    9/12/91";
  777. X#endif
  778. X
  779. Xint    gr_pack (group, buf)
  780. Xstruct    group    *group;
  781. Xchar    *buf;
  782. X{
  783. X    char    *cp;
  784. X    int    i;
  785. X
  786. X    cp = buf;
  787. X    strcpy (cp, group->gr_name);
  788. X    cp += strlen (cp) + 1;
  789. X
  790. X    strcpy (cp, group->gr_passwd);
  791. X    cp += strlen (cp) + 1;
  792. X
  793. X    memcpy (cp, (char *) &group->gr_gid, sizeof group->gr_gid);
  794. X    cp += sizeof group->gr_gid;
  795. X
  796. X    for (i = 0;group->gr_mem[i];i++) {
  797. X        strcpy (cp, group->gr_mem[i]);
  798. X        cp += strlen (cp) + 1;
  799. X    }
  800. X    *cp++ = '\0';
  801. X
  802. X    return cp - buf;
  803. X}
  804. X
  805. Xint    gr_unpack (buf, len, group)
  806. Xchar    *buf;
  807. Xint    len;
  808. Xstruct    group    *group;
  809. X{
  810. X    char    *org = buf;
  811. X    int    i;
  812. X
  813. X    group->gr_name = buf;
  814. X    buf += strlen (buf) + 1;
  815. X    if (buf - org > len)
  816. X        return -1;
  817. X
  818. X    group->gr_passwd = buf;
  819. X    buf += strlen (buf) + 1;
  820. X    if (buf - org > len)
  821. X        return -1;
  822. X
  823. X    memcpy ((char *) &group->gr_gid, (char *) buf, sizeof group->gr_gid);
  824. X    buf += sizeof group->gr_gid;
  825. X    if (buf - org > len)
  826. X        return -1;
  827. X
  828. X    for (i = 0;*buf && i < 1024;i++) {
  829. X        group->gr_mem[i] = buf;
  830. X        buf += strlen (buf) + 1;
  831. X
  832. X        if (buf - org > len)
  833. X            return -1;
  834. X    }
  835. X    group->gr_mem[i] = (char *) 0;
  836. X    return 0;
  837. X}
  838. END_OF_FILE
  839.   if test 1511 -ne `wc -c <'grpack.c'`; then
  840.     echo shar: \"'grpack.c'\" unpacked with wrong size!
  841.   fi
  842.   # end of 'grpack.c'
  843. fi
  844. if test -f 'id.1' -a "${1}" != "-c" ; then 
  845.   echo shar: Will not clobber existing file \"'id.1'\"
  846. else
  847.   echo shar: Extracting \"'id.1'\" \(998 characters\)
  848.   sed "s/^X//" >'id.1' <<'END_OF_FILE'
  849. X.\" Copyright 1991, John F. Haugh II
  850. X.\" All rights reserved.
  851. X.\"
  852. X.\" Permission is granted to copy and create derivative works for any
  853. X.\" non-commercial purpose, provided this copyright notice is preserved
  854. X.\" in all copies of source code, or included in human readable form
  855. X.\" and conspicuously displayed on all copies of object code or
  856. X.\" distribution media.
  857. X.\"
  858. X.\"    @(#)id.1    3.2    07:24:54    8/1/91
  859. X.\"
  860. X.TH ID 1
  861. X.SH NAME
  862. Xid \- Display current user and group ID names
  863. X.SH SYNOPSIS
  864. X.B id
  865. X[
  866. X.B -a
  867. X]
  868. X.SH DESCRIPTION
  869. X.I id
  870. Xdisplays the current real and effective user and group ID names
  871. Xor values.
  872. XIf the value does not have a corresponding entry in \fB/etc/passwd\fR
  873. Xor \fB/etc/group\fR, the value will be displayed without the corresponding
  874. Xname.
  875. XThe optional \fB-a\fR flag will display the group set on systems which
  876. Xsupport multiple concurrent group membership.
  877. X.SH Files
  878. X/etc/passwd \- user account information
  879. X.br
  880. X/etc/group \- group information
  881. X.SH See Also
  882. Xgetuid(2), getgid(2), getgroups(2)
  883. END_OF_FILE
  884.   if test 998 -ne `wc -c <'id.1'`; then
  885.     echo shar: \"'id.1'\" unpacked with wrong size!
  886.   fi
  887.   # end of 'id.1'
  888. fi
  889. if test -f 'lastlog.h' -a "${1}" != "-c" ; then 
  890.   echo shar: Will not clobber existing file \"'lastlog.h'\"
  891. else
  892.   echo shar: Extracting \"'lastlog.h'\" \(511 characters\)
  893.   sed "s/^X//" >'lastlog.h' <<'END_OF_FILE'
  894. X/*
  895. X * Copyright 1989, 1990, John F. Haugh II
  896. X * All rights reserved.
  897. X *
  898. X * Use, duplication, and disclosure prohibited without
  899. X * the express written permission of the author.
  900. X */
  901. X
  902. X/*
  903. X * lastlog.h - structure of lastlog file
  904. X *
  905. X *    @(#)lastlog.h    2.3    19:23:49    7/29/90
  906. X *
  907. X *    This file defines a lastlog file structure which should be sufficient
  908. X *    to hold the information required by login.  It should only be used if
  909. X *    there is no real lastlog.h file.
  910. X */
  911. X
  912. Xstruct    lastlog    {
  913. X    time_t    ll_time;
  914. X    char    ll_line[8];
  915. X};
  916. END_OF_FILE
  917.   if test 511 -ne `wc -c <'lastlog.h'`; then
  918.     echo shar: \"'lastlog.h'\" unpacked with wrong size!
  919.   fi
  920.   # end of 'lastlog.h'
  921. fi
  922. if test -f 'log.c' -a "${1}" != "-c" ; then 
  923.   echo shar: Will not clobber existing file \"'log.c'\"
  924. else
  925.   echo shar: Extracting \"'log.c'\" \(1526 characters\)
  926.   sed "s/^X//" >'log.c' <<'END_OF_FILE'
  927. X/*
  928. X * Copyright 1989, 1990, 1991, John F. Haugh II
  929. X * All rights reserved.
  930. X *
  931. X * Permission is granted to copy and create derivative works for any
  932. X * non-commercial purpose, provided this copyright notice is preserved
  933. X * in all copies of source code, or included in human readable form
  934. X * and conspicuously displayed on all copies of object code or
  935. X * distribution media.
  936. X */
  937. X
  938. X#include <sys/types.h>
  939. X#include <utmp.h>
  940. X#include "pwd.h"
  941. X#include <fcntl.h>
  942. X#include <time.h>
  943. X#ifndef    BSD
  944. X#include <string.h>
  945. X#include <memory.h>
  946. X#else
  947. X#include <strings.h>
  948. X#define    strchr    index
  949. X#define    strrchr    rindex
  950. X#endif
  951. X#include "config.h"
  952. X
  953. X#ifndef    lint
  954. Xstatic    char    sccsid[] = "@(#)log.c    3.2    07:43:10    9/17/91";
  955. X#endif
  956. X
  957. X#include "lastlog.h"
  958. X
  959. Xextern    struct    utmp    utent;
  960. Xextern    struct    passwd    pwent;
  961. Xextern    struct    lastlog    lastlog;
  962. Xextern    char    **environ;
  963. X
  964. Xlong    lseek ();
  965. Xtime_t    time ();
  966. X
  967. Xvoid    log ()
  968. X{
  969. X    int    fd;
  970. X    off_t    offset;
  971. X    struct    lastlog    newlog;
  972. X
  973. X    if ((fd = open ("/usr/adm/lastlog", O_RDWR)) == -1)
  974. X        return;
  975. X
  976. X    offset = pwent.pw_uid * sizeof lastlog;
  977. X
  978. X    if (lseek (fd, offset, 0) != offset) {
  979. X        (void) close (fd);
  980. X        return;
  981. X    }
  982. X    if (read (fd, (char *) &lastlog, sizeof lastlog) != sizeof lastlog)
  983. X#ifndef    BSD
  984. X        memset ((char *) &lastlog, sizeof lastlog, 0);
  985. X#else
  986. X        bzero ((char *) &lastlog, sizeof lastlog);
  987. X#endif
  988. X    newlog = lastlog;
  989. X
  990. X    (void) time (&newlog.ll_time);
  991. X    (void) strncpy (newlog.ll_line, utent.ut_line, sizeof newlog.ll_line);
  992. X    (void) lseek (fd, offset, 0);
  993. X    (void) write (fd, (char *) &newlog, sizeof newlog);
  994. X    (void) close (fd);
  995. X}
  996. X
  997. END_OF_FILE
  998.   if test 1526 -ne `wc -c <'log.c'`; then
  999.     echo shar: \"'log.c'\" unpacked with wrong size!
  1000.   fi
  1001.   # end of 'log.c'
  1002. fi
  1003. if test -f 'logoutd.8' -a "${1}" != "-c" ; then 
  1004.   echo shar: Will not clobber existing file \"'logoutd.8'\"
  1005. else
  1006.   echo shar: Extracting \"'logoutd.8'\" \(999 characters\)
  1007.   sed "s/^X//" >'logoutd.8' <<'END_OF_FILE'
  1008. X.\" Copyright 1991, John F. Haugh II
  1009. X.\" All rights reserved.
  1010. X.\"
  1011. X.\" Permission is granted to copy and create derivative works for any
  1012. X.\" non-commercial purpose, provided this copyright notice is preserved
  1013. X.\" in all copies of source code, or included in human readable form
  1014. X.\" and conspicuously displayed on all copies of object code or
  1015. X.\" distribution media.
  1016. X.\"
  1017. X.\"    @(#)logoutd.8    3.1    16:31:36    9/22/91
  1018. X.\"
  1019. X.TH LOGOUTD 8
  1020. X.SH NAME
  1021. Xlogoutd \- Enforce login time restrictions
  1022. X.SH SYNOPSIS
  1023. X.B /etc/logoutd
  1024. X.SH DESCRIPTION
  1025. X.I logoutd enforces the login time and port restrictions specified in
  1026. X/etc/porttime.
  1027. X.I logoutd should be started from \fB/etc/rc\fR.
  1028. XThe \fB/etc/utmp\fR file is scanned periodically and each user name
  1029. Xis checked to see if the named user is permitted on the named port
  1030. Xat the current time.
  1031. XAny login session which is violating the restrictions in \fB/etc/porttime\fR
  1032. Xis terminated.
  1033. X.SH Files
  1034. X/etc/porttime \- login and port permissions
  1035. X.br
  1036. X/etc/utmp \- current login sessions
  1037. END_OF_FILE
  1038.   if test 999 -ne `wc -c <'logoutd.8'`; then
  1039.     echo shar: \"'logoutd.8'\" unpacked with wrong size!
  1040.   fi
  1041.   # end of 'logoutd.8'
  1042. fi
  1043. if test -f 'logoutd.c' -a "${1}" != "-c" ; then 
  1044.   echo shar: Will not clobber existing file \"'logoutd.c'\"
  1045. else
  1046.   echo shar: Extracting \"'logoutd.c'\" \(1118 characters\)
  1047.   sed "s/^X//" >'logoutd.c' <<'END_OF_FILE'
  1048. X/*
  1049. X * Copyright 1991, John F. Haugh II
  1050. X * An unpublished work.
  1051. X * All rights reserved.
  1052. X *
  1053. X * Permission is granted to copy and create derivative works for any
  1054. X * non-commercial purpose, provided this copyright notice is preserved
  1055. X * in all copies of source code, or included in human readable form
  1056. X * and conspicuously displayed on all copies of object code or
  1057. X * distribution media.
  1058. X */
  1059. X
  1060. X#ifndef lint
  1061. Xstatic    char    sccsid[] = "@(#)logoutd.c    3.1    16:31:39    9/22/91";
  1062. X#endif
  1063. X
  1064. X#include <sys/types.h>
  1065. X#include <stdio.h>
  1066. X#include <signal.h>
  1067. X#include <utmp.h>
  1068. X
  1069. Xmain ()
  1070. X{
  1071. X    int    i;
  1072. X    struct    utmp    utmp;
  1073. X    int    fd;
  1074. X
  1075. X    for (i = 0;close (i) == 0;i++)
  1076. X        ;
  1077. X
  1078. X#ifdef    NDEBUG
  1079. X    setpgrp ();
  1080. X    signal (SIGHUP, SIG_IGN);
  1081. X
  1082. X    if (fork () > 0)
  1083. X        exit (0);
  1084. X#endif
  1085. X    while (1) {
  1086. X#ifdef    NDEBUG
  1087. X        sleep (60);
  1088. X#endif
  1089. X        if ((fd = open ("/etc/utmp", 0)) == -1)
  1090. X            continue;
  1091. X
  1092. X        while (read (fd, &utmp, sizeof utmp) == sizeof utmp) {
  1093. X            if (utmp.ut_type != USER_PROCESS)
  1094. X                continue;
  1095. X
  1096. X            if (isttytime (utmp.ut_user, utmp.ut_line, time (0)))
  1097. X                continue;
  1098. X
  1099. X            kill (- utmp.ut_pid, SIGHUP);
  1100. X            sleep (10);
  1101. X            kill (- utmp.ut_pid, SIGKILL);
  1102. X        }
  1103. X        close (fd);
  1104. X    }
  1105. X}
  1106. END_OF_FILE
  1107.   if test 1118 -ne `wc -c <'logoutd.c'`; then
  1108.     echo shar: \"'logoutd.c'\" unpacked with wrong size!
  1109.   fi
  1110.   # end of 'logoutd.c'
  1111. fi
  1112. if test -f 'mail.c' -a "${1}" != "-c" ; then 
  1113.   echo shar: Will not clobber existing file \"'mail.c'\"
  1114. else
  1115.   echo shar: Extracting \"'mail.c'\" \(1054 characters\)
  1116.   sed "s/^X//" >'mail.c' <<'END_OF_FILE'
  1117. X/*
  1118. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1119. X * All rights reserved.
  1120. X *
  1121. X * Permission is granted to copy and create derivative works for any
  1122. X * non-commercial purpose, provided this copyright notice is preserved
  1123. X * in all copies of source code, or included in human readable form
  1124. X * and conspicuously displayed on all copies of object code or
  1125. X * distribution media.
  1126. X */
  1127. X
  1128. X#include <sys/types.h>
  1129. X#include <sys/stat.h>
  1130. X
  1131. X#ifndef    BSD
  1132. X#include <string.h>
  1133. X#include <memory.h>
  1134. X#else
  1135. X#include <strings.h>
  1136. X#define    strchr    index
  1137. X#define    strrchr    rindex
  1138. X#endif
  1139. X
  1140. X#include "config.h"
  1141. X
  1142. X#ifndef    lint
  1143. Xstatic    char    sccsid[] = "@(#)mail.c    3.3    07:43:42    9/17/91";
  1144. X#endif
  1145. X
  1146. Xextern    char    *getenv();
  1147. Xextern    int    getdef_bool();
  1148. X
  1149. Xvoid    mailcheck ()
  1150. X{
  1151. X    struct    stat    statbuf;
  1152. X    char    *mailbox;
  1153. X
  1154. X    if (! getdef_bool("MAIL_CHECK_ENAB"))
  1155. X        return;
  1156. X    if (! (mailbox = getenv ("MAIL")))
  1157. X        return;
  1158. X
  1159. X    if (stat (mailbox, &statbuf) == -1 || statbuf.st_size == 0)
  1160. X        puts ("No mail.");
  1161. X    else if (statbuf.st_atime > statbuf.st_mtime)
  1162. X        puts ("You have mail.");
  1163. X    else
  1164. X        puts ("You have new mail.");
  1165. X}
  1166. END_OF_FILE
  1167.   if test 1054 -ne `wc -c <'mail.c'`; then
  1168.     echo shar: \"'mail.c'\" unpacked with wrong size!
  1169.   fi
  1170.   # end of 'mail.c'
  1171. fi
  1172. if test -f 'mkrmdir.c' -a "${1}" != "-c" ; then 
  1173.   echo shar: Will not clobber existing file \"'mkrmdir.c'\"
  1174. else
  1175.   echo shar: Extracting \"'mkrmdir.c'\" \(1334 characters\)
  1176.   sed "s/^X//" >'mkrmdir.c' <<'END_OF_FILE'
  1177. X/*
  1178. X * Copyright 1991, John F. Haugh II
  1179. X * All rights reserved.
  1180. X *
  1181. X * Permission is granted to copy and create derivative works for any
  1182. X * non-commercial purpose, provided this copyright notice is preserved
  1183. X * in all copies of source code, or included in human readable form
  1184. X * and conspicuously displayed on all copies of object code or
  1185. X * distribution media.
  1186. X */
  1187. X
  1188. X#include <fcntl.h>
  1189. X#include "config.h"
  1190. X
  1191. X#ifndef lint
  1192. Xstatic    char    sccsid[] = "@(#)mkrmdir.c    3.3    07:43:57    9/17/91";
  1193. X#endif
  1194. X
  1195. X#ifdef    NEED_MKDIR
  1196. X/*
  1197. X * mkdir - create a directory
  1198. X *
  1199. X *    mkdir is provided for systems which do not include the mkdir()
  1200. X *    system call.
  1201. X */
  1202. X
  1203. Xint
  1204. Xmkdir (dir, mode)
  1205. Xchar    *dir;
  1206. Xint    mode;
  1207. X{
  1208. X    int    status;
  1209. X
  1210. X    if (fork ()) {
  1211. X        while (wait (&status) != -1)
  1212. X            ;
  1213. X
  1214. X        return status >> 8;
  1215. X    }
  1216. X#ifdef    USE_SYSLOG
  1217. X    closelog ();
  1218. X#endif
  1219. X    close (2);
  1220. X    open ("/dev/null", O_WRONLY);
  1221. X    umask (0777 & ~ mode);
  1222. X    execl ("/bin/mkdir", "mkdir", dir, 0);
  1223. X    _exit (128);
  1224. X    /*NOTREACHED*/
  1225. X}
  1226. X#endif
  1227. X#ifdef    NEED_RMDIR
  1228. X/*
  1229. X * rmdir - remove a directory
  1230. X *
  1231. X *    rmdir is provided for systems which do not include the rmdir()
  1232. X *    system call.
  1233. X */
  1234. X
  1235. Xint
  1236. Xrmdir (dir)
  1237. Xchar    *dir;
  1238. X{
  1239. X    int    status;
  1240. X
  1241. X    if (fork ()) {
  1242. X        while (wait (&status) != -1)
  1243. X            ;
  1244. X
  1245. X        return status >> 8;
  1246. X    }
  1247. X    close (2);
  1248. X    open ("/dev/null", O_WRONLY);
  1249. X    execl ("/bin/rmdir", "rmdir", dir, 0);
  1250. X    _exit (128);
  1251. X    /*NOTREACHED*/
  1252. X}
  1253. X#endif
  1254. END_OF_FILE
  1255.   if test 1334 -ne `wc -c <'mkrmdir.c'`; then
  1256.     echo shar: \"'mkrmdir.c'\" unpacked with wrong size!
  1257.   fi
  1258.   # end of 'mkrmdir.c'
  1259. fi
  1260. if test -f 'motd.c' -a "${1}" != "-c" ; then 
  1261.   echo shar: Will not clobber existing file \"'motd.c'\"
  1262. else
  1263.   echo shar: Extracting \"'motd.c'\" \(1075 characters\)
  1264.   sed "s/^X//" >'motd.c' <<'END_OF_FILE'
  1265. X/*
  1266. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1267. X * All rights reserved.
  1268. X *
  1269. X * Permission is granted to copy and create derivative works for any
  1270. X * non-commercial purpose, provided this copyright notice is preserved
  1271. X * in all copies of source code, or included in human readable form
  1272. X * and conspicuously displayed on all copies of object code or
  1273. X * distribution media.
  1274. X */
  1275. X
  1276. X#include <stdio.h>
  1277. X#ifndef    BSD
  1278. X#include <string.h>
  1279. X#include <memory.h>
  1280. X#else
  1281. X#include <strings.h>
  1282. X#define    strchr    index
  1283. X#define    strrchr    rindex
  1284. X#endif
  1285. X#include "config.h"
  1286. X
  1287. X#ifndef    lint
  1288. Xstatic    char    _sccsid[] = "@(#)motd.c    3.1    07:43:40    9/17/91";
  1289. X#endif
  1290. X
  1291. Xextern    char    *getdef_str();
  1292. X
  1293. Xvoid    motd ()
  1294. X{
  1295. X    FILE    *fp;
  1296. X    char    motdlist[BUFSIZ], *motd, *mb;
  1297. X    register int    c;
  1298. X
  1299. X    if ((mb = getdef_str("MOTD_FILE")) == NULL)
  1300. X        return;
  1301. X
  1302. X    strncpy(motdlist, mb, sizeof(motdlist));
  1303. X    motdlist[sizeof(motdlist)-1] = '\0';
  1304. X
  1305. X    for (mb = motdlist ; (motd = strtok(mb,":")) != NULL ; mb = NULL) {
  1306. X        if ((fp = fopen(motd,"r")) != NULL) {
  1307. X            while ((c = getc (fp)) != EOF)
  1308. X                putchar (c);
  1309. X            fclose (fp);
  1310. X        }
  1311. X    }
  1312. X    fflush (stdout);
  1313. X}
  1314. END_OF_FILE
  1315.   if test 1075 -ne `wc -c <'motd.c'`; then
  1316.     echo shar: \"'motd.c'\" unpacked with wrong size!
  1317.   fi
  1318.   # end of 'motd.c'
  1319. fi
  1320. if test -f 'newgrp.1' -a "${1}" != "-c" ; then 
  1321.   echo shar: Will not clobber existing file \"'newgrp.1'\"
  1322. else
  1323.   echo shar: Extracting \"'newgrp.1'\" \(1469 characters\)
  1324.   sed "s/^X//" >'newgrp.1' <<'END_OF_FILE'
  1325. X.\" Copyright 1991, John F. Haugh II
  1326. X.\" All rights reserved.
  1327. X.\"
  1328. X.\" Permission is granted to copy and create derivative works for any
  1329. X.\" non-commercial purpose, provided this copyright notice is preserved
  1330. X.\" in all copies of source code, or included in human readable form
  1331. X.\" and conspicuously displayed on all copies of object code or
  1332. X.\" distribution media.
  1333. X.\"
  1334. X.\"    @(#)newgrp.1    3.1    07:47:52    7/13/91
  1335. X.\"
  1336. X.TH NEWGRP 1
  1337. X.SH NAME
  1338. Xnewgrp \- Change group ID
  1339. X.SH SYNOPSIS
  1340. X.B newgrp
  1341. X[ - ] [ \fIgroup\fR ]
  1342. X.SH DESCRIPTION
  1343. X.I newgrp
  1344. Xis used to change the current group ID during a login session.
  1345. XIf the optional \fB\-\fR flag is given, the user's environment
  1346. Xwill be reinitialized as though the user had logged in, otherwise
  1347. Xthe current environment, including current working directory,
  1348. Xremains unchanged.
  1349. X.PP
  1350. X.I newgrp
  1351. Xchanges the current real group ID to the named group, or to
  1352. Xthe default group listed in \fB/etc/passwd\fR if no group name
  1353. Xis given.
  1354. XThe user will be prompted for a password if they do not have a
  1355. Xpassword and the group does, or if the user is not listed as a
  1356. Xmember and the group has a password.
  1357. XThe user will be denied access if the group password is empty
  1358. Xand the user is not listed as a member.
  1359. X.SH CAVEATS
  1360. X.PP
  1361. XThis version of \fInewgrp\fR has many compilation options,
  1362. Xonly some of which may be in use at any particular site.
  1363. X.SH Files
  1364. X/etc/passwd \- user account information
  1365. X.br
  1366. X/etc/group \- group information
  1367. X.SH See Also
  1368. Xlogin(1),
  1369. Xid(1),
  1370. Xsu(1)
  1371. END_OF_FILE
  1372.   if test 1469 -ne `wc -c <'newgrp.1'`; then
  1373.     echo shar: \"'newgrp.1'\" unpacked with wrong size!
  1374.   fi
  1375.   # end of 'newgrp.1'
  1376. fi
  1377. if test -f 'pwconv.8' -a "${1}" != "-c" ; then 
  1378.   echo shar: Will not clobber existing file \"'pwconv.8'\"
  1379. else
  1380.   echo shar: Extracting \"'pwconv.8'\" \(1396 characters\)
  1381.   sed "s/^X//" >'pwconv.8' <<'END_OF_FILE'
  1382. X.\" Copyright 1989, 1990, John F. Haugh II
  1383. X.\" All rights reserved.
  1384. X.\"
  1385. X.\" Use, duplication, and disclosure prohibited without
  1386. X.\" the express written permission of the author.
  1387. X.\"
  1388. X.\"    @(#)pwconv.8    3.1    23:51:34    11/11/90
  1389. X.\"
  1390. X.TH PWCONV 8
  1391. X.SH NAME
  1392. Xpwconv \- convert and update shadow password files
  1393. X.SH SYNOPSIS
  1394. X/etc/pwconv
  1395. X.SH DESCRIPTION
  1396. X\fIPwconv\fR copies the old password file information to a new shadow
  1397. Xpassword file,
  1398. Xmerging entries from an optional existing shadow file.
  1399. XThe new password file is left in \fBnpasswd\fR,
  1400. Xthe new shadow file is left in \fBnshadow\fR.
  1401. XBoth of these are files are created with modes which only permit
  1402. Xread access to the owner.
  1403. XExisting shadow entries are copied as is.
  1404. XShadow entries in the old format will be silently converted to the
  1405. Xnew format on output.
  1406. XAny entries which are missing fields will have those fields
  1407. Xfilled in with default values where appropriate.
  1408. XNew entries are created with passwords which expire in 10000 days,
  1409. Xwith a last changed date of today,
  1410. Xunless password aging information was already present.
  1411. XEntries with blank passwords are not copied to the shadow file at all.
  1412. X.SH Files
  1413. X/etc/passwd \- old encrypted passwords and password aging
  1414. X.br
  1415. X/etc/shadow \- previously converted shadow password file
  1416. X.br
  1417. X./npasswd \- new password file
  1418. X.br
  1419. X./nshadow \- new shadow password file
  1420. X.SH See Also
  1421. Xpasswd(1),
  1422. Xpasswd(4),
  1423. Xshadow(4),
  1424. Xpwunconv(8)
  1425. END_OF_FILE
  1426.   if test 1396 -ne `wc -c <'pwconv.8'`; then
  1427.     echo shar: \"'pwconv.8'\" unpacked with wrong size!
  1428.   fi
  1429.   # end of 'pwconv.8'
  1430. fi
  1431. if test -f 'pwunconv.8' -a "${1}" != "-c" ; then 
  1432.   echo shar: Will not clobber existing file \"'pwunconv.8'\"
  1433. else
  1434.   echo shar: Extracting \"'pwunconv.8'\" \(926 characters\)
  1435.   sed "s/^X//" >'pwunconv.8' <<'END_OF_FILE'
  1436. X.\" Copyright 1989, 1990, John F. Haugh II
  1437. X.\" All rights reserved.
  1438. X.\"
  1439. X.\" Use, duplication, and disclosure prohibited without
  1440. X.\" the express written permission of the author.
  1441. X.\"
  1442. X.\"    @(#)pwunconv.8    3.1    09:34:27    11/21/90
  1443. X.\"
  1444. X.TH PWUNCONV 8
  1445. X.SH NAME
  1446. Xpwunconv \- restore old password file from shadow password file
  1447. X.SH SYNOPSIS
  1448. X/etc/pwunconv
  1449. X.SH DESCRIPTION
  1450. X\fIPwunconv\fR copies the password file information from the shadow
  1451. Xpassword file,
  1452. Xmerging entries from an optional existing shadow file.
  1453. XThe new password file is left in \fBnpasswd\fR.
  1454. XThis file is created with modes which allow read access for
  1455. Xthe owner only.
  1456. XThere is no new shadow file.
  1457. XPassword aging information is translated where possible.
  1458. X.SH Files
  1459. X/etc/passwd \- old encrypted passwords and password aging
  1460. X.br
  1461. X/etc/shadow \- previously converted shadow password file
  1462. X.br
  1463. X./npasswd \- new password file
  1464. X.SH See Also
  1465. Xpasswd(1),
  1466. Xpasswd(4),
  1467. Xshadow(4),
  1468. Xpwconv(8)
  1469. END_OF_FILE
  1470.   if test 926 -ne `wc -c <'pwunconv.8'`; then
  1471.     echo shar: \"'pwunconv.8'\" unpacked with wrong size!
  1472.   fi
  1473.   # end of 'pwunconv.8'
  1474. fi
  1475. if test -f 'spdbm.c' -a "${1}" != "-c" ; then 
  1476.   echo shar: Will not clobber existing file \"'spdbm.c'\"
  1477. else
  1478.   echo shar: Extracting \"'spdbm.c'\" \(1231 characters\)
  1479.   sed "s/^X//" >'spdbm.c' <<'END_OF_FILE'
  1480. X/*
  1481. X * Copyright 1990, 1991, John F. Haugh II
  1482. X * All rights reserved.
  1483. X *
  1484. X * Use, duplication, and disclosure prohibited without
  1485. X * the express written permission of the author.
  1486. X */
  1487. X
  1488. X#ifndef    lint
  1489. Xstatic    char    sccsid[] = "@(#)spdbm.c    3.3    08:46:22    9/12/91";
  1490. X#endif
  1491. X
  1492. X#include <string.h>
  1493. X#include <stdio.h>
  1494. X#include "config.h"
  1495. X#include "shadow.h"
  1496. X
  1497. X#ifdef    NDBM
  1498. X#include <ndbm.h>
  1499. XDBM    *sp_dbm;
  1500. X
  1501. X/*
  1502. X * sp_dbm_update
  1503. X *
  1504. X * Updates the DBM password files, if they exist.
  1505. X */
  1506. X
  1507. Xint
  1508. Xsp_dbm_update (sp)
  1509. Xstruct    spwd    *sp;
  1510. X{
  1511. X    datum    key;
  1512. X    datum    content;
  1513. X    char    data[BUFSIZ];
  1514. X    int    len;
  1515. X    static    int    once;
  1516. X
  1517. X    if (! once) {
  1518. X        if (! sp_dbm)
  1519. X            setspent ();
  1520. X
  1521. X        once++;
  1522. X    }
  1523. X    if (! sp_dbm)
  1524. X        return 0;
  1525. X
  1526. X    len = spw_pack (sp, data);
  1527. X
  1528. X    content.dsize = len;
  1529. X    content.dptr = data;
  1530. X
  1531. X    key.dsize = strlen (sp->sp_namp);
  1532. X    key.dptr = sp->sp_namp;
  1533. X    if (dbm_store (sp_dbm, key, content, DBM_REPLACE))
  1534. X        return 0;
  1535. X
  1536. X    return 1;
  1537. X}
  1538. X
  1539. X/*
  1540. X * sp_dbm_remove
  1541. X *
  1542. X * Updates the DBM password files, if they exist.
  1543. X */
  1544. X
  1545. Xint
  1546. Xsp_dbm_remove (user)
  1547. Xchar    *user;
  1548. X{
  1549. X    datum    key;
  1550. X    static    int    once;
  1551. X
  1552. X    if (! once) {
  1553. X        if (! sp_dbm)
  1554. X            setspent ();
  1555. X
  1556. X        once++;
  1557. X    }
  1558. X    if (! sp_dbm)
  1559. X        return 0;
  1560. X
  1561. X    key.dsize = strlen (user);
  1562. X    key.dptr = user;
  1563. X    if (dbm_delete (sp_dbm, key))
  1564. X        return 0;
  1565. X
  1566. X    return 1;
  1567. X}
  1568. X#endif
  1569. END_OF_FILE
  1570.   if test 1231 -ne `wc -c <'spdbm.c'`; then
  1571.     echo shar: \"'spdbm.c'\" unpacked with wrong size!
  1572.   fi
  1573.   # end of 'spdbm.c'
  1574. fi
  1575. if test -f 'sulog.c' -a "${1}" != "-c" ; then 
  1576.   echo shar: Will not clobber existing file \"'sulog.c'\"
  1577. else
  1578.   echo shar: Extracting \"'sulog.c'\" \(1450 characters\)
  1579.   sed "s/^X//" >'sulog.c' <<'END_OF_FILE'
  1580. X/*
  1581. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1582. X * All rights reserved.
  1583. X *
  1584. X * Permission is granted to copy and create derivative works for any
  1585. X * non-commercial purpose, provided this copyright notice is preserved
  1586. X * in all copies of source code, or included in human readable form
  1587. X * and conspicuously displayed on all copies of object code or
  1588. X * distribution media.
  1589. X */
  1590. X
  1591. X#include <sys/types.h>
  1592. X#include <stdio.h>
  1593. X#include <time.h>
  1594. X#ifndef    BSD
  1595. X#include <string.h>
  1596. X#include <memory.h>
  1597. X#else
  1598. X#include <strings.h>
  1599. X#define    strchr    index
  1600. X#define    strrchr    rindex
  1601. X#endif
  1602. X#include "config.h"
  1603. X
  1604. X#ifndef    lint
  1605. Xstatic    char    sccsid[] = "@(#)sulog.c    3.2    07:43:31    9/17/91";
  1606. X#endif
  1607. X
  1608. Xextern    char    name[];
  1609. Xextern    char    oldname[];
  1610. X
  1611. Xtime_t    time ();
  1612. Xextern    char    *getdef_str();
  1613. X
  1614. Xvoid    sulog (success)
  1615. Xint    success;
  1616. X{
  1617. X    char    *sulog;
  1618. X    char    *tty;
  1619. X    char    *cp;
  1620. X    char    *ttyname ();
  1621. X    time_t    clock;
  1622. X    struct    tm    *tm;
  1623. X    struct    tm    *localtime ();
  1624. X    FILE    *fp;
  1625. X
  1626. X    if ( (sulog=getdef_str("SULOG_FILE")) == (char *) 0 )
  1627. X        return;
  1628. X
  1629. X    if ((fp = fopen (sulog, "a+")) == (FILE *) 0)
  1630. X        return;            /* can't open or create logfile */
  1631. X
  1632. X    (void) time (&clock);
  1633. X    tm = localtime (&clock);
  1634. X
  1635. X    if (isatty (0) && (cp = ttyname (0))) {
  1636. X        if (tty = strrchr (cp, '/'))
  1637. X            tty++;
  1638. X        else
  1639. X            tty = cp;
  1640. X    } else
  1641. X        tty = "???";
  1642. X
  1643. X    (void) fprintf (fp, "SU %.02d/%0.2d %.02d:%.02d %c %.6s %s-%s\n",
  1644. X        tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
  1645. X        success ? '+':'-', tty, oldname, name);
  1646. X
  1647. X    fflush (fp);
  1648. X    fclose (fp);
  1649. X}
  1650. END_OF_FILE
  1651.   if test 1450 -ne `wc -c <'sulog.c'`; then
  1652.     echo shar: \"'sulog.c'\" unpacked with wrong size!
  1653.   fi
  1654.   # end of 'sulog.c'
  1655. fi
  1656. if test -f 'tz.c' -a "${1}" != "-c" ; then 
  1657.   echo shar: Will not clobber existing file \"'tz.c'\"
  1658. else
  1659.   echo shar: Extracting \"'tz.c'\" \(927 characters\)
  1660.   sed "s/^X//" >'tz.c' <<'END_OF_FILE'
  1661. X/*
  1662. X * Copyright 1991, John F. Haugh II and Chip Rosenthal
  1663. X * All rights reserved.
  1664. X *
  1665. X * Permission is granted to copy and create derivative works for any
  1666. X * non-commercial purpose, provided this copyright notice is preserved
  1667. X * in all copies of source code, or included in human readable form
  1668. X * and conspicuously displayed on all copies of object code or
  1669. X * distribution media.
  1670. X */
  1671. X
  1672. X#ifndef lint
  1673. Xstatic    char    sccsid[] = "@(#)tz.c    3.1    07:47:56    9/17/91";
  1674. X#endif
  1675. X
  1676. X#include <stdio.h>
  1677. X
  1678. X/*
  1679. X * tz - return local timezone name
  1680. X *
  1681. X * Tz() determines the name of the local timezone by reading the
  1682. X * contents of the file named by ``fname''.
  1683. X */
  1684. X
  1685. Xchar *
  1686. Xtz (fname)
  1687. Xchar    *fname;
  1688. X{
  1689. X    FILE *fp;
  1690. X    static char tzbuf[64];
  1691. X
  1692. X    if ((fp = fopen(fname,"r")) == NULL)
  1693. X        return "TZ=CST6CDT";
  1694. X    else if (fgets(tzbuf, sizeof(tzbuf), fp) == NULL)
  1695. X        strcpy(tzbuf, "TZ=CST6CDT");
  1696. X    else
  1697. X        tzbuf[strlen(tzbuf) - 1] = '\0';
  1698. X
  1699. X    (void) fclose(fp);
  1700. X    return tzbuf;
  1701. X}
  1702. END_OF_FILE
  1703.   if test 927 -ne `wc -c <'tz.c'`; then
  1704.     echo shar: \"'tz.c'\" unpacked with wrong size!
  1705.   fi
  1706.   # end of 'tz.c'
  1707. fi
  1708. if test -f 'userdel.1' -a "${1}" != "-c" ; then 
  1709.   echo shar: Will not clobber existing file \"'userdel.1'\"
  1710. else
  1711.   echo shar: Extracting \"'userdel.1'\" \(1122 characters\)
  1712.   sed "s/^X//" >'userdel.1' <<'END_OF_FILE'
  1713. X.\" Copyright 1991, John F. Haugh II
  1714. X.\" All rights reserved.
  1715. X.\"
  1716. X.\" Permission is granted to copy and create derivative works for any
  1717. X.\" non-commercial purpose, provided this copyright notice is preserved
  1718. X.\" in all copies of source code, or included in human readable form
  1719. X.\" and conspicuously displayed on all copies of object code or
  1720. X.\" distribution media.
  1721. X.\"
  1722. X.\"    @(#)userdel.1    3.1    07:46:18    7/13/91
  1723. X.\"
  1724. X.TH USERDEL 1M
  1725. X.SH NAME
  1726. Xuserdel \- Delete a user account and related files
  1727. X.SH SYNOPSIS
  1728. X.B userdel
  1729. X[ \fB-r\fI ]
  1730. X.I login
  1731. X.SH DESCRIPTION
  1732. XThe \fIuserdel\fR command modifies the system account files, deleting
  1733. Xall entries that refer to \fIlogin\fR.
  1734. XThe named user must exist.
  1735. X.IP \fB-r\fR
  1736. XFiles in the user's home directory will be removed along with the
  1737. Xhome directory itself.
  1738. XFiles located in other file system will have to be searched for
  1739. Xand deleted manually.
  1740. X.SH Files
  1741. X/etc/passwd \- user account information
  1742. X.br
  1743. X/etc/shadow \- secure user account information
  1744. X.br
  1745. X/etc/group \- group information
  1746. X.SH SEE ALSO
  1747. X\fBchfn(1), chsh(1), groupadd(1M), groupdel(1M), groupmod(1M),
  1748. Xpasswd(1), useradd(1M), usermod(1M)
  1749. END_OF_FILE
  1750.   if test 1122 -ne `wc -c <'userdel.1'`; then
  1751.     echo shar: \"'userdel.1'\" unpacked with wrong size!
  1752.   fi
  1753.   # end of 'userdel.1'
  1754. fi
  1755. echo shar: End of archive 11 \(of 11\).
  1756. cp /dev/null ark11isdone
  1757. MISSING=""
  1758. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  1759.     if test ! -f ark${I}isdone ; then
  1760.     MISSING="${MISSING} ${I}"
  1761.     fi
  1762. done
  1763. if test "${MISSING}" = "" ; then
  1764.     echo You have unpacked all 11 archives.
  1765.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1766. else
  1767.     echo You still must unpack the following archives:
  1768.     echo "        " ${MISSING}
  1769. fi
  1770. exit 0
  1771. exit 0 # Just in case...
  1772.