home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume38 / shadow / part13 < prev    next >
Encoding:
Text File  |  1993-08-14  |  59.7 KB  |  2,183 lines

  1. Newsgroups: comp.sources.misc
  2. From: jfh@rpp386.cactus.org (John F. Haugh II)
  3. Subject: v38i132:  shadow - Shadow Password Suite, v3.3, Part13/14
  4. Message-ID: <1993Aug14.192658.9980@sparky.sterling.com>
  5. X-Md4-Signature: a2d7f04b5241a7fce5b7190a57837407
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Sat, 14 Aug 1993 19:26:58 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: jfh@rpp386.cactus.org (John F. Haugh II)
  12. Posting-number: Volume 38, Issue 132
  13. Archive-name: shadow/part13
  14. Environment: UNIX
  15. Supersedes: shadow: Volume 26, Issue 54-64
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  chfn.1 chsh.1 console.c dialchk.c dialup.h entry.c env.c
  22. #   grpack.c hushed.c lastlog.8 mkpasswd.8 newgrp.1 newusers.8 port.h
  23. #   porttime.4 pwauth.8 pwconv.8 rad64.c scologin.c shadow.4 shadow.h
  24. #   su.1 sub.c sulog.c sulogin.8 ttytype.c userdel.1
  25. # Wrapped by kent@sparky on Sat Aug 14 14:11:42 1993
  26. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 13 (of 14)."'
  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'\" \(1601 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    21 Nov 1990
  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 1601 -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'\" \(1478 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    21 Nov 1990
  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 1478 -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 'console.c' -a "${1}" != "-c" ; then 
  134.   echo shar: Will not clobber existing file \"'console.c'\"
  135. else
  136.   echo shar: Extracting \"'console.c'\" \(2029 characters\)
  137.   sed "s/^X//" >'console.c' <<'END_OF_FILE'
  138. X/*
  139. X * Copyright 1991, John F. Haugh II and Chip Rosenthal
  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#ifndef lint
  150. Xstatic    char    sccsid[] = "@(#)console.c    3.1    07:47:49    17 Sep 1991";
  151. X#endif
  152. X
  153. X#include <stdio.h>
  154. X#ifndef BSD
  155. X# include <string.h>
  156. X#else
  157. X# include <strings.h>
  158. X#endif
  159. X
  160. Xextern    char    *getdef_str();
  161. X
  162. X/*
  163. X * tty - return 1 if the "tty" is a console device, else 0.
  164. X *
  165. X * Note - we need to take extreme care here to avoid locking out root logins
  166. X * if something goes awry.  That's why we do things like call everything a
  167. X * console if the consoles file can't be opened.  Because of this, we must
  168. X * warn the user to protect against the remove of the consoles file since
  169. X * that would allow an unauthorized root login.
  170. X */
  171. X
  172. Xint
  173. Xconsole (tty)
  174. Xchar    *tty;
  175. X{
  176. X    FILE    *fp;
  177. X    char    buf[BUFSIZ], *console, *s;
  178. X
  179. X    /*
  180. X     * If the CONSOLE configuration definition isn't given, call
  181. X     * everything a valid console.
  182. X     */
  183. X
  184. X    if ((console = getdef_str("CONSOLE")) == NULL)
  185. X        return 1;
  186. X
  187. X    /*
  188. X     * If this isn't a filename, then it is a ":" delimited list of
  189. X     * console devices upon which root logins are allowed.
  190. X     */
  191. X
  192. X    if (*console != '/') {
  193. X        console = strcpy(buf,console);
  194. X        while ((s = strtok(console,":")) != NULL) {
  195. X            if (strcmp(s,tty) == 0)
  196. X                return 1;
  197. X
  198. X            console = NULL;
  199. X        }
  200. X        return 0;
  201. X    }
  202. X
  203. X    /*
  204. X     * If we can't open the console list, then call everything a
  205. X     * console - otherwise root will never be allowed to login.
  206. X     */
  207. X
  208. X    if ((fp = fopen(console,"r")) == NULL)
  209. X        return 1;
  210. X
  211. X    /*
  212. X     * See if this tty is listed in the console file.
  213. X     */
  214. X
  215. X    while (fgets(buf,sizeof(buf),fp) != NULL) {
  216. X        buf[strlen(buf)-1] = '\0';
  217. X        if (strcmp(buf,tty) == 0) {
  218. X            (void) fclose(fp);
  219. X            return 1;
  220. X        }
  221. X    }
  222. X
  223. X    /*
  224. X     * This tty isn't a console.
  225. X     */
  226. X
  227. X    (void) fclose(fp);
  228. X    return 0;
  229. X}
  230. END_OF_FILE
  231.   if test 2029 -ne `wc -c <'console.c'`; then
  232.     echo shar: \"'console.c'\" unpacked with wrong size!
  233.   fi
  234.   # end of 'console.c'
  235. fi
  236. if test -f 'dialchk.c' -a "${1}" != "-c" ; then 
  237.   echo shar: Will not clobber existing file \"'dialchk.c'\"
  238. else
  239.   echo shar: Extracting \"'dialchk.c'\" \(1431 characters\)
  240.   sed "s/^X//" >'dialchk.c' <<'END_OF_FILE'
  241. X/*
  242. X * Copyright 1989, 1990, 1991, John F. Haugh II
  243. X * All rights reserved.
  244. X *
  245. X * Permission is granted to copy and create derivative works for any
  246. X * non-commercial purpose, provided this copyright notice is preserved
  247. X * in all copies of source code, or included in human readable form
  248. X * and conspicuously displayed on all copies of object code or
  249. X * distribution media.
  250. X */
  251. X
  252. X#include <stdio.h>
  253. X#ifdef    BSD
  254. X#include <strings.h>
  255. X#else
  256. X#include <string.h>
  257. X#endif
  258. X#include "config.h"
  259. X#include "dialup.h"
  260. X
  261. X#ifndef    lint
  262. Xstatic    char    sccsid[] = "@(#)dialchk.c    3.3    08:54:38    10 Jul 1991";
  263. X#endif
  264. X
  265. Xextern    char    *pw_encrypt();
  266. X
  267. X/*
  268. X * Check for dialup password
  269. X *
  270. X *    dialcheck tests to see if tty is listed as being a dialup
  271. X *    line.  If so, a dialup password may be required if the shell
  272. X *    is listed as one which requires a second password.
  273. X */
  274. X
  275. Xint    dialcheck (tty, shell)
  276. Xchar    *tty;
  277. Xchar    *shell;
  278. X{
  279. X    char    *crypt ();
  280. X    char    *getpass ();
  281. X    struct    dialup    *dialup;
  282. X    char    *pass;
  283. X    char    *cp;
  284. X
  285. X    setduent ();
  286. X
  287. X    if (! isadialup (tty)) {
  288. X        endduent ();
  289. X        return (1);
  290. X    }
  291. X    if (! (dialup = getdushell (shell))) {
  292. X        endduent ();
  293. X        return (1);
  294. X    }
  295. X    endduent ();
  296. X
  297. X    if (dialup->du_passwd[0] == '\0')
  298. X        return (1);
  299. X
  300. X    if (! (pass = getpass ("Dialup Password:")))
  301. X        return (0);
  302. X
  303. X    cp = pw_encrypt (pass, dialup->du_passwd);
  304. X#if defined(USG)
  305. X    memset (pass, 0, strlen (pass));
  306. X#else
  307. X    bzero (pass, strlen (pass));
  308. X#endif
  309. X    return (strcmp (cp, dialup->du_passwd) == 0);
  310. X}
  311. END_OF_FILE
  312.   if test 1431 -ne `wc -c <'dialchk.c'`; then
  313.     echo shar: \"'dialchk.c'\" unpacked with wrong size!
  314.   fi
  315.   # end of 'dialchk.c'
  316. fi
  317. if test -f 'dialup.h' -a "${1}" != "-c" ; then 
  318.   echo shar: Will not clobber existing file \"'dialup.h'\"
  319. else
  320.   echo shar: Extracting \"'dialup.h'\" \(1585 characters\)
  321.   sed "s/^X//" >'dialup.h' <<'END_OF_FILE'
  322. X/*
  323. X * Copyright 1989, 1990, 1991, John F. Haugh II
  324. X * All rights reserved.
  325. X *
  326. X * Permission is granted to copy and create derivative works for any
  327. X * non-commercial purpose, provided this copyright notice is preserved
  328. X * in all copies of source code, or included in human readable form
  329. X * and conspicuously displayed on all copies of object code or
  330. X * distribution media.
  331. X */
  332. X
  333. X/*
  334. X * Structure of the /etc/d_passwd file
  335. X *
  336. X *    The d_passwd file contains the names of login shells which require
  337. X *    dialup passwords.  Each line contains the fully qualified path name
  338. X *    for the shell, followed by an optional password.  Each field is
  339. X *    separated by a ':'.
  340. X *
  341. X * Structure of the /etc/dialups file
  342. X *
  343. X *    The dialups file contains the names of ports which may be dialup
  344. X *    lines.  Each line consists of the last component of the path
  345. X *    name.  The leading "/dev/" string is removed.
  346. X *
  347. X *    @(#)dialup.h    3.2    09:06:55    28 May 1991
  348. X */
  349. X
  350. X#ifndef    _DIALUP_H
  351. X#define    _DIALUP_H
  352. X
  353. Xstruct    dialup {
  354. X    char    *du_shell;
  355. X    char    *du_passwd;
  356. X};
  357. X
  358. X#if !__STDC__
  359. Xextern    void    setduent ();
  360. Xextern    void    endduent ();
  361. Xextern    struct    dialup    *fgetduent ();
  362. Xextern    struct    dialup    *getduent ();
  363. Xextern    struct    dialup    *getdushell ();
  364. Xextern    int    putduent ();
  365. Xextern    int    isadialup ();
  366. X#else
  367. Xextern    void    setduent (void);
  368. Xextern    void    endduent (void);
  369. Xextern    struct    dialup    *fgetduent (FILE *);
  370. Xextern    struct    dialup    *getduent (void);
  371. Xextern    struct    dialup    *getdushell (char *);
  372. Xextern    int    putduent (struct dialup *, FILE *);
  373. Xextern    int    isadialup (char *);
  374. X#endif
  375. X
  376. X#define    DIALPWD    "/etc/d_passwd"
  377. X#define    DIALUPS    "/etc/dialups"
  378. X
  379. X#endif
  380. END_OF_FILE
  381.   if test 1585 -ne `wc -c <'dialup.h'`; then
  382.     echo shar: \"'dialup.h'\" unpacked with wrong size!
  383.   fi
  384.   # end of 'dialup.h'
  385. fi
  386. if test -f 'entry.c' -a "${1}" != "-c" ; then 
  387.   echo shar: Will not clobber existing file \"'entry.c'\"
  388. else
  389.   echo shar: Extracting \"'entry.c'\" \(1998 characters\)
  390.   sed "s/^X//" >'entry.c' <<'END_OF_FILE'
  391. X/*
  392. X * Copyright 1989, 1990, 1991, John F. Haugh II
  393. X * All rights reserved.
  394. X *
  395. X * Permission is granted to copy and create derivative works for any
  396. X * non-commercial purpose, provided this copyright notice is preserved
  397. X * in all copies of source code, or included in human readable form
  398. X * and conspicuously displayed on all copies of object code or
  399. X * distribution media.
  400. X */
  401. X
  402. X#include "config.h"
  403. X#include "pwd.h"
  404. X#ifndef    BSD
  405. X#include <string.h>
  406. X#else
  407. X#include <strings.h>
  408. X#define    strchr    index
  409. X#define    strrchr    rindex
  410. X#endif
  411. X#ifdef    SHADOWPWD
  412. X#include "shadow.h"
  413. X#endif
  414. X
  415. X#ifndef    lint
  416. Xstatic    char    sccsid[] = "@(#)entry.c    3.5    11:59:41    28 Dec 1991";
  417. X#endif
  418. X
  419. Xstruct    passwd    *fgetpwent ();
  420. Xchar    *malloc ();
  421. X
  422. Xvoid    entry (name, pwent)
  423. Xchar    *name;
  424. Xstruct    passwd    *pwent;
  425. X{
  426. X    struct    passwd    *passwd;
  427. X#ifdef    SHADOWPWD
  428. X    struct    spwd    *spwd;
  429. X    char    *l64a ();
  430. X#endif
  431. X    char    *cp;
  432. X    char    *malloc();
  433. X
  434. X    if (! (passwd = getpwnam (name))) {
  435. X        pwent->pw_name = (char *) 0;
  436. X        return;
  437. X    } else  {
  438. X        pwent->pw_name = strdup (passwd->pw_name);
  439. X        pwent->pw_uid = passwd->pw_uid;
  440. X        pwent->pw_gid = passwd->pw_gid;
  441. X#ifdef    ATT_COMMENT
  442. X        pwent->pw_comment = strdup (passwd->pw_comment);
  443. X#endif
  444. X        pwent->pw_gecos = strdup (passwd->pw_gecos);
  445. X        pwent->pw_dir = strdup (passwd->pw_dir);
  446. X        pwent->pw_shell = strdup (passwd->pw_shell);
  447. X#if defined(SHADOWPWD) && !defined(AUTOSHADOW)
  448. X        setspent ();
  449. X        if (spwd = getspnam (name)) {
  450. X            pwent->pw_passwd = strdup (spwd->sp_pwdp);
  451. X#ifdef    ATT_AGE
  452. X            pwent->pw_age = (char *) malloc (5);
  453. X
  454. X            if (spwd->sp_max > (63*7))
  455. X                spwd->sp_max = (63*7);
  456. X            if (spwd->sp_min > (63*7))
  457. X                spwd->sp_min = (63*7);
  458. X
  459. X            pwent->pw_age[0] = i64c (spwd->sp_max / 7);
  460. X            pwent->pw_age[1] = i64c (spwd->sp_min / 7);
  461. X
  462. X            cp = l64a (spwd->sp_lstchg / 7);
  463. X            pwent->pw_age[2] = cp[0];
  464. X            pwent->pw_age[3] = cp[1];
  465. X
  466. X            pwent->pw_age[4] = '\0';
  467. X#endif
  468. X            endspent ();
  469. X            return;
  470. X        }
  471. X        endspent ();
  472. X#endif
  473. X        pwent->pw_passwd = strdup (passwd->pw_passwd);
  474. X#ifdef    ATT_AGE
  475. X        pwent->pw_age = strdup (passwd->pw_age);
  476. X#endif
  477. X    }
  478. X}
  479. END_OF_FILE
  480.   if test 1998 -ne `wc -c <'entry.c'`; then
  481.     echo shar: \"'entry.c'\" unpacked with wrong size!
  482.   fi
  483.   # end of 'entry.c'
  484. fi
  485. if test -f 'env.c' -a "${1}" != "-c" ; then 
  486.   echo shar: Will not clobber existing file \"'env.c'\"
  487. else
  488.   echo shar: Extracting \"'env.c'\" \(2207 characters\)
  489.   sed "s/^X//" >'env.c' <<'END_OF_FILE'
  490. X/*
  491. X * Copyright 1989, 1990, 1992, John F. Haugh II
  492. X * All rights reserved.
  493. X *
  494. X * Permission is granted to copy and create derivative works for any
  495. X * non-commercial purpose, provided this copyright notice is preserved
  496. X * in all copies of source code, or included in human readable form
  497. X * and conspicuously displayed on all copies of object code or
  498. X * distribution media.
  499. X *
  500. X * This software is provided on an AS-IS basis and the author makes
  501. X * no warrantee of any kind.
  502. X */
  503. X
  504. X#include <stdio.h>
  505. X#ifndef    BSD
  506. X#include <string.h>
  507. X#else
  508. X#define    strchr    index
  509. X#define    strrchr    rindex
  510. X#include <strings.h>
  511. X#endif
  512. X
  513. X#ifndef    lint
  514. Xstatic    char    _sccsid[] = "@(#)env.c    3.1    13:00:03    27 Jul 1992";
  515. X#endif
  516. X
  517. Xextern    char    **environ;
  518. Xextern    char    *newenvp[];
  519. Xextern    int    newenvc;
  520. Xextern    int    maxenv;
  521. X
  522. Xchar    *strdup ();
  523. Xvoid    free ();
  524. X
  525. Xstatic    char    *forbid[] = {
  526. X    "HOME",
  527. X    "IFS",
  528. X    "PATH",
  529. X    "SHELL",
  530. X    (char *) 0
  531. X};
  532. X
  533. X/*
  534. X * addenv - add a new environmental entry
  535. X */
  536. X
  537. Xvoid
  538. Xaddenv (entry)
  539. Xchar    *entry;
  540. X{
  541. X    char    *cp;
  542. X    int    i;
  543. X    int    len;
  544. X
  545. X    if (cp = strchr (entry, '='))
  546. X        len = cp - entry;
  547. X    else
  548. X        return;
  549. X
  550. X    for (i = 0;i < newenvc;i++)
  551. X        if (strncmp (entry, newenvp[i], len) == 0 &&
  552. X            (newenvp[i][len] == '=' || newenvp[i][len] == '\0'))
  553. X            break;
  554. X
  555. X    if (i == maxenv) {
  556. X        puts ("Environment overflow");
  557. X        return;
  558. X    }
  559. X    if (i == newenvc) {
  560. X        newenvp[newenvc++] = strdup (entry);
  561. X    } else {
  562. X        free (newenvp[i]);
  563. X        newenvp[i] = strdup (entry);
  564. X    }
  565. X}
  566. X
  567. X/*
  568. X * setenv - copy command line arguments into the environment
  569. X */
  570. X
  571. Xvoid
  572. Xsetenv (argc, argv)
  573. Xint    argc;
  574. Xchar    **argv;
  575. X{
  576. X    int    i;
  577. X    int    n;
  578. X    int    noname = 1;
  579. X    char    variable[BUFSIZ];
  580. X    char    *cp;
  581. X
  582. X    for (i = 0;i < argc;i++) {
  583. X        if ((n = strlen (argv[i])) >= BUFSIZ)
  584. X            continue;    /* ignore long entries */
  585. X
  586. X        if (! (cp = strchr (argv[i], '='))) {
  587. X            (void) strcpy (variable, argv[i]);
  588. X        } else {
  589. X            (void) strncpy (variable, argv[i], cp - argv[i]);
  590. X            variable[cp - argv[i]] = '\0';
  591. X        }
  592. X        for (n = 0;forbid[n] != (char *) 0;n++)
  593. X            if (strcmp (variable, forbid[n]) == 0)
  594. X                break;
  595. X
  596. X        if (forbid[n] != (char *) 0) {
  597. X            printf ("You may not change $%s\n", forbid[n]);
  598. X            continue;
  599. X        }
  600. X        if (cp) {
  601. X            addenv (argv[i]);
  602. X        } else {
  603. X            sprintf (variable, "L%d=%s", noname++, argv[i]);
  604. X            addenv (variable);
  605. X        }
  606. X    }
  607. X}
  608. END_OF_FILE
  609.   if test 2207 -ne `wc -c <'env.c'`; then
  610.     echo shar: \"'env.c'\" unpacked with wrong size!
  611.   fi
  612.   # end of 'env.c'
  613. fi
  614. if test -f 'grpack.c' -a "${1}" != "-c" ; then 
  615.   echo shar: Will not clobber existing file \"'grpack.c'\"
  616. else
  617.   echo shar: Extracting \"'grpack.c'\" \(1515 characters\)
  618.   sed "s/^X//" >'grpack.c' <<'END_OF_FILE'
  619. X/*
  620. X * Copyright 1990, John F. Haugh II
  621. X * All rights reserved.
  622. X *
  623. X * Use, duplication, and disclosure prohibited without
  624. X * the express written permission of the author.
  625. X *
  626. X * Duplication is permitted for non-commercial [ profit making ]
  627. X * purposes provided this and other copyright notices remain
  628. X * intact.
  629. X */
  630. X
  631. X#include <stdio.h>
  632. X#include <grp.h>
  633. X#ifdef    BSD
  634. X#include <strings.h>
  635. X#else
  636. X#include <string.h>
  637. X#endif
  638. X
  639. X#ifndef    lint
  640. Xstatic    char    sccsid[] = "@(#)grpack.c    3.3    08:45:46    12 Sep 1991";
  641. X#endif
  642. X
  643. Xint    gr_pack (group, buf)
  644. Xstruct    group    *group;
  645. Xchar    *buf;
  646. X{
  647. X    char    *cp;
  648. X    int    i;
  649. X
  650. X    cp = buf;
  651. X    strcpy (cp, group->gr_name);
  652. X    cp += strlen (cp) + 1;
  653. X
  654. X    strcpy (cp, group->gr_passwd);
  655. X    cp += strlen (cp) + 1;
  656. X
  657. X    memcpy (cp, (char *) &group->gr_gid, sizeof group->gr_gid);
  658. X    cp += sizeof group->gr_gid;
  659. X
  660. X    for (i = 0;group->gr_mem[i];i++) {
  661. X        strcpy (cp, group->gr_mem[i]);
  662. X        cp += strlen (cp) + 1;
  663. X    }
  664. X    *cp++ = '\0';
  665. X
  666. X    return cp - buf;
  667. X}
  668. X
  669. Xint    gr_unpack (buf, len, group)
  670. Xchar    *buf;
  671. Xint    len;
  672. Xstruct    group    *group;
  673. X{
  674. X    char    *org = buf;
  675. X    int    i;
  676. X
  677. X    group->gr_name = buf;
  678. X    buf += strlen (buf) + 1;
  679. X    if (buf - org > len)
  680. X        return -1;
  681. X
  682. X    group->gr_passwd = buf;
  683. X    buf += strlen (buf) + 1;
  684. X    if (buf - org > len)
  685. X        return -1;
  686. X
  687. X    memcpy ((char *) &group->gr_gid, (char *) buf, sizeof group->gr_gid);
  688. X    buf += sizeof group->gr_gid;
  689. X    if (buf - org > len)
  690. X        return -1;
  691. X
  692. X    for (i = 0;*buf && i < 1024;i++) {
  693. X        group->gr_mem[i] = buf;
  694. X        buf += strlen (buf) + 1;
  695. X
  696. X        if (buf - org > len)
  697. X            return -1;
  698. X    }
  699. X    group->gr_mem[i] = (char *) 0;
  700. X    return 0;
  701. X}
  702. END_OF_FILE
  703.   if test 1515 -ne `wc -c <'grpack.c'`; then
  704.     echo shar: \"'grpack.c'\" unpacked with wrong size!
  705.   fi
  706.   # end of 'grpack.c'
  707. fi
  708. if test -f 'hushed.c' -a "${1}" != "-c" ; then 
  709.   echo shar: Will not clobber existing file \"'hushed.c'\"
  710. else
  711.   echo shar: Extracting \"'hushed.c'\" \(1811 characters\)
  712.   sed "s/^X//" >'hushed.c' <<'END_OF_FILE'
  713. X/*
  714. X * Copyright 1991, 1993, John F. Haugh II and Chip Rosenthal
  715. X * All rights reserved.
  716. X *
  717. X * Permission is granted to copy and create derivative works for any
  718. X * non-commercial purpose, provided this copyright notice is preserved
  719. X * in all copies of source code, or included in human readable form
  720. X * and conspicuously displayed on all copies of object code or
  721. X * distribution media.
  722. X *
  723. X * This software is provided on an AS-IS basis and the author makes
  724. X * no warrantee of any kind.
  725. X */
  726. X
  727. X#ifndef lint
  728. Xstatic    char    sccsid[] = "@(#)hushed.c    3.2    22:02:26    02 Jun 1993";
  729. X#endif
  730. X
  731. X#include <sys/types.h>
  732. X#include <stdio.h>
  733. X#ifndef BSD
  734. X# include <string.h>
  735. X#else
  736. X# include <strings.h>
  737. X#endif
  738. X#include "config.h"
  739. X#include "pwd.h"
  740. X
  741. Xextern char *getdef_str();
  742. X
  743. X/*
  744. X * hushed - determine if a user receives login messages
  745. X *
  746. X * Look in the hushed-logins file (or user's home directory) to see
  747. X * if the user is to receive the login-time messages.
  748. X */
  749. X
  750. Xint
  751. Xhushed(pw)
  752. Xstruct passwd *pw;
  753. X{
  754. X    char *hushfile;
  755. X    char buf[BUFSIZ];
  756. X    int found;
  757. X    FILE *fp;
  758. X
  759. X    /*
  760. X     * Get the name of the file to use.  If this option is not
  761. X     * defined, default to a noisy login.
  762. X     */
  763. X
  764. X    if ( (hushfile=getdef_str("HUSHLOGIN_FILE")) == NULL )
  765. X        return 0;
  766. X
  767. X    /*
  768. X     * If this is not a fully rooted path then see if the
  769. X     * file exists in the user's home directory.
  770. X     */
  771. X
  772. X    if (hushfile[0] != '/') {
  773. X        strcat(strcat(strcpy(buf, pw->pw_dir), "/"), hushfile);
  774. X        return (access(buf, 0) == 0);
  775. X    }
  776. X
  777. X    /*
  778. X     * If this is a fully rooted path then go through the file
  779. X     * and see if this user is in there.
  780. X     */
  781. X
  782. X    if ((fp = fopen(hushfile, "r")) == NULL)
  783. X        return 0;
  784. X
  785. X    for (found = 0;! found && fgets (buf, sizeof buf, fp);) {
  786. X        buf[strlen (buf) - 1] = '\0';
  787. X        found = ! strcmp (buf,
  788. X            buf[0] == '/' ? pw->pw_shell:pw->pw_name);
  789. X    }
  790. X    (void) fclose(fp);
  791. X    return found;
  792. X}
  793. END_OF_FILE
  794.   if test 1811 -ne `wc -c <'hushed.c'`; then
  795.     echo shar: \"'hushed.c'\" unpacked with wrong size!
  796.   fi
  797.   # end of 'hushed.c'
  798. fi
  799. if test -f 'lastlog.8' -a "${1}" != "-c" ; then 
  800.   echo shar: Will not clobber existing file \"'lastlog.8'\"
  801. else
  802.   echo shar: Extracting \"'lastlog.8'\" \(1459 characters\)
  803.   sed "s/^X//" >'lastlog.8' <<'END_OF_FILE'
  804. X.\" Copyright 1992, Phillip Street and John F. Haugh II
  805. X.\" All rights reserved.
  806. X.\"
  807. X.\" Permission is granted to copy and create derivative works for any
  808. X.\" non-commercial purpose, provided this copyright notice is preserved
  809. X.\" in all copies of source code, or included in human readable form
  810. X.\" and conspicuously displayed on all copies of object code or
  811. X.\" distribution media.
  812. X.\"
  813. X.\"    @(#)lastlog.8    3.2    10:35:49    18 Jul 1993 (National Guard Release)
  814. X.\"
  815. X.TH LASTLOG 8
  816. X.SH NAME
  817. Xlastlog \- examine lastlog file
  818. X.SH SYNOPSIS
  819. X/etc/lastlog [ -u uid ] [ -t days ]
  820. X.SH DESCRIPTION
  821. X\fIlastlog\fR formats and prints the contents of the last login log,
  822. X\fI/usr/adm/lastlog\fR.  The \fBlogin-name\fR, \fBport\fR, and \fBlast login 
  823. Xtime\fR will be printed.
  824. XThe default (no flags) causes lastlog entries to be printed in UID
  825. Xorder.
  826. XEntering \fB-u login-name\fR flag will
  827. Xcause the lastlog record for \fBlogin-name\fR only to be printed.
  828. XEntering \fB-t days\fR will cause only the
  829. Xlastlogins more recent than \fBdays\fR to be printed.
  830. XThe \fB-t\fR flag overrides the use of \fB-u\fR.
  831. X.PP
  832. XIf the user has never logged in the message \fB"**Never logged in**"\fR will 
  833. Xbe displayed instead of the port and time.
  834. X.SH Files
  835. X/usr/adm/lastlog \- lastlog logging file
  836. X.SH Caveats
  837. XLarge gaps in uid numbers will cause the lastlog program to run longer with
  838. Xno output to the screen (i.e. if mmdf=800 and last uid=170, program will
  839. Xappear to hang as it processes uid 171-799).
  840. END_OF_FILE
  841.   if test 1459 -ne `wc -c <'lastlog.8'`; then
  842.     echo shar: \"'lastlog.8'\" unpacked with wrong size!
  843.   fi
  844.   # end of 'lastlog.8'
  845. fi
  846. if test -f 'mkpasswd.8' -a "${1}" != "-c" ; then 
  847.   echo shar: Will not clobber existing file \"'mkpasswd.8'\"
  848. else
  849.   echo shar: Extracting \"'mkpasswd.8'\" \(2129 characters\)
  850.   sed "s/^X//" >'mkpasswd.8' <<'END_OF_FILE'
  851. X.\" Copyright 1991, John F. Haugh II
  852. X.\" All rights reserved.
  853. X.\"
  854. X.\" Permission is granted to copy and create derivative works for any
  855. X.\" non-commercial purpose, provided this copyright notice is preserved
  856. X.\" in all copies of source code, or included in human readable form
  857. X.\" and conspicuously displayed on all copies of object code or
  858. X.\" distribution media.
  859. X.\"
  860. X.\"    @(#)mkpasswd.8    3.1    07:49:05    13 Jul 1991
  861. X.\"
  862. X.TH MKPASSWD 1
  863. X.SH NAME
  864. Xmkpasswd \- Update passwd and group database files
  865. X.SH SYNOPSIS
  866. X\fBmkpasswd\fR [ \fB-fvgps\fR ] \fIfile\fR
  867. X.SH DESCRIPTION
  868. X.I mkpasswd
  869. Xreads the file in the format given by the flags and converts it to the
  870. Xcorresponding database file format.
  871. XThese database files are used to improve access performance on systems
  872. Xwith large numbers of users.
  873. XThe output files will be named \fIfile\fR.dir and \fIfile\fR.pag.
  874. X.PP
  875. XThe \fB-f\fR option causes \fImkpasswd\fR to ignore any existing output
  876. Xfiles and overwrite them.
  877. XNormally \fImkpasswd\fR complains about existing output files and quits.
  878. X.PP
  879. XThe \fB-v\fR option causes \fImkpasswd\fR to output information about
  880. Xeach record as it is converted, with a final message at the very end.
  881. X.PP
  882. XThe \fB-g\fR option treats the input file as though it were in
  883. X\fB/etc/group\fR file format.
  884. XWhen combined with the \fB-s\fR option, the \fB/etc/gshadow\fR file
  885. Xformat is used instead.
  886. X.PP
  887. XThe \fB-p\fR option treats the input file as though it were in
  888. X\fB/etc/passwd\fR file format.
  889. XThis is the default.
  890. XWhen combined with the \fB-s\fR option, the \fB/etc/shadow\fR file
  891. Xformat is used instead.
  892. X.SH CAVEATS
  893. XThe use of more than one database file is limited to systems which
  894. Xinclude the NDBM database library and therefore may not be available
  895. Xon every system.
  896. X.SH Note
  897. XSince most commands are capable of updating the database files as
  898. Xchanges are made, this command need only be used when re-creating a
  899. Xdeleted or corrupted database file.
  900. X.SH Files
  901. X/etc/passwd \- user account information
  902. X.br
  903. X/etc/shadow \- shadow user information
  904. X.br
  905. X/etc/group \- group information
  906. X.br
  907. X/etc/gshadow \- shadow group information
  908. X.SH See Also
  909. Xpasswd(4), group(4), shadow(4)
  910. END_OF_FILE
  911.   if test 2129 -ne `wc -c <'mkpasswd.8'`; then
  912.     echo shar: \"'mkpasswd.8'\" unpacked with wrong size!
  913.   fi
  914.   # end of 'mkpasswd.8'
  915. fi
  916. if test -f 'newgrp.1' -a "${1}" != "-c" ; then 
  917.   echo shar: Will not clobber existing file \"'newgrp.1'\"
  918. else
  919.   echo shar: Extracting \"'newgrp.1'\" \(1867 characters\)
  920.   sed "s/^X//" >'newgrp.1' <<'END_OF_FILE'
  921. X.\" Copyright 1991, John F. Haugh II
  922. X.\" All rights reserved.
  923. X.\"
  924. X.\" Permission is granted to copy and create derivative works for any
  925. X.\" non-commercial purpose, provided this copyright notice is preserved
  926. X.\" in all copies of source code, or included in human readable form
  927. X.\" and conspicuously displayed on all copies of object code or
  928. X.\" distribution media.
  929. X.\"
  930. X.\"    @(#)newgrp.1    3.2    14:52:37    28 Apr 1992
  931. X.\"
  932. X.TH NEWGRP 1
  933. X.SH NAME
  934. Xnewgrp \- Change group ID
  935. X.br
  936. Xsg \- Execute command as different group ID
  937. X.SH SYNOPSIS
  938. X.B newgrp
  939. X[ - ] [ \fIgroup\fR ]
  940. X.br
  941. X.B sg
  942. X[ - ] [ \fIgroup\fR [ \fB-c\fR \fIcommand\fR ] ]
  943. X.SH DESCRIPTION
  944. X.I newgrp
  945. Xis used to change the current group ID during a login session.
  946. XIf the optional \fB\-\fR flag is given, the user's environment
  947. Xwill be reinitialized as though the user had logged in, otherwise
  948. Xthe current environment, including current working directory,
  949. Xremains unchanged.
  950. X.PP
  951. X.I newgrp
  952. Xchanges the current real group ID to the named group, or to
  953. Xthe default group listed in \fB/etc/passwd\fR if no group name
  954. Xis given.
  955. XThe user will be prompted for a password if they do not have a
  956. Xpassword and the group does, or if the user is not listed as a
  957. Xmember and the group has a password.
  958. XThe user will be denied access if the group password is empty
  959. Xand the user is not listed as a member.
  960. X.PP
  961. XThe
  962. X.I sg
  963. Xcommand works similiar to \fInewgrp\fR but does not replace the
  964. Xuser's shell, so upon exit from a \fIsg\fR command, you are
  965. Xreturned to your previous group ID.
  966. X.I sg
  967. Xalso accepts a command.
  968. XThe command will be executed with the Bourne shell and must be
  969. Xenclosed in quotes.
  970. X.SH CAVEATS
  971. X.PP
  972. XThis version of \fInewgrp\fR has many compilation options,
  973. Xonly some of which may be in use at any particular site.
  974. X.SH Files
  975. X/etc/passwd \- user account information
  976. X.br
  977. X/etc/group \- group information
  978. X.SH See Also
  979. Xlogin(1),
  980. Xid(1),
  981. Xsu(1)
  982. END_OF_FILE
  983.   if test 1867 -ne `wc -c <'newgrp.1'`; then
  984.     echo shar: \"'newgrp.1'\" unpacked with wrong size!
  985.   fi
  986.   # end of 'newgrp.1'
  987. fi
  988. if test -f 'newusers.8' -a "${1}" != "-c" ; then 
  989.   echo shar: Will not clobber existing file \"'newusers.8'\"
  990. else
  991.   echo shar: Extracting \"'newusers.8'\" \(1810 characters\)
  992.   sed "s/^X//" >'newusers.8' <<'END_OF_FILE'
  993. X.\" Copyright 1991, John F. Haugh II
  994. X.\" All rights reserved.
  995. X.\"
  996. X.\" Permission is granted to copy and create derivative works for any
  997. X.\" non-commercial purpose, provided this copyright notice is preserved
  998. X.\" in all copies of source code, or included in human readable form
  999. X.\" and conspicuously displayed on all copies of object code or
  1000. X.\" distribution media.
  1001. X.\"
  1002. X.\"    @(#)newusers.8    3.1    16:49:47    04 Aug 1991
  1003. X.\"
  1004. X.TH NEWUSERS 8
  1005. X.SH NAME
  1006. X\fBnewusers\fR - update and create new users in batch
  1007. X.SH SYNOPSIS
  1008. X\fBnewusers\fR
  1009. X[ \fI new_users \fR ]
  1010. X.SH DESCRIPTION
  1011. X\fBnewusers\fR reads a file of user name and cleartext password pairs
  1012. Xand uses this information to update a group of existing users or to
  1013. Xcreate new users.
  1014. XEach line is in the same format as the standard password file (see
  1015. X\fIpasswd(4)\fR) with the following exceptions.
  1016. X.IP "pw_passwd"
  1017. XThis field will be encrypted and used as the new value
  1018. Xof the encrpted password.
  1019. X.IP "pw_age"
  1020. XThis field will be ignored for shadow passwords if the user already
  1021. Xexists.
  1022. X.IP "pw_gid"
  1023. XThis field may be the name of an existing group, in which case the
  1024. Xnamed user will be added as a member.  If a non-existent numerical
  1025. Xgroup is given, a new group will be created having this number.
  1026. X.IP "pw_dir"
  1027. XThis field will be checked for existence as a directory and a new
  1028. Xdirectory will the same name created if it does not already exist.
  1029. XThe ownership of the directory will be set to be that of the user
  1030. Xbeing created or updated.
  1031. X.PP
  1032. XThis command is intended to be used in a large system environment where
  1033. Xmany accounts are updated at a single time.
  1034. X.SH CAVEATS
  1035. XThe \fImkpasswd\fR command must be executed afterwards to update the
  1036. XDBM password files.
  1037. XThe input file must be protected since it contains unencrypted passwords.
  1038. X.SH SEE ALSO
  1039. Xmkpasswd(8), passwd(1), useradd(1)
  1040. END_OF_FILE
  1041.   if test 1810 -ne `wc -c <'newusers.8'`; then
  1042.     echo shar: \"'newusers.8'\" unpacked with wrong size!
  1043.   fi
  1044.   # end of 'newusers.8'
  1045. fi
  1046. if test -f 'port.h' -a "${1}" != "-c" ; then 
  1047.   echo shar: Will not clobber existing file \"'port.h'\"
  1048. else
  1049.   echo shar: Extracting \"'port.h'\" \(1748 characters\)
  1050.   sed "s/^X//" >'port.h' <<'END_OF_FILE'
  1051. X/*
  1052. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1053. X * All rights reserved.
  1054. X *
  1055. X * Permission is granted to copy and create derivative works for any
  1056. X * non-commercial purpose, provided this copyright notice is preserved
  1057. X * in all copies of source code, or included in human readable form
  1058. X * and conspicuously displayed on all copies of object code or
  1059. X * distribution media.
  1060. X */
  1061. X
  1062. X/*
  1063. X * port.h - structure of /etc/porttime
  1064. X *
  1065. X *    @(#)port.h    3.1    08:59:36    08 Feb 1991
  1066. X *
  1067. X *    Each entry in /etc/porttime consists of a TTY device
  1068. X *    name or "*" to indicate all TTY devices, followed by
  1069. X *    a list of 1 or more user IDs or "*" to indicate all
  1070. X *    user names, followed by a list of zero or more valid
  1071. X *    login times.  Login time entries consist of zero or
  1072. X *    more day names (Su, Mo, Tu, We, Th, Fr, Sa, Wk, Al)
  1073. X *    followed by a pair of time values in HHMM format
  1074. X *    separated by a "-".
  1075. X */
  1076. X
  1077. X/*
  1078. X * PORTS - Name of system port access time file.
  1079. X * PORT_IDS - Allowable number of IDs per entry.
  1080. X * PORT_TTY - Allowable number of TTYs per entry.
  1081. X * PORT_TIMES - Allowable number of time entries per entry.
  1082. X * PORT_DAY - Day of the week to a bit value (0 = Sunday).
  1083. X */
  1084. X
  1085. X#define    PORTS    "/etc/porttime"
  1086. X#define    PORT_IDS    64
  1087. X#define    PORT_TTY    64
  1088. X#define    PORT_TIMES    24
  1089. X#define    PORT_DAY(day)    (1<<(day))
  1090. X
  1091. X/*
  1092. X *    pt_names - pointer to array of device names in /dev/
  1093. X *    pt_users - pointer to array of applicable user IDs.
  1094. X *    pt_times - pointer to list of allowable time periods.
  1095. X */
  1096. X
  1097. Xstruct    port    {
  1098. X    char    **pt_names;
  1099. X    char    **pt_users;
  1100. X    struct    pt_time    *pt_times;
  1101. X};
  1102. X
  1103. X/*
  1104. X *    t_days - bit array for each day of the week (0 = Sunday)
  1105. X *    t_start - starting time for this entry
  1106. X *    t_end - ending time for this entry
  1107. X */
  1108. X
  1109. Xstruct    pt_time    {
  1110. X    short    t_days;
  1111. X    short    t_start;
  1112. X    short    t_end;
  1113. X};
  1114. END_OF_FILE
  1115.   if test 1748 -ne `wc -c <'port.h'`; then
  1116.     echo shar: \"'port.h'\" unpacked with wrong size!
  1117.   fi
  1118.   # end of 'port.h'
  1119. fi
  1120. if test -f 'porttime.4' -a "${1}" != "-c" ; then 
  1121.   echo shar: Will not clobber existing file \"'porttime.4'\"
  1122. else
  1123.   echo shar: Extracting \"'porttime.4'\" \(1877 characters\)
  1124.   sed "s/^X//" >'porttime.4' <<'END_OF_FILE'
  1125. X.\" Copyright 1989, 1990, John F. Haugh II
  1126. X.\" All rights reserved.
  1127. X.\"
  1128. X.\" Use, duplication, and disclosure prohibited without
  1129. X.\" the express written permission of the author.
  1130. X.\"
  1131. X.\"    @(#)porttime.4    3.2    08:36:07    08 Feb 1991
  1132. X.\"
  1133. X.TH PORTTIME 4
  1134. X.SH NAME
  1135. Xporttime \- port access time file
  1136. X.SH DESCRIPTION
  1137. X.I porttime
  1138. Xcontains a list of tty devices, user names, and permitted login times.
  1139. X.PP
  1140. XEach entry consists of three colon separated fields.
  1141. XThe first field is a comma separated list of tty devices,
  1142. Xor an asterisk to indicate that all tty devices are matched by this entry.
  1143. XThe second field is a comma separated list of user names, or an
  1144. Xasterisk to indicated that all user names are matched by this entry.
  1145. XThe third field is a comma separated list of permitted access times.
  1146. X.PP
  1147. XEach access time entry consists of zero or more days of the week,
  1148. Xabbreviated \fBSu\fR, \fBMo\fR, \fBTu\fR, \fBWe\fR, \fBTh\fR,
  1149. X\fBFr\fR, and \fBSa\fR, followed by a pair of times separated by
  1150. Xa hyphen.
  1151. XThe abbreviation \fBWk\fR may be used to represent Monday thru Friday,
  1152. Xand \fBAl\fR may be used to indicate every day.
  1153. XIf no days are given, \fBAl\fR is assumed.
  1154. X.SH Examples
  1155. XThe following entry allows access to user \fBjfh\fR on every port
  1156. Xduring weekdays from 9am to 5pm.
  1157. X.br
  1158. X.sp 1
  1159. X*:jfh:Wk0900-1700
  1160. X.br
  1161. X.sp 1
  1162. XThe following entries allow access only to the users \fBroot\fR and
  1163. X\fBoper\fR on /dev/console at any time.
  1164. XThis illustrates how the
  1165. X\fB/etc/porttime\fR file is an ordered list of access times.
  1166. XAny other user would match the second entry which does not permit
  1167. Xaccess at any time.
  1168. X.br
  1169. X.sp 1
  1170. Xconsole:root,oper:Al0000-2400
  1171. X.br
  1172. Xconsole:*:
  1173. X.br
  1174. X.sp 1
  1175. XThe following entry allows access for the user \fBgames\fR on any
  1176. Xport during non-working hours.
  1177. X.br
  1178. X.sp 1
  1179. X*:games:Wk1700-0900,SaSu0000-2400
  1180. X.br
  1181. X.sp 1
  1182. X.SH Files
  1183. X/etc/porttime \- file containing port access times
  1184. X.SH See Also
  1185. Xlogin(1)
  1186. END_OF_FILE
  1187.   if test 1877 -ne `wc -c <'porttime.4'`; then
  1188.     echo shar: \"'porttime.4'\" unpacked with wrong size!
  1189.   fi
  1190.   # end of 'porttime.4'
  1191. fi
  1192. if test -f 'pwauth.8' -a "${1}" != "-c" ; then 
  1193.   echo shar: Will not clobber existing file \"'pwauth.8'\"
  1194. else
  1195.   echo shar: Extracting \"'pwauth.8'\" \(1868 characters\)
  1196.   sed "s/^X//" >'pwauth.8' <<'END_OF_FILE'
  1197. X.\" Copyright 1992, John F. Haugh II
  1198. X.\" All rights reserved.
  1199. X.\"
  1200. X.\" Permission is granted to copy and create derivative works for any
  1201. X.\" non-commercial purpose, provided this copyright notice is preserved
  1202. X.\" in all copies of source code, or included in human readable form
  1203. X.\" and conspicuously displayed on all copies of object code or
  1204. X.\" distribution media.
  1205. X.\"
  1206. X.\" This software is provided on an AS-IS basis and the author makes
  1207. X.\" no warrantee of any kind.
  1208. X.\"
  1209. X.\"    @(#)pwauth.8    3.1    08:30:40    01 Oct 1992
  1210. X.\"
  1211. X.TH PWAUTH 8
  1212. X.SH NAME
  1213. Xpwauth \- administrator defined password authentication
  1214. X.SH DESCRIPTION
  1215. XThe system administrator is able to define a list of programs which
  1216. Xare used to validate a user's identity.
  1217. XThese programs are given in place of the encrypted password
  1218. Xinformation which is present in either the \fB/etc/passwd\fR or
  1219. X\fB/etc/shadow\fR files.
  1220. XThe utilities which administer user accounts examine the encrypted
  1221. Xpassword field and determine if the user has an administrator defined
  1222. Xauthentication program.
  1223. XThe \fIpw_auth\fR function will be invoked whenever one of these
  1224. Xadministration programs determines that a user which is being altered
  1225. Xhas authentication programs defined.
  1226. X.PP
  1227. XThe initial entry is created with the \fIuseradd\fR command.
  1228. XAlterations, such as changing authentication information or deleting
  1229. Xthe user account, will cause the \fIpw_auth\fR function to be invoked.
  1230. XThis keeps the authentication information up to date for each user
  1231. Xaccount.
  1232. X.PP
  1233. XThe authentication programs do not create the actual login or network
  1234. Xsessions. 
  1235. XThe exit code from the authentication program is taken as an
  1236. Xindication that the action is to be permitted.
  1237. XThe calling process must have the appropriate priviledges to create
  1238. Xthe login or network session itself.
  1239. X.SH SEE ALSO
  1240. Xlogin(1), passwd(1), su(1), useradd(1), userdel(1), usermod(1), pwauth(3)
  1241. END_OF_FILE
  1242.   if test 1868 -ne `wc -c <'pwauth.8'`; then
  1243.     echo shar: \"'pwauth.8'\" unpacked with wrong size!
  1244.   fi
  1245.   # end of 'pwauth.8'
  1246. fi
  1247. if test -f 'pwconv.8' -a "${1}" != "-c" ; then 
  1248.   echo shar: Will not clobber existing file \"'pwconv.8'\"
  1249. else
  1250.   echo shar: Extracting \"'pwconv.8'\" \(1732 characters\)
  1251.   sed "s/^X//" >'pwconv.8' <<'END_OF_FILE'
  1252. X.\" Copyright 1989, 1990, 1993, John F. Haugh II
  1253. X.\" All rights reserved.
  1254. X.\"
  1255. X.\" Permission is granted to copy and create derivative works for any
  1256. X.\" non-commercial purpose, provided this copyright notice is preserved
  1257. X.\" in all copies of source code, or included in human readable form
  1258. X.\" and conspicuously displayed on all copies of object code or
  1259. X.\" distribution media.
  1260. X.\"
  1261. X.\" This software is provided on an AS-IS basis and the author makes
  1262. X.\" no warrantee of any kind.
  1263. X.\"
  1264. X.\"    @(#)pwconv.8    3.2    12:04:55    02 May 1993
  1265. X.\"
  1266. X.TH PWCONV 8
  1267. X.SH NAME
  1268. Xpwconv \- convert and update shadow password files
  1269. X.SH SYNOPSIS
  1270. Xpwconv
  1271. X.SH DESCRIPTION
  1272. X\fIPwconv\fR copies the old password file information to a new shadow
  1273. Xpassword file,
  1274. Xmerging entries from an optional existing shadow file.
  1275. XThe new password file is left in \fBnpasswd\fR,
  1276. Xthe new shadow file is left in \fBnshadow\fR.
  1277. XBoth of these are files are created with modes which only permit
  1278. Xread access to the owner.
  1279. XExisting shadow entries are copied as is.
  1280. XShadow entries in the System V Release 3.2 format will be silently
  1281. Xconverted to the new System V Release 4 format on output.
  1282. XAny entries which are missing fields will have those fields
  1283. Xfilled in with default values where appropriate.
  1284. XNew entries are created with passwords which expire in 10000 days,
  1285. Xwith a last changed date of today,
  1286. Xunless password aging information was already present.
  1287. XEntries with blank passwords are not copied to the shadow file at all.
  1288. X.SH FILES
  1289. X/etc/passwd \- old encrypted passwords and password aging
  1290. X.br
  1291. X/etc/shadow \- previously converted shadow password file
  1292. X.br
  1293. X./npasswd \- new password file
  1294. X.br
  1295. X./nshadow \- new shadow password file
  1296. X.SH SEE ALSO
  1297. Xpasswd(1),
  1298. Xpasswd(4),
  1299. Xshadow(4),
  1300. Xpwunconv(8)
  1301. END_OF_FILE
  1302.   if test 1732 -ne `wc -c <'pwconv.8'`; then
  1303.     echo shar: \"'pwconv.8'\" unpacked with wrong size!
  1304.   fi
  1305.   # end of 'pwconv.8'
  1306. fi
  1307. if test -f 'rad64.c' -a "${1}" != "-c" ; then 
  1308.   echo shar: Will not clobber existing file \"'rad64.c'\"
  1309. else
  1310.   echo shar: Extracting \"'rad64.c'\" \(1742 characters\)
  1311.   sed "s/^X//" >'rad64.c' <<'END_OF_FILE'
  1312. X/*
  1313. X * Copyright 1989, 1990, 1992, John F. Haugh II
  1314. X * All rights reserved.
  1315. X *
  1316. X * Permission is granted to copy and create derivative works for any
  1317. X * non-commercial purpose, provided this copyright notice is preserved
  1318. X * in all copies of source code, or included in human readable form
  1319. X * and conspicuously displayed on all copies of object code or
  1320. X * distribution media.
  1321. X */
  1322. X
  1323. X#include "config.h"
  1324. X
  1325. X#ifndef    lint
  1326. Xstatic    char    sccsid[] = "@(#)rad64.c    3.3    20:38:01    07 Mar 1992";
  1327. X#endif
  1328. X
  1329. X/*
  1330. X * c64i - convert a radix 64 character to an integer
  1331. X */
  1332. X
  1333. Xint    c64i (c)
  1334. Xchar    c;
  1335. X{
  1336. X    if (c == '.')
  1337. X        return (0);
  1338. X
  1339. X    if (c == '/')
  1340. X        return (1);
  1341. X
  1342. X    if (c >= '0' && c <= '9')
  1343. X        return (c - '0' + 2);
  1344. X
  1345. X    if (c >= 'A' && c <= 'Z')
  1346. X        return (c - 'A' + 12);
  1347. X
  1348. X    if (c >= 'a' && c <= 'z')
  1349. X        return (c - 'a' + 38);
  1350. X    else
  1351. X        return (-1);
  1352. X}
  1353. X
  1354. X/*
  1355. X * i64c - convert an integer to a radix 64 character
  1356. X */
  1357. X
  1358. Xint    i64c (i)
  1359. Xint    i;
  1360. X{
  1361. X    if (i < 0)
  1362. X        return ('.');
  1363. X    else if (i > 63)
  1364. X        return ('z');
  1365. X
  1366. X    if (i == 0)
  1367. X        return ('.');
  1368. X
  1369. X    if (i == 1)
  1370. X        return ('/');
  1371. X
  1372. X    if (i >= 2 && i <= 11)
  1373. X        return ('0' - 2 + i);
  1374. X
  1375. X    if (i >= 12 && i <= 37)
  1376. X        return ('A' - 12 + i);
  1377. X
  1378. X    if (i >= 38 && i <= 63)
  1379. X        return ('a' - 38 + i);
  1380. X
  1381. X    return ('\0');
  1382. X}
  1383. X
  1384. X#ifdef NEED_AL64
  1385. X
  1386. X/*
  1387. X * l64a - convert a long to a string of radix 64 characters
  1388. X */
  1389. X
  1390. Xchar    *l64a (l)
  1391. Xlong    l;
  1392. X{
  1393. X    static    char    buf[8];
  1394. X    int    i = 0;
  1395. X
  1396. X    if (i < 0L)
  1397. X        return ((char *) 0);
  1398. X
  1399. X    do {
  1400. X        buf[i++] = i64c ((int) (l % 64));
  1401. X        buf[i] = '\0';
  1402. X    } while (l /= 64L, l > 0 && i < 6);
  1403. X
  1404. X    return (buf);
  1405. X}
  1406. X
  1407. X/*
  1408. X * a64l - convert a radix 64 string to a long integer
  1409. X */
  1410. X
  1411. Xlong    a64l (s)
  1412. Xchar    *s;
  1413. X{
  1414. X    int    i;
  1415. X    long    value;
  1416. X    long    shift = 0;
  1417. X
  1418. X    for (i = 0, value = 0L;i < 6 && *s;s++) {
  1419. X        value += (c64i (*s) << shift);
  1420. X        shift += 6;
  1421. X    }
  1422. X    return (value);
  1423. X}
  1424. X
  1425. X#endif /* NEED_A64L */
  1426. END_OF_FILE
  1427.   if test 1742 -ne `wc -c <'rad64.c'`; then
  1428.     echo shar: \"'rad64.c'\" unpacked with wrong size!
  1429.   fi
  1430.   # end of 'rad64.c'
  1431. fi
  1432. if test -f 'scologin.c' -a "${1}" != "-c" ; then 
  1433.   echo shar: Will not clobber existing file \"'scologin.c'\"
  1434. else
  1435.   echo shar: Extracting \"'scologin.c'\" \(1837 characters\)
  1436.   sed "s/^X//" >'scologin.c' <<'END_OF_FILE'
  1437. X/*
  1438. X * Copyright 1991, John F. Haugh II and Chip Rosenthal
  1439. X * All rights reserved.
  1440. X *
  1441. X * Permission is granted to copy and create derivative works for any
  1442. X * non-commercial purpose, provided this copyright notice is preserved
  1443. X * in all copies of source code, or included in human readable form
  1444. X * and conspicuously displayed on all copies of object code or
  1445. X * distribution media.
  1446. X */
  1447. X
  1448. X#ifndef lint
  1449. Xstatic    char    sccsid[] = "@(#)scologin.c    3.2    14:38:24    27 Oct 1991";
  1450. X#endif
  1451. X
  1452. X#include <stdio.h>
  1453. X#include "pwd.h"
  1454. X
  1455. X#define USAGE    "usage: %s [ -r remote_host remote_user local_user [ term_type ] ]\n"
  1456. X#define LOGIN    "/etc/login"
  1457. X
  1458. Xextern int errno;
  1459. Xextern char *sys_errlist[];
  1460. Xextern char **environ;
  1461. X
  1462. Xmain(argc, argv)
  1463. Xint argc;
  1464. Xchar *argv[];
  1465. X{
  1466. X    char *rhost, *ruser, *luser;
  1467. X    char term[1024], *nargv[8], *nenvp[2];
  1468. X    int root_user, i;
  1469. X    struct passwd *pw;
  1470. X
  1471. X    if (argc == 1) {
  1472. X
  1473. X        /*
  1474. X         * Called from telnetd.
  1475. X         */
  1476. X        nargv[0] = "login";
  1477. X        nargv[1] = "-p";
  1478. X        nargv[2] = NULL;
  1479. X
  1480. X    } else if (strcmp(argv[1], "-r") == 0 && argc >= 6) {
  1481. X
  1482. X        /*
  1483. X         * Called from rlogind.
  1484. X         */
  1485. X
  1486. X        rhost = argv[2];
  1487. X        ruser = argv[3];
  1488. X        luser = argv[4];
  1489. X        root_user = ((pw = getpwnam(luser)) != NULL && pw->pw_uid == 0);
  1490. X
  1491. X        i = 0;
  1492. X        if ( argc == 6 ) {
  1493. X            strcpy(term, "TERM=");
  1494. X            strncat(term+sizeof("TERM=")-1,
  1495. X                argv[5], sizeof(term)-sizeof("TERM="));
  1496. X            term[sizeof(term)-1] = '\0';
  1497. X            nenvp[i++] = term;
  1498. X        }
  1499. X        nenvp[i++] = NULL;
  1500. X        environ = nenvp;
  1501. X
  1502. X        i = 0;
  1503. X        nargv[i++] = "login";
  1504. X        nargv[i++] = "-p";
  1505. X        nargv[i++] = "-h";
  1506. X        nargv[i++] = rhost;
  1507. X        if (ruserok(rhost, root_user, ruser, luser) == 0)
  1508. X            nargv[i++] = "-f";
  1509. X        nargv[i++] = luser;
  1510. X        nargv[i++] = NULL;
  1511. X
  1512. X    } else {
  1513. X
  1514. X        fprintf(stderr, USAGE, argv[0]);
  1515. X        exit(1);
  1516. X
  1517. X    }
  1518. X
  1519. X    (void) execv(LOGIN, nargv);
  1520. X    fprintf(stderr, "%s: could not exec '%s' [%s]\n",
  1521. X        argv[0], LOGIN, sys_errlist[errno]);
  1522. X    exit(1);
  1523. X    /*NOTREACHED*/
  1524. X}
  1525. END_OF_FILE
  1526.   if test 1837 -ne `wc -c <'scologin.c'`; then
  1527.     echo shar: \"'scologin.c'\" unpacked with wrong size!
  1528.   fi
  1529.   # end of 'scologin.c'
  1530. fi
  1531. if test -f 'shadow.4' -a "${1}" != "-c" ; then 
  1532.   echo shar: Will not clobber existing file \"'shadow.4'\"
  1533. else
  1534.   echo shar: Extracting \"'shadow.4'\" \(2125 characters\)
  1535.   sed "s/^X//" >'shadow.4' <<'END_OF_FILE'
  1536. X.\" Copyright 1989, 1990, John F. Haugh II
  1537. X.\" All rights reserved.
  1538. X.\"
  1539. X.\" Use, duplication, and disclosure prohibited without
  1540. X.\" the express written permission of the author.
  1541. X.\"
  1542. X.\"    @(#)shadow.4    3.1    23:49:44    11 Nov 1990
  1543. X.\"
  1544. X.TH SHADOW 4
  1545. X.SH NAME
  1546. Xshadow \- encrypted password file
  1547. X.SH DESCRIPTION
  1548. X.I shadow
  1549. Xcontains the encrypted password information for user's accounts
  1550. Xand optional the password aging information.
  1551. XIncluded is
  1552. X.IP "" .5i
  1553. XLogin name
  1554. X.IP "" .5i
  1555. XEncrypted password
  1556. X.IP "" .5i
  1557. XDays since Jan 1, 1970 that password was last changed
  1558. X.IP "" .5i
  1559. XDays before password may be changed
  1560. X.IP "" .5i
  1561. XDays after which password must be changed
  1562. X.IP "" .5i
  1563. XDays before password is to expire that user is warned
  1564. X.IP "" .5i
  1565. XDays after password expires that account is disabled
  1566. X.IP "" .5i
  1567. XDays since Jan 1, 1970 that account is disabled
  1568. X.IP "" .5i
  1569. XA reserved field
  1570. X.PP
  1571. XThe password field must be filled.
  1572. XThe encryped password consists of 13 to 24 characters from the
  1573. X64 character alphabet
  1574. Xa thru z, A thru Z, 0 thru 9, \. and /.
  1575. XRefer to \fIcrypt(3)\fR for details on how this string is
  1576. Xinterpreted.
  1577. X.PP
  1578. XThe date of the last password change is given as the number
  1579. Xof days since Jan 1, 1970.
  1580. XThe password may not be changed again until the proper number
  1581. Xof days have passed, and must be changed after the maximum
  1582. Xnumber of days.
  1583. XIf the minimum number of days required is greater than the
  1584. Xmaximum number of day allowed, this password may not be
  1585. Xchanged by the user.
  1586. X.PP
  1587. XAn account is considered to be inactive and is disabled if
  1588. Xthe password is not changed within the specified number of
  1589. Xdays after the password expires.
  1590. XAn account will also be disabled on the specified day
  1591. Xregardless of other password expiration information.
  1592. X.PP
  1593. XThis information supercedes any password or password age
  1594. Xinformation present in \fB/etc/passwd\fR.
  1595. X.PP
  1596. XThis file must not be readable by regular users if password
  1597. Xsecurity is to be maintained.
  1598. X.SH Files
  1599. X/etc/passwd \- user account information
  1600. X.br
  1601. X/etc/shadow \- encrypted user passwords
  1602. X.SH See Also
  1603. Xchage(1),
  1604. Xlogin(1),
  1605. Xpasswd(1),
  1606. Xsu(1),
  1607. Xsulogin(1M),
  1608. Xshadow(3),
  1609. Xpasswd(4),
  1610. Xpwconv(8),
  1611. Xpwunconv(8)
  1612. END_OF_FILE
  1613.   if test 2125 -ne `wc -c <'shadow.4'`; then
  1614.     echo shar: \"'shadow.4'\" unpacked with wrong size!
  1615.   fi
  1616.   # end of 'shadow.4'
  1617. fi
  1618. if test -f 'shadow.h' -a "${1}" != "-c" ; then 
  1619.   echo shar: Will not clobber existing file \"'shadow.h'\"
  1620. else
  1621.   echo shar: Extracting \"'shadow.h'\" \(1827 characters\)
  1622.   sed "s/^X//" >'shadow.h' <<'END_OF_FILE'
  1623. X/*
  1624. X * Copyright 1988, 1989, 1990, John F. Haugh II
  1625. X * All rights reserved.
  1626. X *
  1627. X * Use, duplication, and disclosure prohibited without
  1628. X * the express written permission of the author.
  1629. X */
  1630. X
  1631. X#ifndef    _H_SHADOW
  1632. X#define    _H_SHADOW
  1633. X
  1634. X/*
  1635. X * This information is not derived from AT&T licensed sources.  Posted
  1636. X * to the USENET 11/88, and updated 11/90 with information from SVR4.
  1637. X *
  1638. X *    @(#)shadow.h    3.3    09:06:50    07 Dec 1990
  1639. X */
  1640. X
  1641. X#ifdef    ITI_AGING
  1642. Xtypedef    time_t    sptime;
  1643. X#else
  1644. Xtypedef    long    sptime;
  1645. X#endif
  1646. X
  1647. X/*
  1648. X * Shadow password security file structure.
  1649. X */
  1650. X
  1651. Xstruct    spwd {
  1652. X    char    *sp_namp;    /* login name */
  1653. X    char    *sp_pwdp;    /* encrypted password */
  1654. X    sptime    sp_lstchg;    /* date of last change */
  1655. X    sptime    sp_min;        /* minimum number of days between changes */
  1656. X    sptime    sp_max;        /* maximum number of days between changes */
  1657. X    sptime    sp_warn;    /* number of days of warning before password
  1658. X                   expires */
  1659. X    sptime    sp_inact;    /* number of days after password expires
  1660. X                   until the account becomes unusable. */
  1661. X    sptime    sp_expire;    /* days since 1/1/70 until account expires */
  1662. X    unsigned long    sp_flag; /* reserved for future use */
  1663. X};
  1664. X
  1665. X/*
  1666. X * Shadow password security file functions.
  1667. X */
  1668. X
  1669. Xstruct    spwd    *getspent ();
  1670. Xstruct    spwd    *getspnam ();
  1671. Xstruct    spwd    *sgetspent ();
  1672. Xstruct    spwd    *fgetspent ();
  1673. Xvoid    setspent ();
  1674. Xvoid    endspent ();
  1675. Xint    putspent ();
  1676. X
  1677. X#define  SHADOW "/etc/shadow"
  1678. X
  1679. X/*
  1680. X * Shadow group security file structure
  1681. X */
  1682. X
  1683. Xstruct    sgrp {
  1684. X    char    *sg_name;    /* group name */
  1685. X    char    *sg_passwd;    /* group password */
  1686. X    char    **sg_adm;    /* group administator list */
  1687. X    char    **sg_mem;    /* group membership list */
  1688. X};
  1689. X
  1690. X/*
  1691. X * Shadow group security file functions.
  1692. X */
  1693. X
  1694. Xstruct    sgrp    *getsgent ();
  1695. Xstruct    sgrp    *getsgnam ();
  1696. Xstruct    sgrp    *sgetsgent ();
  1697. Xstruct    sgrp    *fgetsgent ();
  1698. Xvoid    setsgent ();
  1699. Xvoid    endsgent ();
  1700. Xint    putsgent ();
  1701. X
  1702. X#define    GSHADOW    "/etc/gshadow"
  1703. X#endif
  1704. END_OF_FILE
  1705.   if test 1827 -ne `wc -c <'shadow.h'`; then
  1706.     echo shar: \"'shadow.h'\" unpacked with wrong size!
  1707.   fi
  1708.   # end of 'shadow.h'
  1709. fi
  1710. if test -f 'su.1' -a "${1}" != "-c" ; then 
  1711.   echo shar: Will not clobber existing file \"'su.1'\"
  1712. else
  1713.   echo shar: Extracting \"'su.1'\" \(1700 characters\)
  1714.   sed "s/^X//" >'su.1' <<'END_OF_FILE'
  1715. X.\" Copyright 1989, 1990, John F. Haugh II
  1716. X.\" All rights reserved.
  1717. X.\"
  1718. X.\" Use, duplication, and disclosure prohibited without
  1719. X.\" the express written permission of the author.
  1720. X.\"
  1721. X.\"    @(#)su.1    3.1    09:34:28    21 Nov 1990
  1722. X.\"
  1723. X.TH SU 1
  1724. X.SH NAME
  1725. Xsu \- Change user ID or become super-user
  1726. X.SH SYNOPSIS
  1727. X.B su
  1728. X[ - ] [ username [ args ] ]
  1729. X.SH DESCRIPTION
  1730. X.I su
  1731. Xis used to become another user during a login session.
  1732. XInvoked without a username, \fIsu\fR defaults to becoming
  1733. Xthe super user.
  1734. XThe optional argument \fB\-\fR may be used to provide an
  1735. Xenvironment similiar to what the user would expect had
  1736. Xthe user logged in directly.
  1737. X.PP
  1738. XAdditional arguments may be provided after the username,
  1739. Xin which case they are supplied to the user\'s login shell.
  1740. XIn particular, an argument of \fB-c\fR will cause the
  1741. Xnext argument to be treated as a command by most command
  1742. Xinterpreters.
  1743. XThe command will be executed under the shell specified by
  1744. X\fB$SHELL\fR, or if undefined, by the one specified in
  1745. X\fI/etc/passwd\fR.
  1746. X.PP
  1747. XThe user will be prompted for a password, if appropriate.
  1748. XInvalid passwords will produce an error message.
  1749. XAll attempts, both valid and invalid, are logged to detect
  1750. Xabuses of the system.
  1751. X.PP
  1752. XThe current environment is passed to the new shell.
  1753. XThe value of \fB$PATH\fR is reset to \fB/bin:/usr/bin\fR
  1754. Xfor normal users, or \fB/bin:/usr/bin:/etc\fR for the super user.
  1755. X.SH CAVEATS
  1756. X.PP
  1757. XThis version of \fIsu\fR has many compilation options, only some of which
  1758. Xmay be in use at any particular site.
  1759. X.SH Files
  1760. X/etc/passwd \- user account information
  1761. X.br
  1762. X/etc/shadow \- encrypted passwords and age information
  1763. X.br
  1764. X$HOME/.profile \- initialization script for default shell
  1765. X.SH See Also
  1766. Xlogin(1),
  1767. Xsh(1)
  1768. END_OF_FILE
  1769.   if test 1700 -ne `wc -c <'su.1'`; then
  1770.     echo shar: \"'su.1'\" unpacked with wrong size!
  1771.   fi
  1772.   # end of 'su.1'
  1773. fi
  1774. if test -f 'sub.c' -a "${1}" != "-c" ; then 
  1775.   echo shar: Will not clobber existing file \"'sub.c'\"
  1776. else
  1777.   echo shar: Extracting \"'sub.c'\" \(1728 characters\)
  1778.   sed "s/^X//" >'sub.c' <<'END_OF_FILE'
  1779. X/*
  1780. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1781. X * All rights reserved.
  1782. X *
  1783. X * Permission is granted to copy and create derivative works for any
  1784. X * non-commercial purpose, provided this copyright notice is preserved
  1785. X * in all copies of source code, or included in human readable form
  1786. X * and conspicuously displayed on all copies of object code or
  1787. X * distribution media.
  1788. X */
  1789. X
  1790. X#include <sys/types.h>
  1791. X#include "config.h"
  1792. X
  1793. X#ifdef    USE_SYSLOG
  1794. X#include <syslog.h>
  1795. X
  1796. X#ifndef    LOG_WARN
  1797. X#define    LOG_WARN    LOG_WARNING
  1798. X#endif
  1799. X#endif
  1800. X
  1801. X#include "pwd.h"
  1802. X
  1803. X#ifndef    lint
  1804. Xstatic    char    sccsid[] = "@(#)sub.c    3.3    09:08:19    28 May 1991";
  1805. X#endif
  1806. X
  1807. X#define    BAD_SUBROOT    "Invalid root directory \"%s\"\n"
  1808. X#define    BAD_SUBROOT2    "invalid root `%s' for user `%s'\n"
  1809. X#define    NO_SUBROOT    "Can't change root directory to \"%s\"\n"
  1810. X#define    NO_SUBROOT2    "no subsystem root `%s' for user `%s'\n"
  1811. X
  1812. X/*
  1813. X * subsystem - change to subsystem root
  1814. X *
  1815. X *    A subsystem login is indicated by the presense of a "*" as
  1816. X *    the first character of the login shell.  The given home
  1817. X *    directory will be used as the root of a new filesystem which
  1818. X *    the user is actually logged into.
  1819. X */
  1820. X
  1821. Xvoid    subsystem (pw)
  1822. Xstruct    passwd    *pw;
  1823. X{
  1824. X    /*
  1825. X     * The new root directory must begin with a "/" character.
  1826. X     */
  1827. X
  1828. X    if (pw->pw_dir[0] != '/') {
  1829. X        printf (BAD_SUBROOT, pw->pw_dir);
  1830. X#ifdef    USE_SYSLOG
  1831. X        syslog (LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name);
  1832. X        closelog ();
  1833. X#endif
  1834. X        exit (1);
  1835. X    }
  1836. X
  1837. X    /*
  1838. X     * The directory must be accessible and the current process
  1839. X     * must be able to change into it.
  1840. X     */
  1841. X
  1842. X    if (chdir (pw->pw_dir) || chroot (pw->pw_dir)) {
  1843. X        printf (NO_SUBROOT, pw->pw_dir);
  1844. X#ifdef    USE_SYSLOG
  1845. X        syslog (LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name);
  1846. X        closelog ();
  1847. X#endif
  1848. X        exit (1);
  1849. X    }
  1850. X}
  1851. END_OF_FILE
  1852.   if test 1728 -ne `wc -c <'sub.c'`; then
  1853.     echo shar: \"'sub.c'\" unpacked with wrong size!
  1854.   fi
  1855.   # end of 'sub.c'
  1856. fi
  1857. if test -f 'sulog.c' -a "${1}" != "-c" ; then 
  1858.   echo shar: Will not clobber existing file \"'sulog.c'\"
  1859. else
  1860.   echo shar: Extracting \"'sulog.c'\" \(1561 characters\)
  1861.   sed "s/^X//" >'sulog.c' <<'END_OF_FILE'
  1862. X/*
  1863. X * Copyright 1989, 1990, 1991, 1992, John F. Haugh II
  1864. X * All rights reserved.
  1865. X *
  1866. X * Permission is granted to copy and create derivative works for any
  1867. X * non-commercial purpose, provided this copyright notice is preserved
  1868. X * in all copies of source code, or included in human readable form
  1869. X * and conspicuously displayed on all copies of object code or
  1870. X * distribution media.
  1871. X *
  1872. X * This software is provided on an AS-IS basis and the author makes
  1873. X * no warrantee of any kind.
  1874. X */
  1875. X
  1876. X#include <sys/types.h>
  1877. X#include <stdio.h>
  1878. X#include <time.h>
  1879. X#ifndef    BSD
  1880. X#include <string.h>
  1881. X#include <memory.h>
  1882. X#else
  1883. X#include <strings.h>
  1884. X#define    strchr    index
  1885. X#define    strrchr    rindex
  1886. X#endif
  1887. X#include "config.h"
  1888. X
  1889. X#ifndef    lint
  1890. Xstatic    char    sccsid[] = "@(#)sulog.c    3.3    13:02:53    27 Jul 1992";
  1891. X#endif
  1892. X
  1893. Xextern    char    name[];
  1894. Xextern    char    oldname[];
  1895. X
  1896. Xtime_t    time ();
  1897. Xextern    char    *getdef_str();
  1898. X
  1899. X/*
  1900. X * sulog - log a SU command execution result
  1901. X */
  1902. X
  1903. Xvoid
  1904. Xsulog (tty, success)
  1905. Xchar    *tty;        /* Name of terminal SU was executed from */
  1906. Xint    success;    /* Success (1) or failure (0) of command */
  1907. X{
  1908. X    char    *sulog;
  1909. X    char    *cp;
  1910. X    time_t    clock;
  1911. X    struct    tm    *tm;
  1912. X    struct    tm    *localtime ();
  1913. X    FILE    *fp;
  1914. X
  1915. X    if ( (sulog=getdef_str("SULOG_FILE")) == (char *) 0 )
  1916. X        return;
  1917. X
  1918. X    if ((fp = fopen (sulog, "a+")) == (FILE *) 0)
  1919. X        return;            /* can't open or create logfile */
  1920. X
  1921. X    (void) time (&clock);
  1922. X    tm = localtime (&clock);
  1923. X
  1924. X    (void) fprintf (fp, "SU %.02d/%0.2d %.02d:%.02d %c %.6s %s-%s\n",
  1925. X        tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
  1926. X        success ? '+':'-', tty, oldname, name);
  1927. X
  1928. X    fflush (fp);
  1929. X    fclose (fp);
  1930. X}
  1931. END_OF_FILE
  1932.   if test 1561 -ne `wc -c <'sulog.c'`; then
  1933.     echo shar: \"'sulog.c'\" unpacked with wrong size!
  1934.   fi
  1935.   # end of 'sulog.c'
  1936. fi
  1937. if test -f 'sulogin.8' -a "${1}" != "-c" ; then 
  1938.   echo shar: Will not clobber existing file \"'sulogin.8'\"
  1939. else
  1940.   echo shar: Extracting \"'sulogin.8'\" \(2124 characters\)
  1941.   sed "s/^X//" >'sulogin.8' <<'END_OF_FILE'
  1942. X.\" Copyright 1989, 1990, 1992, John F. Haugh II
  1943. X.\" All rights reserved.
  1944. X.\"
  1945. X.\" Permission is granted to copy and create derivative works for any
  1946. X.\" non-commercial purpose, provided this copyright notice is preserved
  1947. X.\" in all copies of source code, or included in human readable form
  1948. X.\" and conspicuously displayed on all copies of object code or
  1949. X.\" distribution media.
  1950. X.\"
  1951. X.\"    @(#)sulogin.8    3.3    09:42:50    20 Jan 1992
  1952. X.\"
  1953. X.TH SULOGIN 8
  1954. X.SH NAME
  1955. Xsulogin \- Single-user login
  1956. X.SH SYNTAX
  1957. X\fBsulogin\fR [ \fItty-device\fR ]
  1958. X.SH DESCRIPTION
  1959. X.I sulogin
  1960. Xis invoked by \fB/etc/init\fR prior to allowing the user
  1961. Xaccess to the system when in single user mode.
  1962. XThis feature may only be available on certain systems where
  1963. X\fIinit\fR has been modified accordingly, or where the
  1964. X\fB/etc/inittab\fR has an entry for a single user login.
  1965. X.PP
  1966. XThe user is prompted
  1967. X.IP "" .5i
  1968. XType control-d for normal startup,
  1969. X.br
  1970. X(or give root password for system maintenance):
  1971. X.PP
  1972. XInput and output will be performed with the standard file
  1973. Xdescriptors unless the optional device name argument is provided.
  1974. X.PP
  1975. XIf the user enters the correct root password, a login session
  1976. Xis initiated.
  1977. XWhen \fBEOF\fR is pressed instead, the system enters multi-user
  1978. Xmode.
  1979. X.PP
  1980. XAfter the user exits the single-user shell, or presses \fBEOF\fR,
  1981. Xthe system begins the initialization process required to enter
  1982. Xmulti-user mode.
  1983. X.SH CAVEATS
  1984. X.PP
  1985. XThis command can only be used if \fIinit\fR has been modified to call
  1986. X\fB/etc/sulogin\fR instead of \fB/bin/sh\fR,
  1987. Xor if the user has set the \fIinittab\fR to support a single user
  1988. Xlogin.
  1989. XFor example, the line
  1990. X.br
  1991. X.sp 1
  1992. Xco:s:respawn:/etc/sulogin /dev/console
  1993. X.br
  1994. X.sp 1
  1995. Xshould execute the sulogin command in single user mode.
  1996. X.PP
  1997. XAs complete an environment as possible is created.
  1998. XHowever, various devices may be unmounted or uninitialized and many 
  1999. Xof the user commands may be unavailable or nonfunctional as a result.
  2000. X.SH Files
  2001. X/etc/passwd \- user account information
  2002. X.br
  2003. X/etc/shadow \- encrypted passwords and age information
  2004. X.br
  2005. X/.profile \- initialization script for single user shell
  2006. X.SH See Also
  2007. Xlogin(1),
  2008. Xinit(1M),
  2009. Xsh(1)
  2010. END_OF_FILE
  2011.   if test 2124 -ne `wc -c <'sulogin.8'`; then
  2012.     echo shar: \"'sulogin.8'\" unpacked with wrong size!
  2013.   fi
  2014.   # end of 'sulogin.8'
  2015. fi
  2016. if test -f 'ttytype.c' -a "${1}" != "-c" ; then 
  2017.   echo shar: Will not clobber existing file \"'ttytype.c'\"
  2018. else
  2019.   echo shar: Extracting \"'ttytype.c'\" \(1717 characters\)
  2020.   sed "s/^X//" >'ttytype.c' <<'END_OF_FILE'
  2021. X/*
  2022. X * Copyright 1989, 1990, 1991, John F. Haugh II
  2023. X * All rights reserved.
  2024. X *
  2025. X * Permission is granted to copy and create derivative works for any
  2026. X * non-commercial purpose, provided this copyright notice is preserved
  2027. X * in all copies of source code, or included in human readable form
  2028. X * and conspicuously displayed on all copies of object code or
  2029. X * distribution media.
  2030. X */
  2031. X
  2032. X#include <stdio.h>
  2033. X#ifndef    BSD
  2034. X#include <string.h>
  2035. X#include <memory.h>
  2036. X#else
  2037. X#include <strings.h>
  2038. X#define    strchr    index
  2039. X#define    strrchr    rindex
  2040. X#endif
  2041. X#include "config.h"
  2042. X
  2043. X#ifndef    lint
  2044. Xstatic    char    _sccsid[] = "@(#)ttytype.c    3.3    19:40:04    28 Dec 1991";
  2045. X#endif
  2046. X
  2047. Xextern    char    *getdef_str();
  2048. X
  2049. X/*
  2050. X * ttytype - set ttytype from port to terminal type mapping database
  2051. X */
  2052. X
  2053. Xvoid
  2054. Xttytype (line)
  2055. Xchar    *line;
  2056. X{
  2057. X    FILE    *fp;
  2058. X    char    buf[BUFSIZ];
  2059. X    char    termvar[BUFSIZ];
  2060. X    char    *typefile;
  2061. X    char    *cp;
  2062. X    char    *type;
  2063. X    char    *port;
  2064. X    char    *getenv ();
  2065. X
  2066. X    if (getenv ("TERM"))
  2067. X        return;
  2068. X    if ((typefile=getdef_str("TTYTYPE_FILE")) == NULL )
  2069. X        return;
  2070. X    if (access (typefile, 0))
  2071. X        return;
  2072. X
  2073. X    if (! (fp = fopen (typefile, "r"))) {
  2074. X        perror (typefile);
  2075. X        return;
  2076. X    }
  2077. X    while (fgets (buf, BUFSIZ, fp)) {
  2078. X        if (buf[0] == '#')
  2079. X            continue;
  2080. X
  2081. X        if (cp = strchr (buf, '\n'))
  2082. X            *cp = '\0';
  2083. X
  2084. X#if defined(SUN) || defined(BSD) || defined(SUN4)
  2085. X        if ((port = strtok (buf, "\t"))
  2086. X                && (type = strtok ((char *) 0, "\t"))
  2087. X                && (type = strtok ((char *) 0, "\t"))) {
  2088. X            if (strcmp (line, port) == 0)
  2089. X                break;
  2090. X        }    
  2091. X#else    /* USG */
  2092. X        if ((type = strtok (buf, " \t"))
  2093. X                && (port = strtok ((char *) 0, " \t"))) {
  2094. X            if (strcmp (line, port) == 0)
  2095. X                break;
  2096. X        }
  2097. X#endif
  2098. X    }
  2099. X    if (! feof (fp) && ! ferror (fp)) {
  2100. X        strcat (strcpy (termvar, "TERM="), type);
  2101. X        addenv (termvar);
  2102. X    }
  2103. X    fclose (fp);
  2104. X}
  2105. END_OF_FILE
  2106.   if test 1717 -ne `wc -c <'ttytype.c'`; then
  2107.     echo shar: \"'ttytype.c'\" unpacked with wrong size!
  2108.   fi
  2109.   # end of 'ttytype.c'
  2110. fi
  2111. if test -f 'userdel.1' -a "${1}" != "-c" ; then 
  2112.   echo shar: Will not clobber existing file \"'userdel.1'\"
  2113. else
  2114.   echo shar: Extracting \"'userdel.1'\" \(1423 characters\)
  2115.   sed "s/^X//" >'userdel.1' <<'END_OF_FILE'
  2116. X.\" Copyright 1991, 1993, John F. Haugh II
  2117. X.\" All rights reserved.
  2118. X.\"
  2119. X.\" Permission is granted to copy and create derivative works for any
  2120. X.\" non-commercial purpose, provided this copyright notice is preserved
  2121. X.\" in all copies of source code, or included in human readable form
  2122. X.\" and conspicuously displayed on all copies of object code or
  2123. X.\" distribution media.
  2124. X.\"
  2125. X.\" This software is provided on an AS-IS basis and the author makes
  2126. X.\" no warrantee of any kind.
  2127. X.\"
  2128. X.\"    @(#)userdel.1    3.2    08:04:38    07 May 1993
  2129. X.\"
  2130. X.TH USERDEL 1M
  2131. X.SH NAME
  2132. Xuserdel \- Delete a user account and related files
  2133. X.SH SYNOPSIS
  2134. X.B userdel
  2135. X[ \fB-r\fI ]
  2136. X.I login
  2137. X.SH DESCRIPTION
  2138. XThe \fIuserdel\fR command modifies the system account files, deleting
  2139. Xall entries that refer to \fIlogin\fR.
  2140. XThe named user must exist.
  2141. X.IP \fB-r\fR
  2142. XFiles in the user's home directory will be removed along with the
  2143. Xhome directory itself.
  2144. XFiles located in other file system will have to be searched for
  2145. Xand deleted manually.
  2146. X.SH Files
  2147. X/etc/passwd \- user account information
  2148. X.br
  2149. X/etc/shadow \- secure user account information
  2150. X.br
  2151. X/etc/group \- group information
  2152. X.SH CAVEATS
  2153. X\fBuserdel\fR will not allow you to remove an account if the user
  2154. Xis currently logged in.
  2155. XYou must kill any running processes which belong to an account that
  2156. Xyou are deleting.
  2157. X.SH SEE ALSO
  2158. X\fBchfn(1), chsh(1), groupadd(1M), groupdel(1M), groupmod(1M),
  2159. Xpasswd(1), useradd(1M), usermod(1M)
  2160. END_OF_FILE
  2161.   if test 1423 -ne `wc -c <'userdel.1'`; then
  2162.     echo shar: \"'userdel.1'\" unpacked with wrong size!
  2163.   fi
  2164.   # end of 'userdel.1'
  2165. fi
  2166. echo shar: End of archive 13 \(of 14\).
  2167. cp /dev/null ark13isdone
  2168. MISSING=""
  2169. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  2170.     if test ! -f ark${I}isdone ; then
  2171.     MISSING="${MISSING} ${I}"
  2172.     fi
  2173. done
  2174. if test "${MISSING}" = "" ; then
  2175.     echo You have unpacked all 14 archives.
  2176.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2177. else
  2178.     echo You still must unpack the following archives:
  2179.     echo "        " ${MISSING}
  2180. fi
  2181. exit 0
  2182. exit 0 # Just in case...
  2183.