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

  1. Newsgroups: comp.sources.misc
  2. From: jfh@rpp386.cactus.org (John F. Haugh II)
  3. Subject: v38i130:  shadow - Shadow Password Suite, v3.3, Part11/14
  4. Message-ID: <1993Aug14.192617.9824@sparky.sterling.com>
  5. X-Md4-Signature: 49f1a5de77c63412d1599e63f55266e8
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Sat, 14 Aug 1993 19:26:17 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 130
  13. Archive-name: shadow/part11
  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:  chage.1 config.h config.h.sun4 config.h.svr4 getpass.c
  22. #   grdbm.c gshadow.c id.c login.1 obscure.c pwconv.c shadow.3
  23. #   usermod.1
  24. # Wrapped by kent@sparky on Sat Aug 14 14:11:41 1993
  25. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 11 (of 14)."'
  28. if test -f 'chage.1' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'chage.1'\"
  30. else
  31.   echo shar: Extracting \"'chage.1'\" \(3437 characters\)
  32.   sed "s/^X//" >'chage.1' <<'END_OF_FILE'
  33. X.\" Copyright 1990, John F. Haugh II
  34. X.\" All rights reserved.
  35. X.\"
  36. X.\" Use, duplication, and disclosure prohibited without
  37. X.\" the express written permission of the author.
  38. X.\"
  39. X.\"    @(#)chage.1    3.2    10:04:46    27 Mar 1992
  40. X.\"
  41. X.TH CHAGE 1
  42. X.SH NAME
  43. Xchage \- change user password expirate information
  44. X.SH SYNOPSIS
  45. X\fBchage\fR [ \fB-m \fImindays\fR ] [ \fB-M \fImaxdays\fR ]
  46. X[ \fB-d \fIlastday\fR ] [ \fB-I \fIinactive\fR ]
  47. X[ \fB-E \fIexpiredate\fR ] [ \fB-W \fIwarndays\fR ] \fIuser\fR
  48. X.sp 1
  49. X\fBchage\fR -l \fIuser\fR
  50. X.SH DESCRIPTION
  51. X\fIchage\f changes the number of days between password changes and the
  52. Xdate of the last password change.
  53. XThis information is used by the system to determine when a user must
  54. Xchange her password.
  55. XThe \fIchage\f command is restricted to the root user, except for the
  56. X\fB-l\fR option, which may be used by an unprivileged user to determine
  57. Xwhen her password or account is due to expire.
  58. X.PP
  59. XWith the \fB-m\fR option, the value of \fImindays\f is the minimum number
  60. Xof days between password changes.
  61. XA value of zero for this field indicates that the user may change
  62. Xher password at any time.
  63. X.PP
  64. XWith the \fB-M\fR option, the value of \fImaxdays\f is the maximum number
  65. Xof days during which a password is valid.
  66. XWhen \fImaxdays\fR plus \fIlastday\fR is less than the current day,
  67. Xthe user will be required to change her password before being
  68. Xable to use her account.
  69. XThis occurance can be planned for in advance by use of the \fB-W\fR option,
  70. Xwhich provides the user with advance warning.
  71. X.PP
  72. XWith the \fB-d\fR option, the value of \fIlastday\f is the number of days
  73. Xsince January 1st, 1970 when the password was last changed.
  74. XThe date may also be expressed in the format MM/DD/YY (or the format more
  75. Xcommonly used in your area).
  76. X.PP
  77. XThe \fB-E\fR option is used to set a date on which the user's account will
  78. Xno longer be accessible.
  79. XThe \fIexpiredate\fR option is the number of days since January 1, 1970 on
  80. Xwhich the accounted is locked.
  81. XThe date may also be expressed in the format MM/DD/YY (or the format more
  82. Xcommonly used in your area).
  83. XA user whose account is locked must contact the system administrator before
  84. Xbeing able to use the system again.
  85. X.PP
  86. XThe \fB-I\fR option is used to set the number of days of inactivity after
  87. Xa password has expired before the account is locked.
  88. XA user whose account is locked must contact the system administrator before
  89. Xbeing able to use the system again.
  90. XThe \fIinactive\fR option is the number of days of inactivity. A value of
  91. X0 disables this feature.
  92. X.PP
  93. XThe \fB-W\fR option is used to set the number of days of warning before a
  94. Xpassword change is required.
  95. XThe \fIwarndays\fR option is the number of days prior to the password
  96. Xexpiring that a user will be warned her password is about to expire.
  97. X.PP
  98. XAll of the above values are stored exactly as days when the shadow
  99. Xpassword file is used, but are converted to and from weeks when the
  100. Xstandard password file is used.
  101. XBecause of this conversion, rounding errors may result.
  102. X.PP
  103. XIf none of the options are selected, \fIchage\f operates in an interactive
  104. Xfashion, prompting the user with the current values for all of the fields.
  105. XEnter the new value to change the field, or leave the line blank to use
  106. Xthe current value.
  107. XThe current value is displayed between a pair of \fB[ ]\f marks.
  108. X.SH Files
  109. X/etc/passwd \- user account information
  110. X.br
  111. X/etc/shadow \- shadow user account information
  112. X.SH See Also
  113. Xpasswd(4),
  114. Xshadow(4)
  115. END_OF_FILE
  116.   if test 3437 -ne `wc -c <'chage.1'`; then
  117.     echo shar: \"'chage.1'\" unpacked with wrong size!
  118.   fi
  119.   # end of 'chage.1'
  120. fi
  121. if test -f 'config.h' -a "${1}" != "-c" ; then 
  122.   echo shar: Will not clobber existing file \"'config.h'\"
  123. else
  124.   echo shar: Extracting \"'config.h'\" \(5064 characters\)
  125.   sed "s/^X//" >'config.h' <<'END_OF_FILE'
  126. X/*
  127. X * Copyright 1989, 1990, 1991, 1992, 1993, John F. Haugh II
  128. X * All rights reserved.
  129. X *
  130. X * Permission is granted to copy and create derivative works for any
  131. X * non-commercial purpose, provided this copyright notice is preserved
  132. X * in all copies of source code, or included in human readable form
  133. X * and conspicuously displayed on all copies of object code or
  134. X * distribution media.
  135. X *
  136. X * This software is provided on an AS-IS basis and the author makes
  137. X * no warrantee of any kind.
  138. X */
  139. X
  140. X/*
  141. X * Configuration file for login.
  142. X *
  143. X *    @(#)config.h    3.16.1.3    17:52:38    09 May 1993
  144. X */
  145. X
  146. X
  147. X/*
  148. X * Pathname to the run-time configuration definitions file.
  149. X */
  150. X
  151. X#define LOGINDEFS "/etc/login.defs"
  152. X
  153. X/*
  154. X * Define SHADOWPWD to use shadow [ unreadable ] password file.
  155. X * Release 3 has a requirement that SHADOWPWD always be defined.
  156. X */
  157. X
  158. X#define    SHADOWPWD
  159. X
  160. X/*
  161. X * Define AUTOSHADOW to have root always copy sp_pwdp to pw_passwd
  162. X * for getpwuid() and getpwnam().  This provides compatibility for
  163. X * privileged applications which are shadow-ignorant.  YOU ARE
  164. X * ENCOURAGED TO NOT USE THIS OPTION UNLESS ABSOLUTELY NECESSARY.
  165. X */
  166. X
  167. X#undef    AUTOSHADOW
  168. X
  169. X/*
  170. X * Define SHADOWGRP to user shadowed group files.  This feature adds
  171. X * the concept of a group administrator.  You MUST NOT define this
  172. X * if you disable SHADOWPWD.
  173. X */
  174. X
  175. X/* #define    SHADOWGRP /**/
  176. X
  177. X/*
  178. X * Define DOUBLESIZE to use 16 character passwords
  179. X */
  180. X
  181. X#define DOUBLESIZE
  182. X
  183. X/*
  184. X * Define AGING if you want the password aging checks made.
  185. X * Release 3 has a requirement that AGING always be defined.
  186. X */
  187. X
  188. X#define    AGING
  189. X
  190. X/*
  191. X * Pick your version of DBM.  If you define either DBM or NDBM, you must
  192. X * define GETPWENT.  If you define NDBM you must define GETGRENT as well.
  193. X */
  194. X
  195. X/* #define    DBM    /**/
  196. X/* #define    NDBM    /**/
  197. X
  198. X/*
  199. X * Define USE_SYSLOG if you want to have SYSLOG functions included in your code.
  200. X */
  201. X
  202. X#define    USE_SYSLOG
  203. X
  204. X/*
  205. X * Enable RLOGIN to support the "-r" and "-h" options.
  206. X * Also enable UT_HOST if your /etc/utmp provides for a host name.
  207. X */
  208. X
  209. X#define RLOGIN
  210. X#undef UT_HOST
  211. X
  212. X/*
  213. X * Define the "success" code from ruserok().  Most modern systems use 0
  214. X * for success and -1 for failure, while certain older versions use 1
  215. X * for success and 0 for failure.  Please check your manpage to be sure.
  216. X */
  217. X
  218. X#define    RUSEROK    0
  219. X
  220. X/*
  221. X * Select one of the following
  222. X */
  223. X
  224. X#define DIR_XENIX    /* include <sys/ndir.h>, use (struct direct)    */
  225. X/* #define DIR_BSD    /* include <ndir.h>, use (struct direct)    */
  226. X/* #define DIR_SYSV    /* include <dirent.h>, use (struct dirent)    */
  227. X
  228. X/*
  229. X * Various system environment definitions.
  230. X */
  231. X
  232. X#define    HAVE_ULIMIT    /* Define if your UNIX supports ulimit()    */
  233. X#undef    HAVE_RLIMIT    /* Define if your UNIX supports setrlimit()     */
  234. X#define    GETPWENT    /* Define if you want my GETPWENT(3) routines    */
  235. X#define    GETGRENT    /* Define if you want my GETGRENT(3) routines    */
  236. X#define    NEED_AL64    /* Define if library does not include a64l()    */
  237. X#define    NEED_MKDIR    /* Define if system does not have mkdir()    */
  238. X#define    NEED_RMDIR    /* Define if system does not have rmdir()    */
  239. X#define    NEED_RENAME    /* Define if system does not have rename()    */
  240. X#define    NEED_STRSTR    /* Define if library does not include strstr()    */
  241. X#undef    NEED_PUTPWENT    /* Define if library does not include putpwent()*/
  242. X#define    SIGTYPE    int    /* Type returned by signal()                    */
  243. X
  244. X/*
  245. X * These definitions MUST agree with the values defined in <pwd.h>.
  246. X */
  247. X
  248. X#undef    BSD_QUOTA    /* the pw_quota field exists */
  249. X#define    ATT_AGE        /* the pw_age field exists */
  250. X#define    ATT_COMMENT    /* the pw_comment field exists */
  251. X
  252. X#define    UID_T    uid_t    /* set to be the type of UID's */
  253. X#define    GID_T    gid_t    /* set to be the type of GID's */
  254. X
  255. X#ifndef    UID_T
  256. X#if defined(SVR4) || defined(_POSIX_SOURCE)
  257. X#define    UID_T    uid_t
  258. X#else
  259. X#define    UID_T    int
  260. X#endif
  261. X#endif
  262. X
  263. X#ifndef    GID_T
  264. X#if defined(SVR4) || defined(_POSIX_SOURCE)
  265. X#define    GID_T    gid_t
  266. X#else
  267. X#define    GID_T    int
  268. X#endif
  269. X#endif
  270. X
  271. X/*
  272. X * Define NDEBUG for production versions
  273. X */
  274. X
  275. X#define    NDEBUG
  276. X
  277. X/*
  278. X * Define PWDFILE and GRPFILE to the names of the password and
  279. X * group files.
  280. X */
  281. X
  282. X#define    PWDFILE    "/etc/passwd"
  283. X#define    GRPFILE    "/etc/group"
  284. X
  285. X/*
  286. X * The structure of the utmp file.  There are two kinds of UTMP files,
  287. X * "BSD" and "USG".  "BSD" has no PID or type information, "USG" does.
  288. X * If you define neither of these, the type will be defaulted by using
  289. X * BSD, SUN, SYS3 and USG defines.
  290. X */
  291. X
  292. X#define USG_UTMP    /**/
  293. X/* #define BSD_UTMP    /**/
  294. X
  295. X#if !defined(USG_UTMP) && !defined(BSD_UTMP)
  296. X#if defined(BSD) || defined(SYS3) || defined(SUN)
  297. X#define    BSD_UTMP
  298. X#else
  299. X#define USG_UTMP
  300. X#endif    /* BSD || SYS3 || SUN */
  301. X#endif /* !USG_UTMP || !BSD_UTMP */
  302. X
  303. X/*
  304. X * Telinit program.  If your system uses /etc/telinit to change run
  305. X * level, define TELINIT and then define the RUNLEVEL macro to be the
  306. X * run-level to switch INIT to.  This is used by sulogin to change
  307. X * from single user to multi-user mode.
  308. X */
  309. X
  310. X#define    TELINIT        /**/
  311. X#define    RUNLEVEL    "2"    /**/
  312. X
  313. X/*
  314. X * Crontab and atrm.  If your system can "crontab -r -u <user>", define
  315. X * HAS_CRONTAB.  If your system can "atrm <user>", define HAS_ATRM.
  316. X */
  317. X
  318. X#undef    HAS_CRONTAB
  319. X#undef    HAS_ATRM
  320. END_OF_FILE
  321.   if test 5064 -ne `wc -c <'config.h'`; then
  322.     echo shar: \"'config.h'\" unpacked with wrong size!
  323.   fi
  324.   # end of 'config.h'
  325. fi
  326. if test -f 'config.h.sun4' -a "${1}" != "-c" ; then 
  327.   echo shar: Will not clobber existing file \"'config.h.sun4'\"
  328. else
  329.   echo shar: Extracting \"'config.h.sun4'\" \(3976 characters\)
  330.   sed "s/^X//" >'config.h.sun4' <<'END_OF_FILE'
  331. X/*
  332. X * Copyright 1989, 1990, 1991, 1993, John F. Haugh II
  333. X * All rights reserved.
  334. X *
  335. X * Permission is granted to copy and create derivative works for any
  336. X * non-commercial purpose, provided this copyright notice is preserved
  337. X * in all copies of source code, or included in human readable form
  338. X * and conspicuously displayed on all copies of object code or
  339. X * distribution media.
  340. X */
  341. X
  342. X/*
  343. X * Configuration file for login.
  344. X *
  345. X *    @(#)config.h.sun4    3.3    20:39:30    23 May 1993 (SunOS 4.1.1)
  346. X */
  347. X
  348. X
  349. X/*
  350. X * Pathname to the run-time configuration definitions file.
  351. X */
  352. X
  353. X#define LOGINDEFS "/etc/login.defs"
  354. X
  355. X/*
  356. X * Define SHADOWPWD to use shadow [ unreadable ] password file.
  357. X * Release 3 has a requirement that SHADOWPWD always be defined.
  358. X */
  359. X
  360. X#define    SHADOWPWD
  361. X
  362. X/*
  363. X * Define AUTOSHADOW to have root always copy sp_pwdp to pw_passwd
  364. X * for getpwuid() and getpwnam().  This provides compatibility for
  365. X * privileged applications which are shadow-ignorant.  YOU ARE
  366. X * ENCOURAGED TO NOT USE THIS OPTION UNLESS ABSOLUTELY NECESSARY.
  367. X */
  368. X
  369. X#undef    AUTOSHADOW
  370. X
  371. X/*
  372. X * Define SHADOWGRP to user shadowed group files.  This feature adds
  373. X * the concept of a group administrator.
  374. X */
  375. X
  376. X#define    SHADOWGRP /**/
  377. X
  378. X/*
  379. X * Define DOUBLESIZE to use 16 character passwords.  Define SW_CRYPT
  380. X * to use 80 character passwords with SecureWare[tm]'s method of
  381. X * generating ciphertext.
  382. X */
  383. X
  384. X#define DOUBLESIZE
  385. X#undef    SW_CRYPT
  386. X
  387. X/*
  388. X * Define AGING if you want the password aging checks made.
  389. X * Release 3 has a requirement that AGING always be defined.
  390. X */
  391. X
  392. X#define    AGING
  393. X
  394. X/*
  395. X * Pick your version of DBM.  If you define either DBM or NDBM, you must
  396. X * define GETPWENT.  If you define NDBM you must define GETGRENT as well.
  397. X */
  398. X
  399. X/* #define    DBM    /**/
  400. X#define    NDBM    /**/
  401. X
  402. X/*
  403. X * Define USE_SYSLOG if you want to have SYSLOG functions included in your code.
  404. X */
  405. X
  406. X#define    USE_SYSLOG
  407. X
  408. X/*
  409. X * Enable RLOGIN to support the "-r" and "-h" options.
  410. X * Also enable UT_HOST if your /etc/utmp provides for a host name.
  411. X */
  412. X
  413. X#define RLOGIN
  414. X#define UT_HOST
  415. X
  416. X/*
  417. X * Define the "success" code from ruserok().  Most modern systems use 0
  418. X * for success and -1 for failure, while certain older versions use 1
  419. X * for success and 0 for failure.  Please check your manpage to be sure.
  420. X */
  421. X
  422. X#define       RUSEROK 0
  423. X
  424. X/*
  425. X * Select one of the following
  426. X */
  427. X
  428. X/* #define DIR_XENIX    /* include <sys/ndir.h>, use (struct direct)    */
  429. X/* #define DIR_BSD    /* include <ndir.h>, use (struct direct)    */
  430. X#define DIR_SYSV    /* include <dirent.h>, use (struct dirent)    */
  431. X
  432. X/*
  433. X * Various system environment definitions.
  434. X */
  435. X
  436. X#define    HAVE_ULIMIT    /* Define if your UNIX supports ulimit()    */
  437. X#define    GETPWENT    /* Define if you want my GETPWENT(3) routines    */
  438. X#define    GETGRENT    /* Define if you want my GETGRENT(3) routines    */
  439. X#undef    NEED_AL64    /* Define if library does not include a64l()    */
  440. X#undef    NEED_MKDIR    /* Define if system does not have mkdir()    */
  441. X#undef    NEED_RMDIR    /* Define if system does not have rmdir()    */
  442. X#undef    NEED_RENAME    /* Define if system does not have rename()    */
  443. X#define    NEED_STRSTR    /* Define if library does not include strstr()    */
  444. X#undef    NEED_PUTPWENT    /* Define if library does not include putpwent()*/
  445. X#define    SIGTYPE    void    /* Type returned by signal()                    */
  446. X
  447. X/*
  448. X * These definitions MUST agree with the values defined in <pwd.h>.
  449. X */
  450. X
  451. X#undef    BSD_QUOTA    /* the pw_quota field exists */
  452. X#define    ATT_AGE        /* the pw_age field exists */
  453. X#define    ATT_COMMENT    /* the pw_comment field exists */
  454. X
  455. X#define    UID_T    uid_t    /* set to be the type of UID's */
  456. X#define    GID_T    gid_t    /* set to be the type of GID's */
  457. X
  458. X#ifndef    UID_T
  459. X#if defined(SVR4) || defined(_POSIX_SOURCE)
  460. X#define    UID_T    uid_t
  461. X#else
  462. X#define    UID_T    int
  463. X#endif
  464. X#endif
  465. X
  466. X#ifndef    GID_T
  467. X#if defined(SVR4) || defined(_POSIX_SOURCE)
  468. X#define    GID_T    gid_t
  469. X#else
  470. X#define    GID_T    int
  471. X#endif
  472. X#endif
  473. X
  474. X/*
  475. X * Define NDEBUG for production versions
  476. X */
  477. X
  478. X#define    NDEBUG
  479. X
  480. X/*
  481. X * Define PWDFILE and GRPFILE to the names of the password and
  482. X * group files.
  483. X */
  484. X
  485. X#define    PWDFILE    "/etc/passwd"
  486. X#define    GRPFILE    "/etc/group"
  487. END_OF_FILE
  488.   if test 3976 -ne `wc -c <'config.h.sun4'`; then
  489.     echo shar: \"'config.h.sun4'\" unpacked with wrong size!
  490.   fi
  491.   # end of 'config.h.sun4'
  492. fi
  493. if test -f 'config.h.svr4' -a "${1}" != "-c" ; then 
  494.   echo shar: Will not clobber existing file \"'config.h.svr4'\"
  495. else
  496.   echo shar: Extracting \"'config.h.svr4'\" \(4648 characters\)
  497.   sed "s/^X//" >'config.h.svr4' <<'END_OF_FILE'
  498. X/*
  499. X * Copyright 1989, 1990, 1991, 1992, 1993, John F. Haugh II
  500. X * All rights reserved.
  501. X *
  502. X * Permission is granted to copy and create derivative works for any
  503. X * non-commercial purpose, provided this copyright notice is preserved
  504. X * in all copies of source code, or included in human readable form
  505. X * and conspicuously displayed on all copies of object code or
  506. X * distribution media.
  507. X *
  508. X * This software is provided on an AS-IS basis and the author makes
  509. X * no warrantee of any kind.
  510. X */
  511. X
  512. X/*
  513. X * Configuration file for login.
  514. X *
  515. X *    @(#)config.h.svr4    3.3    07:18:05    03 Jun 1993    (SVR4)
  516. X */
  517. X
  518. X
  519. X/*
  520. X * Pathname to the run-time configuration definitions file.
  521. X */
  522. X
  523. X#define LOGINDEFS "/etc/login.defs"
  524. X
  525. X/*
  526. X * Define SHADOWPWD to use shadow [ unreadable ] password file.
  527. X * Release 3 has a requirement that SHADOWPWD always be defined.
  528. X */
  529. X
  530. X#define    SHADOWPWD
  531. X
  532. X/*
  533. X * Define AUTOSHADOW to have root always copy sp_pwdp to pw_passwd
  534. X * for getpwuid() and getpwnam().  This provides compatibility for
  535. X * privileged applications which are shadow-ignorant.  YOU ARE
  536. X * ENCOURAGED TO NOT USE THIS OPTION UNLESS ABSOLUTELY NECESSARY.
  537. X *
  538. X * SVR4 has always had /etc/shadow
  539. X */
  540. X
  541. X#undef    AUTOSHADOW
  542. X
  543. X/*
  544. X * Define SHADOWGRP to user shadowed group files.  This feature adds
  545. X * the concept of a group administrator.
  546. X */
  547. X
  548. X/* #define    SHADOWGRP    /**/
  549. X
  550. X/*
  551. X * Define DOUBLESIZE to use 16 character passwords.  Define SW_CRYPT
  552. X * to use 80 character passwords with SecureWare[tm]'s method of
  553. X * generating ciphertext.
  554. X */
  555. X
  556. X#define DOUBLESIZE
  557. X#undef    SW_CRYPT
  558. X
  559. X/*
  560. X * Define AGING if you want the password aging checks made.
  561. X * Release 3 has a requirement that AGING always be defined.
  562. X */
  563. X
  564. X#define    AGING
  565. X
  566. X/*
  567. X * Pick your version of DBM.  If you define either DBM or NDBM, you must
  568. X * define GETPWENT.  If you define NDBM you must define GETGRENT as well.
  569. X *
  570. X * SVR4 doesn't come with mkpasswd.
  571. X */
  572. X
  573. X/* #define    DBM    /**/
  574. X/* #define    NDBM    /**/
  575. X
  576. X/*
  577. X * Define USE_SYSLOG if you want to have SYSLOG functions included in your code.
  578. X *
  579. X * SVR4 includes syslog()
  580. X */
  581. X
  582. X#define    USE_SYSLOG
  583. X
  584. X/*
  585. X * Enable RLOGIN to support the "-r" and "-h" options.
  586. X * Don't define UT_HOST, it's in utmpx.
  587. X */
  588. X
  589. X#define RLOGIN
  590. X#undef UT_HOST
  591. X
  592. X/*
  593. X * Define the "success" code from ruserok().  Most modern systems use 0
  594. X * for success and -1 for failure, while certain older versions use 1
  595. X * for success and 0 for failure.  Please check your manpage to be sure.
  596. X */
  597. X
  598. X#define    RUSEROK    0
  599. X
  600. X/*
  601. X * Use SVR4 directory functions.
  602. X */
  603. X
  604. X#define DIR_SYSV    /* include <dirent.h>, use (struct dirent)    */
  605. X
  606. X/*
  607. X * Various system environment definitions.
  608. X */
  609. X
  610. X#undef    HAVE_ULIMIT    /* Define if your UNIX supports ulimit()    */
  611. X#define    HAVE_RLIMIT    /* Define if your UNIX supports setrlimit()    */
  612. X#define    GETPWENT    /* Define if you want my GETPWENT(3) routines    */
  613. X#undef    GETGRENT    /* Define if you want my GETGRENT(3) routines    */
  614. X#undef    NEED_AL64    /* Define if library does not include a64l()    */
  615. X#undef    NEED_MKDIR    /* Define if system does not have mkdir()    */
  616. X#undef    NEED_RMDIR    /* Define if system does not have rmdir()    */
  617. X#undef    NEED_RENAME    /* Define if system does not have rename()    */
  618. X#undef    NEED_STRSTR    /* Define if library does not include strstr()    */
  619. X#undef    NEED_PUTPWENT    /* Define if library does not include putpwent()*/
  620. X#define    SIGTYPE    void    /* Type returned by signal()                    */
  621. X
  622. X/*
  623. X * These definitions MUST agree with the values defined in <pwd.h>.
  624. X */
  625. X
  626. X#undef    BSD_QUOTA    /* the pw_quota field exists */
  627. X#define    ATT_AGE        /* the pw_age field exists */
  628. X#define    ATT_COMMENT    /* the pw_comment field exists */
  629. X
  630. X#define    UID_T    uid_t    /* set to be the type of UID's */
  631. X#define    GID_T    gid_t    /* set to be the type of GID's */
  632. X
  633. X#ifndef    UID_T
  634. X#if defined(SVR4) || defined(_POSIX_SOURCE)
  635. X#define    UID_T    uid_t
  636. X#else
  637. X#define    UID_T    int
  638. X#endif
  639. X#endif
  640. X
  641. X#ifndef    GID_T
  642. X#if defined(SVR4) || defined(_POSIX_SOURCE)
  643. X#define    GID_T    gid_t
  644. X#else
  645. X#define    GID_T    int
  646. X#endif
  647. X#endif
  648. X
  649. X/*
  650. X * Define NDEBUG for production versions
  651. X */
  652. X
  653. X#define    NDEBUG
  654. X
  655. X/*
  656. X * Define PWDFILE and GRPFILE to the names of the password and
  657. X * group files.
  658. X */
  659. X
  660. X#define    PWDFILE    "/etc/passwd"
  661. X#define    GRPFILE    "/etc/group"
  662. X
  663. X/*
  664. X * This is SVR4.
  665. X */
  666. X
  667. X#define    USG_UTMP
  668. X
  669. X/*
  670. X * Telinit program.  If your system uses /etc/telinit to change run
  671. X * level, define TELINIT and then define the RUNLEVEL macro to be the
  672. X * run-level to switch INIT to.  This is used by sulogin to change
  673. X * from single user to multi-user mode.
  674. X */
  675. X
  676. X#define    TELINIT        /**/
  677. X#define    RUNLEVEL    "2"    /**/
  678. X
  679. X/*
  680. X * Crontab and atrm.  If your system can "crontab -r -u <user>", define
  681. X * HAS_CRONTAB.  If your system can "atrm <user>", define HAS_ATRM.
  682. X *
  683. X * SVR4 has both of these.
  684. X */
  685. X
  686. X#define    HAS_CRONTAB
  687. X#define    HAS_ATRM
  688. END_OF_FILE
  689.   if test 4648 -ne `wc -c <'config.h.svr4'`; then
  690.     echo shar: \"'config.h.svr4'\" unpacked with wrong size!
  691.   fi
  692.   # end of 'config.h.svr4'
  693. fi
  694. if test -f 'getpass.c' -a "${1}" != "-c" ; then 
  695.   echo shar: Will not clobber existing file \"'getpass.c'\"
  696. else
  697.   echo shar: Extracting \"'getpass.c'\" \(3867 characters\)
  698.   sed "s/^X//" >'getpass.c' <<'END_OF_FILE'
  699. X/*
  700. X * Copyright 1990, 1991, 1993, John F. Haugh II
  701. X * All rights reserved.
  702. X *
  703. X * Permission is granted to copy and create derivative works for any
  704. X * non-commercial purpose, provided this copyright notice is preserved
  705. X * in all copies of source code, or included in human readable form
  706. X * and conspicuously displayed on all copies of object code or
  707. X * distribution media.
  708. X *
  709. X * This software is provided on an AS-IS basis and the author makes
  710. X * no warrantee of any kind.
  711. X */
  712. X
  713. X#include <signal.h>
  714. X#include <stdio.h>
  715. X#include "config.h"
  716. X
  717. X#ifdef    BSD
  718. X#include <sgtty.h>
  719. X#include <strings.h>
  720. X#else
  721. X#ifdef    SVR4
  722. X#include <termios.h>
  723. X#else
  724. X#include <termio.h>
  725. X#endif    /* SVR4 */
  726. X#include <string.h>
  727. X#endif
  728. X
  729. X#ifndef    lint
  730. Xstatic    char    sccsid[] = "@(#)getpass.c    3.8    07:26:36    23 Apr 1993";
  731. X#endif
  732. X
  733. X/*
  734. X * limits.h may be kind enough to specify the length of a prompted
  735. X * for password.
  736. X */
  737. X
  738. X#if __STDC__ || _POSIX_SOURCE
  739. X#include <limits.h>
  740. X#endif
  741. X
  742. X/*
  743. X * This is really a giant mess.  On the one hand, it would be nice
  744. X * if PASS_MAX were real big so that DOUBLESIZE isn't needed.  But
  745. X * if it is defined we must honor it because some idiot might use
  746. X * this in a routine expecting some standard behavior.
  747. X */
  748. X
  749. X#ifndef    PASS_MAX
  750. X#ifdef    SW_CRYPT
  751. X#define    PASS_MAX    80
  752. X#else    /* !SW_CRYPT */
  753. X#ifdef    DOUBLESIZE
  754. X#define    PASS_MAX    16
  755. X#else    /* !PASS_MAX */
  756. X#define    PASS_MAX    8
  757. X#endif    /* PASS_MAX */
  758. X#endif    /* SW_CRYPT */
  759. X#endif    /* !PASS_MAX */
  760. X
  761. X#ifdef    BSD
  762. X#define    STTY(fd,termio)    stty(fd, termio)
  763. X#define    GTTY(fd,termio) gtty(fd, termio)
  764. X#define    TERMIO    struct    sgttyb
  765. X#define    INDEX    index
  766. X#else
  767. X#ifdef    SVR4
  768. X#define    STTY(fd,termio) ioctl(fd, TCSETS, termio)
  769. X#define    GTTY(fd,termio) ioctl(fd, TCGETS, termio)
  770. X#define    TERMIO    struct    termios
  771. X#else
  772. X#define    STTY(fd,termio) ioctl(fd, TCSETA, termio)
  773. X#define    GTTY(fd,termio) ioctl(fd, TCGETA, termio)
  774. X#define    TERMIO    struct    termio
  775. X#endif
  776. X#define    INDEX    strchr
  777. X#endif
  778. X
  779. Xstatic    int    sig_caught;
  780. X
  781. Xstatic void
  782. Xsig_catch ()
  783. X{
  784. X    sig_caught = 1;
  785. X}
  786. X
  787. Xchar *
  788. Xgetpass (prompt)
  789. Xchar    *prompt;
  790. X{
  791. X    static    char    input[PASS_MAX+1];
  792. X    char    *return_value = 0;
  793. X    char    *cp;
  794. X    FILE    *fp;
  795. X    int    tty_opened = 0;
  796. X    SIGTYPE    (*old_signal)();
  797. X    TERMIO    new_modes;
  798. X    TERMIO    old_modes;
  799. X
  800. X    /*
  801. X     * set a flag so the SIGINT signal can be re-sent if it
  802. X     * is caught
  803. X     */
  804. X
  805. X    sig_caught = 0;
  806. X
  807. X    /*
  808. X     * if /dev/tty can't be opened, getpass() needs to read
  809. X     * from stdin instead.
  810. X     */
  811. X
  812. X    if ((fp = fopen ("/dev/tty", "r")) == 0) {
  813. X        fp = stdin;
  814. X        setbuf (fp, (char *) 0);
  815. X    } else {
  816. X        tty_opened = 1;
  817. X    }
  818. X
  819. X    /*
  820. X     * the current tty modes must be saved so they can be
  821. X     * restored later on.  echo will be turned off, except
  822. X     * for the newline character (BSD has to punt on this)
  823. X     */
  824. X
  825. X    if (GTTY (fileno (fp), &new_modes))
  826. X        return 0;
  827. X
  828. X    old_modes = new_modes;
  829. X    old_signal = signal (SIGINT, sig_catch);
  830. X
  831. X#ifdef    BSD
  832. X    new_modes.sg_flags &= ~ECHO ;
  833. X#else
  834. X    new_modes.c_lflag &= ~(ECHO|ECHOE|ECHOK);
  835. X    new_modes.c_lflag |= ECHONL;
  836. X#endif
  837. X
  838. X    if (STTY (fileno (fp), &new_modes))
  839. X        goto out;
  840. X
  841. X    /*
  842. X     * the prompt is output, and the response read without
  843. X     * echoing.  the trailing newline must be removed.  if
  844. X     * the fgets() returns an error, a NULL pointer is
  845. X     * returned.
  846. X     */
  847. X
  848. X    if (fputs (prompt, stdout) == EOF)
  849. X        goto out;
  850. X
  851. X    (void) fflush (stdout);
  852. X
  853. X    if (fgets (input, sizeof input, fp) == input) {
  854. X        if (cp = INDEX (input, '\n'))
  855. X            *cp = '\0';
  856. X        else
  857. X            input[sizeof input - 1] = '\0';
  858. X
  859. X        return_value = input;
  860. X#ifdef    BSD
  861. X        putc ('\n', stdout);
  862. X#endif
  863. X    }
  864. Xout:
  865. X    /*
  866. X     * the old SIGINT handler is restored after the tty
  867. X     * modes.  then /dev/tty is closed if it was opened in
  868. X     * the beginning.  finally, if a signal was caught it
  869. X     * is sent to this process for normal processing.
  870. X     */
  871. X
  872. X    if (STTY (fileno (fp), &old_modes))
  873. X        return_value = 0;
  874. X
  875. X    (void) signal (SIGINT, old_signal);
  876. X
  877. X    if (tty_opened)
  878. X        (void) fclose (fp);
  879. X
  880. X    if (sig_caught) {
  881. X        kill (getpid (), SIGINT);
  882. X        return_value = 0;
  883. X    }
  884. X    return return_value;
  885. X}
  886. END_OF_FILE
  887.   if test 3867 -ne `wc -c <'getpass.c'`; then
  888.     echo shar: \"'getpass.c'\" unpacked with wrong size!
  889.   fi
  890.   # end of 'getpass.c'
  891. fi
  892. if test -f 'grdbm.c' -a "${1}" != "-c" ; then 
  893.   echo shar: Will not clobber existing file \"'grdbm.c'\"
  894. else
  895.   echo shar: Extracting \"'grdbm.c'\" \(3622 characters\)
  896.   sed "s/^X//" >'grdbm.c' <<'END_OF_FILE'
  897. X/*
  898. X * Copyright 1990, 1991, John F. Haugh II
  899. X * All rights reserved.
  900. X *
  901. X * Use, duplication, and disclosure prohibited without
  902. X * the express written permission of the author.
  903. X */
  904. X
  905. X#ifndef    lint
  906. Xstatic    char    sccsid[] = "@(#)grdbm.c    3.3    08:44:03    12 Sep 1991";
  907. X#endif
  908. X
  909. X#include <string.h>
  910. X#include <stdio.h>
  911. X#include <grp.h>
  912. X#include "config.h"
  913. X
  914. X#ifdef    NDBM
  915. X#include <ndbm.h>
  916. XDBM    *gr_dbm;
  917. X
  918. X#define    GRP_FRAG    256
  919. X
  920. X/*
  921. X * gr_dbm_update
  922. X *
  923. X * Updates the DBM password files, if they exist.
  924. X */
  925. X
  926. Xint
  927. Xgr_dbm_update (gr)
  928. Xstruct    group    *gr;
  929. X{
  930. X    datum    key;
  931. X    datum    content;
  932. X    char    data[BUFSIZ*8];
  933. X    char    grpkey[60];
  934. X    char    *cp;
  935. X    int    len;
  936. X    int    i;
  937. X    int    cnt;
  938. X    static    int    once;
  939. X
  940. X    if (! once) {
  941. X        if (! gr_dbm)
  942. X            setgrent ();
  943. X
  944. X        once++;
  945. X    }
  946. X    if (! gr_dbm)
  947. X        return 0;
  948. X
  949. X    len = gr_pack (gr, data);
  950. X
  951. X    if (len <= GRP_FRAG) {
  952. X        content.dsize = len;
  953. X        content.dptr = data;
  954. X
  955. X        key.dsize = strlen (gr->gr_name);
  956. X        key.dptr = gr->gr_name;
  957. X        if (dbm_store (gr_dbm, key, content, DBM_REPLACE))
  958. X            return 0;
  959. X
  960. X        key.dsize = sizeof gr->gr_gid;
  961. X        key.dptr = (char *) &gr->gr_gid;
  962. X        if (dbm_store (gr_dbm, key, content, DBM_REPLACE))
  963. X            return 0;
  964. X
  965. X    } else {
  966. X        content.dsize = sizeof cnt;
  967. X        content.dptr = (char *) &cnt;
  968. X        cnt = (len + (GRP_FRAG-1)) / GRP_FRAG;
  969. X
  970. X        key.dsize = strlen (gr->gr_name);
  971. X        key.dptr = gr->gr_name;
  972. X        if (dbm_store (gr_dbm, key, content, DBM_REPLACE))
  973. X            return 0;
  974. X
  975. X        key.dsize = sizeof gr->gr_gid;
  976. X        key.dptr = (char *) &gr->gr_gid;
  977. X        if (dbm_store (gr_dbm, key, content, DBM_REPLACE))
  978. X            return 0;
  979. X
  980. X        for (cp = data, i = 0;i < cnt;i++) {
  981. X            content.dsize = len > GRP_FRAG ? GRP_FRAG:len;
  982. X            len -= content.dsize;
  983. X            content.dptr = cp;
  984. X            cp += content.dsize;
  985. X
  986. X            key.dsize = sizeof i + strlen (gr->gr_name);
  987. X            key.dptr = grpkey;
  988. X            memcpy (grpkey, (char *) &i, sizeof i);
  989. X            strcpy (grpkey + sizeof i, gr->gr_name);
  990. X            if (dbm_store (gr_dbm, key, content, DBM_REPLACE))
  991. X                return 0;
  992. X
  993. X            key.dsize = sizeof i + sizeof gr->gr_gid;
  994. X            key.dptr = grpkey;
  995. X            memcpy (grpkey, (char *) &i, sizeof i);
  996. X            memcpy (grpkey + sizeof i, (char *) &gr->gr_gid,
  997. X                sizeof gr->gr_gid);
  998. X            if (dbm_store (gr_dbm, key, content, DBM_REPLACE))
  999. X                return 0;
  1000. X        }
  1001. X    }
  1002. X    return 1;
  1003. X}
  1004. X
  1005. X/*
  1006. X * gr_dbm_remove
  1007. X *
  1008. X * Deletes the DBM group file entries, if they exist.
  1009. X */
  1010. X
  1011. Xint
  1012. Xgr_dbm_remove (gr)
  1013. Xstruct    group    *gr;
  1014. X{
  1015. X    datum    key;
  1016. X    datum    content;
  1017. X    char    grpkey[60];
  1018. X    int    i;
  1019. X    int    cnt;
  1020. X    int    errors = 0;
  1021. X    static    int    once;
  1022. X
  1023. X    if (! once) {
  1024. X        if (! gr_dbm)
  1025. X            setgrent ();
  1026. X
  1027. X        once++;
  1028. X    }
  1029. X    if (! gr_dbm)
  1030. X        return 0;
  1031. X
  1032. X    key.dsize = strlen (gr->gr_name);
  1033. X    key.dptr = (char *) gr->gr_name;
  1034. X    content = dbm_fetch (gr_dbm, key);
  1035. X    if (content.dptr == 0)
  1036. X        ++errors;
  1037. X    else {
  1038. X        if (content.dsize == sizeof (int)) {
  1039. X            memcpy ((char *) &cnt, content.dptr, sizeof cnt);
  1040. X
  1041. X            for (i = 0;i < cnt;i++) {
  1042. X                key.dsize = sizeof i + strlen (gr->gr_name);
  1043. X                key.dptr = grpkey;
  1044. X                memcpy (grpkey, (char *) &i, sizeof i);
  1045. X                strcpy (grpkey + sizeof i, gr->gr_name);
  1046. X                if (dbm_delete (gr_dbm, key))
  1047. X                    ++errors;
  1048. X            }
  1049. X        } else {
  1050. X            if (dbm_delete (gr_dbm, key))
  1051. X                ++errors;
  1052. X        }
  1053. X    }
  1054. X    key.dsize = sizeof gr->gr_gid;
  1055. X    key.dptr = (char *) &gr->gr_gid;
  1056. X    content = dbm_fetch (gr_dbm, key);
  1057. X    if (content.dptr == 0)
  1058. X        ++errors;
  1059. X    else {
  1060. X        if (content.dsize == sizeof (int)) {
  1061. X            memcpy ((char *) &cnt, content.dptr, sizeof cnt);
  1062. X
  1063. X            for (i = 0;i < cnt;i++) {
  1064. X                key.dsize = sizeof i + sizeof gr->gr_gid;
  1065. X                key.dptr = grpkey;
  1066. X                memcpy (grpkey, (char *) &i, sizeof i);
  1067. X                memcpy (grpkey + sizeof i, (char *) &gr->gr_gid,
  1068. X                    sizeof gr->gr_gid);
  1069. X
  1070. X                if (dbm_delete (gr_dbm, key))
  1071. X                    ++errors;
  1072. X            }
  1073. X        } else {
  1074. X            if (dbm_delete (gr_dbm, key))
  1075. X                ++errors;
  1076. X        }
  1077. X    }
  1078. X    return errors ? 0:1;
  1079. X}
  1080. X#endif
  1081. END_OF_FILE
  1082.   if test 3622 -ne `wc -c <'grdbm.c'`; then
  1083.     echo shar: \"'grdbm.c'\" unpacked with wrong size!
  1084.   fi
  1085.   # end of 'grdbm.c'
  1086. fi
  1087. if test -f 'gshadow.c' -a "${1}" != "-c" ; then 
  1088.   echo shar: Will not clobber existing file \"'gshadow.c'\"
  1089. else
  1090.   echo shar: Extracting \"'gshadow.c'\" \(4977 characters\)
  1091.   sed "s/^X//" >'gshadow.c' <<'END_OF_FILE'
  1092. X/*
  1093. X * Copyright 1990, 1991, 1992, 1993, John F. Haugh II
  1094. X * All rights reserved.
  1095. X *
  1096. X * Permission is granted to copy and create derivative works for any
  1097. X * non-commercial purpose, provided this copyright notice is preserved
  1098. X * in all copies of source code, or included in human readable form
  1099. X * and conspicuously displayed on all copies of object code or
  1100. X * distribution media.
  1101. X *
  1102. X * This software is provided on an AS-IS basis and the author makes
  1103. X * no warrantee of any kind.
  1104. X */
  1105. X
  1106. X#include "config.h"
  1107. X
  1108. X#ifdef    SHADOWGRP
  1109. X
  1110. X#include "shadow.h"
  1111. X#include <stdio.h>
  1112. X#ifndef    BSD
  1113. X#include <string.h>
  1114. X#include <memory.h>
  1115. X#else
  1116. X#include <strings.h>
  1117. X#define    strchr    index
  1118. X#define    strrchr    rindex
  1119. X#endif
  1120. X
  1121. X#ifdef    NDBM
  1122. X#include <ndbm.h>
  1123. X#include <fcntl.h>
  1124. XDBM    *sg_dbm;
  1125. Xint    sg_dbm_mode = -1;
  1126. Xstatic    int    dbmopened;
  1127. Xstatic    int    dbmerror;
  1128. X#endif
  1129. X
  1130. X
  1131. X#ifndef    lint
  1132. Xstatic    char    sccsid[] = "@(#)gshadow.c    3.9    08:57:38    10 Jun 1993";
  1133. X#endif
  1134. X
  1135. X#define    MAXMEM    1024
  1136. X
  1137. Xstatic    FILE    *shadow;
  1138. Xstatic    char    *sgrpfile = "/etc/gshadow";
  1139. Xstatic    char    sgrbuf[BUFSIZ*4];
  1140. Xstatic    char    *members[MAXMEM+1];
  1141. Xstatic    char    *admins[MAXMEM+1];
  1142. Xstatic    struct    sgrp    sgroup;
  1143. X
  1144. Xextern    char    *fgetsx();
  1145. Xextern    int    fputsx();
  1146. X
  1147. X#define    FIELDS    4
  1148. X
  1149. Xstatic char **
  1150. Xlist (s, l)
  1151. Xchar    *s;
  1152. Xchar    **l;
  1153. X{
  1154. X    int    nmembers = 0;
  1155. X
  1156. X    while (s && *s) {
  1157. X        l[nmembers++] = s;
  1158. X        if (s = strchr (s, ','))
  1159. X            *s++ = '\0';
  1160. X    }
  1161. X    l[nmembers] = (char *) 0;
  1162. X    return l;
  1163. X}
  1164. X
  1165. Xvoid
  1166. Xsetsgent ()
  1167. X{
  1168. X#ifdef    NDBM
  1169. X    int    mode;
  1170. X#endif    /* NDBM */
  1171. X
  1172. X    if (shadow)
  1173. X        rewind (shadow);
  1174. X    else
  1175. X        shadow = fopen (GSHADOW, "r");
  1176. X
  1177. X    /*
  1178. X     * Attempt to open the DBM files if they have never been opened
  1179. X     * and an error has never been returned.
  1180. X     */
  1181. X
  1182. X#ifdef NDBM
  1183. X    if (! dbmerror && ! dbmopened) {
  1184. X        char    dbmfiles[BUFSIZ];
  1185. X
  1186. X        strcpy (dbmfiles, sgrpfile);
  1187. X        strcat (dbmfiles, ".pag");
  1188. X
  1189. X        if (sg_dbm_mode == -1)
  1190. X            mode = O_RDWR;
  1191. X        else
  1192. X            mode = (sg_dbm_mode == O_RDWR) ? O_RDWR:O_RDONLY;
  1193. X
  1194. X        if (access (dbmfiles, 0) ||
  1195. X            (! (sg_dbm = dbm_open (sgrpfile, mode, 0))))
  1196. X            dbmerror = 1;
  1197. X        else
  1198. X            dbmopened = 1;
  1199. X    }
  1200. X#endif    /* NDBM */
  1201. X}
  1202. X
  1203. Xvoid
  1204. Xendsgent ()
  1205. X{
  1206. X    if (shadow)
  1207. X        (void) fclose (shadow);
  1208. X
  1209. X    shadow = (FILE *) 0;
  1210. X#ifdef    NDBM
  1211. X    if (dbmopened && sg_dbm) {
  1212. X        dbm_close (sg_dbm);
  1213. X        dbmopened = 0;
  1214. X        sg_dbm = 0;
  1215. X    }
  1216. X#endif
  1217. X}
  1218. X
  1219. Xstruct sgrp *
  1220. Xsgetsgent (string)
  1221. Xchar    *string;
  1222. X{
  1223. X    char    *fields[FIELDS];
  1224. X    char    *cp;
  1225. X    int    atoi ();
  1226. X    long    atol ();
  1227. X    int    i;
  1228. X
  1229. X    strncpy (sgrbuf, string, (int) sizeof sgrbuf - 1);
  1230. X    sgrbuf[sizeof sgrbuf - 1] = '\0';
  1231. X
  1232. X    if (cp = strrchr (sgrbuf, '\n'))
  1233. X        *cp = '\0';
  1234. X
  1235. X    /*
  1236. X     * There should be exactly 4 colon separated fields.  Find
  1237. X     * all 4 of them and save the starting addresses in fields[].
  1238. X     */
  1239. X
  1240. X    for (cp = sgrbuf, i = 0;i < FIELDS && cp;i++) {
  1241. X        fields[i] = cp;
  1242. X        if (cp = strchr (cp, ':'))
  1243. X            *cp++ = '\0';
  1244. X    }
  1245. X
  1246. X    /*
  1247. X     * If there was an extra field somehow, or perhaps not enough,
  1248. X     * the line is invalid.
  1249. X     */
  1250. X
  1251. X    if (cp || i != FIELDS)
  1252. X        return 0;
  1253. X
  1254. X    sgroup.sg_name = fields[0];
  1255. X    sgroup.sg_passwd = fields[1];
  1256. X    sgroup.sg_adm = list (fields[2], admins);
  1257. X    sgroup.sg_mem = list (fields[3], members);
  1258. X
  1259. X    return &sgroup;
  1260. X}
  1261. X
  1262. Xstruct sgrp
  1263. X*fgetsgent (fp)
  1264. XFILE    *fp;
  1265. X{
  1266. X    char    buf[sizeof sgrbuf];
  1267. X
  1268. X    if (! fp)
  1269. X        return (0);
  1270. X
  1271. X    if (fgetsx (buf, sizeof buf, fp) == (char *) 0)
  1272. X        return (0);
  1273. X
  1274. X    return sgetsgent (buf);
  1275. X}
  1276. X
  1277. Xstruct sgrp
  1278. X*getsgent ()
  1279. X{
  1280. X    if (! shadow)
  1281. X        setsgent ();
  1282. X
  1283. X    return (fgetsgent (shadow));
  1284. X}
  1285. X
  1286. Xstruct sgrp *
  1287. Xgetsgnam (name)
  1288. Xchar    *name;
  1289. X{
  1290. X    struct    sgrp    *sgrp;
  1291. X#ifdef NDBM
  1292. X    datum    key;
  1293. X    datum    content;
  1294. X#endif
  1295. X
  1296. X    setsgent ();
  1297. X
  1298. X#ifdef NDBM
  1299. X
  1300. X    /*
  1301. X     * If the DBM file are now open, create a key for this group and
  1302. X     * try to fetch the entry from the database.  A matching record
  1303. X     * will be unpacked into a static structure and returned to
  1304. X     * the user.
  1305. X     */
  1306. X
  1307. X    if (dbmopened) {
  1308. X        key.dsize = strlen (name);
  1309. X        key.dptr = name;
  1310. X
  1311. X        content = dbm_fetch (sg_dbm, key);
  1312. X        if (content.dptr != 0) {
  1313. X            memcpy (sgrbuf, content.dptr, content.dsize);
  1314. X            sgroup.sg_mem = members;
  1315. X            sgroup.sg_adm = admins;
  1316. X            sgr_unpack (sgrbuf, content.dsize, &sgroup);
  1317. X            return &sgroup;
  1318. X        }
  1319. X    }
  1320. X#endif
  1321. X    while ((sgrp = getsgent ()) != (struct sgrp *) 0) {
  1322. X        if (strcmp (name, sgrp->sg_name) == 0)
  1323. X            return (sgrp);
  1324. X    }
  1325. X    return (0);
  1326. X}
  1327. X
  1328. Xint
  1329. Xputsgent (sgrp, fp)
  1330. Xstruct    sgrp    *sgrp;
  1331. XFILE    *fp;
  1332. X{
  1333. X    char    buf[sizeof sgrbuf];
  1334. X    char    *cp = buf;
  1335. X    int    i;
  1336. X
  1337. X    if (! fp || ! sgrp)
  1338. X        return -1;
  1339. X
  1340. X    /*
  1341. X     * Copy the group name and passwd.
  1342. X     */
  1343. X
  1344. X    strcpy (cp, sgrp->sg_name);
  1345. X    cp += strlen (cp);
  1346. X    *cp++ = ':';
  1347. X
  1348. X    strcpy (cp, sgrp->sg_passwd);
  1349. X    cp += strlen (cp);
  1350. X    *cp++ = ':';
  1351. X
  1352. X    /*
  1353. X     * Copy the administrators, separating each from the other
  1354. X     * with a ",".
  1355. X     */
  1356. X
  1357. X    for (i = 0;sgrp->sg_adm[i];i++) {
  1358. X        if (i > 0)
  1359. X            *cp++ = ',';
  1360. X
  1361. X        strcpy (cp, sgrp->sg_adm[i]);
  1362. X        cp += strlen (cp);
  1363. X    }
  1364. X    *cp++ = ':';
  1365. X
  1366. X    /*
  1367. X     * Now do likewise with the group members.
  1368. X     */
  1369. X
  1370. X    for (i = 0;sgrp->sg_mem[i];i++) {
  1371. X        if (i > 0)
  1372. X            *cp++ = ',';
  1373. X
  1374. X        strcpy (cp, sgrp->sg_mem[i]);
  1375. X        cp += strlen (cp);
  1376. X    }
  1377. X    *cp++ = '\n';
  1378. X    *cp = '\0';
  1379. X
  1380. X    /*
  1381. X     * Output using the function which understands the line
  1382. X     * continuation conventions.
  1383. X     */
  1384. X
  1385. X    return fputsx (buf, fp);
  1386. X}
  1387. X
  1388. X#endif    /* SHADOWGRP */
  1389. END_OF_FILE
  1390.   if test 4977 -ne `wc -c <'gshadow.c'`; then
  1391.     echo shar: \"'gshadow.c'\" unpacked with wrong size!
  1392.   fi
  1393.   # end of 'gshadow.c'
  1394. fi
  1395. if test -f 'id.c' -a "${1}" != "-c" ; then 
  1396.   echo shar: Will not clobber existing file \"'id.c'\"
  1397. else
  1398.   echo shar: Extracting \"'id.c'\" \(3386 characters\)
  1399.   sed "s/^X//" >'id.c' <<'END_OF_FILE'
  1400. X/*
  1401. X * Copyright 1991, 1992, 1993, John F. Haugh II
  1402. X * All rights reserved.
  1403. X *
  1404. X * Permission is granted to copy and create derivative works for any
  1405. X * non-commercial purpose, provided this copyright notice is preserved
  1406. X * in all copies of source code, or included in human readable form
  1407. X * and conspicuously displayed on all copies of object code or
  1408. X * distribution media.
  1409. X *
  1410. X * This software is provided on an AS-IS basis and the author makes
  1411. X * no warrantee of any kind.
  1412. X */
  1413. X
  1414. X/*
  1415. X * id - print current process user identification information
  1416. X *
  1417. X *    Print the current process identifiers.  This includes the
  1418. X *    UID, GID, effective-UID and effective-GID.  Optionally print
  1419. X *    the concurrent group set if the current system supports it.
  1420. X */
  1421. X
  1422. X#include <sys/types.h>
  1423. X#include <stdio.h>
  1424. X#include <grp.h>
  1425. X#include "config.h"
  1426. X#include "pwd.h"
  1427. X
  1428. X#ifndef    lint
  1429. Xstatic    char    sccsid[] = "@(#)id.c    3.7    07:17:31    03 Jun 1993";
  1430. X#endif
  1431. X
  1432. Xusage ()
  1433. X{
  1434. X#if NGROUPS > 0
  1435. X    fprintf (stderr, "usage: id [ -a ]\n");
  1436. X#else
  1437. X    fprintf (stderr, "usage: id\n");
  1438. X#endif
  1439. X    exit (1);
  1440. X}
  1441. X
  1442. X/*ARGSUSED*/
  1443. Xmain (argc, argv)
  1444. Xint    argc;
  1445. Xchar    **argv;
  1446. X{
  1447. X    int    id;
  1448. X#if NGROUPS > 0
  1449. X#if NGROUPS > 100
  1450. X    GID_T    *groups;
  1451. X#else
  1452. X    GID_T    groups[NGROUPS];
  1453. X#endif
  1454. X    int    ngroups;
  1455. X    int    aflg = 0;
  1456. X#endif
  1457. X    struct    passwd    *pw,
  1458. X            *getpwuid();
  1459. X    struct    group    *gr,
  1460. X            *getgrgid();
  1461. X
  1462. X#if NGROUPS > 0
  1463. X    /*
  1464. X     * See if the -a flag has been given to print out the
  1465. X     * concurrent group set.
  1466. X     */
  1467. X
  1468. X    if (argc > 1) {
  1469. X        if (argc > 2 || strcmp (argv[1], "-a"))
  1470. X            usage ();
  1471. X        else
  1472. X            aflg = 1;
  1473. X    }
  1474. X#else
  1475. X    if (argc > 1)
  1476. X        usage ();
  1477. X#endif
  1478. X
  1479. X    /*
  1480. X     * Print out the real user ID and group ID.  If the user or
  1481. X     * group does not exist, just give the numerical value.
  1482. X     */
  1483. X
  1484. X    if (pw = getpwuid (id = getuid ()))
  1485. X        printf ("uid=%d(%s)", id, pw->pw_name);
  1486. X    else
  1487. X        printf ("uid=%d", id);
  1488. X
  1489. X    if (gr = getgrgid (id = getgid ()))
  1490. X        printf (" gid=%d(%s)", id, gr->gr_name);
  1491. X    else
  1492. X        printf (" gid=%d", id);
  1493. X
  1494. X    /*
  1495. X     * Print out the effective user ID and group ID if they are
  1496. X     * different from the real values.
  1497. X     */
  1498. X
  1499. X    if (getuid () != geteuid ()) {
  1500. X        if (pw = getpwuid (id = geteuid ()))
  1501. X            printf (" euid=%d(%s)", id, pw->pw_name);
  1502. X        else
  1503. X            printf (" euid=%d", id);
  1504. X    }
  1505. X    if (getgid () != getegid ()) {
  1506. X        if (gr = getgrgid (id = getegid ()))
  1507. X            printf (" egid=%d(%s)", id, gr->gr_name);
  1508. X        else
  1509. X            printf (" egid=%d", id);
  1510. X    }
  1511. X#if NGROUPS > 0
  1512. X
  1513. X    /*
  1514. X     * Print out the concurrent group set if the user has requested
  1515. X     * it.  The group numbers will be printed followed by their
  1516. X     * names.
  1517. X     */
  1518. X
  1519. X    if (aflg && (ngroups = getgroups (0, 0)) != -1) {
  1520. X        int    i;
  1521. X
  1522. X#if NGROUPS > 100
  1523. X        /*
  1524. X         * The size of the group set is determined so an array
  1525. X         * large enough to hold it can be allocated.
  1526. X         */
  1527. X
  1528. X        if (groups = (int *) malloc (ngroups * sizeof *groups)) {
  1529. X            putchar ('\n');
  1530. X            perror ("out of memory");
  1531. X            exit (1);
  1532. X        }
  1533. X#endif
  1534. X        /*
  1535. X         * Start off the group message.  It will be of the format
  1536. X         *
  1537. X         *    groups=###(aaa),###(aaa),###(aaa)
  1538. X         *
  1539. X         * where "###" is a numerical value and "aaa" is the
  1540. X         * corresponding name for each respective numerical value.
  1541. X         */
  1542. X
  1543. X        getgroups (ngroups, groups);
  1544. X        printf (" groups=");
  1545. X        for (i = 0;i < ngroups;i++) {
  1546. X            if (i)
  1547. X                putchar (',');
  1548. X
  1549. X            if (gr = getgrgid (groups[i]))
  1550. X                printf ("%d(%s)", (int) groups[i], gr->gr_name);
  1551. X            else
  1552. X                printf ("%d", (int) groups[i]);
  1553. X        }
  1554. X    }
  1555. X#endif
  1556. X
  1557. X    /*
  1558. X     * Finish off the line.
  1559. X     */
  1560. X
  1561. X    putchar ('\n');
  1562. X    exit (0);
  1563. X    /*NOTREACHED*/
  1564. X}
  1565. END_OF_FILE
  1566.   if test 3386 -ne `wc -c <'id.c'`; then
  1567.     echo shar: \"'id.c'\" unpacked with wrong size!
  1568.   fi
  1569.   # end of 'id.c'
  1570. fi
  1571. if test -f 'login.1' -a "${1}" != "-c" ; then 
  1572.   echo shar: Will not clobber existing file \"'login.1'\"
  1573. else
  1574.   echo shar: Extracting \"'login.1'\" \(3347 characters\)
  1575.   sed "s/^X//" >'login.1' <<'END_OF_FILE'
  1576. X.\" Copyright 1989, 1990, John F. Haugh II
  1577. X.\" All rights reserved.
  1578. X.\"
  1579. X.\" Use, duplication, and disclosure prohibited without
  1580. X.\" the express written permission of the author.
  1581. X.\"
  1582. X.\"    @(#)login.1    3.1    09:34:21    21 Nov 1990
  1583. X.\"
  1584. X.TH LOGIN 1
  1585. X.SH NAME
  1586. Xlogin \- Begin session on the system
  1587. X.SH SYNOPSIS
  1588. X.B login
  1589. X[ username [ environmental-variables ] ]
  1590. X.SH DESCRIPTION
  1591. X.I login
  1592. Xis used to establish a new session with the system.
  1593. XIt is normally invoked automatically by responding to the
  1594. X.B login:
  1595. Xprompt on the user\'s terminal.
  1596. X.I login
  1597. Xmay be special to the shell and may not be invoked as a sub-process.
  1598. XTypically,
  1599. X.I login
  1600. Xis treated by the shell as \fBexec login\fR which causes the user
  1601. Xto exit from the current shell.
  1602. XAttempting to execute \fIlogin\fR from any shell but the login shell
  1603. Xwill produce an error message.
  1604. X.PP
  1605. XWhen invoked from the \fBlogin:\fR prompt, the user may enter
  1606. Xenvironmental variables after the username.
  1607. XThese variables are entered in the form \fBNAME=VALUE\fR.
  1608. XNot all variables may be set in the fashion, notably \fBPATH\fR,
  1609. X\fBHOME\fR and \fBSHELL\fR.
  1610. XAdditionally, \fBIFS\fR may be inhibited if the user\'s login
  1611. Xshell is \fB/bin/sh\fR.
  1612. X.PP
  1613. XThe user is then prompted for a password, where appropriate.
  1614. XEchoing is disabled to prevent revealing the password.
  1615. XOnly a small number of password failures are permitted before
  1616. X\fIlogin\fR exits and the communications link is severed.
  1617. X.PP
  1618. XIf password aging has been enabled for your account, you may be
  1619. Xprompted for a new password before proceeding.
  1620. XYou will be forced to provide your old password and the new
  1621. Xpassword before continuing.
  1622. XPlease refer to \fIpasswd(1)\fR for more information.
  1623. X.PP
  1624. XAfter a successful login,
  1625. Xyou will be informed of any system messages and the presence
  1626. Xof mail.
  1627. XYou may turn off the printing of the system message file,
  1628. X\fI/etc/motd\fR, by creating a zero-length file \fI.hushlogin\fR
  1629. Xin your login directory.
  1630. XThe mail message will be one of "\fIYou have new mail.\fR",
  1631. X"\fIYou have mail.\fR", or "\fINo Mail.\fR" according to
  1632. Xthe condition of your mailbox.
  1633. X.PP
  1634. XYour user and group ID will be set according to their values in
  1635. Xthe \fI/etc/passwd\fR file.
  1636. XThe value for \fB$HOME\fR, \fB$SHELL\fR, \fB$PATH\fR, \fB$LOGNAME\fR,
  1637. Xand \fB$MAIL\fR are set according to the appropriate fields in the
  1638. Xpassword entry.
  1639. XUlimit, umask and nice values may also be set according to
  1640. Xentries in the GECOS field.
  1641. X.PP
  1642. XOn some installations, the environmental variable \fB$TERM\fR will be
  1643. Xinitialize to the terminal type on your tty line, as specified in
  1644. X\fI/etc/ttytype\fR.
  1645. X.PP
  1646. XAn initialization script for your command interpreter may also be
  1647. Xexecuted.
  1648. XPlease see the appropriate manual section for more information on
  1649. Xthis function.
  1650. X.SH CAVEATS
  1651. X.PP
  1652. XThis version of \fIlogin\fR has many compilation options, only some of which
  1653. Xmay be in use at any particular site.
  1654. X.SH Files
  1655. X/etc/utmp \- list of current login sessions
  1656. X.br
  1657. X/etc/wtmp \- list of previous login sessions
  1658. X.br
  1659. X/etc/passwd \- user account information
  1660. X.br
  1661. X/etc/shadow \- encrypted passwords and age information
  1662. X.br
  1663. X/etc/motd \- system message file
  1664. X.br
  1665. X/etc/ttytype \- list of terminal types
  1666. X.br
  1667. X$HOME/.profile \- initialization script for default shell
  1668. X.br
  1669. X$HOME/.hushlogin \- suppress printing of system messages
  1670. X.br
  1671. X.SH See Also
  1672. X.PP
  1673. Xgetty(1M),
  1674. Xmail(1),
  1675. Xpasswd(1),
  1676. Xsh(1),
  1677. Xsu(1),
  1678. Xd_passwd(4),
  1679. Xpasswd(4)
  1680. END_OF_FILE
  1681.   if test 3347 -ne `wc -c <'login.1'`; then
  1682.     echo shar: \"'login.1'\" unpacked with wrong size!
  1683.   fi
  1684.   # end of 'login.1'
  1685. fi
  1686. if test -f 'obscure.c' -a "${1}" != "-c" ; then 
  1687.   echo shar: Will not clobber existing file \"'obscure.c'\"
  1688. else
  1689.   echo shar: Extracting \"'obscure.c'\" \(4080 characters\)
  1690.   sed "s/^X//" >'obscure.c' <<'END_OF_FILE'
  1691. X/*
  1692. X * Copyright 1989, 1990, 1991, 1992, 1993, John F. Haugh II
  1693. X * All rights reserved.
  1694. X *
  1695. X * Permission is granted to copy and create derivative works for any
  1696. X * non-commercial purpose, provided this copyright notice is preserved
  1697. X * in all copies of source code, or included in human readable form
  1698. X * and conspicuously displayed on all copies of object code or
  1699. X * distribution media.
  1700. X */
  1701. X
  1702. X/*
  1703. X * This version of obscure.c contains modifications to support "cracklib"
  1704. X * by Alec Muffet (alec.muffett@uk.sun.com).  You must obtain the Cracklib
  1705. X * library source code for this function to operate.
  1706. X */
  1707. X
  1708. X#include <ctype.h>
  1709. X#ifndef    BSD
  1710. X#include <string.h>
  1711. X#include <memory.h>
  1712. X#else
  1713. X#include <strings.h>
  1714. X#define    strchr    index
  1715. X#define    strrchr    rindex
  1716. X#endif
  1717. X#include "config.h"
  1718. X
  1719. X#ifndef    lint
  1720. Xstatic    char    sccsid[] = "@(#)obscure.c    3.7    18:10:59    03 Jul 1993";
  1721. X#endif
  1722. X
  1723. Xextern    int    getdef_bool();
  1724. Xextern    int    getdef_num();
  1725. X
  1726. X#ifdef    NEED_STRSTR
  1727. X/*
  1728. X * strstr - find substring in string
  1729. X */
  1730. X
  1731. Xchar *
  1732. Xstrstr (string, pattern)
  1733. Xchar    *string;
  1734. Xchar    *pattern;
  1735. X{
  1736. X    char    *cp;
  1737. X    int    len;
  1738. X
  1739. X    len = strlen (pattern);
  1740. X
  1741. X    for (cp = string;cp = strchr (cp, *pattern);) {
  1742. X        if (strncmp (cp, pattern, len) == 0)
  1743. X            return cp;
  1744. X
  1745. X        cp++;
  1746. X    }
  1747. X    return 0;
  1748. X}
  1749. X#endif
  1750. X
  1751. X/*
  1752. X * Obscure - see if password is obscure enough.
  1753. X *
  1754. X *    The programmer is encouraged to add as much complexity to this
  1755. X *    routine as desired.  Included are some of my favorite ways to
  1756. X *    check passwords.
  1757. X */
  1758. X
  1759. X/*ARGSUSED*/
  1760. Xint    obscure (old, new)
  1761. Xchar    *old;
  1762. Xchar    *new;
  1763. X{
  1764. X    int    i;
  1765. X    char    oldmono[32];
  1766. X    char    newmono[32];
  1767. X    char    wrapped[64];
  1768. X#ifdef    CRACKLIB_DICTPATH
  1769. X    char    *msg;
  1770. X    char    *FascistCheck();
  1771. X#endif
  1772. X
  1773. X    if (old[0] == '\0')
  1774. X        return (1);
  1775. X
  1776. X    if ( strlen(new) < getdef_num("PASS_MIN_LEN", 0) ) {
  1777. X        printf ("Too short.  ");
  1778. X        return (0);
  1779. X    }
  1780. X
  1781. X    /*
  1782. X     * Remaining checks are optional.
  1783. X     */
  1784. X    if ( !getdef_bool("OBSCURE_CHECKS_ENAB") )
  1785. X        return (1);
  1786. X
  1787. X    for (i = 0;new[i];i++)
  1788. X        newmono[i] = tolower (new[i]);
  1789. X
  1790. X    for (i = 0;old[i];i++)
  1791. X        oldmono[i] = tolower (old[i]); 
  1792. X
  1793. X    if (strcmp (new, old) == 0) {    /* the same */
  1794. X        printf ("No Change.  ");
  1795. X        return (0);
  1796. X    }
  1797. X    if (palindrome (newmono, oldmono))    /* a palindrome */
  1798. X        return (0);
  1799. X
  1800. X    if (strcmp (newmono, oldmono) == 0) {    /* case shifted */
  1801. X        printf ("Case changes only.  ");
  1802. X        return (0);
  1803. X    }
  1804. X    if (similiar (newmono, oldmono))    /* jumbled version */
  1805. X        return (0);
  1806. X
  1807. X    if (simple (old, new))            /* keyspace size */
  1808. X        return (0);
  1809. X
  1810. X    strcpy (wrapped, oldmono);
  1811. X    strcat (wrapped, oldmono);
  1812. X    if (strstr (wrapped, newmono)) {
  1813. X        printf ("Rotated.  ");
  1814. X        return (0);
  1815. X    }
  1816. X#ifdef CRACKLIB_DICTPATH    
  1817. X
  1818. X    /*
  1819. X     * Invoke Alec Muffett's cracklib routines.
  1820. X     */
  1821. X
  1822. X    if (msg = FascistCheck (new, CRACKLIB_DICTPATH)) {
  1823. X        printf("Bad Password: %s.  ", msg);
  1824. X        return (0);
  1825. X    }
  1826. X#endif /* CRACKLIB_DICTPATH */
  1827. X
  1828. X    return (1);
  1829. X}
  1830. X
  1831. X/*
  1832. X * can't be a palindrome - like `R A D A R' or `M A D A M'
  1833. X */
  1834. X
  1835. X/*ARGSUSED*/
  1836. Xint    palindrome (old, new)
  1837. Xchar    *old;
  1838. Xchar    *new;
  1839. X{
  1840. X    int    i, j;
  1841. X
  1842. X    i = strlen (new);
  1843. X
  1844. X    for (j = 0;j < i;j++)
  1845. X        if (new[i - j - 1] != new[j])
  1846. X            return (0);
  1847. X
  1848. X    printf ("A palindrome.  ");
  1849. X    return (1);
  1850. X}
  1851. X
  1852. X/*
  1853. X * more than half of the characters are different ones.
  1854. X */
  1855. X
  1856. X/*ARGSUSED*/
  1857. Xint    similiar (old, new)
  1858. Xchar    *old;
  1859. Xchar    *new;
  1860. X{
  1861. X    int    i, j;
  1862. X    char    *strchr ();
  1863. X
  1864. X    for (i = j = 0;new[i] && old[i];i++)
  1865. X        if (strchr (new, tolower (old[i])))
  1866. X            j++;
  1867. X
  1868. X    if (i >= j * 2)
  1869. X        return (0);
  1870. X
  1871. X    printf ("Too similiar.  ");
  1872. X    return (1);
  1873. X}
  1874. X
  1875. X/*
  1876. X * a nice mix of characters.
  1877. X */
  1878. X
  1879. X/*ARGSUSED*/
  1880. Xint    simple (old, new)
  1881. Xchar    *old;
  1882. Xchar    *new;
  1883. X{
  1884. X    int    digits = 0;
  1885. X    int    uppers = 0;
  1886. X    int    lowers = 0;
  1887. X    int    others = 0;
  1888. X    int    size;
  1889. X    int    i;
  1890. X
  1891. X    for (i = 0;new[i];i++) {
  1892. X        if (isdigit (new[i]))
  1893. X            digits++;
  1894. X        else if (isupper (new[i]))
  1895. X            uppers++;
  1896. X        else if (islower (new[i]))
  1897. X            lowers++;
  1898. X        else
  1899. X            others++;
  1900. X    }
  1901. X
  1902. X    /*
  1903. X     * The scam is this - a password of only one character type
  1904. X     * must be 8 letters long.  Two types, 7, and so on.
  1905. X     */
  1906. X
  1907. X    size = 9;
  1908. X    if (digits) size--;
  1909. X    if (uppers) size--;
  1910. X    if (lowers) size--;
  1911. X    if (others) size--;
  1912. X
  1913. X    if (size <= i)
  1914. X        return 0;
  1915. X
  1916. X    printf ("Too Simple.  Use a longer password, or a mix of upper\n");
  1917. X    printf ("and lower case letters and numerics.  ");
  1918. X    return 1;
  1919. X}
  1920. END_OF_FILE
  1921.   if test 4080 -ne `wc -c <'obscure.c'`; then
  1922.     echo shar: \"'obscure.c'\" unpacked with wrong size!
  1923.   fi
  1924.   # end of 'obscure.c'
  1925. fi
  1926. if test -f 'pwconv.c' -a "${1}" != "-c" ; then 
  1927.   echo shar: Will not clobber existing file \"'pwconv.c'\"
  1928. else
  1929.   echo shar: Extracting \"'pwconv.c'\" \(4449 characters\)
  1930.   sed "s/^X//" >'pwconv.c' <<'END_OF_FILE'
  1931. X/*
  1932. X * Copyright 1989, 1990, 1991, John F. Haugh II
  1933. X * All rights reserved.
  1934. X *
  1935. X * Permission is granted to copy and create derivative works for any
  1936. X * non-commercial purpose, provided this copyright notice is preserved
  1937. X * in all copies of source code, or included in human readable form
  1938. X * and conspicuously displayed on all copies of object code or
  1939. X * distribution media.
  1940. X *
  1941. X * pwconv - convert and update shadow password files
  1942. X *
  1943. X *    Pwconv copies the old password file information to a new shadow
  1944. X *    password file, merging entries from an optional existing shadow
  1945. X *    file.
  1946. X *
  1947. X *    The new password file is left in npasswd, the new shadow file is
  1948. X *    left in nshadow.  Existing shadow entries are copied as is.
  1949. X *    New entries are created with passwords which expire in MAXDAYS days,
  1950. X *    with a last changed date of today, unless password aging
  1951. X *    information was already present.  Likewise, the minimum number of
  1952. X *    days before which the password may be changed is controlled by
  1953. X *    MINDAYS.  The number of warning days is set to WARNAGE if that
  1954. X *    macro exists.  Entries with blank passwordsare not copied to the
  1955. X *    shadow file at all.
  1956. X */
  1957. X
  1958. X#include <sys/types.h>
  1959. X#include <stdio.h>
  1960. X#include <fcntl.h>
  1961. X#include "pwd.h"
  1962. X#ifndef    BSD
  1963. X#include <string.h>
  1964. X#else
  1965. X#define    strchr    index
  1966. X#define    strrchr    rindex
  1967. X#include <strings.h>
  1968. X#endif
  1969. X#include "config.h"
  1970. X#include "shadow.h"
  1971. X
  1972. X#ifndef    lint
  1973. Xstatic    char    _sccsid[] = "@(#)pwconv.c    3.4    07:43:52    17 Sep 1991";
  1974. X#endif
  1975. X
  1976. Xchar    buf[BUFSIZ];
  1977. X
  1978. Xlong    time ();
  1979. Xlong    a64l ();
  1980. Xextern    int    getdef_num();
  1981. X
  1982. Xint    main ()
  1983. X{
  1984. X    long    today;
  1985. X    struct    passwd    *pw;
  1986. X    struct    passwd    *sgetpwent ();
  1987. X    FILE    *pwd;
  1988. X    FILE    *npwd;
  1989. X    FILE    *shadow;
  1990. X    struct    spwd    *spwd;
  1991. X    struct    spwd    tspwd;
  1992. X    int    fd;
  1993. X    char    *cp;
  1994. X
  1995. X    if (! (pwd = fopen (PWDFILE, "r"))) {
  1996. X        perror (PWDFILE);
  1997. X        exit (1);
  1998. X    }
  1999. X    unlink ("npasswd");
  2000. X    if ((fd = open ("npasswd", O_WRONLY|O_CREAT|O_EXCL, 0644)) < 0 ||
  2001. X            ! (npwd = fdopen (fd, "w"))) {
  2002. X        perror ("npasswd");
  2003. X        exit (1);
  2004. X    }
  2005. X    unlink  ("nshadow");
  2006. X    if ((fd = open ("nshadow", O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0 ||
  2007. X            ! (shadow = fdopen (fd, "w"))) {
  2008. X        perror ("nshadow");
  2009. X        (void) unlink ("npasswd");
  2010. X        (void) unlink ("nshadow");
  2011. X        exit (1);
  2012. X    }
  2013. X
  2014. X    (void) time (&today);
  2015. X    today /= (24L * 60L * 60L);
  2016. X
  2017. X    while (fgets (buf, BUFSIZ, pwd) == buf) {
  2018. X        if (cp = strrchr (buf, '\n'))
  2019. X            *cp = '\0';
  2020. X
  2021. X        if (buf[0] == '#') {    /* comment line */
  2022. X            (void) fprintf (npwd, "%s\n", buf);
  2023. X            continue;
  2024. X        }
  2025. X        if (! (pw = sgetpwent (buf))) { /* copy bad lines verbatim */
  2026. X            (void) fprintf (npwd, "%s\n", buf);
  2027. X            continue;
  2028. X        }
  2029. X        if (pw->pw_passwd[0] == '\0') { /* no password, skip */
  2030. X            (void) fprintf (npwd, "%s\n", buf);
  2031. X            continue;
  2032. X        }
  2033. X        setspent ();        /* rewind old shadow file */
  2034. X
  2035. X        if (spwd = getspnam (pw->pw_name)) {
  2036. X            if (putspent (spwd, shadow)) { /* copy old entry */
  2037. X                perror ("nshadow");
  2038. X                goto error;
  2039. X            }
  2040. X        } else {        /* need a new entry. */
  2041. X            tspwd.sp_namp = pw->pw_name;
  2042. X            tspwd.sp_pwdp = pw->pw_passwd;
  2043. X            pw->pw_passwd = "x";
  2044. X#ifdef    ATT_AGE
  2045. X            if (pw->pw_age) { /* copy old password age stuff */
  2046. X                if (strlen (pw->pw_age) >= 2) {
  2047. X                    tspwd.sp_min = c64i (pw->pw_age[1]);
  2048. X                    tspwd.sp_max = c64i (pw->pw_age[0]);
  2049. X                } else {
  2050. X                    tspwd.sp_min = tspwd.sp_max = -1;
  2051. X                }
  2052. X                if (strlen (pw->pw_age) == 4)
  2053. X                    tspwd.sp_lstchg = a64l (&pw->pw_age[2]);
  2054. X                else
  2055. X                    tspwd.sp_lstchg = -1;
  2056. X
  2057. X                /*
  2058. X                 * Convert weeks to days
  2059. X                 */
  2060. X
  2061. X                if (tspwd.sp_min != -1)
  2062. X                    tspwd.sp_min *= 7;
  2063. X
  2064. X                if (tspwd.sp_max != -1)
  2065. X                    tspwd.sp_max *= 7;
  2066. X
  2067. X                if (tspwd.sp_lstchg != -1)
  2068. X                    tspwd.sp_lstchg *= 7;
  2069. X            } else
  2070. X#endif    /* ATT_AGE */
  2071. X            {    /* fake up new password age stuff */
  2072. X                tspwd.sp_max =
  2073. X                    getdef_num("PASS_MAX_DAYS", 10000);
  2074. X                tspwd.sp_min = getdef_num("PASS_MIN_DAYS", 0);
  2075. X                tspwd.sp_lstchg = today;
  2076. X            }
  2077. X            tspwd.sp_warn = getdef_num("PASS_WARN_AGE", -1);
  2078. X            tspwd.sp_inact = tspwd.sp_expire = tspwd.sp_flag = -1;
  2079. X            if (putspent (&tspwd, shadow)) { /* output entry */
  2080. X                perror ("nshadow");
  2081. X                goto error;
  2082. X            }
  2083. X        }
  2084. X        (void) fprintf (npwd, "%s:%s:%d:%d:%s:%s:",
  2085. X                pw->pw_name, pw->pw_passwd,
  2086. X                pw->pw_uid, pw->pw_gid,
  2087. X                pw->pw_gecos, pw->pw_dir);
  2088. X
  2089. X        if (fprintf (npwd, "%s\n",
  2090. X                pw->pw_shell ? pw->pw_shell:"") == EOF) {
  2091. X            perror ("npasswd");
  2092. X            goto error;
  2093. X        }
  2094. X    }
  2095. X    endspent ();
  2096. X
  2097. X    if (ferror (npwd) || ferror (shadow)) {
  2098. X        perror ("pwconv");
  2099. Xerror:
  2100. X        (void) unlink ("npasswd");
  2101. X        (void) unlink ("nshadow");
  2102. X        exit (1);
  2103. X    }
  2104. X    (void) fclose (pwd);
  2105. X    (void) fclose (npwd);
  2106. X    (void) fclose (shadow);
  2107. X
  2108. X    exit (0);
  2109. X}
  2110. END_OF_FILE
  2111.   if test 4449 -ne `wc -c <'pwconv.c'`; then
  2112.     echo shar: \"'pwconv.c'\" unpacked with wrong size!
  2113.   fi
  2114.   # end of 'pwconv.c'
  2115. fi
  2116. if test -f 'shadow.3' -a "${1}" != "-c" ; then 
  2117.   echo shar: Will not clobber existing file \"'shadow.3'\"
  2118. else
  2119.   echo shar: Extracting \"'shadow.3'\" \(3624 characters\)
  2120.   sed "s/^X//" >'shadow.3' <<'END_OF_FILE'
  2121. X.\" Copyright 1989, 1990, 1992, 1993, John F. Haugh II
  2122. X.\" All rights reserved.
  2123. X.\"
  2124. X.\" Permission is granted to copy and create derivative works for any
  2125. X.\" non-commercial purpose, provided this copyright notice is preserved
  2126. X.\" in all copies of source code, or included in human readable form
  2127. X.\" and conspicuously displayed on all copies of object code or
  2128. X.\" distribution media.
  2129. X.\"
  2130. X.\" This software is provided on an AS-IS basis and the author makes
  2131. X.\" no warrantee of any kind.
  2132. X.\"
  2133. X.\"    @(#)shadow.3    3.2    07:54:45    06 May 1993
  2134. X.\"
  2135. X.TH SHADOW 3
  2136. X.SH NAME
  2137. Xshadow \- encrypted password file routines
  2138. X.SH SYNTAX
  2139. X#include <shadow.h>
  2140. X.br
  2141. Xstruct spwd *getspent();
  2142. X.br
  2143. Xstruct spwd *getspnam(char * name);
  2144. X.br
  2145. Xvoid setspent();
  2146. X.br
  2147. Xvoid endspent();
  2148. X.br
  2149. Xstruct spwd *fgetspent(FILE *fp);
  2150. X.br
  2151. Xstruct spwd *sgetspent(char *cp);
  2152. X.br
  2153. Xint putspent(struct spwd *p,FILE *fp);
  2154. X.br
  2155. Xint lckpwdf ();
  2156. X.br
  2157. Xint ulckpwdf ();
  2158. X.SH DESCRIPTION
  2159. X.I shadow
  2160. Xmanipulates the contents of the shadow password file,
  2161. X\fB/etc/shadow\fR.
  2162. XThe structure in the \fI#include\fR file is
  2163. X.sp
  2164. Xstruct spwd {
  2165. X.in +.5i
  2166. X.br
  2167. X    char    *sp_namp; /* user login name */
  2168. X.br
  2169. X    char    *sp_pwdp; /* encrypted password */
  2170. X.br
  2171. X    long    sp_lstchg; /* last password change */
  2172. X.br
  2173. X    int    sp_min; /* days until change allowed. */
  2174. X.br
  2175. X    int    sp_max; /* days before change required */
  2176. X.br
  2177. X    int    sp_warn; /* days warning for expiration */
  2178. X.br
  2179. X    int    sp_inact; /* days before account inactive */
  2180. X.br
  2181. X    int    sp_expire; /* date when account expires */
  2182. X.br
  2183. X    int    sp_flag; /* reserved for future use */
  2184. X.br
  2185. X.in -.5i
  2186. X}
  2187. X.PP
  2188. XThe meanings of each field are
  2189. X.sp
  2190. Xsp_namp \- pointer to null-terminated user name.
  2191. X.br
  2192. Xsp_pwdp \- pointer to null-terminated password.
  2193. X.br
  2194. Xsp_lstchg \- days since Jan 1, 1970 password was last changed.
  2195. X.br
  2196. Xsp_min \- days before which password may not be changed.
  2197. X.br
  2198. Xsp_max \- days after which password must be changed.
  2199. X.br
  2200. Xsp_warn \- days before password is to expire that user is warned
  2201. Xof pending password expiration.
  2202. X.br
  2203. Xsp_inact \- days after password expires that account is considered
  2204. Xinactive and disabled.
  2205. X.br
  2206. Xsp_expire \- days since Jan 1, 1970 when account will be disabled.
  2207. X.br
  2208. Xsp_flag \- reserved for future use.
  2209. X.SH DESCRIPTION
  2210. X\fIgetspent\fR, \fIgetspname\fR, \fIfgetspent\fR, and \fIsgetspent\fR
  2211. Xeach return a pointer to a \fBstruct spwd\fR.
  2212. X\fIgetspent\fR returns the
  2213. Xnext entry from the file, and \fIfgetspent\fR returns the next
  2214. Xentry from the given stream, which is assumed to be a file of
  2215. Xthe proper format.
  2216. X\fIsgetspent\fR returns a pointer to a \fBstruct spwd\fR using the
  2217. Xprovided string as input.
  2218. X\fIgetspnam\fR searches from the current position in the file for
  2219. Xan entry matching \fIname\fR.
  2220. X.PP
  2221. X\fIsetspent\fR and \fIendspent\fR may be used to begin and end,
  2222. Xrespectively, access to the shadow password file.
  2223. X.PP
  2224. XThe \fIlckpwdf\fR and \fIulckpwdf\fR routines should be used to
  2225. Xinsure exclusive access to the \fB/etc/shadow\fR file.
  2226. X\fIlckpwdf\fR attempts to acquire a lock using \fIpw_lock\fR for
  2227. Xup to 15 seconds.
  2228. XIt continues by attempting to acquire a second lock using \fIspw_lock\fR
  2229. Xfor the remainder of the initial 15 seconds.
  2230. XShould either attempt fail after a total of 15 seconds, \fIlckpwdf\fR
  2231. Xreturns -1.
  2232. XWhen both locks are acquired 0 is returned.
  2233. X.SH DIAGNOSTICS
  2234. XRoutines return NULL if no more entries are available or if an
  2235. Xerror occurs during processing.
  2236. XRoutines which have \fBint\fR as the return value return 0 for
  2237. Xsuccess and -1 for failure.
  2238. X.SH CAVEATS
  2239. XThese routines may only be used by the super user as access to
  2240. Xthe shadow password file is restricted.
  2241. X.SH FILES
  2242. X/etc/shadow \- encrypted user passwords
  2243. X.SH SEE ALSO
  2244. Xgetpwent(3),
  2245. Xshadow(4)
  2246. END_OF_FILE
  2247.   if test 3624 -ne `wc -c <'shadow.3'`; then
  2248.     echo shar: \"'shadow.3'\" unpacked with wrong size!
  2249.   fi
  2250.   # end of 'shadow.3'
  2251. fi
  2252. if test -f 'usermod.1' -a "${1}" != "-c" ; then 
  2253.   echo shar: Will not clobber existing file \"'usermod.1'\"
  2254. else
  2255.   echo shar: Extracting \"'usermod.1'\" \(4212 characters\)
  2256.   sed "s/^X//" >'usermod.1' <<'END_OF_FILE'
  2257. X.\" Copyright 1991, 1992, 1993, John F. Haugh II
  2258. X.\" All rights reserved.
  2259. X.\"
  2260. X.\" Permission is granted to copy and create derivative works for any
  2261. X.\" non-commercial purpose, provided this copyright notice is preserved
  2262. X.\" in all copies of source code, or included in human readable form
  2263. X.\" and conspicuously displayed on all copies of object code or
  2264. X.\" distribution media.
  2265. X.\"
  2266. X.\" This software is provided on an AS-IS basis and the author makes
  2267. X.\" no warrantee of any kind.
  2268. X.\"
  2269. X.\"    @(#)usermod.1    3.4    08:10:31    07 May 1993
  2270. X.\"
  2271. X.TH USERMOD 1M
  2272. X.SH NAME
  2273. Xusermod \- Modify a user account
  2274. X.SH SYNOPSIS
  2275. X.B usermod
  2276. X[ \fB-A\fI method\fR | \fBDEFAULT\fR ]
  2277. X[ \fB-c\fI comment\fR ]
  2278. X[ \fB-d\fI home_dir \fR[ \fB-m\fR ] ]
  2279. X[ \fB-e\fI expire_date\fR ]
  2280. X[ \fB-f\fI inactive_time\fR ]
  2281. X[ \fB-g\fI initial_group\fR ]
  2282. X[ \fB-G\fI group[,...]\fR ]
  2283. X[ \fB-l\fI login_name \fR ]
  2284. X[ \fB-s\fI shell\fR ]
  2285. X[ \fB-u\fI uid \fR[ \fB-o\fR ]
  2286. X.I login
  2287. X.SH DESCRIPTION
  2288. XThe \fIusermod\fR command modifies the system account files to reflect
  2289. Xthe changes that are specified on the command line.
  2290. XThe options which apply to the \fIusermod\fR command are
  2291. X.IP "\fB-A \fImethod\fR|\fBDEFAULT\fR"
  2292. XThe new value of the user's authentication method.
  2293. XThe authentication method is the name of a program which is responsible
  2294. Xfor validating the user's identity.
  2295. XThe string \fBDEFAULT\fR may be used to change the user's authentication
  2296. Xmethod to the standard system password method.
  2297. X.IP "\fB-c \fIcomment\fR"
  2298. XThe new value of the user's password file comment field.
  2299. XIt is normally modified using the \fBchfn(1)\fR utility.
  2300. X.IP "\fB-d \fIhome_dir\fR"
  2301. XThe user's new login directory.
  2302. XIf the \fB-m\fR option is given the contents of the current home directory
  2303. Xwill be moved to the new home directory, which is created if it does not
  2304. Xalready exist.
  2305. X.IP "\fB-e \fIexpire_date\fR"
  2306. XThe date on which the user account will be disabled.
  2307. XThe date is specified in the format \fIMM/DD/YY\fR.
  2308. X.IP "\fB-f \fIinactive_days\fR"
  2309. XThe number of days after a password expires until the account
  2310. Xis permanently disabled.
  2311. XA value of 0 disables the account as soon as the password has
  2312. Xexpired, and a value of -1 disables the feature.
  2313. XThe default value is -1.
  2314. X.IP "\fB-g \fIinitial_group\fR"
  2315. XThe group name or number of the user's new initial login group.
  2316. XThe group name must exist.  A group number must refer to an
  2317. Xalready existing group.
  2318. XThe default group number is 1.
  2319. X.IP "\fB-G \fIgroup,[...]\fR"
  2320. XA list of supplementary groups which the user is also a member
  2321. Xof.
  2322. XEach group is separated from the next by a comma, with no
  2323. Xintervening whitespace.
  2324. XThe groups are subject to the same restrictions as the group
  2325. Xgiven with the \fB-g\fR option.
  2326. XIf the user is currently a member of a group which is not listed,
  2327. Xthe user will be removed from the group
  2328. X.IP "\fB-l \fIlogin_name\fR"
  2329. XThe name of the user will be changed from \fIlogin\fR to
  2330. X\fIlogin_name\fR.
  2331. XNothing else is changed.
  2332. XIn particular, the user's home directory name should probably
  2333. Xbe changed to reflect the new login name.
  2334. X.IP "\fB-s \fIshell\fR"
  2335. XThe name of the user's new login shell.
  2336. XSetting this field to blank causes the system
  2337. Xto select the default login shell.
  2338. X.IP "\fB-u \fIuid\fR"
  2339. XThe numerical value of the user's ID.
  2340. XThis value must be unique, unless the \fI-o\fR option is used.
  2341. XThe value must be non-negative.
  2342. XValues between 0 and 99 are typically reserved for system accounts.
  2343. XAny files which the user owns and which are located in the directory
  2344. Xtree rooted at the user's home directory will have the file user ID
  2345. Xchanged automatically.
  2346. XFiles outside of the user's home directory must be altered manually.
  2347. X.SH CAVEATS
  2348. X\fBusermod\fB will not allow you to change the name of a user who is
  2349. Xlogged in.
  2350. XYou must make certain that the named user is not executing any processes
  2351. Xwhen this command is being executed if the user's numerical user ID is
  2352. Xbeing changed.
  2353. XYou must change the owner of any crontab files manually.
  2354. XYou must change the owner of any at jobs manually.
  2355. X.SH Files
  2356. X/etc/passwd \- user account information
  2357. X.br
  2358. X/etc/shadow \- secure user account information
  2359. X.br
  2360. X/etc/group \- group information
  2361. X.SH SEE ALSO
  2362. X\fBchfn(1), chsh(1), groupadd(1M), groupdel(1M), groupmod(1M),
  2363. Xpasswd(1), useradd(1M), userdel(1M)
  2364. END_OF_FILE
  2365.   if test 4212 -ne `wc -c <'usermod.1'`; then
  2366.     echo shar: \"'usermod.1'\" unpacked with wrong size!
  2367.   fi
  2368.   # end of 'usermod.1'
  2369. fi
  2370. echo shar: End of archive 11 \(of 14\).
  2371. cp /dev/null ark11isdone
  2372. MISSING=""
  2373. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  2374.     if test ! -f ark${I}isdone ; then
  2375.     MISSING="${MISSING} ${I}"
  2376.     fi
  2377. done
  2378. if test "${MISSING}" = "" ; then
  2379.     echo You have unpacked all 14 archives.
  2380.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2381. else
  2382.     echo You still must unpack the following archives:
  2383.     echo "        " ${MISSING}
  2384. fi
  2385. exit 0
  2386. exit 0 # Just in case...
  2387.