home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / idutil < prev    next >
Encoding:
Text File  |  1992-06-12  |  45.0 KB  |  1,815 lines

  1. Newsgroups: comp.sources.unix
  2. From: dtb@otto.bf.rmit.oz.au (David Bath)
  3. Subject: v26i060: idutil - command-line i'face to cuserid(3), getpwnam(3), &etc
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: dtb@otto.bf.rmit.oz.au (David Bath)
  8. Posting-Number: Volume 26, Issue 60
  9. Archive-Name: idutil
  10.  
  11. [ This package command-line interfaces to the C-library functions that
  12.   handle user- and group-id's.  I would normally reject something that
  13.   has no README file, but since this one has a good Makefile and complete
  14.   man pages, I'm letting it through.                --vix ]
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 1 (of 1)."
  23. # Contents:  MANIFEST Makefile cuserid.1l cuserid.c getgrgid.1l
  24. #   getgrgid.c getgrnam.1l getgrnam.c getid.c getlogin.1l getlogin.c
  25. #   getpwnam.1l getpwnam.c getpwuid.1l getpwuid.c getuid.1l grinf.c
  26. #   grinf.h pwinf.c pwinf.h
  27. # Wrapped by dtb@cheops on Tue Feb 25 14:01:25 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  31. else
  32. echo shar: Extracting \"'MANIFEST'\" \(1171 characters\)
  33. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  34. X   File Name        Archive #    Description
  35. X-----------------------------------------------------------
  36. X MANIFEST                   1    makekit(1) control - this file
  37. X Makefile                   1    Instructions to make the binaries
  38. X cuserid.1l                 1    Manual page
  39. X cuserid.c                  1    Mainline for cuserid(1)
  40. X getgrgid.1l                1    Manual page
  41. X getgrgid.c                 1    Mainline for getgrgid(1)
  42. X getgrnam.1l                1    Manual page
  43. X getgrnam.c                 1    Mainline for getgrnam(1)
  44. X getid.c                    1    Mainline for getuid(1), getgid(1)....
  45. X getlogin.1l                1    Manual page
  46. X getlogin.c                 1    Mainline for getlogin(1)
  47. X getpwnam.1l                1    Manual page
  48. X getpwnam.c                 1    Mainline for getpwnam(1)
  49. X getpwuid.1l                1    Manual page
  50. X getpwuid.c                 1    Mainline for getpwuid(1)
  51. X getuid.1l                  1    Manual page
  52. X grinf.c                    1    grp information format functions
  53. X grinf.h                    1    declarations for grinf.c functions
  54. X pwinf.c                    1    passwd information format functions
  55. X pwinf.h                    1    declarations for pwinf.c functions
  56. END_OF_FILE
  57. if test 1171 -ne `wc -c <'MANIFEST'`; then
  58.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  59. fi
  60. # end of 'MANIFEST'
  61. fi
  62. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  63.   echo shar: Will not clobber existing file \"'Makefile'\"
  64. else
  65. echo shar: Extracting \"'Makefile'\" \(3267 characters\)
  66. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  67. X# $Header: Makefile,v 1.13 92/02/25 13:26:23 dtb Exp $
  68. X# Makefile for group and user information utilities by David T. Bath
  69. X# Look at the doco under /MAKE VARIABLES/ and /PSEUDOTARGETS/ and
  70. X# edit them as appropriate
  71. X
  72. X######################################################################
  73. X# MAKE VARIABLES
  74. X# CC         Your C compiler
  75. X# BIN         Binaries created
  76. X# MAN         Directory (less the 1) where manual pages live
  77. X# CATMAN     Name of program that automatically formats man pages
  78. X# CPPOPTS     Options for cpp
  79. X# LINKLIBS     Directions for cc(1) to link in libraries
  80. XCC = cc -g
  81. XLOCALBIN = /usr/local/bin
  82. XBIN = cuserid getgrnam getgrgid getpwnam getpwuid getid getlogin
  83. XMAN = /usr/man/local/man
  84. XCATMAN = /usr/catman/local/man
  85. XCPPOPTS = -I/usr/local/include
  86. X
  87. X# For linking, the Pyramid use the version of LINKLIBS with -Wl, in it
  88. XLINKLIBS = -Wl,-L/usr/local/lib/gnu -lfu
  89. X#LINKLIBS = -L/usr/local/lib/gnu -lfu
  90. X
  91. X######################################################################
  92. X# PSEUDOTARGETS
  93. X# all         Make up all binaries in current directory
  94. X# install     Link binaries into installation directory
  95. X# xrf         Create idutil.xrf - cross reference
  96. X# manual     Copy manual source and format it - change for BSD
  97. X# man         Format manual pages - change for BSD
  98. X# clean        Remove binaries
  99. X# distshar     Use makekit(1) to create distribution idutilnn file(s)
  100. X# disttar     Create distribution tar file
  101. X# distshar     Create distribution cpio file
  102. X
  103. Xall : $(BIN)
  104. X
  105. Xinstall : all manual
  106. X    - ln $(BIN) $(LOCALBIN) || cp $(BIN) $(LOCALBIN)
  107. X    - mv $(LOCALBIN)/getid $(LOCALBIN)/getuid
  108. X    - ln $(LOCALBIN)/getuid $(LOCALBIN)/geteuid
  109. X    - ln $(LOCALBIN)/getuid $(LOCALBIN)/getegid
  110. X    - ln $(LOCALBIN)/getuid $(LOCALBIN)/getgid
  111. X
  112. Xxrf :
  113. X    cxref $(CPPOPTS) -c -o idutil.xrf *.c
  114. X
  115. Xmanual :
  116. X    cp cuserid.1l $(MAN)1
  117. X    cp getgrnam.1l $(MAN)1
  118. X    cp getgrgid.1l $(MAN)1
  119. X    cp getlogin.1l $(MAN)1
  120. X    cp getpwnam.1l $(MAN)1
  121. X    cp getpwuid.1l $(MAN)1
  122. X    cp getuid.1l   $(MAN)1
  123. X    catman 1 || make man
  124. X
  125. Xman :
  126. X    nroff -man < $(MAN)1/cuserid.1l > $(CATMAN)1/cuserid.1l
  127. X    nroff -man < $(MAN)1/getgrgid.1l > $(CATMAN)1/getgrgid.1l
  128. X    nroff -man < $(MAN)1/getgrnam.1l > $(CATMAN)1/getgrnam.1l
  129. X    nroff -man < $(MAN)1/getlogin.1l > $(CATMAN)1/getlogin.1l
  130. X    nroff -man < $(MAN)1/getpwnam.1l > $(CATMAN)1/getpwnam.1l
  131. X    nroff -man < $(MAN)1/getpwuid.1l > $(CATMAN)1/getpwuid.1l
  132. X    nroff -man < $(MAN)1/getuid.1l > $(CATMAN)1/getuid.1l
  133. X
  134. Xclean : 
  135. X    - rm $(BIN) *.o a.out core *.tar *.cpio
  136. X    echo "Cleanup done"
  137. X
  138. Xdistshar :
  139. X    - makekit -m -nidutil
  140. X
  141. Xdistcpio :
  142. X    - tail +3 MANIFEST | sed 's!^ \([^     ]*\).*!\1!' | \
  143. X        cpio -oBcv > idutil.cpio
  144. X
  145. Xdisttar :
  146. X    - tar -cvf idutil.tar `tail +3 MANIFEST | sed 's!\(^ [^     ]*\).*!\1!'`
  147. X
  148. X##### BORING BITS BELOW HERE - YOU SHOULD NOT HAVE TO PLAY WITH THIS #######
  149. X
  150. Xmainutil.o : mainutil.c mainutil.h
  151. X
  152. Xgrinf.o : grinf.c grinf.h
  153. X
  154. Xpwinf.o : pwinf.c pwinf.h
  155. X
  156. Xcuserid : cuserid.c
  157. X    cc $(CPPOPTS) -o $@ $@.c $(LINKLIBS)
  158. X
  159. Xgetgrnam : getgrnam.c grinf.o
  160. X    cc $(CPPOPTS) -o $@ $@.c grinf.o $(LINKLIBS)
  161. X
  162. Xgetgrgid : getgrgid.c grinf.o 
  163. X    cc $(CPPOPTS) -o $@ $@.c grinf.o $(LINKLIBS)
  164. X
  165. Xgetid    : getid.c 
  166. X    cc $(CPPOPTS) -o $@ $@.c $(LINKLIBS)
  167. X
  168. Xgetlogin : getlogin.c
  169. X    cc $(CPPOPTS) -o $@ $@.c $(LINKLIBS)
  170. X
  171. Xgetpwnam : getpwnam.c pwinf.o
  172. X    cc $(CPPOPTS) -o $@ $@.c pwinf.o $(LINKLIBS)
  173. X
  174. Xgetpwuid : getpwuid.c pwinf.o
  175. X    cc $(CPPOPTS) -o $@ $@.c pwinf.o $(LINKLIBS)
  176. X
  177. END_OF_FILE
  178. if test 3267 -ne `wc -c <'Makefile'`; then
  179.     echo shar: \"'Makefile'\" unpacked with wrong size!
  180. fi
  181. # end of 'Makefile'
  182. fi
  183. if test -f 'cuserid.1l' -a "${1}" != "-c" ; then 
  184.   echo shar: Will not clobber existing file \"'cuserid.1l'\"
  185. else
  186. echo shar: Extracting \"'cuserid.1l'\" \(784 characters\)
  187. sed "s/^X//" >'cuserid.1l' <<'END_OF_FILE'
  188. X.TH CUSERID 1 LOCAL
  189. X.SH NAME
  190. Xcuserid \- Get username information
  191. X.SH SYNOPSIS
  192. X.B cuserid
  193. X.I [-Iv] 
  194. X.SH DESCRIPTION
  195. X.LP
  196. X.B cuserid
  197. Xuses
  198. X.I "cuserid(3)"
  199. Xto echo the login name to standard output with optional extra information
  200. Xand verbose leader.
  201. X.LP
  202. X.SH USAGE
  203. X.SS Options
  204. X.I
  205. X.IP \fB\-I\fR
  206. XGives information about the program.
  207. X.IP \fB\-v\fR
  208. XTrue if the command is to work in \fBverbose\fR mode, not suitable for
  209. Xbackquoting and echoing more information to standard output or standard
  210. Xerror.
  211. X.RE
  212. X.LP
  213. X.SH DIAGNOSTICS
  214. XThe following values may be returned to the calling process:
  215. X.RS 
  216. X.IP \fB0\fR
  217. XNo errors noted
  218. X.IP \fB1\fR 
  219. XReturned when the user information is not available.
  220. X.SH "SEE ALSO"
  221. X.BR cuserid(3)
  222. X.BR getlogin(3)
  223. X.BR getlogin(1)
  224. X.SH AUTHOR 
  225. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  226. END_OF_FILE
  227. if test 784 -ne `wc -c <'cuserid.1l'`; then
  228.     echo shar: \"'cuserid.1l'\" unpacked with wrong size!
  229. fi
  230. # end of 'cuserid.1l'
  231. fi
  232. if test -f 'cuserid.c' -a "${1}" != "-c" ; then 
  233.   echo shar: Will not clobber existing file \"'cuserid.c'\"
  234. else
  235. echo shar: Extracting \"'cuserid.c'\" \(1292 characters\)
  236. sed "s/^X//" >'cuserid.c' <<'END_OF_FILE'
  237. X/* 
  238. X** NAME : cuserid.c
  239. X** PURPOSE : Shell level access to cuserid(3)
  240. X*/
  241. X#include <stdio.h>
  242. X#include <errno.h>
  243. X#include <gnu/fileutil.h>
  244. X
  245. Xstatic char *RCSid="$Header: cuserid.c,v 1.1 92/02/25 12:43:31 dtb Exp $";
  246. X
  247. Xint     fpr_usage();
  248. X
  249. Xstatic char     *trim_main_name;
  250. Xstatic short     main_verbose = 0;
  251. X
  252. Xint    main ( argc, argv, envp )
  253. Xint    argc;
  254. Xchar    **argv;
  255. Xchar    **envp;
  256. X{
  257. X    char    *optstring = "Iv" ;
  258. X    int        optchar;
  259. X    extern char    *optarg;
  260. X    extern int    optind;
  261. X    extern int    opterr;
  262. X    char     *login_name;
  263. X    int     rval = 0;                 /* Default return success */
  264. X
  265. X    trim_main_name = basename(*argv);
  266. X    main_verbose = 0;        /* verbose off */
  267. X    opterr = 0;
  268. X    while ((optchar = getopt(argc, argv, optstring)) != -1)
  269. X        switch (optchar) {
  270. X        case 'I':
  271. X            fprintf (stderr, "%s %s\n", __FILE__, RCSid);
  272. X            break;
  273. X        case 'v':
  274. X            main_verbose = 1;
  275. X            break;
  276. X        case '?':
  277. X            fpr_usage (stderr);
  278. X            exit (EINVAL);
  279. X        }
  280. X    if ((login_name = cuserid(NULL))==NULL) {
  281. X        if (main_verbose) {
  282. X            fprintf(stderr, "%s: cuserid() returned null\n",
  283. X                trim_main_name);
  284. X            rval = 1;
  285. X        }
  286. X    } else {
  287. X        if (main_verbose) 
  288. X            printf("Your login according to clogin is ");
  289. X        printf ("%s\n", login_name);
  290. X    }
  291. X    return (rval);
  292. X
  293. X}
  294. X
  295. X
  296. Xint     fpr_usage (fp)
  297. XFILE     *fp;
  298. X{
  299. X    int     nout = 0;
  300. X    nout += fprintf (stderr, "Usage: %s [-v]\n", trim_main_name);
  301. X    return (nout);
  302. X}
  303. END_OF_FILE
  304. if test 1292 -ne `wc -c <'cuserid.c'`; then
  305.     echo shar: \"'cuserid.c'\" unpacked with wrong size!
  306. fi
  307. # end of 'cuserid.c'
  308. fi
  309. if test -f 'getgrgid.1l' -a "${1}" != "-c" ; then 
  310.   echo shar: Will not clobber existing file \"'getgrgid.1l'\"
  311. else
  312. echo shar: Extracting \"'getgrgid.1l'\" \(2342 characters\)
  313. sed "s/^X//" >'getgrgid.1l' <<'END_OF_FILE'
  314. X.TH GETGRGID 1 LOCAL
  315. X.SH NAME
  316. Xgetgrgid \- Group information from group numeric id
  317. X.SH SYNOPSIS
  318. X.B getgrgid
  319. X.I [-Iagmnpv] 
  320. X.I [-d 
  321. Xchar
  322. X.I ] 
  323. X.I [-e 
  324. Xchar
  325. X.I ]
  326. X[ grpnum ... ]
  327. X.SH DESCRIPTION
  328. X.LP
  329. X.B getgrgid
  330. Xechoes group information given a list of group numeric identifiers.
  331. XError messages generated from within the
  332. X.B getgrgid
  333. Xutility are sent to stderr, not stdout, allowing the programmer to use
  334. Xappropriate backquoting for this command.
  335. X.LP
  336. XIf no arguments are given, the current effective group is assumed.
  337. X.LP
  338. X.SH USAGE
  339. X.SS Options
  340. X.I
  341. X.IP \fB\-I\fR
  342. XGives information about the program.
  343. X.IP \fB\-a\fR
  344. XSame as setting npgm flags.  See below.
  345. X.IP \fB\-g\fR
  346. XWill echo group identifier (gid).
  347. X.IP \fB\-n\fR
  348. XWill echo group name.
  349. X.IP \fB\-m\fR
  350. XWill echo group member list.
  351. X.IP \fB\-p\fR
  352. XWill echo group encrypted password.
  353. X.IP \fB\-r\fR
  354. XWill report on exceptions to standard error, for example when groups are
  355. Xnot found.
  356. X.IP \fB\-v\fR
  357. XTrue if the command is to work in \fBverbose\fR mode, not suitable for
  358. Xbackquoting and echoing more information to standard output or standard
  359. Xerror.
  360. X.IP \fB-d\fR
  361. XThe character following the option indication is used as a delimiter
  362. Xbetween output fields.  The default is ':' in line with the format of 
  363. Xthe \fB/etc/group\fR file.
  364. X.IP \fB-e\fR
  365. XThe character following the option indication is used as a delimiter
  366. Xbetween member fields.  The default is ',' in line with the format of 
  367. Xthe \fB/etc/group\fR file.
  368. X.IP \fB\-?\fR
  369. XPresents brief help text to the user.  This option causes an error to
  370. Xbe returned as no group number is echoed.
  371. X.SH EXAMPLE
  372. X.LP
  373. X.nf
  374. Xexample$ getgrgid -a
  375. Xcmim::208:cmim,dtb,asd,rhs,marg,mah,sab,yxn,spl,krf,gxf
  376. Xexample$ getgrgid -rvgn 1 2 6 7
  377. Xgetgrgid: could not find group 7
  378. Xgname=other:gid=1
  379. Xgname=bin:gid=2
  380. Xgname=mail:gid=6
  381. Xexample$ getgrgid -nm -d +
  382. Xcmim+cmim,dtb,asd,rhs,marg,mah,sab,yxn,spl,krf,gxf
  383. Xexample$ getgrgid -vgn -d +
  384. Xgname=cmim+gid=208
  385. X.fi
  386. X.ft R
  387. X.RE
  388. X.LP
  389. X.SH DIAGNOSTICS
  390. XThe following values may be returned to the calling process:
  391. X.RS 
  392. X.IP \fB0\fR
  393. XNo errors noted
  394. X.IP \fB1\fR 
  395. XReturned when the group information is not available.
  396. X.IP \fB12\fR
  397. XENOMEM: Problem with memory.
  398. X.IP \fB22\fR
  399. XEINVAL: Invalid argument supplied.
  400. X.SH FILES
  401. X.B /etc/group
  402. X.SH "SEE ALSO"
  403. X.BR group(4)
  404. X.BR getegid(2)
  405. X.BR getgrgid(2)
  406. X.BR getgrnam(1L)
  407. X.SH AUTHOR 
  408. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  409. END_OF_FILE
  410. if test 2342 -ne `wc -c <'getgrgid.1l'`; then
  411.     echo shar: \"'getgrgid.1l'\" unpacked with wrong size!
  412. fi
  413. # end of 'getgrgid.1l'
  414. fi
  415. if test -f 'getgrgid.c' -a "${1}" != "-c" ; then 
  416.   echo shar: Will not clobber existing file \"'getgrgid.c'\"
  417. else
  418. echo shar: Extracting \"'getgrgid.c'\" \(2188 characters\)
  419. sed "s/^X//" >'getgrgid.c' <<'END_OF_FILE'
  420. X#include <stdio.h>
  421. X#include <errno.h>
  422. X#include <grp.h>
  423. X#include "grinf.h"
  424. X#include <gnu/fileutil.h>
  425. X
  426. Xstatic char *RCSid="$Header: getgrgid.c,v 1.6 92/02/25 13:59:51 dtb Exp $";
  427. X
  428. Xint     fpr_usage();
  429. Xint    process_it();
  430. Xstatic char     *trim_main_name;
  431. X
  432. Xstatic int     report_except = 0;
  433. Xstatic char     all_found     = 1;
  434. X
  435. Xint    main ( argc, argv, envp )
  436. Xint    argc;
  437. Xchar    **argv;
  438. Xchar    **envp;
  439. X{
  440. X    char        *optstring = "ad:e:Igmnprv" ;
  441. X    int        optchar;
  442. X    extern char    *optarg;
  443. X    extern int    optind;
  444. X    extern int     opterr;
  445. X    struct grinfrq     *grinf;
  446. X
  447. X    trim_main_name = basename(*argv);
  448. X    if ((grinf = grinfrq_set_dflt (NULL)) == NULL)
  449. X        exit (ENOMEM);
  450. X    opterr = 0;
  451. X    while ((optchar = getopt(argc, argv, optstring)) != -1)
  452. X        switch (optchar) {
  453. X        case 'I':
  454. X            fprintf (stderr, "%s %s\n", __FILE__, RCSid);
  455. X            grinf_info_fpr (stderr);
  456. X            break;
  457. X        case 'a':
  458. X            grinf->epw = grinf->nam = grinf->mem = grinf->gid = 1;
  459. X            break;
  460. X        case 'd':
  461. X            grinf->dlm = *optarg;
  462. X            break;
  463. X        case 'e' :
  464. X            grinf->mdl = *optarg;
  465. X            break;
  466. X        case 'g':
  467. X            grinf->gid = 1;
  468. X            break;
  469. X        case 'm':
  470. X            grinf->mem = 1;
  471. X            break;
  472. X        case 'n':
  473. X            grinf->nam = 1;
  474. X            break;
  475. X        case 'p':
  476. X            grinf->epw = 1;
  477. X            break;
  478. X        case 'r':
  479. X            report_except = 1;
  480. X            break;
  481. X        case 'v':
  482. X            grinf->vbs = 1;
  483. X            break;
  484. X        case '?':
  485. X            fpr_usage (stderr);
  486. X            exit (EINVAL);
  487. X        }
  488. X    if (optind == argc)
  489. X        process_it (getegid(), grinf);
  490. X    while (optind < argc) {
  491. X        int     gid;
  492. X        if (sscanf(*(argv+optind), "%d", &gid) != 1) {
  493. X            fprintf (stderr, "%s: %s not a valid integer\n",
  494. X                trim_main_name, *(argv+optind));
  495. X            exit (EINVAL);
  496. X        }
  497. X        process_it (gid, grinf);
  498. X        optind++;
  499. X    }
  500. X    exit (all_found ? 0 : 1);
  501. X}
  502. X
  503. X
  504. Xint    process_it( grpgid, grinf)
  505. Xint    grpgid;
  506. Xstruct     grinfrq     *grinf;
  507. X{
  508. X    struct     group *gp;
  509. X    int     nout = 0;
  510. X
  511. X    if (( gp = (struct group *) getgrgid (grpgid) ) == NULL) {
  512. X        all_found = 0;
  513. X        if (report_except) {
  514. X            fprintf (stderr, "%s: could not find group %d\n",
  515. X            trim_main_name, grpgid);
  516. X        }
  517. X    } else {
  518. X        nout = grinf_fpr (stdout, gp, grinf);
  519. X    }
  520. X    return (nout);
  521. X}
  522. X
  523. X
  524. Xint     fpr_usage (fp)
  525. XFILE     *fp;
  526. X{
  527. X    int     nout = 0;
  528. X    nout += fprintf (stderr, 
  529. X        "Usage: %s [-%s] [-%s] [-%s] grpname [...]\n",
  530. X        trim_main_name,
  531. X        "Iagmnprv", "d char", "e char" );
  532. X    return (nout);
  533. X}
  534. X
  535. END_OF_FILE
  536. if test 2188 -ne `wc -c <'getgrgid.c'`; then
  537.     echo shar: \"'getgrgid.c'\" unpacked with wrong size!
  538. fi
  539. # end of 'getgrgid.c'
  540. fi
  541. if test -f 'getgrnam.1l' -a "${1}" != "-c" ; then 
  542.   echo shar: Will not clobber existing file \"'getgrnam.1l'\"
  543. else
  544. echo shar: Extracting \"'getgrnam.1l'\" \(2381 characters\)
  545. sed "s/^X//" >'getgrnam.1l' <<'END_OF_FILE'
  546. X.TH GETGRNAM 1 LOCAL
  547. X.SH NAME
  548. Xgetgrnam \- Group information from group name
  549. X.SH SYNOPSIS
  550. X.B getgrnam
  551. X.I [-Iagmnpv] 
  552. X.I [-d 
  553. Xchar
  554. X.I ] 
  555. X.I [-e 
  556. Xchar
  557. X.I ]
  558. X[ name ... ]
  559. X.SH DESCRIPTION
  560. X.LP
  561. X.B getgrnam
  562. Xechoes group information given a list of possible group names.
  563. XError messages generated from within the
  564. X.B getgrnam
  565. Xutility are sent to stderr, not stdout, allowing the programmer to use
  566. Xappropriate backquoting for this command.
  567. X.LP
  568. XIf no arguments are given, the current effective group is assumed.
  569. X.LP
  570. X.SH USAGE
  571. X.SS Options
  572. X.I
  573. X.IP \fB\-I\fR
  574. XGives information about the program.
  575. X.IP \fB\-a\fR
  576. XSame as setting npgm flags.  (a is for "all"). See below.
  577. X.IP \fB\-g\fR
  578. XWill echo group identifier (gid).
  579. X.IP \fB\-n\fR
  580. XWill echo group name.
  581. X.IP \fB\-m\fR
  582. XWill echo group member list.
  583. X.IP \fB\-p\fR
  584. XWill echo group encrypted password.
  585. X.IP \fB\-r\fR
  586. XWill report on exceptions to standard error, for example when groups are
  587. Xnot found.
  588. X.IP \fB\-v\fR
  589. XTrue if the command is to work in \fBverbose\fR mode, not suitable for
  590. Xbackquoting and echoing more information to standard output or standard
  591. Xerror.
  592. X.IP \fB-d\fR
  593. XThe character following the option indication is used as a delimiter
  594. Xbetween output fields.  The default is ':' in line with the format of 
  595. Xthe \fB/etc/group\fR file.
  596. X.IP \fB-e\fR
  597. XThe character following the option indication is used as a delimiter
  598. Xbetween member fields.  The default is ',' in line with the format of 
  599. Xthe \fB/etc/group\fR file.
  600. X.IP \fB\-?\fR
  601. XPresents brief help text to the user.  This option causes an error to
  602. Xbe returned as no group number is echoed.
  603. X.SH EXAMPLE
  604. X.LP
  605. X.nf
  606. Xexample$ getgrnam -a
  607. Xcmim::208:cmim,dtb,asd,rhs,marg,mah,sab,yxn,spl,krf,gxf
  608. Xexample$ getgrnam -rvgn bin nosuch ftp
  609. Xgetgrnam: could not find group nosuch
  610. Xgname=bin:gid=2
  611. Xgname=ftp:gid=204
  612. Xexample$ getgrnam -nm -d +
  613. Xroot+root,adm,ucbroot,attroot,dtb
  614. Xcmim+cmim,dtb,asd,rhs,marg,mah,sab,yxn,spl,krf,gxf
  615. Xexample$ getgrnam -vpgn -d ,
  616. Xgname=root,pass=,gid=0
  617. X.fi
  618. X.ft R
  619. X.RE
  620. X.LP
  621. X.SH DIAGNOSTICS
  622. XThe following values may be returned to the calling process:
  623. X.RS 
  624. X.IP \fB0\fR
  625. XNo errors noted
  626. X.IP \fB1\fR 
  627. XReturned when the group information is not available.
  628. X.IP \fB12\fR
  629. XENOMEM: Problem with memory.
  630. X.IP \fB22\fR
  631. XEINVAL: Invalid argument supplied.
  632. X.SH FILES
  633. X.B /etc/group
  634. X.SH "SEE ALSO"
  635. X.BR group(4)
  636. X.BR getegid(2)
  637. X.BR getgrnam(2)
  638. X.BR getgrgid(1L)
  639. X.SH AUTHOR 
  640. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  641. END_OF_FILE
  642. if test 2381 -ne `wc -c <'getgrnam.1l'`; then
  643.     echo shar: \"'getgrnam.1l'\" unpacked with wrong size!
  644. fi
  645. # end of 'getgrnam.1l'
  646. fi
  647. if test -f 'getgrnam.c' -a "${1}" != "-c" ; then 
  648.   echo shar: Will not clobber existing file \"'getgrnam.c'\"
  649. else
  650. echo shar: Extracting \"'getgrnam.c'\" \(2400 characters\)
  651. sed "s/^X//" >'getgrnam.c' <<'END_OF_FILE'
  652. X#include <stdio.h>
  653. X#include <errno.h>
  654. X#include <grp.h>
  655. X#include <gnu/fileutil.h>
  656. X#include "grinf.h"
  657. X
  658. Xstatic char *RCSid="$Header: getgrnam.c,v 1.7 92/02/25 14:00:01 dtb Exp $";
  659. X
  660. Xint     fpr_usage();
  661. Xint    process_it();
  662. X
  663. Xstatic int     report_except = 0;
  664. Xstatic char     all_found     = 1;
  665. Xstatic char     *trim_main_name;
  666. X
  667. Xint    main ( argc, argv, envp )
  668. Xint    argc;
  669. Xchar    **argv;
  670. Xchar    **envp;
  671. X{
  672. X    char        *optstring = "ad:e:Igmnprv" ;
  673. X    int        optchar;
  674. X    extern char    *optarg;
  675. X    extern int    optind;
  676. X    extern int     opterr;
  677. X    struct grinfrq     *grinf;
  678. X
  679. X    trim_main_name =basename(*argv);
  680. X    if ((grinf = grinfrq_set_dflt (NULL)) == NULL)
  681. X        exit (ENOMEM);
  682. X    opterr = 0;
  683. X    while ((optchar = getopt(argc, argv, optstring)) != -1)
  684. X        switch (optchar) {
  685. X        case 'I':
  686. X            fprintf (stderr, "%s %s\n", __FILE__, RCSid);
  687. X            grinf_info_fpr (stderr);
  688. X            break;
  689. X        case 'a':
  690. X            grinf->epw = grinf->nam = grinf->mem = grinf->gid = 1;
  691. X            break;
  692. X        case 'd':
  693. X            grinf->dlm = *optarg;
  694. X            break;
  695. X        case 'e' :
  696. X            grinf->mdl = *optarg;
  697. X            break;
  698. X        case 'g':
  699. X            grinf->gid = 1;
  700. X            break;
  701. X        case 'm':
  702. X            grinf->mem = 1;
  703. X            break;
  704. X        case 'n':
  705. X            grinf->nam = 1;
  706. X            break;
  707. X        case 'p':
  708. X            grinf->epw = 1;
  709. X            break;
  710. X        case 'r':
  711. X            report_except = 1;
  712. X            break;
  713. X        case 'v':
  714. X            grinf->vbs = 1;
  715. X            break;
  716. X        case '?':
  717. X            fpr_usage (stderr);
  718. X            exit (EINVAL);
  719. X        }
  720. X    if (optind == argc) {
  721. X        struct group * gp;
  722. X        char          gnametmp[256];
  723. X        gp = (struct group *)getgrgid (getegid());
  724. X        strcpy (gnametmp, gp->gr_name);
  725. X        /* 
  726. X        We need a temporary buffer for the current group name
  727. X        rather than passing gp->gr_name to process_it as the
  728. X        buffer pointed at by the returning getgrnam call will
  729. X        overwrite the passed parameter
  730. X        */
  731. X        process_it (&gnametmp[0], grinf);
  732. X    }
  733. X    while (optind < argc) {
  734. X        process_it (*(argv+optind++), grinf);
  735. X    }
  736. X    exit (all_found ? 0 : 1);
  737. X}
  738. X
  739. X
  740. Xint    process_it( grpnam, grinf)
  741. Xchar    *grpnam;
  742. Xstruct     grinfrq     *grinf;
  743. X{
  744. X    struct     group *grp;
  745. X    int     nout = 0;
  746. X
  747. X    grp = (struct group *) getgrnam ( grpnam );
  748. X    if ( grp == NULL) {
  749. X        all_found = 0;
  750. X        if (report_except) {
  751. X            fprintf (stderr, "%s: could not find group %s\n",
  752. X            trim_main_name, grpnam);
  753. X        }
  754. X    } else {
  755. X        nout = grinf_fpr (stdout, grp, grinf);
  756. X    }
  757. X    return (nout);
  758. X}
  759. X
  760. X
  761. Xint     fpr_usage (fp)
  762. XFILE     *fp;
  763. X{
  764. X    int     nout = 0;
  765. X    nout += fprintf (stderr, 
  766. X        "Usage: %s [-%s] [-%s] [-%s] grpname [...]\n",
  767. X        trim_main_name,
  768. X        "Iagmnprv", "d char", "e char" );
  769. X    return (nout);
  770. X}
  771. X
  772. END_OF_FILE
  773. if test 2400 -ne `wc -c <'getgrnam.c'`; then
  774.     echo shar: \"'getgrnam.c'\" unpacked with wrong size!
  775. fi
  776. # end of 'getgrnam.c'
  777. fi
  778. if test -f 'getid.c' -a "${1}" != "-c" ; then 
  779.   echo shar: Will not clobber existing file \"'getid.c'\"
  780. else
  781. echo shar: Extracting \"'getid.c'\" \(786 characters\)
  782. sed "s/^X//" >'getid.c' <<'END_OF_FILE'
  783. X/*
  784. X * NAME
  785. X *     getid.c     - get id information
  786. X * NOTES
  787. X *     Forms getuid, getgid, geteuid, getegid commands
  788. X *     all linked to same inode and kept in /usr/local/bin
  789. X */
  790. X
  791. X#include <stdio.h>
  792. X#include <string.h>
  793. X#include <gnu/fileutil.h>
  794. X
  795. X
  796. Xstatic char *RCSid="$Header: getid.c,v 1.3 92/01/23 15:05:31 dtb Exp $";
  797. Xstatic char *trim_main_name;
  798. X
  799. Xint main (argc, argv, envp)
  800. Xint     argc;
  801. Xchar     **argv;
  802. Xchar     **envp;
  803. X{
  804. X    int currid;
  805. X
  806. X    trim_main_name=basename(*argv);
  807. X    if (!strcmp(trim_main_name, "getuid"))
  808. X    currid=getuid();
  809. X    else if (!strcmp(trim_main_name, "geteuid"))
  810. X    currid=geteuid();
  811. X    else if (!strcmp(trim_main_name, "getgid"))
  812. X    currid=getgid();
  813. X    else if (!strcmp(trim_main_name, "getegid"))
  814. X    currid=getegid();
  815. X    else
  816. X    currid=getuid();
  817. X    
  818. X    printf ("%d\n", currid);
  819. X}
  820. X
  821. END_OF_FILE
  822. if test 786 -ne `wc -c <'getid.c'`; then
  823.     echo shar: \"'getid.c'\" unpacked with wrong size!
  824. fi
  825. # end of 'getid.c'
  826. fi
  827. if test -f 'getlogin.1l' -a "${1}" != "-c" ; then 
  828.   echo shar: Will not clobber existing file \"'getlogin.1l'\"
  829. else
  830. echo shar: Extracting \"'getlogin.1l'\" \(875 characters\)
  831. sed "s/^X//" >'getlogin.1l' <<'END_OF_FILE'
  832. X.TH GETLOGIN 1 LOCAL
  833. X.SH NAME
  834. Xgetlogin \- Get login information
  835. X.SH SYNOPSIS
  836. X.B getlogin
  837. X.I [-Iv] 
  838. X.SH DESCRIPTION
  839. X.LP
  840. X.B getlogin
  841. Xuses
  842. X.I "getlogin(3)"
  843. Xto echo the login name to standard output with optional extra information
  844. Xand verbose leader and has the same problems as
  845. X.I "getlogin(3)"
  846. Xso consider using 
  847. X.I "cuserid(1L)"
  848. Xinstead.
  849. X.LP
  850. X.SH USAGE
  851. X.SS Options
  852. X.I
  853. X.IP \fB\-I\fR
  854. XGives information about the program.
  855. X.IP \fB\-v\fR
  856. XTrue if the command is to work in \fBverbose\fR mode, not suitable for
  857. Xbackquoting and echoing more information to standard output or standard
  858. Xerror.
  859. X.RE
  860. X.LP
  861. X.SH DIAGNOSTICS
  862. XThe following values may be returned to the calling process:
  863. X.RS 
  864. X.IP \fB0\fR
  865. XNo errors noted
  866. X.IP \fB1\fR 
  867. XReturned when the user information is not available.
  868. X.SH "SEE ALSO"
  869. X.BR getlogin(3)
  870. X.BR cuserid(3)
  871. X.BR cuserid(1)
  872. X.SH AUTHOR 
  873. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  874. END_OF_FILE
  875. if test 875 -ne `wc -c <'getlogin.1l'`; then
  876.     echo shar: \"'getlogin.1l'\" unpacked with wrong size!
  877. fi
  878. # end of 'getlogin.1l'
  879. fi
  880. if test -f 'getlogin.c' -a "${1}" != "-c" ; then 
  881.   echo shar: Will not clobber existing file \"'getlogin.c'\"
  882. else
  883. echo shar: Extracting \"'getlogin.c'\" \(1305 characters\)
  884. sed "s/^X//" >'getlogin.c' <<'END_OF_FILE'
  885. X/* 
  886. X** NAME : getlogin.c
  887. X** PURPOSE : Shell level access to getlogin(3)
  888. X*/
  889. X#include <stdio.h>
  890. X#include <errno.h>
  891. X#include <gnu/fileutil.h>
  892. X
  893. Xstatic char *RCSid="$Header: getlogin.c,v 1.3 92/02/25 14:00:06 dtb Exp $";
  894. X
  895. Xint     fpr_usage();
  896. X
  897. Xstatic char     *trim_main_name;
  898. Xstatic short     main_verbose = 0;
  899. X
  900. Xint    main ( argc, argv, envp )
  901. Xint    argc;
  902. Xchar    **argv;
  903. Xchar    **envp;
  904. X{
  905. X    char    *optstring = "Iv" ;
  906. X    int        optchar;
  907. X    extern char    *optarg;
  908. X    extern int    optind;
  909. X    extern int    opterr;
  910. X    char     *login_name;
  911. X    int     rval = 0;                 /* Default return success */
  912. X
  913. X    trim_main_name = basename(*argv);
  914. X    main_verbose = 0;        /* verbose off */
  915. X    opterr = 0;
  916. X    while ((optchar = getopt(argc, argv, optstring)) != -1)
  917. X        switch (optchar) {
  918. X        case 'I':
  919. X            fprintf (stderr, "%s %s\n", __FILE__, RCSid);
  920. X            break;
  921. X        case 'v':
  922. X            main_verbose = 1;
  923. X            break;
  924. X        case '?':
  925. X            fpr_usage (stderr);
  926. X            exit (EINVAL);
  927. X        }
  928. X    if ((login_name = (char *)getlogin())==NULL) {
  929. X        if (main_verbose) {
  930. X            fprintf(stderr, "%s: getlogin() returned null\n",
  931. X                trim_main_name);
  932. X            rval = 1;
  933. X        }
  934. X    } else {
  935. X        if (main_verbose) 
  936. X            printf("Your login according to /etc/utmp is ");
  937. X        printf ("%s\n", login_name);
  938. X    }
  939. X    return (rval);
  940. X
  941. X}
  942. X
  943. X
  944. Xint     fpr_usage (fp)
  945. XFILE     *fp;
  946. X{
  947. X    int     nout = 0;
  948. X    nout += fprintf (stderr, "Usage: %s [-v]\n", trim_main_name);
  949. X    return (nout);
  950. X}
  951. X
  952. END_OF_FILE
  953. if test 1305 -ne `wc -c <'getlogin.c'`; then
  954.     echo shar: \"'getlogin.c'\" unpacked with wrong size!
  955. fi
  956. # end of 'getlogin.c'
  957. fi
  958. if test -f 'getpwnam.1l' -a "${1}" != "-c" ; then 
  959.   echo shar: Will not clobber existing file \"'getpwnam.1l'\"
  960. else
  961. echo shar: Extracting \"'getpwnam.1l'\" \(2402 characters\)
  962. sed "s/^X//" >'getpwnam.1l' <<'END_OF_FILE'
  963. X.TH GETPWNAM 1 LOCAL
  964. X.SH NAME
  965. Xgetpwnam \- User information from user name
  966. X.SH SYNOPSIS
  967. X.B getpwnam
  968. X.I [-Iacghnprsuv] 
  969. X.I [-d 
  970. Xchar
  971. X.I ] 
  972. X[ name ... ]
  973. X.SH DESCRIPTION
  974. X.LP
  975. X.B getpwnam
  976. Xechoes user information given a list of possible user names.
  977. XError messages generated from within the
  978. X.B getpwnam
  979. Xutility are sent to stderr, not stdout, allowing the programmer to use
  980. Xappropriate backquoting for this command.
  981. X.LP
  982. XIf no arguments are given, the program will use various means to get a 
  983. Xlogin name, and failing that use the effective user id.
  984. X.LP
  985. X.SH USAGE
  986. X.SS Options
  987. X.I
  988. X.IP \fB\-I\fR
  989. XGives information about the program.
  990. X.IP \fB\-a\fR
  991. XSame as setting cghnpsu flags.  See below.
  992. X.IP \fB\-c\fR
  993. XWill echo comment about user, typically name in English.
  994. X.IP \fB\-g\fR
  995. XWill echo default group identifier (gid).
  996. X.IP \fB\-h\fR
  997. XWill echo home directory.
  998. X.IP \fB\-n\fR
  999. XWill echo user name.
  1000. X.IP \fB\-p\fR
  1001. XWill echo user encrypted password.
  1002. X.IP \fB\-r\fR
  1003. XWill report on exceptions to standard error, for example when groups are
  1004. Xnot found.
  1005. X.IP \fB\-s\fR
  1006. XWill echo default user shell.
  1007. X.IP \fB\-u\fR
  1008. XWill echo user numeric identifier (uid).
  1009. X.IP \fB\-v\fR
  1010. XTrue if the command is to work in \fBverbose\fR mode, not suitable for
  1011. Xbackquoting and echoing more information to standard output or standard
  1012. Xerror.
  1013. X.IP \fB-d\fR
  1014. XThe character following the option indication is used as a delimiter
  1015. Xbetween output fields.  The default is ':' in line with the format of 
  1016. Xthe \fB/etc/group\fR file.
  1017. X.IP \fB\-?\fR
  1018. XPresents brief help text to the user.  This option causes an error to
  1019. Xbe returned as no user number is echoed.
  1020. X.SH EXAMPLE
  1021. X.LP
  1022. X.nf
  1023. Xexample$ getpwnam -a
  1024. Xdtb:/j2cPZsqllg3Y:201:208:David T. Bath:/users/dtb:/.ucbbin/ksh
  1025. Xexample$ getpwnam -rvgun bin nosuch ftp dtb marg
  1026. Xgetpwnam: could not find user nosuch
  1027. Xusrname=bin:uid=2:gid=2
  1028. Xusrname=dtb:uid=201:gid=208
  1029. Xusrname=marg:uid=209:gid=208
  1030. Xexample$ getpwnam -vcnugs -d ,
  1031. Xusrname=dtb,uid=201,gid=208,comment=David T. Bath,shell=/.ucbbin/ksh
  1032. X.fi
  1033. X.ft R
  1034. X.RE
  1035. X.LP
  1036. X.SH DIAGNOSTICS
  1037. XThe following values may be returned to the calling process:
  1038. X.RS 
  1039. X.IP \fB0\fR
  1040. XNo errors noted
  1041. X.IP \fB1\fR 
  1042. XReturned when the user information is not available.
  1043. X.IP \fB12\fR
  1044. XENOMEM: Problem with memory.
  1045. X.IP \fB22\fR
  1046. XEINVAL: Invalid argument supplied.
  1047. X.SH FILES
  1048. X.B /etc/passwd
  1049. X.SH "SEE ALSO"
  1050. X.BR passwd(4)
  1051. X.BR geteuid(2)
  1052. X.BR getpwnam(2)
  1053. X.BR getpwuid(1L)
  1054. X.SH AUTHOR 
  1055. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  1056. END_OF_FILE
  1057. if test 2402 -ne `wc -c <'getpwnam.1l'`; then
  1058.     echo shar: \"'getpwnam.1l'\" unpacked with wrong size!
  1059. fi
  1060. # end of 'getpwnam.1l'
  1061. fi
  1062. if test -f 'getpwnam.c' -a "${1}" != "-c" ; then 
  1063.   echo shar: Will not clobber existing file \"'getpwnam.c'\"
  1064. else
  1065. echo shar: Extracting \"'getpwnam.c'\" \(3026 characters\)
  1066. sed "s/^X//" >'getpwnam.c' <<'END_OF_FILE'
  1067. X#include <stdio.h>
  1068. X#include <errno.h>
  1069. X#include <pwd.h>
  1070. X#include "pwinf.h"
  1071. X#include <gnu/fileutil.h>
  1072. Xstatic char    *RCSid = "$Header: getpwnam.c,v 1.4 92/02/25 14:00:08 dtb Exp $";
  1073. X
  1074. Xint    fpr_usage();
  1075. Xint    process_it();
  1076. X
  1077. Xstatic int    report_except = 0;
  1078. Xstatic char    all_found     = 1;
  1079. Xstatic char    *trim_main_name;
  1080. X
  1081. X
  1082. Xint    main ( argc, argv, envp )
  1083. Xint    argc;
  1084. Xchar    **argv;
  1085. Xchar    **envp;
  1086. X{
  1087. X    char    *optstring = "acd:Ighnprsuv" ;
  1088. X    int    optchar;
  1089. X    extern char    *optarg;
  1090. X    extern int    optind;
  1091. X    extern int    opterr;
  1092. X    struct pwinfrq *pwinf;
  1093. X
  1094. X    trim_main_name = basename(*argv);
  1095. X    if ((pwinf = pwinfrq_set_dflt (NULL)) == NULL)
  1096. X        exit (ENOMEM);
  1097. X    opterr = 0;
  1098. X    while ((optchar = getopt(argc, argv, optstring)) != -1)
  1099. X        switch (optchar) {
  1100. X        case 'I':
  1101. X            fprintf (stderr, "%s %s\n", __FILE__, RCSid);
  1102. X            pwinf_info_fpr (stderr);
  1103. X            break;
  1104. X        case 'a':
  1105. X            pwinf->epw = pwinf->nam = pwinf->uid = pwinf->gid
  1106. X                 = pwinf->age = pwinf->cmt = pwinf->dir =
  1107. X                pwinf->shl = 1;
  1108. X            break;
  1109. X        case 'c':
  1110. X            pwinf->cmt = 1;
  1111. X            break;
  1112. X        case 'd':
  1113. X            pwinf->dlm = *optarg;
  1114. X            break;
  1115. X        case 'g':
  1116. X            pwinf->gid = 1;
  1117. X            break;
  1118. X        case 'h':
  1119. X            pwinf->dir = 1;
  1120. X            break;
  1121. X        case 'n':
  1122. X            pwinf->nam = 1;
  1123. X            break;
  1124. X        case 'p':
  1125. X            pwinf->epw = 1;
  1126. X            break;
  1127. X        case 'r':
  1128. X            report_except = 1;
  1129. X            break;
  1130. X        case 's':
  1131. X            pwinf->shl = 1;
  1132. X            break;
  1133. X        case 'u':
  1134. X            pwinf->uid = 1;
  1135. X            break;
  1136. X        case 'v':
  1137. X            pwinf->vbs = 1;
  1138. X            break;
  1139. X        case '?':
  1140. X            fpr_usage (stderr);
  1141. X            exit (EINVAL);
  1142. X        }
  1143. X    if (optind == argc) {
  1144. X        struct passwd *pw = NULL;
  1145. X        char    unametmp[256];
  1146. X        char    *loginname = NULL;
  1147. X
  1148. X
  1149. X        if ((loginname = cuserid(NULL)) == NULL)
  1150. X            loginname = (char *) getlogin();
  1151. X        if (loginname != NULL) {
  1152. X            if ((pw = (struct passwd *) getpwnam (loginname))
  1153. X                == NULL) {
  1154. X                fprintf (stderr, "%s: No password entry for %s\n",
  1155. X                                         trim_main_name, loginname);
  1156. X                loginname = NULL;
  1157. X            }
  1158. X        }
  1159. X        if (loginname != NULL) {
  1160. X            strcpy (unametmp, loginname);
  1161. X        } else {
  1162. X            int    euid;
  1163. X
  1164. X            euid = getuid();
  1165. X            if ((pw = (struct passwd *) getpwuid (euid)) == NULL) {
  1166. X                unametmp[0] = '\0';
  1167. X            } else {
  1168. X                strcpy (unametmp, pw->pw_name);
  1169. X            }
  1170. X        }
  1171. X        /* 
  1172. X        We need a temporary buffer for the current user name
  1173. X        rather than passing pw->pw_name to process_it as the
  1174. X        buffer pointed at by the returning getpwnam call will
  1175. X        overwrite the passed parameter
  1176. X        */
  1177. X        process_it (&unametmp[0], pwinf);
  1178. X    }
  1179. X    while (optind < argc) {
  1180. X        process_it (*(argv + optind++), pwinf);
  1181. X    }
  1182. X    exit (all_found ? 0 : 1);
  1183. X}
  1184. X
  1185. X
  1186. Xint    process_it( usrnam, pwinf)
  1187. Xchar    *usrnam;
  1188. Xstruct pwinfrq *pwinf;
  1189. X{
  1190. X    struct passwd *pwent;
  1191. X    int    nout = 0;
  1192. X
  1193. X    pwent = (struct passwd *) getpwnam ( usrnam );
  1194. X    if ( pwent == NULL) {
  1195. X        all_found = 0;
  1196. X        if (report_except) {
  1197. X            fprintf (stderr, "%s: could not find user %s\n",
  1198. X                                 trim_main_name, usrnam);
  1199. X        }
  1200. X    } else {
  1201. X        nout = pwinf_fpr (stdout, pwent, pwinf);
  1202. X    }
  1203. X    return (nout);
  1204. X}
  1205. X
  1206. X
  1207. Xint    fpr_usage (fp)
  1208. XFILE     *fp;
  1209. X{
  1210. X    int    nout = 0;
  1211. X    nout += fprintf (stderr,  "Usage: %s [-%s] [-%s] usrname [...]\n",
  1212. X                 trim_main_name, "Iacghnprsuv", "d char" );
  1213. X    return (nout);
  1214. X}
  1215. X
  1216. X
  1217. END_OF_FILE
  1218. if test 3026 -ne `wc -c <'getpwnam.c'`; then
  1219.     echo shar: \"'getpwnam.c'\" unpacked with wrong size!
  1220. fi
  1221. # end of 'getpwnam.c'
  1222. fi
  1223. if test -f 'getpwuid.1l' -a "${1}" != "-c" ; then 
  1224.   echo shar: Will not clobber existing file \"'getpwuid.1l'\"
  1225. else
  1226. echo shar: Extracting \"'getpwuid.1l'\" \(2355 characters\)
  1227. sed "s/^X//" >'getpwuid.1l' <<'END_OF_FILE'
  1228. X.TH GETPWUID 1 LOCAL
  1229. X.SH NAME
  1230. Xgetpwnam \- User information from user numeric identifier
  1231. X.SH SYNOPSIS
  1232. X.B getpuid
  1233. X.I [-Iacghnprsuv] 
  1234. X.I [-d 
  1235. Xchar
  1236. X.I ] 
  1237. X[ uid ... ]
  1238. X.SH DESCRIPTION
  1239. X.LP
  1240. X.B getpwuid
  1241. Xechoes user information given a list of possible user numeric identifiers.
  1242. XError messages generated from within the
  1243. X.B getpwuid
  1244. Xutility are sent to stderr, not stdout, allowing the programmer to use
  1245. Xappropriate backquoting for this command.
  1246. X.LP
  1247. XIf no arguments are given, the current effective user id is assumed.
  1248. X.LP
  1249. X.SH USAGE
  1250. X.SS Options
  1251. X.I
  1252. X.IP \fB\-I\fR
  1253. XGives information about the program.
  1254. X.IP \fB\-a\fR
  1255. XSame as setting cghnpsu flags.  See below.
  1256. X.IP \fB\-c\fR
  1257. XWill echo comment about user, typically name in English.
  1258. X.IP \fB\-g\fR
  1259. XWill echo default group identifier (gid).
  1260. X.IP \fB\-h\fR
  1261. XWill echo home directory.
  1262. X.IP \fB\-n\fR
  1263. XWill echo user name.
  1264. X.IP \fB\-p\fR
  1265. XWill echo user encrypted password.
  1266. X.IP \fB\-r\fR
  1267. XWill report on exceptions to standard error, for example when groups are
  1268. Xnot found.
  1269. X.IP \fB\-s\fR
  1270. XWill echo default user shell.
  1271. X.IP \fB\-u\fR
  1272. XWill echo user numeric identifier (uid).
  1273. X.IP \fB\-v\fR
  1274. XTrue if the command is to work in \fBverbose\fR mode, not suitable for
  1275. Xbackquoting and echoing more information to standard output or standard
  1276. Xerror.
  1277. X.IP \fB-d\fR
  1278. XThe character following the option indication is used as a delimiter
  1279. Xbetween output fields.  The default is ':' in line with the format of 
  1280. Xthe \fB/etc/group\fR file.
  1281. X.IP \fB\-?\fR
  1282. XPresents brief help text to the user.  This option causes an error to
  1283. Xbe returned as no user number is echoed.
  1284. X.SH EXAMPLE
  1285. X.LP
  1286. X.nf
  1287. Xexample$ getpwuid -a
  1288. Xdtb:/j2cPZsqllg3Y:201:208:David T. Bath:/users/dtb:/.ucbbin/ksh
  1289. Xexample$ getpwuid -rvgun 0 99 201 209
  1290. Xgetpwuid: could not find user 99
  1291. Xusrname=root:uid=0:gid=0
  1292. Xusrname=dtb:uid=201:gid=208
  1293. Xusrname=marg:uid=209:gid=208
  1294. Xexample$ getpwuid -vcnugs -d ,
  1295. Xusrname=dtb,uid=201,gid=208,comment=David T. Bath,shell=/.ucbbin/ksh
  1296. X.fi
  1297. X.ft R
  1298. X.RE
  1299. X.LP
  1300. X.SH DIAGNOSTICS
  1301. XThe following values may be returned to the calling process:
  1302. X.RS 
  1303. X.IP \fB0\fR
  1304. XNo errors noted
  1305. X.IP \fB1\fR 
  1306. XReturned when the user information is not available.
  1307. X.IP \fB12\fR
  1308. XENOMEM: Problem with memory.
  1309. X.IP \fB22\fR
  1310. XEINVAL: Invalid argument supplied.
  1311. X.SH FILES
  1312. X.B /etc/passwd
  1313. X.SH "SEE ALSO"
  1314. X.BR passwd(4)
  1315. X.BR geteuid(2)
  1316. X.BR getpwuid(2)
  1317. X.BR getpwnam(1L)
  1318. X.SH AUTHOR 
  1319. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  1320. END_OF_FILE
  1321. if test 2355 -ne `wc -c <'getpwuid.1l'`; then
  1322.     echo shar: \"'getpwuid.1l'\" unpacked with wrong size!
  1323. fi
  1324. # end of 'getpwuid.1l'
  1325. fi
  1326. if test -f 'getpwuid.c' -a "${1}" != "-c" ; then 
  1327.   echo shar: Will not clobber existing file \"'getpwuid.c'\"
  1328. else
  1329. echo shar: Extracting \"'getpwuid.c'\" \(2320 characters\)
  1330. sed "s/^X//" >'getpwuid.c' <<'END_OF_FILE'
  1331. X#include <stdio.h>
  1332. X#include <errno.h>
  1333. X#include <pwd.h>
  1334. X#include <gnu/fileutil.h>
  1335. X#include "pwinf.h"
  1336. X
  1337. Xstatic char *RCSid="$Header: getpwuid.c,v 1.3 92/02/25 14:00:10 dtb Exp $";
  1338. X
  1339. Xint     fpr_usage();
  1340. Xint    process_it();
  1341. X
  1342. Xstatic int     report_except = 0;
  1343. Xstatic char     all_found     = 1;
  1344. Xstatic char     *trim_main_name;
  1345. X
  1346. Xint    main ( argc, argv, envp )
  1347. Xint    argc;
  1348. Xchar    **argv;
  1349. Xchar    **envp;
  1350. X{
  1351. X    char        *optstring = "acd:Ighnprsuv" ;
  1352. X    int        optchar;
  1353. X    extern char    *optarg;
  1354. X    extern int    optind;
  1355. X    extern int    opterr;
  1356. X    struct pwinfrq     *pwinf;
  1357. X
  1358. X    trim_main_name = basename(*argv);
  1359. X    if ((pwinf = pwinfrq_set_dflt (NULL)) == NULL)
  1360. X        exit (ENOMEM);
  1361. X    opterr = 0;
  1362. X    while ((optchar = getopt(argc, argv, optstring)) != -1)
  1363. X        switch (optchar) {
  1364. X        case 'I':
  1365. X            fprintf (stderr, "%s %s\n", __FILE__, RCSid);
  1366. X            pwinf_info_fpr (stderr);
  1367. X            break;
  1368. X        case 'a':
  1369. X            pwinf->epw = pwinf->nam = pwinf->uid = pwinf->gid
  1370. X                = pwinf->age = pwinf->cmt = pwinf->dir
  1371. X                = pwinf->shl = 1;
  1372. X            break;
  1373. X        case 'c':
  1374. X            pwinf->cmt = 1;
  1375. X            break;
  1376. X        case 'd':
  1377. X            pwinf->dlm = *optarg;
  1378. X            break;
  1379. X        case 'g':
  1380. X            pwinf->gid = 1;
  1381. X            break;
  1382. X        case 'h':
  1383. X            pwinf->dir = 1;
  1384. X            break;
  1385. X        case 'n':
  1386. X            pwinf->nam = 1;
  1387. X            break;
  1388. X        case 'p':
  1389. X            pwinf->epw = 1;
  1390. X            break;
  1391. X        case 'r':
  1392. X            report_except = 1;
  1393. X            break;
  1394. X        case 's':
  1395. X            pwinf->shl = 1;
  1396. X            break;
  1397. X        case 'u':
  1398. X            pwinf->uid = 1;
  1399. X            break;
  1400. X        case 'v':
  1401. X            pwinf->vbs = 1;
  1402. X            break;
  1403. X        case '?':
  1404. X            fpr_usage (stderr);
  1405. X            exit (EINVAL);
  1406. X        }
  1407. X    if (optind == argc)
  1408. X        process_it (geteuid(), pwinf);
  1409. X    while (optind < argc) {
  1410. X        int     uid;
  1411. X        if (sscanf(*(argv+optind), "%d", &uid) != 1) {
  1412. X            fprintf (stderr, "%s: %s not a valid integer\n",
  1413. X                trim_main_name, *(argv+optind));
  1414. X            exit (EINVAL);
  1415. X        }
  1416. X        process_it (uid, pwinf);
  1417. X        optind++;
  1418. X    }
  1419. X    exit (all_found ? 0 : 1);
  1420. X
  1421. X}
  1422. X
  1423. X
  1424. Xint    process_it( uid, pwinf)
  1425. Xint    uid;
  1426. Xstruct     pwinfrq     *pwinf;
  1427. X{
  1428. X    struct     passwd *pwent;
  1429. X    int     nout = 0;
  1430. X
  1431. X    pwent = (struct passwd *) getpwuid ( uid );
  1432. X    if ( pwent == NULL) {
  1433. X        all_found = 0;
  1434. X        if (report_except) {
  1435. X            fprintf (stderr, "%s: could not find user %d\n",
  1436. X            trim_main_name, uid);
  1437. X        }
  1438. X    } else {
  1439. X        nout = pwinf_fpr (stdout, pwent, pwinf);
  1440. X    }
  1441. X    return (nout);
  1442. X}
  1443. X
  1444. X
  1445. Xint     fpr_usage (fp)
  1446. XFILE     *fp;
  1447. X{
  1448. X    int     nout = 0;
  1449. X    nout += fprintf (stderr, 
  1450. X        "Usage: %s [-%s] [-%s] usrid [...]\n",
  1451. X        trim_main_name,
  1452. X        "Iacghnprsuv", "d char" );
  1453. X    return (nout);
  1454. X}
  1455. X
  1456. END_OF_FILE
  1457. if test 2320 -ne `wc -c <'getpwuid.c'`; then
  1458.     echo shar: \"'getpwuid.c'\" unpacked with wrong size!
  1459. fi
  1460. # end of 'getpwuid.c'
  1461. fi
  1462. if test -f 'getuid.1l' -a "${1}" != "-c" ; then 
  1463.   echo shar: Will not clobber existing file \"'getuid.1l'\"
  1464. else
  1465. echo shar: Extracting \"'getuid.1l'\" \(501 characters\)
  1466. sed "s/^X//" >'getuid.1l' <<'END_OF_FILE'
  1467. X.TH GETUID 1 LOCAL
  1468. X.SH NAME
  1469. Xgetuid, geteuid, getgid, getgid \- get real user, effective user, real group, and effective group IDs
  1470. X.SH SYNOPSIS
  1471. X.B getuid
  1472. X.LP
  1473. X.B geteuid
  1474. X.LP
  1475. X.B getgid
  1476. X.LP
  1477. X.B getegid
  1478. X.SH DESCRIPTION
  1479. X.LP
  1480. X.B getid,
  1481. Xwhen linked to
  1482. X.B getuid,
  1483. X.B geteuid,
  1484. X.B getgid and
  1485. X.B getegid
  1486. Xechoes the identifexpect given the name similarity to the section 2 system
  1487. Xcalls of the same name.
  1488. X.SH "SEE ALSO"
  1489. X.BR getuid(2)
  1490. X.BR getpwnam(1L)
  1491. X.BR getgrnam(1L)
  1492. X.SH AUTHOR 
  1493. XDavid T. Bath dtb@otto.bf.rmit.oz.au
  1494. END_OF_FILE
  1495. if test 501 -ne `wc -c <'getuid.1l'`; then
  1496.     echo shar: \"'getuid.1l'\" unpacked with wrong size!
  1497. fi
  1498. # end of 'getuid.1l'
  1499. fi
  1500. if test -f 'grinf.c' -a "${1}" != "-c" ; then 
  1501.   echo shar: Will not clobber existing file \"'grinf.c'\"
  1502. else
  1503. echo shar: Extracting \"'grinf.c'\" \(2017 characters\)
  1504. sed "s/^X//" >'grinf.c' <<'END_OF_FILE'
  1505. X#include <stdio.h>
  1506. X#include <memory.h>
  1507. X#include <grp.h>
  1508. X#include "grinf.h"
  1509. X
  1510. Xstatic char *RCSid="$Header: grinf.c,v 1.4 92/01/23 15:05:34 dtb Exp $";
  1511. X
  1512. Xint     grinf_info_fpr (fp)
  1513. XFILE     * fp;
  1514. X{
  1515. X    int nout = 0;
  1516. X    nout += fprintf (fp, "%s %s\n", __FILE__, GRINF_RCSid);
  1517. X    return (nout);
  1518. X}
  1519. X
  1520. X/*
  1521. X    grinfrq_set_dflt
  1522. X    Puts default values in grinfrq structure.
  1523. X    A pointer to the structure is passed as an argument.
  1524. X    If a NULL pointer is used as an argument, then memory will
  1525. X    be allocated and a pointer to the new structure returned.
  1526. X    If a NULL pointer is returned, memory could not be allocated.
  1527. X*/
  1528. Xstruct grinfrq     *    grinfrq_set_dflt ( p)
  1529. Xstruct grinfrq     *     p;
  1530. X{
  1531. X    if (p == NULL)
  1532. X        p = (struct grinfrq *) malloc ( sizeof (struct grinfrq) ) ;
  1533. X    if (p != NULL) {
  1534. X        (void) memset (p, 0, sizeof (struct grinfrq) );
  1535. X        p->dlm = GRINFRQ_DLM_DFLT ;
  1536. X        p->mdl = GRINFRQ_MDL_DFLT ; 
  1537. X    }
  1538. X    return (p);
  1539. X}
  1540. X
  1541. Xint         grinf_fpr ( fp, grp, grinf)
  1542. XFILE         *     fp;
  1543. Xstruct     group     *     grp;
  1544. Xstruct     grinfrq *     grinf;
  1545. X{
  1546. X    int     nout = 0;     /* Number of bytes output */
  1547. X    int     dreq = 0;     /* Is delimiter required */
  1548. X
  1549. X    if (grinf->nam) {
  1550. X        if (grinf->vbs)
  1551. X            nout += fprintf (fp, "gname=");
  1552. X        nout += fprintf (fp, "%s", grp->gr_name);
  1553. X        dreq = 1;
  1554. X    }
  1555. X    if (grinf->epw) {
  1556. X        if (dreq)
  1557. X            nout += fprintf (fp, "%c", grinf->dlm);
  1558. X        if (grinf->vbs)
  1559. X            nout += fprintf (fp, "pass=");
  1560. X        nout += fprintf (fp, "%s", grp->gr_passwd);
  1561. X    }
  1562. X    if (grinf->gid) {
  1563. X        if (dreq)
  1564. X            nout += fprintf (fp, "%c", grinf->dlm);
  1565. X        if (grinf->vbs)
  1566. X            nout += fprintf (fp, "gid=");
  1567. X        nout += fprintf (fp, "%d", grp->gr_gid);
  1568. X    }
  1569. X    if (grinf->mem) {
  1570. X        int mdreq = 0;
  1571. X        int mno = 0;
  1572. X        char **vmem = grp->gr_mem;
  1573. X        
  1574. X        if (dreq)
  1575. X            nout += fprintf (fp, "%c", grinf->dlm);
  1576. X        if (grinf->vbs)
  1577. X            nout += fprintf (fp, "members=");
  1578. X        for (; *vmem != NULL; vmem++) {
  1579. X            if (mdreq) {
  1580. X            nout += fprintf (fp, "%c", grinf->mdl);
  1581. X            }
  1582. X            nout += fprintf (fp, "%s", *vmem);
  1583. X            mdreq = 1;
  1584. X        }
  1585. X    }
  1586. X    if ( grinf->nam | grinf->epw | grinf->gid | grinf->mem )
  1587. X        nout += fprintf (fp, "\n");
  1588. X    return (nout);
  1589. X}
  1590. X
  1591. X
  1592. END_OF_FILE
  1593. if test 2017 -ne `wc -c <'grinf.c'`; then
  1594.     echo shar: \"'grinf.c'\" unpacked with wrong size!
  1595. fi
  1596. # end of 'grinf.c'
  1597. fi
  1598. if test -f 'grinf.h' -a "${1}" != "-c" ; then 
  1599.   echo shar: Will not clobber existing file \"'grinf.h'\"
  1600. else
  1601. echo shar: Extracting \"'grinf.h'\" \(826 characters\)
  1602. sed "s/^X//" >'grinf.h' <<'END_OF_FILE'
  1603. X#ifndef GRINF_INCLUDED
  1604. X#define GRINF_INCLUDED
  1605. X
  1606. Xstatic char *GRINF_RCSid="$Header: grinf.h,v 1.3 91/10/28 10:39:42 dtb Exp $" ;
  1607. X
  1608. X/* Header for group information utilities by David T. Bath */
  1609. X
  1610. X/*
  1611. X    Structure for specification of group information required and
  1612. X    formatting requirements.
  1613. X*/
  1614. Xstruct     grinfrq {
  1615. X    char     nam;     /* Boolean : group name required */
  1616. X    char     epw;     /* Boolean : encrypted password required */
  1617. X    char     gid;     /* Boolean : group id required */
  1618. X    char     mem;     /* Boolean : group member list required */
  1619. X    char     vbs;     /* Boolean : verbose output required */
  1620. X    char     dlm;     /* Delimiter between major fields */
  1621. X    char     mdl;     /* Delimiter between members */
  1622. X} ;
  1623. X
  1624. X#define GRINFRQ_DLM_DFLT ':'
  1625. X#define GRINFRQ_MDL_DFLT ','
  1626. X
  1627. Xstruct     grinfrq *     grinfrq_set_dflt ();
  1628. Xint             grinf_fpr ();
  1629. Xint             grinf_info_fpr ();
  1630. X
  1631. X#endif
  1632. END_OF_FILE
  1633. if test 826 -ne `wc -c <'grinf.h'`; then
  1634.     echo shar: \"'grinf.h'\" unpacked with wrong size!
  1635. fi
  1636. # end of 'grinf.h'
  1637. fi
  1638. if test -f 'pwinf.c' -a "${1}" != "-c" ; then 
  1639.   echo shar: Will not clobber existing file \"'pwinf.c'\"
  1640. else
  1641. echo shar: Extracting \"'pwinf.c'\" \(2565 characters\)
  1642. sed "s/^X//" >'pwinf.c' <<'END_OF_FILE'
  1643. X
  1644. X#include <stdio.h>
  1645. X#include <memory.h>
  1646. X#include <pwd.h>
  1647. X#include "pwinf.h"
  1648. X
  1649. Xstatic char *RCSid="$Header: pwinf.c,v 1.1 91/10/28 10:38:25 dtb Exp $";
  1650. X
  1651. Xint     pwinf_info_fpr (fp)
  1652. XFILE     * fp;
  1653. X{
  1654. X    int nout = 0;
  1655. X    nout += fprintf (fp, "%s %s\n", __FILE__, PWINF_RCSid);
  1656. X    return (nout);
  1657. X}
  1658. X
  1659. X/*
  1660. X    pwinfrq_set_dflt
  1661. X    Puts default values in pwinfrq structure.
  1662. X    A pointer to the structure is passed as an argument.
  1663. X    If a NULL pointer is used as an argument, then memory will
  1664. X    be allocated and a pointer to the new structure returned.
  1665. X    If a NULL pointer is returned, memory could not be allocated.
  1666. X*/
  1667. Xstruct pwinfrq     *    pwinfrq_set_dflt ( p)
  1668. Xstruct pwinfrq     *     p;
  1669. X{
  1670. X    if (p == NULL)
  1671. X        p = (struct pwinfrq *) malloc ( sizeof (struct pwinfrq) ) ;
  1672. X    if (p != NULL) {
  1673. X        (void) memset (p, 0, sizeof (struct pwinfrq) );
  1674. X        p->dlm = PWINFRQ_DLM_DFLT ;
  1675. X    }
  1676. X    return (p);
  1677. X}
  1678. X
  1679. Xint         pwinf_fpr ( fp, pwd, pwinf)
  1680. XFILE         *     fp;
  1681. Xstruct     passwd     *     pwd;
  1682. Xstruct     pwinfrq *     pwinf;
  1683. X{
  1684. X    int     nout = 0;     /* Number of bytes output */
  1685. X    int     dreq = 0;     /* Is delimiter required */
  1686. X
  1687. X    if (pwinf->nam) {
  1688. X        if (pwinf->vbs)
  1689. X            nout += fprintf (fp, "usrname=");
  1690. X        nout += fprintf (fp, "%s", pwd->pw_name);
  1691. X        dreq = 1;
  1692. X    }
  1693. X    if (pwinf->epw) {
  1694. X        if (dreq)
  1695. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1696. X        if (pwinf->vbs)
  1697. X            nout += fprintf (fp, "pass=");
  1698. X        nout += fprintf (fp, "%s", pwd->pw_passwd);
  1699. X    }
  1700. X    if (pwinf->uid) {
  1701. X        if (dreq)
  1702. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1703. X        if (pwinf->vbs)
  1704. X            nout += fprintf (fp, "uid=");
  1705. X        nout += fprintf (fp, "%d", pwd->pw_uid);
  1706. X    }
  1707. X    if (pwinf->gid) {
  1708. X        if (dreq)
  1709. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1710. X        if (pwinf->vbs)
  1711. X            nout += fprintf (fp, "gid=");
  1712. X        nout += fprintf (fp, "%d", pwd->pw_gid);
  1713. X    }
  1714. X    /*
  1715. X    if (pwinf->age) {
  1716. X        if (dreq)
  1717. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1718. X        if (pwinf->vbs)
  1719. X            nout += fprintf (fp, "age=");
  1720. X        nout += fprintf (fp, "%s", pwd->pw_age);
  1721. X    }
  1722. X    */
  1723. X    if (pwinf->cmt) {
  1724. X        if (dreq)
  1725. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1726. X        if (pwinf->vbs)
  1727. X            nout += fprintf (fp, "comment=");
  1728. X        nout += fprintf (fp, "%s", pwd->pw_comment);
  1729. X    }
  1730. X    if (pwinf->dir) {
  1731. X        if (dreq)
  1732. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1733. X        if (pwinf->vbs)
  1734. X            nout += fprintf (fp, "home_dir=");
  1735. X        nout += fprintf (fp, "%s", pwd->pw_dir);
  1736. X    }
  1737. X    if (pwinf->shl) {
  1738. X        if (dreq)
  1739. X            nout += fprintf (fp, "%c", pwinf->dlm);
  1740. X        if (pwinf->vbs)
  1741. X            nout += fprintf (fp, "shell=");
  1742. X        nout += fprintf (fp, "%s", pwd->pw_shell);
  1743. X    }
  1744. X    if ( pwinf->nam | pwinf->epw | pwinf->uid | pwinf->gid | pwinf->age 
  1745. X        | pwinf->cmt | pwinf->dir | pwinf->shl )
  1746. X        nout += fprintf (fp, "\n");
  1747. X    return (nout);
  1748. X}
  1749. X
  1750. END_OF_FILE
  1751. if test 2565 -ne `wc -c <'pwinf.c'`; then
  1752.     echo shar: \"'pwinf.c'\" unpacked with wrong size!
  1753. fi
  1754. # end of 'pwinf.c'
  1755. fi
  1756. if test -f 'pwinf.h' -a "${1}" != "-c" ; then 
  1757.   echo shar: Will not clobber existing file \"'pwinf.h'\"
  1758. else
  1759. echo shar: Extracting \"'pwinf.h'\" \(948 characters\)
  1760. sed "s/^X//" >'pwinf.h' <<'END_OF_FILE'
  1761. X#ifndef PWINF_INCLUDED
  1762. X#define PWINF_INCLUDED
  1763. X
  1764. Xstatic char *PWINF_RCSid="$Header: pwinf.h,v 1.1 91/10/28 10:39:58 dtb Exp $" ;
  1765. X
  1766. X/* Header for passwd information utilities by David T. Bath */
  1767. X
  1768. X/*
  1769. X    Structure for specification of passwd information required and
  1770. X    formatting requirements.
  1771. X*/
  1772. Xstruct     pwinfrq {
  1773. X    char     nam;     /* Boolean : user name required */
  1774. X    char     epw;     /* Boolean : encrypted password required */
  1775. X    char     uid;     /* Boolean : user id required */
  1776. X    char     gid;     /* Boolean : group id required */
  1777. X    char     age;     /* Boolean : age information required */
  1778. X    char     cmt;     /* Boolean : comment required */
  1779. X    char     dir;     /* Boolean : home directory required */
  1780. X    char     shl;     /* Boolean : initial shell required */
  1781. X    char     vbs;     /* Boolean : verbose output required */
  1782. X    char     dlm;     /* Delimiter between major fields */
  1783. X} ;
  1784. X
  1785. X#define PWINFRQ_DLM_DFLT ':'
  1786. X
  1787. Xstruct     pwinfrq *     pwinfrq_set_dflt ();
  1788. Xint             pwinf_fpr ();
  1789. Xint             pwinf_info_fpr ();
  1790. X
  1791. X#endif
  1792. END_OF_FILE
  1793. if test 948 -ne `wc -c <'pwinf.h'`; then
  1794.     echo shar: \"'pwinf.h'\" unpacked with wrong size!
  1795. fi
  1796. # end of 'pwinf.h'
  1797. fi
  1798. echo shar: End of archive 1 \(of 1\).
  1799. cp /dev/null ark1isdone
  1800. MISSING=""
  1801. for I in 1 ; do
  1802.     if test ! -f ark${I}isdone ; then
  1803.     MISSING="${MISSING} ${I}"
  1804.     fi
  1805. done
  1806. if test "${MISSING}" = "" ; then
  1807.     echo You have the archive.
  1808.     rm -f ark[1-9]isdone
  1809. else
  1810.     echo You still need to unpack the following archives:
  1811.     echo "        " ${MISSING}
  1812. fi
  1813. ##  End of shell archive.
  1814. exit 0
  1815.