brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (05/07/91)
kstuff includes a whole bunch of stuff related to reading the kernel, including pff, a more portable, improved version of ofiles/fstat. Of long-term interest are the many kernel-reading libraries---you might never have to open kmem again. Also here is an updated release of my authd server and authuser client RFC 931 implementation, and as an extra bonus you get findinode, a user-level reverse namei for BSD systems with ndbm. I stole a few pieces of code from various versions of ofiles (as indicated in the source). Everything else here is public-domain. At various times various parts of kstuff have been run under each of these systems: SunOS 4.0.3, SunOS 4.1, Ultrix 2.2, Ultrix 4.1, BSD 4.3-Tahoe, Convex UNIX 9.0, Dynix 3.0.17. If you're interested in porting these programs or libraries to other BSD variants, get in touch with me. If you're brave enough to attempt a System V port, good luck. This is kstuff 0.18. Keep in mind that it's alpha software---it's not supposed to work, and if it happens to compile and install without a hitch on your machine, you should be happy. When you post constructive criticism of kstuff to alt.sources.d, remember that I don't consider the package finished. You shouldn't be complaining that the package doesn't do something. You should be explaining your needs and showing how kstuff 1.00 could fulfill them. ---Dan Bernstein, brnstnd@nyu.edu #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 6)." # Contents: README README.authd auread.h authuser.h avenrun.h # boottime.h confclonedev.h confconvexfilegarbage.h # confconvexrpcnfs.h confconvexsysfile.h confdevt.h confdomain.h # confetcconfhfileh.h conffcredptr.h conffree.h confgetuserconvex.h # confgetuserdynix.h confgetusermips.h confgetusersupport.h # confgnode.h confhavepflag.h confhaveppid.h confhavepsuid.h # confhaveucred.h confhaveusigintr.h confhavevmseg.h confitype.h # confkvm.h confloadavglong.h confmajorminor.h confmalloc.h # confmntent.h confmntult.h confneedartospte.h confneedmachparam.h # confneedmntinfo.h confnfs.h confnlistknlist.h confnlistmeaning.h # confnlistunder.h confnlname.h confnonsfinet.h confnounpaddr.h # confodofe.h confopalf.h confpcredinproc.h confpcredunderproc.h # confpsess.h confregion.h confrtype.h confslowstat.h # confsocketneedsxnode.h confsyncsema.h confsysucred.h # conftcpnlist.h conftext.h conftextneedsvmparam.h confttyvp.h # confultrixrpcnfs.h confundefstdcbeforedir.h confusrptnlist.h # confvmunix.h confvtype.h filetable.h findinode findinode/FIDDIR # findinode/FILES findinode/findinode.1 findinode/fsupdatefid # findinode/getopt.h findinode/updatefid.8 getdevicename.h # getfcred.h getopt.h getpcred.h getsocket.h getuser.h getvmseg.h # groupname.h inpcblist.h kmem.h mallocfree.h mmem.h mntops.h # netinp.h nlistlist.h numeric.c numeric.h portname.h printfamily.h # printfflag.h printftype.h printprotoinet.h printpstat.h # printrlimits.h printrusage.h printsocktype.h printucred.h # proctable.h revnamei.h smem.h stattimeout.h strerr.h structmbuf.h # structproc.h structprotosw.h structsockaddrin.h structsocket.h # structtcp.h structtext.h structucred.h structunpcb.h structuser.h # username.h virtype.h vmstuff.h # Wrapped by brnstnd@kramden on Mon May 6 23:58:51 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(6212 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' Xkstuff 0.18, 5/6/91, Daniel J. Bernstein. X XThis code is in alpha test. That means you shouldn't be surprised at Xbugs, annoying restrictions, exceedingly poor documentation, etc. XHowever, I don't know of any bugs, and you should feel free to use the Xlibraries in other programs. Some of the previous contributors to ofiles Xmay want some rights to getdevicename.c, getuser.c, getvmseg.c, Xmntops.c, stattimeout.c, getnode.c, and virtype.c; other than that, this Xis all public-domain. (Nothing here is derived from any AT&T or Berkeley Xor GPL-infected code.) Please send any comments, criticism, or code to Xme at brnstnd@nyu.edu. X XBe sure to apply the changes indicated at the top of Makefile for your Xsystem. Particular thanks to Vic Abell for portability mods, bug fixes, Xand extensive testing. X XThis package includes, among other things: load, a fast version of Xuptime; pff, an improved replacement for ofiles/fstat; authd, a revised Xversion of the RFC 931 server; netstatuids, a version of netstat plus Xusernames on both sides; kmem, nlist, strerr, and u area libraries; the Xauthuser library. See README.authd for an updated extract of the Xauthd/authuser documentation. X XTo compile, just make. To install, run INSTALL from a root shell. X(INSTALL checks each action with you before doing it.) To test, run X``make tests'' as any user. X XI've included the findinode package here in directory findinode. It's Xentirely independent of kstuff, but pff can make good use of it. You Xprobably want to look at that directory, and perhaps make and install Xfindinode, before continuing with kstuff. X X XPrograms: X Xload is a fast version of uptime with a slightly different output Xformat, meant to illustrate how to use these libraries. I don't know why Xuptime is so slow. Documentation is in load.1. X Xpff (process-file-file) is a mostly rewritten version of the popular Xofiles utility. See pff.doc for some documentation. (Man page donations Xwould be appreciated. :-)) See OFILES.hist for a history of ofiles. XAlthough I think I've included almost every popular feature from the XDupuy-Leres ofiles, the Abell ofiles, and the Christiansen fstat, as Xwell as some extras, pff should be quite a bit more portable than any of Xits predecessors. pff handles open files (and filesystems), network Xconnections, mmaps, process texts, cwds, root directories, and Xcontrolling ttys. It works over NFS. It even handles process texts on Xthe Convex, unlike the Christiansen fstat. Late addition: if you have Xfindinode running, pff gives you filenames! Please send me any further Xextensions and portability mods you have. Thanks to all the ofiles and Xfstat authors for lots of code and ideas. X Xnetstatuids uses the RFC 931 authuser library in authuser.c and the Xkernel libraries here to show you all active TCP connections, with the Xusernames on both sides. Naturally, it's faster than netstat -n, though XI suppose this is excusable since netstat shows more information. Thanks Xto Seth Robertson for suggesting this program and writing a prototype. X Xauthd is a revised version of the RFC 931 authd server (previous version Xavailable separately). It should be somewhat faster and somewhat more Xportable. Thanks to Kim Hoeglund for comments and code. Documentation is Xin authd.8, tcpuid.8, and tcpuname.8, copied from the authd 3.01 Xdistribution. (tcpuid and tcpuname should be linked to authd.) X X XLibraries: X Xkmem.h and nlistlist.h are kmem/nlist libraries meant to provide an Xintuitive yet powerful interface. (mmem.h and smem.h are like kmem.h but Xhandle /dev/mem and /dev/drum instead of /dev/kmem.) Intuitive: Xkmemcpy() works just like memcpy() but out of kmem. Powerful: If Xlibraries X and Y are developed independently but both need to use kmem Xand nlist, normally they'd open independent descriptors and do separate Xnlist()s. This is horrendously inefficient. These libraries solve the Xproblem. See avenrun.c, boottime.c, and load.c for examples. X Xgetuser.h is a reasonably portable library to get the u area of a given Xstruct proc. Together with kmem.h and nlistlist.h, getuser.h provides an Xinterface about as useful as Sun's kvm library for kernel-reading Xapplications but a lot more portable. (Well, I cheated a bit: under X#ifdef sun, getuser.h just calls kvm_getu. The point is that Xapplications don't have to worry whether getuser() is running on a Sun Xor not.) X Xavenrun.h, boottime.h, filetable.h, getfcred.h, inpcblist.h, and Xproctable.h are straightforward applications of the kmem and nlistlist Xlibraries. X Xnetinp.h is an experiment. I will probably eliminate it if inpcblist.h Xturns out to be portable enough. Thanks again to Kim Hoeglund. X Xstrerr.h is another piece of my forthcoming error-handling library. It Xlets you set up libraries or sections of code so that callers can get a Xmeaningful error message with a single function call. strerr handles Xrecursion, so that if one library forwards an error from another library Xit called, the error message will include an error from the sublibrary. XBut none of the libraries have to worry about malloc()ing space or Xconcatenating messages manually. Oh, yeah, and strerr(strerrno) is Xequivalent to ANSI C's strerror(errno) if you don't have ANSI libraries. X Xstruct*.h are meant to keep you (well, me) from going insane when using Xvendor include files. If you #include "structproc.h", then no matter how Xbadly structured the vendor's include files are, no matter how many of Xtheir files neglect to include their dependencies, no matter how many Xfiles blow up if they are included twice, you should get a working Xstruct proc and the definitions necessary to use that struct. (You may Xnot understand what struct proc is for, but that's a separate problem. X:-)) X Xconf*.h form a two-level #include system. Why is it good to have a Xsingle file for each #define, like confgnode.h for #ifdef GNODE? Among Xother reasons, this opens up the chance of vendors standardizing these X#include files with the same names and meanings they have here. It also Xinsulates the main code from OS changes. Feel free to use conf*.h in Xother packages. I am considering setting up a central registration Xsystem for files like this. X XI know, there are lots of other libraries here... I'll document them Xsoon. END_OF_FILE if test 6212 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'README.authd' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README.authd'\" else echo shar: Extracting \"'README.authd'\" \(1711 characters\) sed "s/^X//" >'README.authd' <<'END_OF_FILE' Xauthd - authentication server daemon Xtcpuid, tcpuname - find out which user owns a connection Xauthuser - remote authentication library X Xauthd is an implementation of RFC 931, the Authentication Server under XBSD. RFC 931 provides the name of the user owning a TCP connection. This Xhelps network security: unless TCP itself is compromised, it is Ximpossible to forge mail or news between computers supporting RFC 931. XIt also becomes much easier to trace attackers than in the current, Xlargely anonymous, network. authd requires no changes to current code: Xevery connect() and accept() is authenticated automatically, with no Xloss of efficiency. X Xtcpuid and tcpuname are the same program, but more suitable for local Xuse from the command line by a user or system administrator. They show Xwhich local user created a given TCP connection. X Xauthuser is a library encapsulating client use of RFC 931. It talks to a Xremote Authentication Server to find out the username on the other side Xof a given connection. X XOnly root can install authd. However, most current systems are insecure Xenough that any user can run tcpuid and tcpuname. authuser is meant for Xuse by any program. X X X XDerived from authd version 3.01, February 7, 1991. XPlaced into the public domain by Daniel J. Bernstein. XSome of the code in authd was inspired by code written by XVic Abell, abe@mace.cc.purdue.edu, for the ofiles program. X XParticular thanks to the following people for comments, criticism, and Xcode: X X Gary Rosenblum (rosenblg@nyu.edu) X Seth Robertson (seth@sirius.ctr.columbia.edu) X Nick Sayer (mrapple@quack.sac.ca.us) X Chris Metcalf (metcalf@masala.lcs.mit.edu) X Tim Ramsey (tar@math.ksu.edu) X Tor Lillqvist (tml@tik.vtt.fi) END_OF_FILE if test 1711 -ne `wc -c <'README.authd'`; then echo shar: \"'README.authd'\" unpacked with wrong size! fi # end of 'README.authd' fi if test -f 'auread.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'auread.h'\" else echo shar: Extracting \"'auread.h'\" \(129 characters\) sed "s/^X//" >'auread.h' <<'END_OF_FILE' X#ifndef AUREAD_H X#define AUREAD_H X X#define MAXNUMLEN 15 X#define LOOPMAX 1000 Xextern int readport(); Xextern int readlr(); X X#endif END_OF_FILE if test 129 -ne `wc -c <'auread.h'`; then echo shar: \"'auread.h'\" unpacked with wrong size! fi # end of 'auread.h' fi if test -f 'authuser.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'authuser.h'\" else echo shar: Extracting \"'authuser.h'\" \(161 characters\) sed "s/^X//" >'authuser.h' <<'END_OF_FILE' X#ifndef AUTHUSER_H X#define AUTHUSER_H X Xextern unsigned short auth_tcpport; Xextern char *auth_xline(); Xextern int auth_fd(); Xextern char *auth_tcpuser(); X X#endif END_OF_FILE if test 161 -ne `wc -c <'authuser.h'`; then echo shar: \"'authuser.h'\" unpacked with wrong size! fi # end of 'authuser.h' fi if test -f 'avenrun.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'avenrun.h'\" else echo shar: Extracting \"'avenrun.h'\" \(130 characters\) sed "s/^X//" >'avenrun.h' <<'END_OF_FILE' X#ifndef AVENRUN_H X#define AVENRUN_H X Xextern char *avenrunstrerr(); Xextern int avenruninit(); Xextern double *getavenrun(); X X#endif END_OF_FILE if test 130 -ne `wc -c <'avenrun.h'`; then echo shar: \"'avenrun.h'\" unpacked with wrong size! fi # end of 'avenrun.h' fi if test -f 'boottime.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'boottime.h'\" else echo shar: Extracting \"'boottime.h'\" \(180 characters\) sed "s/^X//" >'boottime.h' <<'END_OF_FILE' X#ifndef BOOTTIME_H X#define BOOTTIME_H X Xextern char *boottimestrerr(); Xextern int boottimeinit(); Xextern long getboottime(); /* should be time_t on some systems, too bad */ X X#endif END_OF_FILE if test 180 -ne `wc -c <'boottime.h'`; then echo shar: \"'boottime.h'\" unpacked with wrong size! fi # end of 'boottime.h' fi if test -f 'confclonedev.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confclonedev.h'\" else echo shar: Extracting \"'confclonedev.h'\" \(143 characters\) sed "s/^X//" >'confclonedev.h' <<'END_OF_FILE' X#ifndef CONF_CLONEDEV_H X#define CONF_CLONEDEV_H X X#ifdef SUNOS4 X#define CLONEDEV 37 /* streams clone major device number */ X#endif X X#endif END_OF_FILE if test 143 -ne `wc -c <'confclonedev.h'`; then echo shar: \"'confclonedev.h'\" unpacked with wrong size! fi # end of 'confclonedev.h' fi if test -f 'confconvexfilegarbage.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confconvexfilegarbage.h'\" else echo shar: Extracting \"'confconvexfilegarbage.h'\" \(242 characters\) sed "s/^X//" >'confconvexfilegarbage.h' <<'END_OF_FILE' X#ifndef CONF_CONVEXFILEGARBAGE_H X#define CONF_CONVEXFILEGARBAGE_H X X/* Define CONVEXFILEGARBAGE if lots of Convex-specific #includes are Xnecessary for structxnode.h. Not well defined. */ X X#ifdef CONVEX X#define CONVEXFILEGARBAGE X#endif X X#endif END_OF_FILE if test 242 -ne `wc -c <'confconvexfilegarbage.h'`; then echo shar: \"'confconvexfilegarbage.h'\" unpacked with wrong size! fi # end of 'confconvexfilegarbage.h' fi if test -f 'confconvexrpcnfs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confconvexrpcnfs.h'\" else echo shar: Extracting \"'confconvexrpcnfs.h'\" \(107 characters\) sed "s/^X//" >'confconvexrpcnfs.h' <<'END_OF_FILE' X#ifndef CONF_CONVEXRPCNFS_H X#define CONF_CONVEXRPCNFS_H X X#ifdef CONVEX X#define CONVEXRPCNFS X#endif X X#endif END_OF_FILE if test 107 -ne `wc -c <'confconvexrpcnfs.h'`; then echo shar: \"'confconvexrpcnfs.h'\" unpacked with wrong size! fi # end of 'confconvexrpcnfs.h' fi if test -f 'confconvexsysfile.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confconvexsysfile.h'\" else echo shar: Extracting \"'confconvexsysfile.h'\" \(110 characters\) sed "s/^X//" >'confconvexsysfile.h' <<'END_OF_FILE' X#ifndef CONF_CONVEXSYSFILE_H X#define CONF_CONVEXSYSFILE_H X X#ifdef CONVEX X#define CONVEXSYSFILE X#endif X X#endif END_OF_FILE if test 110 -ne `wc -c <'confconvexsysfile.h'`; then echo shar: \"'confconvexsysfile.h'\" unpacked with wrong size! fi # end of 'confconvexsysfile.h' fi if test -f 'confdevt.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confdevt.h'\" else echo shar: Extracting \"'confdevt.h'\" \(175 characters\) sed "s/^X//" >'confdevt.h' <<'END_OF_FILE' X#ifndef CONF_DEV_T_H X#define CONF_DEV_T_H X X/* XXXX: talk to me if you have better ideas about this */ X#ifdef CONVEX X#define DEV_T int X#else X#define DEV_T short X#endif X X#endif END_OF_FILE if test 175 -ne `wc -c <'confdevt.h'`; then echo shar: \"'confdevt.h'\" unpacked with wrong size! fi # end of 'confdevt.h' fi if test -f 'confdomain.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confdomain.h'\" else echo shar: Extracting \"'confdomain.h'\" \(219 characters\) sed "s/^X//" >'confdomain.h' <<'END_OF_FILE' X#ifndef CONF_DOMAIN_H X#define CONF_DOMAIN_H X X/* -DDOMAIN if <sys/domain.h> exists and defines struct domain. */ X X#if defined(BSD43) || defined(DYNIX) || (defined(ULTRIX) && (ULTRIX == 22)) X#define DOMAIN X#endif X X#endif END_OF_FILE if test 219 -ne `wc -c <'confdomain.h'`; then echo shar: \"'confdomain.h'\" unpacked with wrong size! fi # end of 'confdomain.h' fi if test -f 'confetcconfhfileh.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confetcconfhfileh.h'\" else echo shar: Extracting \"'confetcconfhfileh.h'\" \(110 characters\) sed "s/^X//" >'confetcconfhfileh.h' <<'END_OF_FILE' X#ifndef CONF_ETCCONFHFILEH_H X#define CONF_ETCCONFHFILEH_H X X#ifdef __hpux X#define ETCCONFHFILEH X#endif X X#endif END_OF_FILE if test 110 -ne `wc -c <'confetcconfhfileh.h'`; then echo shar: \"'confetcconfhfileh.h'\" unpacked with wrong size! fi # end of 'confetcconfhfileh.h' fi if test -f 'conffcredptr.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'conffcredptr.h'\" else echo shar: Extracting \"'conffcredptr.h'\" \(281 characters\) sed "s/^X//" >'conffcredptr.h' <<'END_OF_FILE' X#ifndef CONF_FCREDPTR_H X#define CONF_FCREDPTR_H X X/* -DFCRED_ISNOT_POINTER if file->f_cred is a struct ucred. */ X/* -UFCRED_ISNOT_POINTER if file->f_cred is a pointer to struct ucred. */ X/* Irrelevant under -UHAVE_UCRED. */ X X#ifdef CONVEX X#define FCRED_ISNOT_POINTER X#endif X X#endif END_OF_FILE if test 281 -ne `wc -c <'conffcredptr.h'`; then echo shar: \"'conffcredptr.h'\" unpacked with wrong size! fi # end of 'conffcredptr.h' fi if test -f 'conffree.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'conffree.h'\" else echo shar: Extracting \"'conffree.h'\" \(133 characters\) sed "s/^X//" >'conffree.h' <<'END_OF_FILE' X#ifndef CONF_FREE_H X#define CONF_FREE_H X X/* -DVOID_FREE if free() returns void. */ X X#ifndef SUNOS41 X#define VOID_FREE X#endif X X#endif END_OF_FILE if test 133 -ne `wc -c <'conffree.h'`; then echo shar: \"'conffree.h'\" unpacked with wrong size! fi # end of 'conffree.h' fi if test -f 'confgetuserconvex.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confgetuserconvex.h'\" else echo shar: Extracting \"'confgetuserconvex.h'\" \(113 characters\) sed "s/^X//" >'confgetuserconvex.h' <<'END_OF_FILE' X#ifndef CONF_GETUSER_CONVEX_H X#define CONF_GETUSER_CONVEX_H X X#ifdef CONVEX X#define GETUSER_CONVEX X#endif X X#endif END_OF_FILE if test 113 -ne `wc -c <'confgetuserconvex.h'`; then echo shar: \"'confgetuserconvex.h'\" unpacked with wrong size! fi # end of 'confgetuserconvex.h' fi if test -f 'confgetuserdynix.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confgetuserdynix.h'\" else echo shar: Extracting \"'confgetuserdynix.h'\" \(109 characters\) sed "s/^X//" >'confgetuserdynix.h' <<'END_OF_FILE' X#ifndef CONF_GETUSER_DYNIX_H X#define CONF_GETUSER_DYNIX_H X X#ifdef DYNIX X#define GETUSER_DYNIX X#endif X X#endif END_OF_FILE if test 109 -ne `wc -c <'confgetuserdynix.h'`; then echo shar: \"'confgetuserdynix.h'\" unpacked with wrong size! fi # end of 'confgetuserdynix.h' fi if test -f 'confgetusermips.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confgetusermips.h'\" else echo shar: Extracting \"'confgetusermips.h'\" \(105 characters\) sed "s/^X//" >'confgetusermips.h' <<'END_OF_FILE' X#ifndef CONF_GETUSER_MIPS_H X#define CONF_GETUSER_MIPS_H X X#ifdef mips X#define GETUSER_MIPS X#endif X X#endif END_OF_FILE if test 105 -ne `wc -c <'confgetusermips.h'`; then echo shar: \"'confgetusermips.h'\" unpacked with wrong size! fi # end of 'confgetusermips.h' fi if test -f 'confgetusersupport.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confgetusersupport.h'\" else echo shar: Extracting \"'confgetusersupport.h'\" \(272 characters\) sed "s/^X//" >'confgetusersupport.h' <<'END_OF_FILE' X#ifndef CONF_GETUSERSUPPORT_H X#define CONF_GETUSERSUPPORT_H X X/* -DGETUSERSUPPORT if the system supports a get-u-area library routine Xunderstood by getuser.c. Not well defined. */ X X#if defined(DYNIX) || defined(sun) || defined(CONVEX) X#define GETUSERSUPPORT X#endif X X#endif END_OF_FILE if test 272 -ne `wc -c <'confgetusersupport.h'`; then echo shar: \"'confgetusersupport.h'\" unpacked with wrong size! fi # end of 'confgetusersupport.h' fi if test -f 'confgnode.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confgnode.h'\" else echo shar: Extracting \"'confgnode.h'\" \(86 characters\) sed "s/^X//" >'confgnode.h' <<'END_OF_FILE' X#ifndef CONF_GNODE_H X#define CONF_GNODE_H X X#ifdef ULTRIX X#define GNODE X#endif X X#endif END_OF_FILE if test 86 -ne `wc -c <'confgnode.h'`; then echo shar: \"'confgnode.h'\" unpacked with wrong size! fi # end of 'confgnode.h' fi if test -f 'confhavepflag.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confhavepflag.h'\" else echo shar: Extracting \"'confhavepflag.h'\" \(227 characters\) sed "s/^X//" >'confhavepflag.h' <<'END_OF_FILE' X#ifndef CONF_HAVEPFLAG_H X#define CONF_HAVEPFLAG_H X X/* -DHAVE_PFLAG if struct proc has a p_flag element. */ X X#include "structproc.h" X#ifndef P_DYING /* only defined in systems without p_flag */ X#define HAVE_PFLAG X#endif X X#endif END_OF_FILE if test 227 -ne `wc -c <'confhavepflag.h'`; then echo shar: \"'confhavepflag.h'\" unpacked with wrong size! fi # end of 'confhavepflag.h' fi if test -f 'confhaveppid.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confhaveppid.h'\" else echo shar: Extracting \"'confhaveppid.h'\" \(202 characters\) sed "s/^X//" >'confhaveppid.h' <<'END_OF_FILE' X#ifndef CONF_HAVE_PPID_H X#define CONF_HAVE_PPID_H X X/* -DHAVE_PPID if struct proc has a p_ppid element. */ X X#ifndef ZS /* XXX: could look it up in user relation table */ X#define HAVE_PPID X#endif X X#endif END_OF_FILE if test 202 -ne `wc -c <'confhaveppid.h'`; then echo shar: \"'confhaveppid.h'\" unpacked with wrong size! fi # end of 'confhaveppid.h' fi if test -f 'confhavepsuid.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confhavepsuid.h'\" else echo shar: Extracting \"'confhavepsuid.h'\" \(243 characters\) sed "s/^X//" >'confhavepsuid.h' <<'END_OF_FILE' X#ifndef CONF_HAVEPSUID_H X#define CONF_HAVEPSUID_H X X/* -DHAVE_PSUID if struct proc has a p_suid element. */ X X#if defined(sun) || defined(CONVEX) || defined(DYNIX) || (defined(ULTRIX) && ULTRIX >= 40) /* XXX */ X#define HAVE_PSUID X#endif X X#endif END_OF_FILE if test 243 -ne `wc -c <'confhavepsuid.h'`; then echo shar: \"'confhavepsuid.h'\" unpacked with wrong size! fi # end of 'confhavepsuid.h' fi if test -f 'confhaveucred.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confhaveucred.h'\" else echo shar: Extracting \"'confhaveucred.h'\" \(128 characters\) sed "s/^X//" >'confhaveucred.h' <<'END_OF_FILE' X#ifndef CONF_HAVE_UCRED_H X#define CONF_HAVE_UCRED_H X X#if !defined(ZS) && !defined(BSD43TAHOE) X#define HAVE_UCRED X#endif X X#endif END_OF_FILE if test 128 -ne `wc -c <'confhaveucred.h'`; then echo shar: \"'confhaveucred.h'\" unpacked with wrong size! fi # end of 'confhaveucred.h' fi if test -f 'confhaveusigintr.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confhaveusigintr.h'\" else echo shar: Extracting \"'confhaveusigintr.h'\" \(109 characters\) sed "s/^X//" >'confhaveusigintr.h' <<'END_OF_FILE' X#ifndef CONF_HAVE_USIGINTR_H X#define CONF_HAVE_USIGINTR_H X X#ifdef BSD43 X#define HAVE_USIGINTR X#endif X X#endif END_OF_FILE if test 109 -ne `wc -c <'confhaveusigintr.h'`; then echo shar: \"'confhaveusigintr.h'\" unpacked with wrong size! fi # end of 'confhaveusigintr.h' fi if test -f 'confhavevmseg.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confhavevmseg.h'\" else echo shar: Extracting \"'confhavevmseg.h'\" \(101 characters\) sed "s/^X//" >'confhavevmseg.h' <<'END_OF_FILE' X#ifndef CONF_HAVE_VMSEG_H X#define CONV_HAVE_VMSEG_H X X#ifdef SUNOS4 X#define HAVE_VMSEG X#endif X X#endif END_OF_FILE if test 101 -ne `wc -c <'confhavevmseg.h'`; then echo shar: \"'confhavevmseg.h'\" unpacked with wrong size! fi # end of 'confhavevmseg.h' fi if test -f 'confitype.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confitype.h'\" else echo shar: Extracting \"'confitype.h'\" \(66 characters\) sed "s/^X//" >'confitype.h' <<'END_OF_FILE' X#ifndef CONF_ITYPE_H X#define CONF_ITYPE_H X X#define I_TYPE X X#endif END_OF_FILE if test 66 -ne `wc -c <'confitype.h'`; then echo shar: \"'confitype.h'\" unpacked with wrong size! fi # end of 'confitype.h' fi if test -f 'confkvm.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confkvm.h'\" else echo shar: Extracting \"'confkvm.h'\" \(77 characters\) sed "s/^X//" >'confkvm.h' <<'END_OF_FILE' X#ifndef CONF_KVM_H X#define CONF_KVM_H X X#ifdef sun X#define KVM X#endif X X#endif END_OF_FILE if test 77 -ne `wc -c <'confkvm.h'`; then echo shar: \"'confkvm.h'\" unpacked with wrong size! fi # end of 'confkvm.h' fi if test -f 'confloadavglong.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confloadavglong.h'\" else echo shar: Extracting \"'confloadavglong.h'\" \(203 characters\) sed "s/^X//" >'confloadavglong.h' <<'END_OF_FILE' X#ifndef CONF_LOADAVGLONG_H X#define CONF_LOADAVGLONG_H X X#ifdef sun X#define LOADAVGISLONG 256.0 X#endif X#ifdef mips X#define LOADAVGISLONG 256.0 X#endif X#ifdef ZS X#define LOADAVGISLONG 65536.0 X#endif X X#endif END_OF_FILE if test 203 -ne `wc -c <'confloadavglong.h'`; then echo shar: \"'confloadavglong.h'\" unpacked with wrong size! fi # end of 'confloadavglong.h' fi if test -f 'confmajorminor.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confmajorminor.h'\" else echo shar: Extracting \"'confmajorminor.h'\" \(165 characters\) sed "s/^X//" >'confmajorminor.h' <<'END_OF_FILE' X#ifndef CONF_MAJOR_MINOR_H X#define CONF_MAJOR_MINOR_H X X#ifdef ZS X#define major(x) ((int)(((unsigned)(x)>>8)&0377)) X#define minor(x) ((int)((x)&0377)) X#endif X X#endif END_OF_FILE if test 165 -ne `wc -c <'confmajorminor.h'`; then echo shar: \"'confmajorminor.h'\" unpacked with wrong size! fi # end of 'confmajorminor.h' fi if test -f 'confmalloc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confmalloc.h'\" else echo shar: Extracting \"'confmalloc.h'\" \(250 characters\) sed "s/^X//" >'confmalloc.h' <<'END_OF_FILE' X#ifndef CONF_MALLOC_H X#define CONF_MALLOC_H X X/* -DVOID_MALLOC if malloc() returns a void pointer. */ X/* -UVOID_MALLOC if malloc() returns a char pointer. */ X X#if (defined(ULTRIX) && ULTRIX >= 40) || defined(CONVEX) X#define VOID_MALLOC X#endif X X#endif END_OF_FILE if test 250 -ne `wc -c <'confmalloc.h'`; then echo shar: \"'confmalloc.h'\" unpacked with wrong size! fi # end of 'confmalloc.h' fi if test -f 'confmntent.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confmntent.h'\" else echo shar: Extracting \"'confmntent.h'\" \(181 characters\) sed "s/^X//" >'confmntent.h' <<'END_OF_FILE' X#ifndef CONF_MNTENT_H X#define CONF_MNTENT_H X X/* -DMNTENT if <mntent.h> and getmntent() exist */ X X#if defined(sun) || defined(CONVEX) || defined(DYNIX) X#define MNTENT X#endif X X#endif END_OF_FILE if test 181 -ne `wc -c <'confmntent.h'`; then echo shar: \"'confmntent.h'\" unpacked with wrong size! fi # end of 'confmntent.h' fi if test -f 'confmntult.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confmntult.h'\" else echo shar: Extracting \"'confmntult.h'\" \(89 characters\) sed "s/^X//" >'confmntult.h' <<'END_OF_FILE' X#ifndef CONF_MNTULT_H X#define CONF_MNTULT_H X X#ifdef ULTRIX X#define MNTULT X#endif X X#endif END_OF_FILE if test 89 -ne `wc -c <'confmntult.h'`; then echo shar: \"'confmntult.h'\" unpacked with wrong size! fi # end of 'confmntult.h' fi if test -f 'confneedartospte.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confneedartospte.h'\" else echo shar: Extracting \"'confneedartospte.h'\" \(107 characters\) sed "s/^X//" >'confneedartospte.h' <<'END_OF_FILE' X#ifndef CONF_NEEDARTOSPTE_H X#define CONF_NEEDARTOSPTE_H X X#ifdef ZS X#define NEED_ARTOS_PTE_H X#endif X X#endif END_OF_FILE if test 107 -ne `wc -c <'confneedartospte.h'`; then echo shar: \"'confneedartospte.h'\" unpacked with wrong size! fi # end of 'confneedartospte.h' fi if test -f 'confneedmachparam.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confneedmachparam.h'\" else echo shar: Extracting \"'confneedmachparam.h'\" \(151 characters\) sed "s/^X//" >'confneedmachparam.h' <<'END_OF_FILE' X#ifndef CONF_NEEDMACHPARAM_H X#define CONF_NEEDMACHPARAM_H X X#if !defined(ULTRIX) && !defined(sun) && !defined(ZS) X#define NEED_MACHPARAM X#endif X X#endif END_OF_FILE if test 151 -ne `wc -c <'confneedmachparam.h'`; then echo shar: \"'confneedmachparam.h'\" unpacked with wrong size! fi # end of 'confneedmachparam.h' fi if test -f 'confneedmntinfo.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confneedmntinfo.h'\" else echo shar: Extracting \"'confneedmntinfo.h'\" \(132 characters\) sed "s/^X//" >'confneedmntinfo.h' <<'END_OF_FILE' X#ifndef CONF_NEEDMNTINFO_H X#define CONF_NEEDMNTINFO_H X X#if !defined(SUNOS4) && !defined(CONVEX) X#define NEED_MNTINFO X#endif X X#endif END_OF_FILE if test 132 -ne `wc -c <'confneedmntinfo.h'`; then echo shar: \"'confneedmntinfo.h'\" unpacked with wrong size! fi # end of 'confneedmntinfo.h' fi if test -f 'confnfs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnfs.h'\" else echo shar: Extracting \"'confnfs.h'\" \(99 characters\) sed "s/^X//" >'confnfs.h' <<'END_OF_FILE' X#ifndef CONF_NFS_H X#define CONF_NFS_H X X/* XXX: NFS is already a higher-level definition */ X X#endif END_OF_FILE if test 99 -ne `wc -c <'confnfs.h'`; then echo shar: \"'confnfs.h'\" unpacked with wrong size! fi # end of 'confnfs.h' fi if test -f 'confnlistknlist.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnlistknlist.h'\" else echo shar: Extracting \"'confnlistknlist.h'\" \(99 characters\) sed "s/^X//" >'confnlistknlist.h' <<'END_OF_FILE' X#ifndef CONF_NLISTKNLIST_H X#define CONF_NLISTKNLIST_H X X#ifdef CONVEX X#define KNLIST X#endif X X#endif END_OF_FILE if test 99 -ne `wc -c <'confnlistknlist.h'`; then echo shar: \"'confnlistknlist.h'\" unpacked with wrong size! fi # end of 'confnlistknlist.h' fi if test -f 'confnlistmeaning.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnlistmeaning.h'\" else echo shar: Extracting \"'confnlistmeaning.h'\" \(180 characters\) sed "s/^X//" >'confnlistmeaning.h' <<'END_OF_FILE' X#ifndef CONF_NLISTMEANING_H X#define CONF_NLISTMEANING_H X X/* -DMEANINGLESS_NLIST if nlist() does not return -1 on errors. */ X X#ifdef ULTRIX X#define MEANINGLESS_NLIST X#endif X X#endif END_OF_FILE if test 180 -ne `wc -c <'confnlistmeaning.h'`; then echo shar: \"'confnlistmeaning.h'\" unpacked with wrong size! fi # end of 'confnlistmeaning.h' fi if test -f 'confnlistunder.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnlistunder.h'\" else echo shar: Extracting \"'confnlistunder.h'\" \(187 characters\) sed "s/^X//" >'confnlistunder.h' <<'END_OF_FILE' X#ifndef CONF_NLISTUNDER_H X#define CONF_NLISTUNDER_H X X#if defined(__hp9000s800) || defined(sun386i) X#define FORGET_UNDERSCORE /* wants, e.g., "nproc" instead of "_nproc" */ X#endif X X#endif END_OF_FILE if test 187 -ne `wc -c <'confnlistunder.h'`; then echo shar: \"'confnlistunder.h'\" unpacked with wrong size! fi # end of 'confnlistunder.h' fi if test -f 'confnlname.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnlname.h'\" else echo shar: Extracting \"'confnlname.h'\" \(241 characters\) sed "s/^X//" >'confnlname.h' <<'END_OF_FILE' X#ifndef CONF_NLNAME_H X#define CONF_NLNAME_H X X#ifdef CONVEX X#define NLNAME(foo) ((foo).n_un.n_name) X/* why? why? why? why? haven't these people heard of portability? */ X#endif X X#ifndef NLNAME X#define NLNAME(foo) ((foo).n_name) X#endif X X#endif END_OF_FILE if test 241 -ne `wc -c <'confnlname.h'`; then echo shar: \"'confnlname.h'\" unpacked with wrong size! fi # end of 'confnlname.h' fi if test -f 'confnonsfinet.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnonsfinet.h'\" else echo shar: Extracting \"'confnonsfinet.h'\" \(123 characters\) sed "s/^X//" >'confnonsfinet.h' <<'END_OF_FILE' X#ifndef CONF_NONSFINET_H X#define CONF_NONSFINET_H X X#ifdef __hpux X#define NONSFINET /* no netstat -f inet */ X#endif X X#endif END_OF_FILE if test 123 -ne `wc -c <'confnonsfinet.h'`; then echo shar: \"'confnonsfinet.h'\" unpacked with wrong size! fi # end of 'confnonsfinet.h' fi if test -f 'confnounpaddr.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confnounpaddr.h'\" else echo shar: Extracting \"'confnounpaddr.h'\" \(157 characters\) sed "s/^X//" >'confnounpaddr.h' <<'END_OF_FILE' X#ifndef CONF_NOUNPADDR_H X#define CONF_NOUNPADDR_H X X#if defined(DYNIX) || (defined(ULTRIX) && ULTRIX == 22) /*XXX: BSD43?*/ X#define NO_UNPADDR X#endif X X#endif END_OF_FILE if test 157 -ne `wc -c <'confnounpaddr.h'`; then echo shar: \"'confnounpaddr.h'\" unpacked with wrong size! fi # end of 'confnounpaddr.h' fi if test -f 'confodofe.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confodofe.h'\" else echo shar: Extracting \"'confodofe.h'\" \(85 characters\) sed "s/^X//" >'confodofe.h' <<'END_OF_FILE' X#ifndef CONF_ODOFE_H X#define CONF_ODOFE_H X X#ifdef DYNIX X#define ODOFE X#endif X X#endif END_OF_FILE if test 85 -ne `wc -c <'confodofe.h'`; then echo shar: \"'confodofe.h'\" unpacked with wrong size! fi # end of 'confodofe.h' fi if test -f 'confopalf.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confopalf.h'\" else echo shar: Extracting \"'confopalf.h'\" \(87 characters\) sed "s/^X//" >'confopalf.h' <<'END_OF_FILE' X#ifndef CONF_OPALF_H X#define CONF_OPALF_H X X#ifdef SUNOS41 X#define OPALF X#endif X X#endif END_OF_FILE if test 87 -ne `wc -c <'confopalf.h'`; then echo shar: \"'confopalf.h'\" unpacked with wrong size! fi # end of 'confopalf.h' fi if test -f 'confpcredinproc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confpcredinproc.h'\" else echo shar: Extracting \"'confpcredinproc.h'\" \(106 characters\) sed "s/^X//" >'confpcredinproc.h' <<'END_OF_FILE' X#ifndef CONF_PCREDINPROC_H X#define CONF_PCREDINPROC_H X X#ifdef CONVEX X#define PCRED_IN_PROC X#endif X X#endif END_OF_FILE if test 106 -ne `wc -c <'confpcredinproc.h'`; then echo shar: \"'confpcredinproc.h'\" unpacked with wrong size! fi # end of 'confpcredinproc.h' fi if test -f 'confpcredunderproc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confpcredunderproc.h'\" else echo shar: Extracting \"'confpcredunderproc.h'\" \(112 characters\) sed "s/^X//" >'confpcredunderproc.h' <<'END_OF_FILE' X#ifndef CONF_PCREDUNDERPROC_H X#define CONF_PCREDUNDERPROC_H X X#ifdef sun X#define PCRED_UNDER_PROC X#endif X X#endif END_OF_FILE if test 112 -ne `wc -c <'confpcredunderproc.h'`; then echo shar: \"'confpcredunderproc.h'\" unpacked with wrong size! fi # end of 'confpcredunderproc.h' fi if test -f 'confpsess.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confpsess.h'\" else echo shar: Extracting \"'confpsess.h'\" \(87 characters\) sed "s/^X//" >'confpsess.h' <<'END_OF_FILE' X#ifndef CONF_PSESS_H X#define CONF_PSESS_H X X#ifdef SUNOS41 X#define PSESS X#endif X X#endif END_OF_FILE if test 87 -ne `wc -c <'confpsess.h'`; then echo shar: \"'confpsess.h'\" unpacked with wrong size! fi # end of 'confpsess.h' fi if test -f 'confregion.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confregion.h'\" else echo shar: Extracting \"'confregion.h'\" \(89 characters\) sed "s/^X//" >'confregion.h' <<'END_OF_FILE' X#ifndef CONF_REGION_H X#define CONF_REGION_H X X#ifdef CONVEX X#define REGION X#endif X X#endif END_OF_FILE if test 89 -ne `wc -c <'confregion.h'`; then echo shar: \"'confregion.h'\" unpacked with wrong size! fi # end of 'confregion.h' fi if test -f 'confrtype.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confrtype.h'\" else echo shar: Extracting \"'confrtype.h'\" \(110 characters\) sed "s/^X//" >'confrtype.h' <<'END_OF_FILE' X#ifndef CONF_RTYPE_H X#define CONF_RTYPE_H X X#if defined(NFS) && !defined(SUNOS4) X#define R_TYPE X#endif X X#endif END_OF_FILE if test 110 -ne `wc -c <'confrtype.h'`; then echo shar: \"'confrtype.h'\" unpacked with wrong size! fi # end of 'confrtype.h' fi if test -f 'confslowstat.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confslowstat.h'\" else echo shar: Extracting \"'confslowstat.h'\" \(117 characters\) sed "s/^X//" >'confslowstat.h' <<'END_OF_FILE' X#ifndef CONF_SLOWSTAT_H X#define CONF_SLOWSTAT_H X X#if defined(NFS) || defined(ULTRIX) X#define SLOWSTAT X#endif X X#endif END_OF_FILE if test 117 -ne `wc -c <'confslowstat.h'`; then echo shar: \"'confslowstat.h'\" unpacked with wrong size! fi # end of 'confslowstat.h' fi if test -f 'confsocketneedsxnode.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confsocketneedsxnode.h'\" else echo shar: Extracting \"'confsocketneedsxnode.h'\" \(119 characters\) sed "s/^X//" >'confsocketneedsxnode.h' <<'END_OF_FILE' X#ifndef CONF_SOCKETNEEDSXNODE_H X#define CONF_SOCKETNEEDSXNODE_H X X#ifdef CONVEX X#define SOCKETNEEDSXNODE X#endif X X#endif END_OF_FILE if test 119 -ne `wc -c <'confsocketneedsxnode.h'`; then echo shar: \"'confsocketneedsxnode.h'\" unpacked with wrong size! fi # end of 'confsocketneedsxnode.h' fi if test -f 'confsyncsema.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confsyncsema.h'\" else echo shar: Extracting \"'confsyncsema.h'\" \(95 characters\) sed "s/^X//" >'confsyncsema.h' <<'END_OF_FILE' X#ifndef CONF_SYNCSEMA_H X#define CONF_SYNCSEMA_H X X#ifdef CONVEX X#define SYNCSEMA X#endif X X#endif END_OF_FILE if test 95 -ne `wc -c <'confsyncsema.h'`; then echo shar: \"'confsyncsema.h'\" unpacked with wrong size! fi # end of 'confsyncsema.h' fi if test -f 'confsysucred.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confsysucred.h'\" else echo shar: Extracting \"'confsysucred.h'\" \(95 characters\) sed "s/^X//" >'confsysucred.h' <<'END_OF_FILE' X#ifndef CONF_SYSUCRED_H X#define CONF_SYSUCRED_H X X#ifdef CONVEX X#define SYSUCRED X#endif X X#endif END_OF_FILE if test 95 -ne `wc -c <'confsysucred.h'`; then echo shar: \"'confsysucred.h'\" unpacked with wrong size! fi # end of 'confsysucred.h' fi if test -f 'conftcpnlist.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'conftcpnlist.h'\" else echo shar: Extracting \"'conftcpnlist.h'\" \(135 characters\) sed "s/^X//" >'conftcpnlist.h' <<'END_OF_FILE' X#ifndef CONF_TCPNLIST_H X#define CONF_TCPNLIST_H X X#ifdef __hpux X#define TCPNLIST "_tcp_cb" X#else X#define TCPNLIST "_tcb" X#endif X X#endif END_OF_FILE if test 135 -ne `wc -c <'conftcpnlist.h'`; then echo shar: \"'conftcpnlist.h'\" unpacked with wrong size! fi # end of 'conftcpnlist.h' fi if test -f 'conftext.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'conftext.h'\" else echo shar: Extracting \"'conftext.h'\" \(129 characters\) sed "s/^X//" >'conftext.h' <<'END_OF_FILE' X#ifndef CONF_TEXT_H X#define CONF_TEXT_H X X#if !defined(SUNOS4) && !defined(CONVEX) && !defined(DYNIX) X#define TEXT X#endif X X#endif END_OF_FILE if test 129 -ne `wc -c <'conftext.h'`; then echo shar: \"'conftext.h'\" unpacked with wrong size! fi # end of 'conftext.h' fi if test -f 'conftextneedsvmparam.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'conftextneedsvmparam.h'\" else echo shar: Extracting \"'conftextneedsvmparam.h'\" \(115 characters\) sed "s/^X//" >'conftextneedsvmparam.h' <<'END_OF_FILE' X#ifndef CONF_TEXTNEEDSVMPARAM_H X#define CONF_TEXTNEEDSVMPARAM_H X X#ifdef ZS X#define TEXTNEEDSVMPARAM X#endif X X#endif END_OF_FILE if test 115 -ne `wc -c <'conftextneedsvmparam.h'`; then echo shar: \"'conftextneedsvmparam.h'\" unpacked with wrong size! fi # end of 'conftextneedsvmparam.h' fi if test -f 'confttyvp.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confttyvp.h'\" else echo shar: Extracting \"'confttyvp.h'\" \(83 characters\) sed "s/^X//" >'confttyvp.h' <<'END_OF_FILE' X#ifndef CONF_TTYVP_H X#define CONF_TTYVP_H X X#ifdef sun X#define TTYVP X#endif X X#endif END_OF_FILE if test 83 -ne `wc -c <'confttyvp.h'`; then echo shar: \"'confttyvp.h'\" unpacked with wrong size! fi # end of 'confttyvp.h' fi if test -f 'confultrixrpcnfs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confultrixrpcnfs.h'\" else echo shar: Extracting \"'confultrixrpcnfs.h'\" \(107 characters\) sed "s/^X//" >'confultrixrpcnfs.h' <<'END_OF_FILE' X#ifndef CONF_ULTRIXRPCNFS_H X#define CONF_ULTRIXRPCNFS_H X X#ifdef ULTRIX X#define ULTRIXRPCNFS X#endif X X#endif END_OF_FILE if test 107 -ne `wc -c <'confultrixrpcnfs.h'`; then echo shar: \"'confultrixrpcnfs.h'\" unpacked with wrong size! fi # end of 'confultrixrpcnfs.h' fi if test -f 'confundefstdcbeforedir.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confundefstdcbeforedir.h'\" else echo shar: Extracting \"'confundefstdcbeforedir.h'\" \(125 characters\) sed "s/^X//" >'confundefstdcbeforedir.h' <<'END_OF_FILE' X#ifndef CONF_UNDEFSTDCBEFOREDIR_H X#define CONF_UNDEFSTDCBEFOREDIR_H X X#ifdef CONVEX X#define UNDEFSTDCBEFOREDIR X#endif X X#endif END_OF_FILE if test 125 -ne `wc -c <'confundefstdcbeforedir.h'`; then echo shar: \"'confundefstdcbeforedir.h'\" unpacked with wrong size! fi # end of 'confundefstdcbeforedir.h' fi if test -f 'confusrptnlist.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confusrptnlist.h'\" else echo shar: Extracting \"'confusrptnlist.h'\" \(356 characters\) sed "s/^X//" >'confusrptnlist.h' <<'END_OF_FILE' X#ifndef CONF_USRPTNLIST_H X#define CONF_USRPTNLIST_H X X#include "confgetusersupport.h" X X#ifndef GETUSERSUPPORT X#if defined(BSD43TAHOE) || (defined(ULTRIX) && (ULTRIX < 40)) X#define NLISTPAGES "_Usrptmap" X#define NLISTBASE "_usrpt" X#else X#define NLISTPAGES "_Sysmap" /* is this _pages on a Sun? who cares */ X#define NLISTBASE "_Sysbase" X#endif X#endif X X#endif END_OF_FILE if test 356 -ne `wc -c <'confusrptnlist.h'`; then echo shar: \"'confusrptnlist.h'\" unpacked with wrong size! fi # end of 'confusrptnlist.h' fi if test -f 'confvmunix.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confvmunix.h'\" else echo shar: Extracting \"'confvmunix.h'\" \(300 characters\) sed "s/^X//" >'confvmunix.h' <<'END_OF_FILE' X#ifndef CONF_VMUNIX_H X#define CONF_VMUNIX_H X X#ifndef VMUNIX X#ifdef __hpux X#define VMUNIX "/hp-ux" X#endif X#endif X X#ifndef VMUNIX X#ifdef DYNIX X#define VMUNIX "/dynix" X#endif X#endif X X#ifndef VMUNIX X#ifdef ZS X#define VMUNIX "/zsunix" X#endif X#endif X X#ifndef VMUNIX X#define VMUNIX "/vmunix" X#endif X X#endif END_OF_FILE if test 300 -ne `wc -c <'confvmunix.h'`; then echo shar: \"'confvmunix.h'\" unpacked with wrong size! fi # end of 'confvmunix.h' fi if test -f 'confvtype.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confvtype.h'\" else echo shar: Extracting \"'confvtype.h'\" \(109 characters\) sed "s/^X//" >'confvtype.h' <<'END_OF_FILE' X#ifndef CONF_VTYPE_H X#define CONF_VTYPE_H X X#if defined(NFS) || defined(ULTRIX) X#define V_TYPE X#endif X X#endif END_OF_FILE if test 109 -ne `wc -c <'confvtype.h'`; then echo shar: \"'confvtype.h'\" unpacked with wrong size! fi # end of 'confvtype.h' fi if test -f 'filetable.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'filetable.h'\" else echo shar: Extracting \"'filetable.h'\" \(193 characters\) sed "s/^X//" >'filetable.h' <<'END_OF_FILE' X#ifndef FILETABLE_H X#define FILETABLE_H X Xextern char *filetablestrerr(); Xextern int mynfile; Xextern int filetableinit(); Xextern struct file *myfile; Xextern struct file *getfiletable(); X X#endif END_OF_FILE if test 193 -ne `wc -c <'filetable.h'`; then echo shar: \"'filetable.h'\" unpacked with wrong size! fi # end of 'filetable.h' fi if test ! -d 'findinode' ; then echo shar: Creating directory \"'findinode'\" mkdir 'findinode' fi if test -f 'findinode/FIDDIR' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/FIDDIR'\" else echo shar: Extracting \"'findinode/FIDDIR'\" \(105 characters\) sed "s/^X//" >'findinode/FIDDIR' <<'END_OF_FILE' X/etc/fid XThe first line of this file should be a directory where the findinode Xdatabases will be stored. END_OF_FILE if test 105 -ne `wc -c <'findinode/FIDDIR'`; then echo shar: \"'findinode/FIDDIR'\" unpacked with wrong size! fi # end of 'findinode/FIDDIR' fi if test -f 'findinode/FILES' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/FILES'\" else echo shar: Extracting \"'findinode/FILES'\" \(118 characters\) sed "s/^X//" >'findinode/FILES' <<'END_OF_FILE' XREADME XFILES XMakefile XFIDDIR XINSTALL Xfsupdatefid Xfid.h Xfid.c Xupdatefid.c Xfindinode.c Xupdatefid.8 Xfindinode.1 Xgetopt.h END_OF_FILE if test 118 -ne `wc -c <'findinode/FILES'`; then echo shar: \"'findinode/FILES'\" unpacked with wrong size! fi # end of 'findinode/FILES' fi if test -f 'findinode/findinode.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/findinode.1'\" else echo shar: Extracting \"'findinode/findinode.1'\" \(0 characters\) sed "s/^X//" >'findinode/findinode.1' <<'END_OF_FILE' END_OF_FILE if test 0 -ne `wc -c <'findinode/findinode.1'`; then echo shar: \"'findinode/findinode.1'\" unpacked with wrong size! fi # end of 'findinode/findinode.1' fi if test -f 'findinode/fsupdatefid' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/fsupdatefid'\" else echo shar: Extracting \"'findinode/fsupdatefid'\" \(427 characters\) sed "s/^X//" >'findinode/fsupdatefid' <<'END_OF_FILE' X#!/bin/sh X# X# Note the hard-coded /etc/updatefid. X# X# If the speed of this script is important, it should be rewritten with X# xargs to run updatefid on several directories at once. X# X# On NFS systems you may want to use several find -xdev commands on just X# the local filesystems. Or you may want to include everything. Your X# choice. X# XSLEEP=3 Xwhile : Xdo X find / -type d -exec sleep $SLEEP \; -exec /etc/updatefid {} \; Xdone END_OF_FILE if test 427 -ne `wc -c <'findinode/fsupdatefid'`; then echo shar: \"'findinode/fsupdatefid'\" unpacked with wrong size! fi chmod +x 'findinode/fsupdatefid' # end of 'findinode/fsupdatefid' fi if test -f 'findinode/getopt.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/getopt.h'\" else echo shar: Extracting \"'findinode/getopt.h'\" \(177 characters\) sed "s/^X//" >'findinode/getopt.h' <<'END_OF_FILE' X#ifndef GETOPT_H X#define GETOPT_H X X/* The following should be in /usr/include/getopt.h but often aren't. */ Xextern int getopt(); Xextern char *optarg; Xextern int optind; X X#endif END_OF_FILE if test 177 -ne `wc -c <'findinode/getopt.h'`; then echo shar: \"'findinode/getopt.h'\" unpacked with wrong size! fi # end of 'findinode/getopt.h' fi if test -f 'findinode/updatefid.8' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/updatefid.8'\" else echo shar: Extracting \"'findinode/updatefid.8'\" \(0 characters\) sed "s/^X//" >'findinode/updatefid.8' <<'END_OF_FILE' END_OF_FILE if test 0 -ne `wc -c <'findinode/updatefid.8'`; then echo shar: \"'findinode/updatefid.8'\" unpacked with wrong size! fi # end of 'findinode/updatefid.8' fi if test -f 'getdevicename.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getdevicename.h'\" else echo shar: Extracting \"'getdevicename.h'\" \(117 characters\) sed "s/^X//" >'getdevicename.h' <<'END_OF_FILE' X#ifndef GETDEVICENAME_H X#define GETDEVICENAME_H X Xextern char *getdevicename(); Xextern char *getttydevname(); X X#endif END_OF_FILE if test 117 -ne `wc -c <'getdevicename.h'`; then echo shar: \"'getdevicename.h'\" unpacked with wrong size! fi # end of 'getdevicename.h' fi if test -f 'getfcred.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getfcred.h'\" else echo shar: Extracting \"'getfcred.h'\" \(111 characters\) sed "s/^X//" >'getfcred.h' <<'END_OF_FILE' X#ifndef GETFCRED_H X#define GETFCRED_H X Xextern char *getfcredstrerr(); Xextern struct ucred *getfcred(); X X#endif END_OF_FILE if test 111 -ne `wc -c <'getfcred.h'`; then echo shar: \"'getfcred.h'\" unpacked with wrong size! fi # end of 'getfcred.h' fi if test -f 'getopt.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getopt.h'\" else echo shar: Extracting \"'getopt.h'\" \(177 characters\) sed "s/^X//" >'getopt.h' <<'END_OF_FILE' X#ifndef GETOPT_H X#define GETOPT_H X X/* The following should be in /usr/include/getopt.h but often aren't. */ Xextern int getopt(); Xextern char *optarg; Xextern int optind; X X#endif END_OF_FILE if test 177 -ne `wc -c <'getopt.h'`; then echo shar: \"'getopt.h'\" unpacked with wrong size! fi # end of 'getopt.h' fi if test -f 'getpcred.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getpcred.h'\" else echo shar: Extracting \"'getpcred.h'\" \(111 characters\) sed "s/^X//" >'getpcred.h' <<'END_OF_FILE' X#ifndef GETPCRED_H X#define GETPCRED_H X Xextern char *getpcredstrerr(); Xextern struct ucred *getpcred(); X X#endif END_OF_FILE if test 111 -ne `wc -c <'getpcred.h'`; then echo shar: \"'getpcred.h'\" unpacked with wrong size! fi # end of 'getpcred.h' fi if test -f 'getsocket.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getsocket.h'\" else echo shar: Extracting \"'getsocket.h'\" \(575 characters\) sed "s/^X//" >'getsocket.h' <<'END_OF_FILE' X#ifndef GETSOCKET_H X#define GETSOCKET_H X X#define FSW_UNK 0 X#define FSW_INET 1 X#define FSW_UNIX 2 X Xstruct socketbuf X { X int socktype; char *strsockt; X int flagaccept; int flagreuse; int flaghead; X int family; char *famname; /* may be truncated to 30 chars */ X int fsw; X union X { X struct { X int proto; char *strpro; X int r0; int r1; int r2; int r3; int rp; X int l0; int l1; int l2; int l3; int lp; X } inet; X struct { char *unpcb; char *node; char *conn; char path[108]; /* XXX: gag */ X } un; X } X fu; X } X; X Xextern int getsocket(); X X#endif END_OF_FILE if test 575 -ne `wc -c <'getsocket.h'`; then echo shar: \"'getsocket.h'\" unpacked with wrong size! fi # end of 'getsocket.h' fi if test -f 'getuser.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getuser.h'\" else echo shar: Extracting \"'getuser.h'\" \(132 characters\) sed "s/^X//" >'getuser.h' <<'END_OF_FILE' X#ifndef GETUSER_H X#define GETUSER_H X Xextern char *getuserstrerr(); Xextern int getuserinit(); Xextern struct user *getuser(); X X#endif END_OF_FILE if test 132 -ne `wc -c <'getuser.h'`; then echo shar: \"'getuser.h'\" unpacked with wrong size! fi # end of 'getuser.h' fi if test -f 'getvmseg.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getvmseg.h'\" else echo shar: Extracting \"'getvmseg.h'\" \(124 characters\) sed "s/^X//" >'getvmseg.h' <<'END_OF_FILE' X#ifndef GETVMSEG_H X#define GETVMSEG_H X Xextern int vmsegmax; Xextern struct vnode **getvmseg(); Xextern int seginit(); X X#endif END_OF_FILE if test 124 -ne `wc -c <'getvmseg.h'`; then echo shar: \"'getvmseg.h'\" unpacked with wrong size! fi # end of 'getvmseg.h' fi if test -f 'groupname.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'groupname.h'\" else echo shar: Extracting \"'groupname.h'\" \(105 characters\) sed "s/^X//" >'groupname.h' <<'END_OF_FILE' X#ifndef GROUPNAME_H X#define GROUPNAME_H X Xextern int gid2groupname(); Xextern int groupname2gid(); X X#endif END_OF_FILE if test 105 -ne `wc -c <'groupname.h'`; then echo shar: \"'groupname.h'\" unpacked with wrong size! fi # end of 'groupname.h' fi if test -f 'inpcblist.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'inpcblist.h'\" else echo shar: Extracting \"'inpcblist.h'\" \(203 characters\) sed "s/^X//" >'inpcblist.h' <<'END_OF_FILE' X#ifndef INPCBLIST_H X#define INPCBLIST_H X Xextern int inperrno; /*XXX*/ Xextern char *inpcbliststrerr(); Xextern struct inpcb *inpcbloc; Xextern int inpcblistinit(); Xextern struct inpcb *nextinpcb(); X X#endif END_OF_FILE if test 203 -ne `wc -c <'inpcblist.h'`; then echo shar: \"'inpcblist.h'\" unpacked with wrong size! fi # end of 'inpcblist.h' fi if test -f 'kmem.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'kmem.h'\" else echo shar: Extracting \"'kmem.h'\" \(111 characters\) sed "s/^X//" >'kmem.h' <<'END_OF_FILE' X#ifndef KMEM_H X#define KMEM_H X Xextern char *kmemstrerr(); Xextern int kmeminit(); Xextern int kmemcpy(); X X#endif END_OF_FILE if test 111 -ne `wc -c <'kmem.h'`; then echo shar: \"'kmem.h'\" unpacked with wrong size! fi # end of 'kmem.h' fi if test -f 'mallocfree.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mallocfree.h'\" else echo shar: Extracting \"'mallocfree.h'\" \(245 characters\) sed "s/^X//" >'mallocfree.h' <<'END_OF_FILE' X#ifndef MALLOCFREE_H X#define MALLOCFREE_H X X#include "confmalloc.h" X#include "conffree.h" X X#ifdef VOID_MALLOC Xextern void *malloc(); X#else Xextern char *malloc(); X#endif X#ifdef VOID_FREE Xextern void free(); X#else Xextern int free(); X#endif X X#endif END_OF_FILE if test 245 -ne `wc -c <'mallocfree.h'`; then echo shar: \"'mallocfree.h'\" unpacked with wrong size! fi # end of 'mallocfree.h' fi if test -f 'mmem.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mmem.h'\" else echo shar: Extracting \"'mmem.h'\" \(111 characters\) sed "s/^X//" >'mmem.h' <<'END_OF_FILE' X#ifndef MMEM_H X#define MMEM_H X Xextern char *mmemstrerr(); Xextern int mmeminit(); Xextern int mmemcpy(); X X#endif END_OF_FILE if test 111 -ne `wc -c <'mmem.h'`; then echo shar: \"'mmem.h'\" unpacked with wrong size! fi # end of 'mmem.h' fi if test -f 'mntops.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mntops.h'\" else echo shar: Extracting \"'mntops.h'\" \(503 characters\) sed "s/^X//" >'mntops.h' <<'END_OF_FILE' X#ifndef MNTOPS_H X#define MNTOPS_H X X#include <sys/types.h> X#include "structmtab.h" /* for MNTMAXSTR */ X Xstruct mounted X { X char *mountpoint; X char *filesystem; X } X; X Xstruct statlist X { X struct statlist *next; X char filename[MNTMAXSTR]; X char fsname[MNTMAXSTR]; X dev_t device; X } X; X Xextern struct statlist *stats; X Xextern int get_mntlist(); Xextern struct mounted *getmntname(); /* for directory or block dev name */ Xextern struct mounted *getmntfile(); /* for dev number (in struct stat) */ X X#endif END_OF_FILE if test 503 -ne `wc -c <'mntops.h'`; then echo shar: \"'mntops.h'\" unpacked with wrong size! fi # end of 'mntops.h' fi if test -f 'netinp.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'netinp.h'\" else echo shar: Extracting \"'netinp.h'\" \(124 characters\) sed "s/^X//" >'netinp.h' <<'END_OF_FILE' X#ifndef NETINP_H X#define NETINP_H X Xextern char *inploc; Xextern int netinpinit(); Xextern struct inpcb *nextnetinp(); X X#endif END_OF_FILE if test 124 -ne `wc -c <'netinp.h'`; then echo shar: \"'netinp.h'\" unpacked with wrong size! fi # end of 'netinp.h' fi if test -f 'nlistlist.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'nlistlist.h'\" else echo shar: Extracting \"'nlistlist.h'\" \(149 characters\) sed "s/^X//" >'nlistlist.h' <<'END_OF_FILE' X#ifndef NLISTLIST_H X#define NLISTLIST_H X Xextern char *nlistnotin(); Xextern char *nliststrerr(); Xextern int nlistadd(); Xextern int nlistdo(); X X#endif END_OF_FILE if test 149 -ne `wc -c <'nlistlist.h'`; then echo shar: \"'nlistlist.h'\" unpacked with wrong size! fi # end of 'nlistlist.h' fi if test -f 'numeric.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'numeric.c'\" else echo shar: Extracting \"'numeric.c'\" \(422 characters\) sed "s/^X//" >'numeric.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xint numeric(s) char *s; returns 1 if s is entirely composed of the Xdigits 0 through 9, 0 otherwise. X X*/ X X#include "numeric.h" X Xint numeric(s) Xchar *s; X{ X while (*s) X { X if ((*s != '0') && (*s != '1') && (*s != '2') && (*s != '3') && (*s != '4') X && (*s != '5') && (*s != '6') && (*s != '7') && (*s != '8') && (*s != '9')) X return 0; X ++s; X } X return 1; X} END_OF_FILE if test 422 -ne `wc -c <'numeric.c'`; then echo shar: \"'numeric.c'\" unpacked with wrong size! fi # end of 'numeric.c' fi if test -f 'numeric.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'numeric.h'\" else echo shar: Extracting \"'numeric.h'\" \(67 characters\) sed "s/^X//" >'numeric.h' <<'END_OF_FILE' X#ifndef NUMERIC_H X#define NUMERIC_H X Xextern int numeric(); X X#endif END_OF_FILE if test 67 -ne `wc -c <'numeric.h'`; then echo shar: \"'numeric.h'\" unpacked with wrong size! fi # end of 'numeric.h' fi if test -f 'portname.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'portname.h'\" else echo shar: Extracting \"'portname.h'\" \(103 characters\) sed "s/^X//" >'portname.h' <<'END_OF_FILE' X#ifndef PORTNAME_H X#define PORTNAME_H X Xextern int port2portname(); Xextern int portname2port(); X X#endif END_OF_FILE if test 103 -ne `wc -c <'portname.h'`; then echo shar: \"'portname.h'\" unpacked with wrong size! fi # end of 'portname.h' fi if test -f 'printfamily.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printfamily.h'\" else echo shar: Extracting \"'printfamily.h'\" \(81 characters\) sed "s/^X//" >'printfamily.h' <<'END_OF_FILE' X#ifndef PRINTFAMILY_H X#define PRINTFAMILY_H X Xextern char *printfamily(); X X#endif END_OF_FILE if test 81 -ne `wc -c <'printfamily.h'`; then echo shar: \"'printfamily.h'\" unpacked with wrong size! fi # end of 'printfamily.h' fi if test -f 'printfflag.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printfflag.h'\" else echo shar: Extracting \"'printfflag.h'\" \(303 characters\) sed "s/^X//" >'printfflag.h' <<'END_OF_FILE' X#ifndef PRINTFFLAG_H X#define PRINTFFLAG_H X Xextern char *printfflag(); X/* printfflag(f,0) produces rwa */ X/* wn */ X/* printfflag(f,1) produces rwa */ X/* wn */ X/* printfflag(f,2) produces rw a */ X/* wn */ X X#endif END_OF_FILE if test 303 -ne `wc -c <'printfflag.h'`; then echo shar: \"'printfflag.h'\" unpacked with wrong size! fi # end of 'printfflag.h' fi if test -f 'printftype.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printftype.h'\" else echo shar: Extracting \"'printftype.h'\" \(78 characters\) sed "s/^X//" >'printftype.h' <<'END_OF_FILE' X#ifndef PRINTFTYPE_H X#define PRINTFTYPE_H X Xextern char *printftype(); X X#endif END_OF_FILE if test 78 -ne `wc -c <'printftype.h'`; then echo shar: \"'printftype.h'\" unpacked with wrong size! fi # end of 'printftype.h' fi if test -f 'printprotoinet.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printprotoinet.h'\" else echo shar: Extracting \"'printprotoinet.h'\" \(90 characters\) sed "s/^X//" >'printprotoinet.h' <<'END_OF_FILE' X#ifndef PRINTPROTOINET_H X#define PRINTPROTOINET_H X Xextern char *printprotoinet(); X X#endif END_OF_FILE if test 90 -ne `wc -c <'printprotoinet.h'`; then echo shar: \"'printprotoinet.h'\" unpacked with wrong size! fi # end of 'printprotoinet.h' fi if test -f 'printpstat.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printpstat.h'\" else echo shar: Extracting \"'printpstat.h'\" \(78 characters\) sed "s/^X//" >'printpstat.h' <<'END_OF_FILE' X#ifndef PRINTPSTAT_H X#define PRINTPSTAT_H X Xextern char *printpstat(); X X#endif END_OF_FILE if test 78 -ne `wc -c <'printpstat.h'`; then echo shar: \"'printpstat.h'\" unpacked with wrong size! fi # end of 'printpstat.h' fi if test -f 'printrlimits.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printrlimits.h'\" else echo shar: Extracting \"'printrlimits.h'\" \(84 characters\) sed "s/^X//" >'printrlimits.h' <<'END_OF_FILE' X#ifndef PRINTRLIMITS_H X#define PRINTRLIMITS_H X Xextern char *printrlimits(); X X#endif END_OF_FILE if test 84 -ne `wc -c <'printrlimits.h'`; then echo shar: \"'printrlimits.h'\" unpacked with wrong size! fi # end of 'printrlimits.h' fi if test -f 'printrusage.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printrusage.h'\" else echo shar: Extracting \"'printrusage.h'\" \(81 characters\) sed "s/^X//" >'printrusage.h' <<'END_OF_FILE' X#ifndef PRINTRUSAGE_H X#define PRINTRUSAGE_H X Xextern char *printrusage(); X X#endif END_OF_FILE if test 81 -ne `wc -c <'printrusage.h'`; then echo shar: \"'printrusage.h'\" unpacked with wrong size! fi # end of 'printrusage.h' fi if test -f 'printsocktype.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printsocktype.h'\" else echo shar: Extracting \"'printsocktype.h'\" \(87 characters\) sed "s/^X//" >'printsocktype.h' <<'END_OF_FILE' X#ifndef PRINTSOCKTYPE_H X#define PRINTSOCKTYPE_H X Xextern char *printsocktype(); X X#endif END_OF_FILE if test 87 -ne `wc -c <'printsocktype.h'`; then echo shar: \"'printsocktype.h'\" unpacked with wrong size! fi # end of 'printsocktype.h' fi if test -f 'printucred.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printucred.h'\" else echo shar: Extracting \"'printucred.h'\" \(78 characters\) sed "s/^X//" >'printucred.h' <<'END_OF_FILE' X#ifndef PRINTUCRED_H X#define PRINTUCRED_H X Xextern char *printucred(); X X#endif END_OF_FILE if test 78 -ne `wc -c <'printucred.h'`; then echo shar: \"'printucred.h'\" unpacked with wrong size! fi # end of 'printucred.h' fi if test -f 'proctable.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'proctable.h'\" else echo shar: Extracting \"'proctable.h'\" \(193 characters\) sed "s/^X//" >'proctable.h' <<'END_OF_FILE' X#ifndef PROCTABLE_H X#define PROCTABLE_H X Xextern char *proctablestrerr(); Xextern struct proc *myproc; Xextern int mynproc; Xextern int proctableinit(); Xextern struct proc *getproctable(); X X#endif END_OF_FILE if test 193 -ne `wc -c <'proctable.h'`; then echo shar: \"'proctable.h'\" unpacked with wrong size! fi # end of 'proctable.h' fi if test -f 'revnamei.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'revnamei.h'\" else echo shar: Extracting \"'revnamei.h'\" \(0 characters\) sed "s/^X//" >'revnamei.h' <<'END_OF_FILE' END_OF_FILE if test 0 -ne `wc -c <'revnamei.h'`; then echo shar: \"'revnamei.h'\" unpacked with wrong size! fi # end of 'revnamei.h' fi if test -f 'smem.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'smem.h'\" else echo shar: Extracting \"'smem.h'\" \(111 characters\) sed "s/^X//" >'smem.h' <<'END_OF_FILE' X#ifndef SMEM_H X#define SMEM_H X Xextern char *smemstrerr(); Xextern int smeminit(); Xextern int smemcpy(); X X#endif END_OF_FILE if test 111 -ne `wc -c <'smem.h'`; then echo shar: \"'smem.h'\" unpacked with wrong size! fi # end of 'smem.h' fi if test -f 'stattimeout.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stattimeout.h'\" else echo shar: Extracting \"'stattimeout.h'\" \(79 characters\) sed "s/^X//" >'stattimeout.h' <<'END_OF_FILE' X#ifndef STATTIMEOUT_H X#define STATTIMEOUT_H X Xextern int stattimeout(); X X#endif END_OF_FILE if test 79 -ne `wc -c <'stattimeout.h'`; then echo shar: \"'stattimeout.h'\" unpacked with wrong size! fi # end of 'stattimeout.h' fi if test -f 'strerr.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'strerr.h'\" else echo shar: Extracting \"'strerr.h'\" \(450 characters\) sed "s/^X//" >'strerr.h' <<'END_OF_FILE' X#ifndef STRERR_H X#define STRERR_H X Xtypedef char *(*strerrfun)(); X /* Note that you'd need to use structs to prototype this. */ Xstruct strerrtab X { X int err; X char *s; X strerrfun next; X } X; X Xextern char *strerrsys(); Xextern char *strerrno(); Xextern char *strerr(); Xextern char *strerrtaberr(); Xextern char *strerrstr(); X X/* REturn setting ERror Number */ X/* err must be lvalue */ X#define RETERN(ret,err,no) { (err) = (no); return (ret); } X X#endif END_OF_FILE if test 450 -ne `wc -c <'strerr.h'`; then echo shar: \"'strerr.h'\" unpacked with wrong size! fi # end of 'strerr.h' fi if test -f 'structmbuf.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structmbuf.h'\" else echo shar: Extracting \"'structmbuf.h'\" \(96 characters\) sed "s/^X//" >'structmbuf.h' <<'END_OF_FILE' X#ifndef STRUCT_MBUF_H X#define STRUCT_MBUF_H X X#ifndef MSIZE X#include <sys/mbuf.h> X#endif X X#endif END_OF_FILE if test 96 -ne `wc -c <'structmbuf.h'`; then echo shar: \"'structmbuf.h'\" unpacked with wrong size! fi # end of 'structmbuf.h' fi if test -f 'structproc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structproc.h'\" else echo shar: Extracting \"'structproc.h'\" \(333 characters\) sed "s/^X//" >'structproc.h' <<'END_OF_FILE' X#ifndef STRUCT_PROC_H X#define STRUCT_PROC_H X X/* On an optimal system, this file would contain solely: */ X/* #include <sys/proc.h> */ X X#include <sys/types.h> X#include <sys/param.h> X#ifndef ITIMER_REAL X#include <sys/time.h> X#endif X#include <sys/proc.h> X#include "confhavepsuid.h" X#ifndef HAVE_PSUID X#define p_suid p_uid X#endif X X#endif END_OF_FILE if test 333 -ne `wc -c <'structproc.h'`; then echo shar: \"'structproc.h'\" unpacked with wrong size! fi # end of 'structproc.h' fi if test -f 'structprotosw.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structprotosw.h'\" else echo shar: Extracting \"'structprotosw.h'\" \(153 characters\) sed "s/^X//" >'structprotosw.h' <<'END_OF_FILE' X#ifndef STRUCT_PROTOSW_H X#define STRUCT_PROTOSW_H X X#include "confdomain.h" X#ifdef DOMAIN X#include <sys/domain.h> X#endif X#include <sys/protosw.h> X X#endif END_OF_FILE if test 153 -ne `wc -c <'structprotosw.h'`; then echo shar: \"'structprotosw.h'\" unpacked with wrong size! fi # end of 'structprotosw.h' fi if test -f 'structsockaddrin.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structsockaddrin.h'\" else echo shar: Extracting \"'structsockaddrin.h'\" \(283 characters\) sed "s/^X//" >'structsockaddrin.h' <<'END_OF_FILE' X#ifndef STRUCT_SOCKADDR_IN_H X#define STRUCT_SOCKADDR_IN_H X X/* On an optimal system, this file would contain solely: */ X/* #include <netinet/in.h> */ X X#include <sys/types.h> X#ifndef SOCK_STREAM X#include <sys/socket.h> X#endif X#ifndef IPPROTO_TCP X#include <netinet/in.h> X#endif X X#endif END_OF_FILE if test 283 -ne `wc -c <'structsockaddrin.h'`; then echo shar: \"'structsockaddrin.h'\" unpacked with wrong size! fi # end of 'structsockaddrin.h' fi if test -f 'structsocket.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structsocket.h'\" else echo shar: Extracting \"'structsocket.h'\" \(406 characters\) sed "s/^X//" >'structsocket.h' <<'END_OF_FILE' X#ifndef STRUCT_SOCKET_H X#define STRUCT_SOCKET_H X X/* On an optimal system, this file would contain solely: */ X/* #include <sys/socketvar.h> */ X X#include <sys/types.h> X#include "confsocketneedsxnode.h" X#ifdef SOCKETNEEDSXNODE X#include "structxnode.h" /* easier than copying */ X#endif X#ifndef SOCK_STREAM X#include <sys/socket.h> X#endif X#ifndef SS_ISCONNECTED /*XXX*/ X#include <sys/socketvar.h> X#endif X X#endif END_OF_FILE if test 406 -ne `wc -c <'structsocket.h'`; then echo shar: \"'structsocket.h'\" unpacked with wrong size! fi # end of 'structsocket.h' fi if test -f 'structtcp.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structtcp.h'\" else echo shar: Extracting \"'structtcp.h'\" \(261 characters\) sed "s/^X//" >'structtcp.h' <<'END_OF_FILE' X#ifndef STRUCT_TCP_H X#define STRUCT_TCP_H X X/* On an optimal system, this file would contain solely: */ X/* #include <netinet/tcp_var.h> */ X X#include <netinet/tcp.h> X#include <netinet/tcp_fsm.h> X#include <netinet/tcp_timer.h> X#include <netinet/tcp_var.h> X X#endif END_OF_FILE if test 261 -ne `wc -c <'structtcp.h'`; then echo shar: \"'structtcp.h'\" unpacked with wrong size! fi # end of 'structtcp.h' fi if test -f 'structtext.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structtext.h'\" else echo shar: Extracting \"'structtext.h'\" \(368 characters\) sed "s/^X//" >'structtext.h' <<'END_OF_FILE' X#ifndef STRUCT_TEXT_H X#define STRUCT_TEXT_H X X#include "conftext.h" X#include "confregion.h" X#include "conftextneedsvmparam.h" X X#include <sys/types.h> X#ifdef TEXTNEEDSVMPARAM X#include <sys/vmparam.h> X#endif X#ifdef TEXT X#include <sys/text.h> X#endif X#ifdef REGION X#include <machine/vmparam.h> X#include <sys/region.h> /*XXX*/ X#include <sys/vspace.h> /*XXX*/ X#endif X X#endif END_OF_FILE if test 368 -ne `wc -c <'structtext.h'`; then echo shar: \"'structtext.h'\" unpacked with wrong size! fi # end of 'structtext.h' fi if test -f 'structucred.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structucred.h'\" else echo shar: Extracting \"'structucred.h'\" \(437 characters\) sed "s/^X//" >'structucred.h' <<'END_OF_FILE' X#ifndef STRUCT_UCRED_H X#define STRUCT_UCRED_H X X/* On an optimal system, this file would contain solely: */ X/* #include <sys/user.h> */ X X#include "structuser.h" X#include "confsysucred.h" X#include "confhaveucred.h" X#ifdef HAVE_UCRED X#ifdef SYSUCRED X#include <sys/ucred.h> /* dorks */ X#endif X#else X/* XXX: If the system doesn't support ucreds, some operations on them X won't make sense. */ Xstruct ucred X { X long uid; X } X; X#endif X X#endif END_OF_FILE if test 437 -ne `wc -c <'structucred.h'`; then echo shar: \"'structucred.h'\" unpacked with wrong size! fi # end of 'structucred.h' fi if test -f 'structunpcb.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structunpcb.h'\" else echo shar: Extracting \"'structunpcb.h'\" \(218 characters\) sed "s/^X//" >'structunpcb.h' <<'END_OF_FILE' X#ifndef STRUCT_UNPCB_H X#define STRUCT_UNPCB_H X X#include <sys/types.h> X#include <sys/unpcb.h> /* XXX: any way to bracket this? */ X#include "confnounpaddr.h" X#ifdef NO_UNPADDR X#define unp_addr unp_remaddr X#endif X X#endif END_OF_FILE if test 218 -ne `wc -c <'structunpcb.h'`; then echo shar: \"'structunpcb.h'\" unpacked with wrong size! fi # end of 'structunpcb.h' fi if test -f 'structuser.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structuser.h'\" else echo shar: Extracting \"'structuser.h'\" \(231 characters\) sed "s/^X//" >'structuser.h' <<'END_OF_FILE' X#ifndef STRUCT_USER_H X#define STRUCT_USER_H X X/* On an optimal system, this file would contain solely: */ X/* #include <sys/user.h> */ X X#include <sys/types.h> X#include <sys/param.h> X#include <sys/dir.h> X#include <sys/user.h> X X#endif END_OF_FILE if test 231 -ne `wc -c <'structuser.h'`; then echo shar: \"'structuser.h'\" unpacked with wrong size! fi # end of 'structuser.h' fi if test -f 'username.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'username.h'\" else echo shar: Extracting \"'username.h'\" \(101 characters\) sed "s/^X//" >'username.h' <<'END_OF_FILE' X#ifndef USERNAME_H X#define USERNAME_H X Xextern int uid2username(); Xextern int username2uid(); X X#endif END_OF_FILE if test 101 -ne `wc -c <'username.h'`; then echo shar: \"'username.h'\" unpacked with wrong size! fi # end of 'username.h' fi if test -f 'virtype.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'virtype.h'\" else echo shar: Extracting \"'virtype.h'\" \(244 characters\) sed "s/^X//" >'virtype.h' <<'END_OF_FILE' X#ifndef VIRTYPE_H X#define VIRTYPE_H X X#include "confvtype.h" X#include "confrtype.h" X#include "confitype.h" X X#ifdef V_TYPE Xextern char *vtype(); X#endif X#ifdef R_TYPE Xextern char *rtype(); X#endif X#ifdef I_TYPE Xextern char *itype(); X#endif X X#endif END_OF_FILE if test 244 -ne `wc -c <'virtype.h'`; then echo shar: \"'virtype.h'\" unpacked with wrong size! fi # end of 'virtype.h' fi if test -f 'vmstuff.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'vmstuff.h'\" else echo shar: Extracting \"'vmstuff.h'\" \(346 characters\) sed "s/^X//" >'vmstuff.h' <<'END_OF_FILE' X#ifndef VMSTUFF_H X#define VMSTUFF_H X X/* XXX: This file isn't particularly logical. Hence the name. */ X X#include <sys/types.h> X#include "confhavevmseg.h" X X#ifdef HAVE_VMSEG X#include <vm/hat.h> X#include <vm/as.h> X#include <vm/seg.h> X#include <vm/seg_vn.h> X#include <vm/seg_dev.h> X#include <vm/seg_map.h> X#else X#include <sys/vmmac.h> X#endif X X#endif END_OF_FILE if test 346 -ne `wc -c <'vmstuff.h'`; then echo shar: \"'vmstuff.h'\" unpacked with wrong size! fi # end of 'vmstuff.h' fi echo shar: End of archive 1 \(of 6\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (05/07/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 6)." # Contents: BLURB FORMLETTER auread.c authd.8 boottime.c confuofile.h # findinode/INSTALL findinode/Makefile findinode/fid.h getfcred.c # getnode.h getpcred.c getvmseg.c groupname.c inpcblist.c load.1 # load.c mmem.c portname.c printfamily.c printfflag.c printftype.c # printprotoinet.c printrlimits.c printrusage.c printsocktype.c # revnamei.c rpcnfs.h smem.c stattimeout.c structfile.h # structinpcb.h structmtab.h structpte.h structxnode.h tcpuid.8 # tcpuname.8 username.c virtype.c # Wrapped by brnstnd@kramden on Mon May 6 23:58:56 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'BLURB' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'BLURB'\" else echo shar: Extracting \"'BLURB'\" \(1394 characters\) sed "s/^X//" >'BLURB' <<'END_OF_FILE' Xkstuff includes a whole bunch of stuff related to reading the kernel, Xincluding pff, a more portable, improved version of ofiles/fstat. Of Xlong-term interest are the many kernel-reading libraries---you might Xnever have to open kmem again. Also here is an updated release of my Xauthd server and authuser client RFC 931 implementation, and as an extra Xbonus you get findinode, a user-level reverse namei for BSD systems with Xndbm. I stole a few pieces of code from various versions of ofiles (as Xindicated in the source). Everything else here is public-domain. X XAt various times various parts of kstuff have been run under each of Xthese systems: SunOS 4.0.3, SunOS 4.1, Ultrix 2.2, Ultrix 4.1, BSD X4.3-Tahoe, Convex UNIX 9.0, Dynix 3.0.17. If you're interested in Xporting these programs or libraries to other BSD variants, get in touch Xwith me. If you're brave enough to attempt a System V port, good luck. X XThis is kstuff 0.18. Keep in mind that it's alpha software---it's not Xsupposed to work, and if it happens to compile and install without a Xhitch on your machine, you should be happy. When you post constructive Xcriticism of kstuff to alt.sources.d, remember that I don't consider the Xpackage finished. You shouldn't be complaining that the package doesn't Xdo something. You should be explaining your needs and showing how kstuff X1.00 could fulfill them. X X---Dan Bernstein, brnstnd@nyu.edu END_OF_FILE if test 1394 -ne `wc -c <'BLURB'`; then echo shar: \"'BLURB'\" unpacked with wrong size! fi # end of 'BLURB' fi if test -f 'FORMLETTER' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'FORMLETTER'\" else echo shar: Extracting \"'FORMLETTER'\" \(621 characters\) sed "s/^X//" >'FORMLETTER' <<'END_OF_FILE' XTo: brnstnd@nyu.edu XFrom: XDate: X XPackage: kstuff 0.18 XObtained from (e.g., uunet.uu.net): XObtained by (e.g., ftp): X X1. Machine architecture (e.g., Sun 4/280): X2. Operating system (e.g., SunOS 4.1): X3. OS vendor (e.g., Sun): X4. Does load work on your machine (yes/no)? X5. Does pff work on your machine so far (yes/no)? X6. Does authd work on your machine so far (yes/no)? X7. What are CC, CCOPTS, LIBS, GETULIBS, and MACHOPTS in your Makefile? X CC= X CCOPTS= X LIBS= X GETULIBS= X MACHOPTS= X X8. Describe any problems you've had with kstuff. X X X9. Any further questions, comments, or suggestions? X X XYour name: END_OF_FILE if test 621 -ne `wc -c <'FORMLETTER'`; then echo shar: \"'FORMLETTER'\" unpacked with wrong size! fi # end of 'FORMLETTER' fi if test -f 'auread.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'auread.c'\" else echo shar: Extracting \"'auread.c'\" \(1579 characters\) sed "s/^X//" >'auread.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X#include <stdio.h> X#include <ctype.h> X#include "auread.h" X#include "structsockaddrin.h" X Xint readport(port,term) Xchar *port; /* must have MAXNUMLEN characters available */ Xchar term; X{ X int ch; X int loop; X int portlen; X X portlen = loop = 0; X while ((ch = getchar()) != term) X { X if (ch == EOF) X return -1; X if (isascii(ch) && isdigit(ch)) X port[portlen++] = ch; X if (portlen == MAXNUMLEN) X return -1; X if ((++loop) > LOOPMAX) X return -1; X } X port[portlen] = 0; X return 0; X} X Xint readlr(localport,remoteport,loc4,rem4,lp,rp) Xchar *localport; Xchar *remoteport; Xint *loc4; Xint *rem4; Xint *lp; Xint *rp; X{ X struct sockaddr_in sa; X int salen; X X if (readport(localport,',') == -1) X return -1; X if (readport(remoteport,'\n') == -1) X return -1; X *lp = atoi(localport); X *rp = atoi(remoteport); X X salen = sizeof(sa); X if (getpeername(0,&sa,&salen) == -1) X return -1; X rem4[0] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[0]; X rem4[1] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[1]; X rem4[2] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[2]; X rem4[3] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[3]; X X salen = sizeof(sa); X if (getsockname(0,&sa,&salen) == -1) X return -1; X loc4[0] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[0]; X loc4[1] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[1]; X loc4[2] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[2]; X loc4[3] = (int) (unsigned int) ((unsigned char *) &sa.sin_addr)[3]; X X return 0; X} END_OF_FILE if test 1579 -ne `wc -c <'auread.c'`; then echo shar: \"'auread.c'\" unpacked with wrong size! fi # end of 'auread.c' fi if test -f 'authd.8' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'authd.8'\" else echo shar: Extracting \"'authd.8'\" \(1532 characters\) sed "s/^X//" >'authd.8' <<'END_OF_FILE' X.TH authd 8 X.SH NAME Xauthd \- Authentication Server daemon X.SH SYNTAX Xauthd X.SH DESCRIPTION X.I authd Xis a daemon implementing the XRFC 931 Authentication Server protocol. XIt should be invoked by a network server, Xsuch as X.I attachport(1) Xor X.I inetd(8), Xfor connections to TCP port 113 (auth). X.PP XThe client host Xgives X.I authd Xtwo numbers separated by a comma. X.I authd Xinterprets the numbers as TCP port numbers Xfor the local and remote sides respectively Xof a TCP connection between this host and the client host. XIt returns a line of the form X.EX Xlocalport, remoteport: USERID: UNIX: username X.EE Xwhere username Xis the name of the user on this side of Xthe specified connection. XIf X.I authd Xdoes not have an authentication entry for that connection, Xit returns a line of the form X.EX Xlocalport, remoteport: ERROR: UNKNOWN-ERROR. X.EE X.PP X.SH DIAGNOSTICS X.TP XNone. X.SH BUGS XNone known. X.SH VERSION Xauthd version 3.5 alpha, May 1, 1991. X.SH AUTHOR XPlaced into the public domain by Daniel J. Bernstein. XPartially inspired by code written by Vic Abell for ofiles. X.SH REFERENCES XThe authentication server is more secure than passwords Xin some ways, but less secure than passwords in many ways. X(It's certainly better than no password at all---e.g., for Xmail or news.) XIt is not the final solution. XFor an excellent discussion of security problems within Xthe TCP/IP protocol suite, see XSteve Bellovin's article X``Security Problems in the TCP/IP Protocol Suite.'' X.SH "SEE ALSO" Xauthtcp(1), Xattachport(1), Xauthuser(3), Xtcp(4), Xinetd(8) END_OF_FILE if test 1532 -ne `wc -c <'authd.8'`; then echo shar: \"'authd.8'\" unpacked with wrong size! fi # end of 'authd.8' fi if test -f 'boottime.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'boottime.c'\" else echo shar: Extracting \"'boottime.c'\" \(1577 characters\) sed "s/^X//" >'boottime.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* getboottime() returns the time that the system wwas booted. It */ X/* returns 0 on error. */ X X/* boottimeinit() does optional initialization to cooperate with other */ X/* libraries that use nlistlist. boottimeinit returns -1 on error. */ X X/* boottimestrerr is a strerrfun for use with the strerr library. */ X X#include "boottime.h" X#include "kmem.h" X#include "nlistlist.h" X#include "strerr.h" X X#define BOOTTIMENLIST "_boottime" X Xstatic int btinit = 0; X Xstatic long boottime; Xstatic short bttype; Xstatic unsigned long btvalue; Xstatic int boottimeerrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "boottime error 0", 0 } X#define BT_INIT 1 X, { BT_INIT, "cannot init boottime: ", nliststrerr } X#define BT_NLIST 2 X, { BT_NLIST, "cannot nlist: ", nliststrerr } X#define BT_NLISTFOUND 3 X, { BT_NLISTFOUND, BOOTTIMENLIST, nlistnotin } X#define BT_KMEM 4 X, { BT_KMEM, "cannot read boottime: ", kmemstrerr } X} ; X Xchar *boottimestrerr(ke) Xstrerrfun *ke; X{ X *ke = 0; X return strerrtaberr(ke,boottimeerrno,e,sizeof(e)/sizeof(*e),"unknown boottime error"); X} X Xint boottimeinit() X{ X if (nlistadd(BOOTTIMENLIST,&bttype,&btvalue) == -1) X RETERN(-1,boottimeerrno,BT_INIT) X btinit = 1; X return 0; X} X Xlong getboottime() X{ X if (!btinit) X if (boottimeinit() == -1) X return 0; X if (bttype == -1) X if (nlistdo() == -1) X RETERN(0,boottimeerrno,BT_NLIST) X if (!bttype) X RETERN(0,boottimeerrno,BT_NLISTFOUND) X if (kmemcpy((char *) &boottime,(char *) btvalue,sizeof(boottime)) == -1) X RETERN(0,boottimeerrno,BT_KMEM) X return boottime; X} END_OF_FILE if test 1577 -ne `wc -c <'boottime.c'`; then echo shar: \"'boottime.c'\" unpacked with wrong size! fi # end of 'boottime.c' fi if test -f 'confuofile.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'confuofile.h'\" else echo shar: Extracting \"'confuofile.h'\" \(579 characters\) sed "s/^X//" >'confuofile.h' <<'END_OF_FILE' X#ifndef CONF_UOFILE_H X#define CONF_UOFILE_H X X#include "confopalf.h" X#include "confodofe.h" X X#ifdef DYNIX X#ifdef ODOFE X#define UOFILE(u,n) ((u)->u_lofile[0].of_file) X#define NUOFILE(u) ((u)->u_nofile) X#else X#define UOFILE(u,n) ((u)->u_lofile[n].of_file) X#define NUOFILE(u) ((u)->u_nofile) X#endif X#else X#ifdef CONVEX X#define UOFILE(u,n) ((u)->u_fd[n].ofile) X#define NUOFILE(u) NOFILE X#else X#ifdef OPALF X#define UOFILE(u,n) ((u)->u_ofile[n]) X#define NUOFILE(u) ((u)->u_lastfile + 1) X#else X#define UOFILE(u,n) ((u)->u_ofile[n]) X#define NUOFILE(u) NOFILE X#endif X#endif X#endif X X#endif END_OF_FILE if test 579 -ne `wc -c <'confuofile.h'`; then echo shar: \"'confuofile.h'\" unpacked with wrong size! fi # end of 'confuofile.h' fi if test -f 'findinode/INSTALL' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/INSTALL'\" else echo shar: Extracting \"'findinode/INSTALL'\" \(1581 characters\) sed "s/^X//" >'findinode/INSTALL' <<'END_OF_FILE' X#!/bin/sh X X# Change mode to 0700 if you don't want normal users to have access to X# these utilities. XMODE=04755 XOWNER=root XINSTALL="install -c" XPROGINSTALL="$INSTALL -o $OWNER -m $MODE" XSYSINSTALL="$INSTALL -o $OWNER -m 0700" XMANINSTALL="$INSTALL -o $OWNER -m 0444" X X# Directories. XFIDDIR="`head -1 FIDDIR`" X X# Programs. XFINDINODE=/bin/findinode XUPDATEFID=/etc/updatefid XFSUPDATEFID=/etc/fsupdatefid X X# Man pages. XMFINDINODE=/usr/man/man1/findinode.1 XMUPDATEFID=/usr/man/man8/updatefid.8 X Xecho "Each action will be printed before it is run. Press return to proceed." X Xecho "1. Install findinode and updatefid." Xecho "! $PROGINSTALL findinode $FINDINODE: " | tr -d '\012' Xread line Xeval "$PROGINSTALL" findinode "$FINDINODE" X Xecho "! $SYSINSTALL updatefid $UPDATEFID: " | tr -d '\012' Xread line Xeval "$SYSINSTALL" updatefid "$UPDATEFID" X Xecho "! $SYSINSTALL fsupdatefid $FSUPDATEFID: " | tr -d '\012' Xread line Xeval "$SYSINSTALL" fsupdatefid "$FSUPDATEFID" X Xecho "2. Make the man pages available." Xecho "! $MANINSTALL findinode.1 $MFINDINODE: " | tr -d '\012' Xread line Xeval "$MANINSTALL" findinode.1 "$MFINDINODE" X Xecho "! $MANINSTALL updatefid.8 $MUPDATEFID: " | tr -d '\012' Xread line Xeval "$MANINSTALL" updatefid.8 "$MUPDATEFID" X Xecho "3. Make the database directory." Xecho "! mkdir $FIDDIR: " | tr -d '\012' Xread line Xmkdir "$FIDDIR" X Xecho "4. Start fsupdatefid running now to build the database." Xecho "! $FSUPDATEFID &: " | tr -d '\012' Xread line X( eval "$FDUPDATEFID" ) & X Xecho "5. Start fsupdatefid in /etc/rc.local." Xecho "I'll leave this step to you. That's it!" X Xexit 0 END_OF_FILE if test 1581 -ne `wc -c <'findinode/INSTALL'`; then echo shar: \"'findinode/INSTALL'\" unpacked with wrong size! fi chmod +x 'findinode/INSTALL' # end of 'findinode/INSTALL' fi if test -f 'findinode/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/Makefile'\" else echo shar: Extracting \"'findinode/Makefile'\" \(1154 characters\) sed "s/^X//" >'findinode/Makefile' <<'END_OF_FILE' XCC=cc XCCOPTS=-g X Xall: updatefid findinode X Xshar: findinode.shar X Xupdatefid: fid.o updatefid.o X $(CC) $(CCOPTS) -o updatefid fid.o updatefid.o X Xfindinode: fid.o findinode.o X $(CC) $(CCOPTS) -o findinode fid.o findinode.o X Xfid.o: fid.c fid.h X @echo "$(CC) $(CCOPTS) -c fid.c -DDBLOCK=\\\"`head -1 FIDDIR`/+fidlock\\\" -DDBFILES=\\\"`head -1 FIDDIR`/+fidfiles\\\" -DDBDIRS=\\\"`head -1 FIDDIR`/+fiddirs\\\" -DDBDIRTIMES=\\\"`head -1 FIDDIR`/+fiddirtimes\\\" -DDBF2D=\\\"`head -1 FIDDIR`/+fidf2d\\\" -DDBD2F=\\\"`head -1 FIDDIR`/+fidd2f\\\"" X @eval "$(CC) $(CCOPTS) -c fid.c -DDBLOCK=\\\"`head -1 FIDDIR`/+fidlock\\\" -DDBFILES=\\\"`head -1 FIDDIR`/+fidfiles\\\" -DDBDIRS=\\\"`head -1 FIDDIR`/+fiddirs\\\" -DDBDIRTIMES=\\\"`head -1 FIDDIR`/+fiddirtimes\\\" -DDBF2D=\\\"`head -1 FIDDIR`/+fidf2d\\\" -DDBD2F=\\\"`head -1 FIDDIR`/+fidd2f\\\"" X Xupdatefid.o: updatefid.c fid.h X $(CC) $(CCOPTS) -c updatefid.c X Xfindinode.o: findinode.c fid.h X $(CC) $(CCOPTS) -c findinode.c X Xinstall: X @echo 'Run INSTALL from a root shell.' X Xclean: X rm findinode.o updatefid.o fid.o findinode updatefid X Xfindinode.shar: X shar `cat FILES` > findinode.shar X chmod 400 findinode.shar END_OF_FILE if test 1154 -ne `wc -c <'findinode/Makefile'`; then echo shar: \"'findinode/Makefile'\" unpacked with wrong size! fi # end of 'findinode/Makefile' fi if test -f 'findinode/fid.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/fid.h'\" else echo shar: Extracting \"'findinode/fid.h'\" \(749 characters\) sed "s/^X//" >'findinode/fid.h' <<'END_OF_FILE' X#ifndef FID_H X#define FID_H X X/* XXX: structure passing throughout */ Xstruct node { unsigned long i; unsigned long d; } ; Xstruct dnode { unsigned long i; unsigned long d; } ; Xstruct nodenum { struct node x; int n; } ; Xstruct dnodenum { struct dnode x; int n; } ; X Xextern int fidinit(); X Xextern int fidlock(); Xextern int fidunlock(); X Xextern int fidfilesput(); Xextern int fidfilesdel(); Xextern int fidfilesget(); Xextern int fiddirsput(); Xextern int fiddirsdel(); Xextern int fiddirsget(); Xextern int fiddirtimesput(); Xextern int fiddirtimesdel(); Xextern long fiddirtimesget(); Xextern int fidf2dput(); Xextern int fidf2ddel(); Xextern struct dnodenum fidf2dget(); Xextern int fidd2fput(); Xextern int fidd2fdel(); Xextern struct nodenum fidd2fget(); X X#endif END_OF_FILE if test 749 -ne `wc -c <'findinode/fid.h'`; then echo shar: \"'findinode/fid.h'\" unpacked with wrong size! fi # end of 'findinode/fid.h' fi if test -f 'getfcred.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getfcred.c'\" else echo shar: Extracting \"'getfcred.c'\" \(1175 characters\) sed "s/^X//" >'getfcred.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB modified to have safe behavior under !HAVE_UCRED X5/1/91 DJB baseline public domain X*/ X X/* X Xstruct ucred *getfcred(f) struct file *f; returns the user credentials Xfor open file f (in user memory). Note that on machines without struct Xucred, all open file descriptions are considered to be owned by root. X Xgetfcredstrerr is a strerrfun for getfcred(). X X*/ X X#include "structfile.h" X#include "structucred.h" X#include "getfcred.h" X#include "kmem.h" X#include "strerr.h" X#include "conffcredptr.h" X#include "confhaveucred.h" X Xstatic int getfcrederrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "getfcred error 0", 0 } X#define GF_KMEM 1 X, { GF_KMEM, "cannot get file credentials: ", kmemstrerr } X} ; X Xchar *getfcredstrerr(ke) Xstrerrfun *ke; X{ X return strerrtaberr(ke,getfcrederrno,e,sizeof(e)/sizeof(*e),"unknown getfcred error"); X} X Xstatic struct ucred uc; X Xstruct ucred *getfcred(f) Xstruct file *f; X{ X#ifndef HAVE_UCRED X uc.uid = -1; uc.gid = -1; /*XXX*/ X return &uc; X#else X#ifdef FCRED_ISNOT_POINTER X return &(f->f_cred); X#else X if (kmemcpy((char *) &uc,(char *) f->f_cred,sizeof(uc)) == -1) X RETERN(0,getfcrederrno,GF_KMEM) X return &uc; X#endif X#endif X} END_OF_FILE if test 1175 -ne `wc -c <'getfcred.c'`; then echo shar: \"'getfcred.c'\" unpacked with wrong size! fi # end of 'getfcred.c' fi if test -f 'getnode.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getnode.h'\" else echo shar: Extracting \"'getnode.h'\" \(696 characters\) sed "s/^X//" >'getnode.h' <<'END_OF_FILE' X#ifndef GETNODE_H X#define GETNODE_H X X#include "confdevt.h" X X/* don't give me any crap about one statement per line. */ X/* this is a lot more readable on half a page than on two. */ X X/* names can be 0 for not found. */ X X#define NODE_ID_INO 0 X#define NODE_ID_DEV 1 X#define NODE_ID_FIFOINO 2 X#define NODE_ID_FIFO 3 X Xstruct nodebuf X { X char *type; /* e.g., chr, blk, reg */ X int flagdev; /* one of the NODE_ID settings */ X union X { X /* XXX for inum/dev types here */ X struct { unsigned inum; unsigned DEV_T dev; char *name; int flagnfs; } ino; X struct { int maj; int min; char *name; } dev; X } X id; /* inode or device */ X } X; X Xextern int getnode(); Xextern int getnodeinit(); X X#endif END_OF_FILE if test 696 -ne `wc -c <'getnode.h'`; then echo shar: \"'getnode.h'\" unpacked with wrong size! fi # end of 'getnode.h' fi if test -f 'getpcred.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getpcred.c'\" else echo shar: Extracting \"'getpcred.c'\" \(1368 characters\) sed "s/^X//" >'getpcred.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB added reasonable behavior on !HAVE_UCRED X5/1/91 DJB baseline public domain X*/ X X/* X Xstruct ucred *getpcred(p) struct proc *p; returns the user credentials Xfor process p (in user memory). Note that on machines without struct Xproc, all processes are considered to have XXX root credentials. X Xgetpcredstrerr is a strerrfun for getpcred(). X X*/ X X#include "structfile.h" X#include "structucred.h" X#include "structproc.h" X#include "getpcred.h" X#include "kmem.h" X#include "strerr.h" X#include "confpcredinproc.h" X#include "confpcredunderproc.h" X#include "confhaveucred.h" X Xstatic int getpcrederrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "getpcred error 0", 0 } X#define GP_KMEM 1 X, { GP_KMEM, "cannot get process credentials: ", kmemstrerr } X} ; X Xchar *getpcredstrerr(ke) Xstrerrfun *ke; X{ X return strerrtaberr(ke,getpcrederrno,e,sizeof(e)/sizeof(*e),"unknown getpcred error"); X} X Xstatic struct ucred uc; X Xstruct ucred *getpcred(p,u) Xstruct proc *p; Xstruct user *u; X{ X#ifndef HAVE_UCRED X uc.uid = p->p_uid; X return &uc; X#else X#ifdef PCRED_IN_PROC X return &(p->p_cred); X#else X#ifdef PCRED_UNDER_PROC X if (kmemcpy((char *) &uc,(char *) p->p_cred,sizeof(uc)) == -1) X RETERN(0,getpcrederrno,GP_KMEM) X return &uc; X#else X if (kmemcpy((char *) &uc,(char *) u->u_cred,sizeof(uc)) == -1) X RETERN(0,getpcrederrno,GP_KMEM) X return &uc; X#endif X#endif X#endif X} END_OF_FILE if test 1368 -ne `wc -c <'getpcred.c'`; then echo shar: \"'getpcred.c'\" unpacked with wrong size! fi # end of 'getpcred.c' fi if test -f 'getvmseg.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getvmseg.c'\" else echo shar: Extracting \"'getvmseg.c'\" \(1515 characters\) sed "s/^X//" >'getvmseg.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline XOriginally stolen from Dupuy ofiles. X*/ X X/* X XXXX: Don't ask me what this does; I dunno nuthin' bout no mmaps, bro. X X*/ X X#include "structproc.h" X#include "vmstuff.h" X#include "getvmseg.h" X#include "structxnode.h" X#include "kmem.h" X#include "confhavevmseg.h" X Xint vmsegmax; X X#ifndef HAVE_VMSEG Xstatic struct vnode *result = 0; X Xstruct vnode **getvmseg(p) Xstruct proc *p; X{ X vmsegmax = 1; X return &result; X} X Xint seginit() X{ X ; X} X X#else X X#define SEGNLIST "_segvn_ops" X#define MAXSEGS 256 X Xstatic int init = 0; Xstatic unsigned long nlsegvnv; Xstatic short nlsegvnt; X Xint seginit() X{ X nlistadd(SEGNLIST,&nlsegvnt,&nlsegvnv); X init = 1; X return 0; X} X Xstruct vnode **getvmseg(p) Xstruct proc *p; X{ X static struct vnode *segvns[MAXSEGS]; X struct as as; X struct seg seg; X struct seg *s; X register int segn; X union gseg X { X struct segvn_data segvn; X struct segdev_data segdev; X struct segmap_data segmap; X } X gseg; X X segvns[0] = 0; X if (!(p->p_as)) X return segvns; X X if (!init) X seginit(); X if (nlsegvnt == -1) X nlistdo(); X X kmemcpy((char *) &as,(char *) p->p_as,sizeof(as)); X X segn = 0; X X for (s = as.a_segs;;s = seg.s_next) X { X kmemcpy((char *) &seg,(char *) s,sizeof(seg)); X kmemcpy((char *) &gseg,(char *) seg.s_data,sizeof(gseg)); X if ((unsigned long) seg.s_ops == nlsegvnv X &&gseg.segvn.vp X &&!gseg.segvn.amp) X segvns[segn++] = gseg.segvn.vp; X if (s == as.a_seglast || segn == MAXSEGS) X { X vmsegmax = segn; X return segvns; X } X } X} X X#endif END_OF_FILE if test 1515 -ne `wc -c <'getvmseg.c'`; then echo shar: \"'getvmseg.c'\" unpacked with wrong size! fi # end of 'getvmseg.c' fi if test -f 'groupname.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'groupname.c'\" else echo shar: Extracting \"'groupname.c'\" \(1171 characters\) sed "s/^X//" >'groupname.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain. todo: cache groups. X*/ X X/* X Xint gid2groupname(gid,gnp) int gid; char **gnp; looks up group gid and Xpoints *gnp to the name for that group (possibly stored in a static area Xinterfering with getgrgid()). If gid does not have a system name, Xgid2groupname() uses gid in decimal as the name and returns 1. Normally Xit returns 0. X Xint groupname2gid(gn,gid); char *gn; int *gid; looks up group name gn Xand sets *gid to the number of that group. If gn is entirely numeric it Xsimply sets *gid to that number are returns 1. Otherwise it returns 0. XIf gn is not numeric and not a system group name, groupname2gid returns X-1 and leaves *gid alone. X X*/ X X#include <grp.h> X#include "groupname.h" X#include "numeric.h" X Xint gid2groupname(gid,gnp) Xint gid; Xchar **gnp; X{ X struct group *gr; X static char gn[20]; X X if (gr = getgrgid(gid)) X { X *gnp = gr->gr_name; X return 0; X } X sprintf(gn,"%d",gid); X *gnp = gn; X return 1; X} X Xint groupname2gid(gn,gid) Xchar *gn; Xint *gid; X{ X struct group *gr; X X if (numeric(gn)) X { X *gid = atoi(gn); X return 1; X } X gr = getgrnam(gn); X if (!gr) X return -1; /*XXX*/ X *gid = gr->gr_gid; X return 0; X} END_OF_FILE if test 1171 -ne `wc -c <'groupname.c'`; then echo shar: \"'groupname.c'\" unpacked with wrong size! fi # end of 'groupname.c' fi if test -f 'inpcblist.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'inpcblist.c'\" else echo shar: Extracting \"'inpcblist.c'\" \(1642 characters\) sed "s/^X//" >'inpcblist.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB unhid inperrno X5/1/91 DJB baseline public domain X*/ X X#include "inpcblist.h" X#include "structinpcb.h" X#include "kmem.h" X#include "nlistlist.h" X#include "strerr.h" X#include "conftcpnlist.h" X Xint inperrno = 0; Xstatic int inpinit = 0; Xstatic struct inpcb inp; Xstruct inpcb *inpcbloc = 0; Xstatic short intype; Xstatic unsigned long invalue; X Xchar *inpcbliststrerr(ke) Xstrerrfun *ke; X{ X *ke = 0; X switch(inperrno) X { X case 0: X return "inpcblist error 0"; X#define INP_INIT 1 X case INP_INIT: X *ke = nliststrerr; X return "cannot init inpcblit: "; X#define INP_NLIST 2 X case INP_NLIST: X *ke = nliststrerr; X return "cannot nlist: "; X#define INP_NLFOUND 3 X case INP_NLFOUND: X *ke = nlistnotin; X return TCPNLIST; X#define INP_KMEM 4 X case INP_KMEM: X *ke = kmemstrerr; X return "cannot read inpcb: "; X default: X return "unknown inpcblist error"; X } X} X Xint inpcblistinit() X{ X if (nlistadd(TCPNLIST,&intype,&invalue) == -1) X RETERN(-1,inperrno,INP_INIT) X inpinit = 1; X return 0; X} X Xstruct inpcb *nextinpcb(inpcb) Xstruct inpcb *inpcb; X{ X if (!inpcb) X { X if (!inpinit) X if (inpcblistinit() == -1) X return 0; X if (intype == -1) X if (nlistdo() == -1) X RETERN(0,inperrno,INP_NLIST) X if (!intype) X RETERN(0,inperrno,INP_NLFOUND) X if (kmemcpy((char *) &inp,(char *) invalue,sizeof(inp)) == -1) X RETERN(0,inperrno,INP_KMEM) X inpcb = &inp; X } X inpcbloc = inpcb->inp_next; X if ((char *) inpcbloc == (char *) invalue) X RETERN(0,inperrno,0) X if (kmemcpy((char *) &inp,(char *) inpcbloc,sizeof(inp)) == -1) X RETERN(0,inperrno,INP_KMEM) X return &inp; X} END_OF_FILE if test 1642 -ne `wc -c <'inpcblist.c'`; then echo shar: \"'inpcblist.c'\" unpacked with wrong size! fi # end of 'inpcblist.c' fi if test -f 'load.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'load.1'\" else echo shar: Extracting \"'load.1'\" \(914 characters\) sed "s/^X//" >'load.1' <<'END_OF_FILE' X.TH load 1 X.SH NAME Xload \- show boot time, current time, number of users, and load X.SH SYNTAX Xload X.SH DESCRIPTION X.I load Xprints one line in the following format: X.EX XMay 1 03:03:57, booted Apr 25 22:04:05, 9 users, load 1.16 1.02 1.00 X.EE XThe first date is the current time (actually characters X5 through 19 of the format returned by X.I ctime). XThe second is when the system was booted. XThe number of users is the number of lines shown in utmp. XThe three decimal numbers are the one-minute, five-minute, Xand fifteen-minute load averages. X X.I load Xis faster than X.I uptime Xand has an easier-to-parse format. X.PP X.SH DIAGNOSTICS XVarious errors if the boot time, current load average, or /etc/utmp Xcannot be read. In this case X.I load Xexits with exit value 1. X.SH BUGS XNone known. X.SH VERSION Xload 0.17 alpha, May 1, 1991. X.SH AUTHOR XPlaced into the public domain by Daniel J. Bernstein. X.SH "SEE ALSO" Xuptime(1) END_OF_FILE if test 914 -ne `wc -c <'load.1'`; then echo shar: \"'load.1'\" unpacked with wrong size! fi # end of 'load.1' fi if test -f 'load.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'load.c'\" else echo shar: Extracting \"'load.c'\" \(1206 characters\) sed "s/^X//" >'load.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X#include <stdio.h> X#include <time.h> X#include <utmp.h> X#include "avenrun.h" X#include "boottime.h" X#include "strerr.h" X X#ifndef UTMP_FILE X#define UTMP_FILE "/etc/utmp" X#endif X Xstatic char progname[] = "load"; X Xmain() X{ X double *av; X long now; X long boottime; X FILE *fi; X struct utmp ut; X int numusers; X X if (avenruninit() == -1) X { fprintf(stderr,"%s: %s\n",progname,strerr(avenrunstrerr)); exit(1); } X if (boottimeinit() == -1) X { fprintf(stderr,"%s: %s\n",progname,strerr(boottimestrerr)); exit(1); } X X if (!(av = getavenrun())) X { fprintf(stderr,"%s: %s\n",progname,strerr(avenrunstrerr)); exit(1); } X if (!(boottime = getboottime())) X { fprintf(stderr,"%s: %s\n",progname,strerr(boottimestrerr)); exit(1); } X X if (!(fi = fopen(UTMP_FILE,"r"))) X { fprintf(stderr,"%s: cannot open %s",progname,UTMP_FILE); exit(1); } X numusers = 0; X while (fread((char *) &ut,sizeof(ut),1,fi)) X if (*ut.ut_name) X ++numusers; X /* don't bother closing fi */ X X (void) time(&now); X X printf("%15.15s, ",ctime(&now) + 4); X printf("booted %15.15s, %d users, load %.2f %.2f %.2f\n" X ,ctime(&boottime) + 4 X ,numusers X ,av[0] X ,av[1] X ,av[2] X ); X exit(0); X} END_OF_FILE if test 1206 -ne `wc -c <'load.c'`; then echo shar: \"'load.c'\" unpacked with wrong size! fi # end of 'load.c' fi if test -f 'mmem.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mmem.c'\" else echo shar: Extracting \"'mmem.c'\" \(1461 characters\) sed "s/^X//" >'mmem.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X XSee kmem.c for documentation. X X*/ X X#include <sys/types.h> X#include <sys/file.h> X#include "mmem.h" X#include "strerr.h" X X#define MMEM "/dev/mem" X X#define LSEEKFROMSTART 0 X Xstatic int mmemfd = -1; Xstatic int mmemerrno = 0; X Xstatic char *mmemerrprk(ke) strerrfun *ke; { *ke = strerrsys; return MMEM; } X Xchar *mmemstrerr(ke) Xstrerrfun *ke; X{ X *ke = 0; X switch(mmemerrno) X { X case 0: X return "mem error 0"; X#define MMEM_OPEN 1 X case MMEM_OPEN: X *ke = mmemerrprk; X return "cannot open "; X#define MMEM_LSEEK 2 X case MMEM_LSEEK: X *ke = strerrsys; X return "cannot lseek mem"; X#define MMEM_READ 3 X case MMEM_READ: X *ke = strerrsys; X return "cannot read mem"; X#define MMEM_READZERO 4 X case MMEM_READZERO: X return "mem read 0 bytes"; X default: X return "unknown mem error"; X } X} X Xint mmeminit() X{ X mmemfd = open(MMEM,O_RDONLY); X if (mmemfd == -1) X RETERN(-1,mmemerrno,MMEM_OPEN) X return 0; X} X Xint mmemcpy(buf,pos,n) Xchar *buf; Xchar *pos; Xint n; X{ X int r; X X if (!n) X return 0; X if (mmemfd == -1) X if (mmeminit() == -1) X return -1; X if (lseek(mmemfd,(long) pos,LSEEKFROMSTART) == -1) X RETERN(-1,mmemerrno,MMEM_LSEEK) X while ((r = read(mmemfd,buf,n)) < n) X if (r == -1) X RETERN(-1,mmemerrno,MMEM_READ) X else if (r == 0) /* XXX: this can never happen */ X RETERN(-1,mmemerrno,MMEM_READZERO) X else X { X buf += r; X n -= r; X } X return 0; X} END_OF_FILE if test 1461 -ne `wc -c <'mmem.c'`; then echo shar: \"'mmem.c'\" unpacked with wrong size! fi # end of 'mmem.c' fi if test -f 'portname.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'portname.c'\" else echo shar: Extracting \"'portname.c'\" \(700 characters\) sed "s/^X//" >'portname.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X XSee groupname.c for documentation. X X*/ X X#include "portname.h" X#include "numeric.h" X#include <netdb.h> X X/* XXX: is getservby{port,name}(blah,0) standard? does it make sense here? */ X X/* XXX: cache */ X Xint port2portname(port,pop) Xint port; Xchar **pop; X{ X struct servent *se; X static char po[20]; X X if (se = getservbyport(port,0)) X { X *pop = se->s_name; X return 0; X } X sprintf(po,"%d",port); X *pop = po; X return 1; X} X Xint portname2port(po,port) Xchar *po; Xint *port; X{ X struct servent *se; X X if (numeric(po)) X { X *port = atoi(po); X return 1; X } X se = getservbyname(po,0); X if (!se) X return -1; /*XXX*/ X *port = se->s_port; X return 0; X} END_OF_FILE if test 700 -ne `wc -c <'portname.c'`; then echo shar: \"'portname.c'\" unpacked with wrong size! fi # end of 'portname.c' fi if test -f 'printfamily.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printfamily.c'\" else echo shar: Extracting \"'printfamily.c'\" \(1534 characters\) sed "s/^X//" >'printfamily.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printfamily(family) int family; returns a string representation of Xthe given address family, or 0 if the family is unrecognized. The string Xreturned might not be malloced but will not be overwritten on separate Xcalls. X X*/ X X#include "structsocket.h" X#include "printfamily.h" X Xchar *printfamily(family) Xint family; X{ X switch(family) X { X#ifdef AF_UNSPEC X case AF_UNSPEC: return "unspec"; X#endif X#ifdef AF_UNIX X case AF_UNIX: return "unix"; X#endif X#ifdef AF_INET X case AF_INET: return "internet"; X#endif X#ifdef AF_IMPLINK X case AF_IMPLINK: return "implink"; X#endif X#ifdef AF_PUP X case AF_PUP: return "pup"; X#endif X#ifdef AF_CHAOS X case AF_CHAOS: return "chaos"; X#endif X#ifdef AF_NS X case AF_NS: return "ns"; X#endif X#ifdef AF_NBS X case AF_NBS: return "nbs"; X#endif X#ifdef AF_ECMA X case AF_ECMA: return "ecma"; X#endif X#ifdef AF_DATAKIT X case AF_DATAKIT: return "datakit"; X#endif X#ifdef AF_CCITT X case AF_CCITT: return "ccitt"; X#endif X#ifdef AF_SNA X case AF_SNA: return "sna"; X#endif X#ifdef AF_DECnet X case AF_DECnet: return "decnet"; X#endif X#ifdef AF_DLI X case AF_DLI: return "dli"; X#endif X#ifdef AF_LAT X case AF_LAT: return "lat"; X#endif X#ifdef AF_HYLINK X case AF_HYLINK: return "hylink"; X#endif X#ifdef AF_APPLETALK X case AF_APPLETALK: return "appletalk"; X#endif X#ifdef AF_BSC X case AF_BSC: return "bsc"; X#endif X#ifdef AF_DSS X case AF_DSS: return "dss"; X#endif X#ifdef AF_OSI X case AF_OSI: return "osi"; X#endif X default: return 0; X } X} END_OF_FILE if test 1534 -ne `wc -c <'printfamily.c'`; then echo shar: \"'printfamily.c'\" unpacked with wrong size! fi # end of 'printfamily.c' fi if test -f 'printfflag.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printfflag.c'\" else echo shar: Extracting \"'printfflag.c'\" \(1253 characters\) sed "s/^X//" >'printfflag.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printfflag(f,style) struct file *f; int style; returns a string Xrepresentation of the file flag, f->f_flag (with f in user memory), in Xthe given style. Known styles, and examples with a RDWR | NDELAY file: Xstyle 0 produces "rwn", style 1 produces "rwn ", style 2 produces X"rw n ", style 4 produces "rw-n-----". Nonzero styles will always Xproduce 9-character outputs. The returned string is stored in a static Xarea that will be overwritten on each call. X X*/ X X#include <stdio.h> X#include "structfile.h" X#include "printfflag.h" X Xstatic char result[15]; X Xchar *printfflag(f,style) Xstruct file *f; Xint style; X{ X int fflag; X int pos; X X if (style) X for (pos = 0;pos < sizeof(result);++pos) X result[pos] = ((style == 4) ? '-' : ' '); X pos = 0; X X fflag = f->f_flag; X#define FFLAG(F,X,P) \ Xif (fflag & F) { result[(style < 2) ? pos++ : P] = X; fflag &= ~F; } X X FFLAG(FREAD,'r',0) X FFLAG(FWRITE,'w',1) X FFLAG(FAPPEND,'a',2) X FFLAG(FNDELAY,'n',3) X FFLAG(FMARK,'m',4) X FFLAG(FASYNC,'y',5) X FFLAG(FSHLOCK,'s',6) X FFLAG(FEXLOCK,'e',7) X FFLAG(fflag,'?',8) X X /* omitted FDEFER---not a user-level flag, I don't think */ X X if (style) X result[9] = 0; X else X result[pos] = 0; X X return result; X} END_OF_FILE if test 1253 -ne `wc -c <'printfflag.c'`; then echo shar: \"'printfflag.c'\" unpacked with wrong size! fi # end of 'printfflag.c' fi if test -f 'printftype.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printftype.c'\" else echo shar: Extracting \"'printftype.c'\" \(1081 characters\) sed "s/^X//" >'printftype.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printftype(f) struct file *f; returns a single-character string Xrepresentation of f->f_type (with f in user memory). In particular: "I" Xif f is a filesystem node, "S" if f is a socket, "N" if f is a named Xpipe or port with semantics similar to POSIX fifos; "P" if f is a pipe X(note that in some systems, pipes are implemented on top of sockets); X"p" if f refers to a process, typically for the debugger. printftype Xreturns "?" if it does not recognize f->f_type. X X*/ X X#include "structxnode.h" X#include "structfile.h" X#include "printftype.h" X Xchar *printftype(f) Xstruct file *f; X{ X if (f->f_type == DTYPE_INODE) return "I"; X if (f->f_type == DTYPE_SOCKET) return "S"; X#ifdef DTYPE_PORT X if (f->f_type == DTYPE_PORT) return "N"; X#endif X#ifdef DTYPE_PIPE X if (f->f_type == DTYPE_PIPE) return "P"; X#endif X#ifdef DTYPE_PROCESS X if (f->f_type == DTYPE_PROCESS) return "p"; X#endif X#ifdef DTYPE_KRPC X if (f->f_type == DTYPE_KRPC) return "k"; X#endif X#ifdef DTYPE_SPU X if (f->f_type == DTYPE_SPU) return "u"; X#endif X return "?"; X} END_OF_FILE if test 1081 -ne `wc -c <'printftype.c'`; then echo shar: \"'printftype.c'\" unpacked with wrong size! fi # end of 'printftype.c' fi if test -f 'printprotoinet.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printprotoinet.c'\" else echo shar: Extracting \"'printprotoinet.c'\" \(1107 characters\) sed "s/^X//" >'printprotoinet.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printprotoinet(proto) int proto; returns a string representation Xof the given Internet protocol, or 0 if the protocol is unrecognized. XThe string returned might not be malloced but will not be overwritten on Xseparate calls. X X*/ X X#include "structsockaddrin.h" X#include "printprotoinet.h" X Xchar *printprotoinet(proto) Xint proto; X{ X switch(proto) X { X#ifdef IPPROTO_TCP X case IPPROTO_TCP: return "tcp"; X#endif X#ifdef IPPROTO_UDP X case IPPROTO_UDP: return "udp"; X#endif X#ifdef IPPROTO_IP X case IPPROTO_IP: return "ip"; X#endif X#ifdef IPPROTO_ICMP X case IPPROTO_ICMP: return "icmp"; X#endif X#ifdef IPPROTO_IGMP X case IPPROTO_IGMP: return "igmp"; X#endif X#ifdef IPPROTO_GGP X case IPPROTO_GGP: return "ggp"; X#endif X#ifdef IPPROTO_EGP X case IPPROTO_EGP: return "egp"; X#endif X#ifdef IPPROTO_PUP X case IPPROTO_PUP: return "pup"; X#endif X#ifdef IPPROTO_IDP X case IPPROTO_IDP: return "idp"; X#endif X#ifdef IPPROTO_ND X case IPPROTO_ND: return "nd"; X#endif X#ifdef IPPROTO_RAW X case IPPROTO_RAW: return "raw"; X#endif X default: return 0; X } X} END_OF_FILE if test 1107 -ne `wc -c <'printprotoinet.c'`; then echo shar: \"'printprotoinet.c'\" unpacked with wrong size! fi # end of 'printprotoinet.c' fi if test -f 'printrlimits.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printrlimits.c'\" else echo shar: Extracting \"'printrlimits.c'\" \(1506 characters\) sed "s/^X//" >'printrlimits.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printrlimits(rl) struct rlimit *rl; returns a string representing Xvarious information about rlimit array rl. Not well defined. X X*/ X X#include <stdio.h> X#include <strings.h> X#include <sys/types.h> X#include <sys/time.h> X#include <sys/resource.h> X#include "printrlimits.h" X Xstatic char result[500]; X X/* XXX: print anything other than max? */ X Xchar *printrlimits(rl) Xstruct rlimit *rl; X{ X char *t; X X t = result; X X#ifdef RLIMIT_CPU X if (rl[RLIMIT_CPU].rlim_max == RLIM_INFINITY) sprintf(t,"cpu inf "); X else sprintf(t,"cpu %8d ",rl[RLIMIT_CPU].rlim_max); X t += strlen(t); X#endif X#ifdef RLIMIT_FSIZE X if (rl[RLIMIT_FSIZE].rlim_max == RLIM_INFINITY) sprintf(t,"file inf "); X else sprintf(t,"fsize %8d ",rl[RLIMIT_FSIZE].rlim_max); X t += strlen(t); X#endif X#ifdef RLIMIT_DATA X if (rl[RLIMIT_DATA].rlim_max == RLIM_INFINITY) sprintf(t,"data inf "); X else sprintf(t,"data %8d ",rl[RLIMIT_DATA].rlim_max); X t += strlen(t); X#endif X#ifdef RLIMIT_STACK X if (rl[RLIMIT_STACK].rlim_max == RLIM_INFINITY) sprintf(t,"stack inf "); X else sprintf(t,"stack %8d ",rl[RLIMIT_STACK].rlim_max); X t += strlen(t); X#endif X#ifdef RLIMIT_CORE X if (rl[RLIMIT_CORE].rlim_max == RLIM_INFINITY) sprintf(t,"core inf "); X else sprintf(t,"core %8d ",rl[RLIMIT_CORE].rlim_max); X t += strlen(t); X#endif X#ifdef RLIMIT_RSS X if (rl[RLIMIT_RSS].rlim_max == RLIM_INFINITY) sprintf(t,"mem inf "); X else sprintf(t,"rss %8d ",rl[RLIMIT_RSS].rlim_max); X t += strlen(t); X#endif X X return result; X} END_OF_FILE if test 1506 -ne `wc -c <'printrlimits.c'`; then echo shar: \"'printrlimits.c'\" unpacked with wrong size! fi # end of 'printrlimits.c' fi if test -f 'printrusage.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printrusage.c'\" else echo shar: Extracting \"'printrusage.c'\" \(1440 characters\) sed "s/^X//" >'printrusage.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printrusage(ru) struct rusage *ru; returns a string representation Xof practically everything about ru. Not well defined. X X*/ X X#include <stdio.h> X#include <strings.h> X#include <sys/types.h> X#include <sys/time.h> X#include <sys/resource.h> X#include "printrusage.h" X Xstatic char result[500]; X X#define hz 30 /*XXX*/ X Xchar *printrusage(ru) Xstruct rusage *ru; X{ X char *t; X long ticks; X X t = result; X sprintf(t,"%d.%02.2du ",ru->ru_utime.tv_sec,ru->ru_utime.tv_usec/10000); X t += strlen(t); X sprintf(t,"%d.%02.2ds ",ru->ru_stime.tv_sec,ru->ru_stime.tv_usec/10000); X t += strlen(t); X X /* XXX: ru_maxrss? ru_isrss? */ X /* XXX: maybe we should print total, not average, rss here? */ X ticks = hz * (ru->ru_utime.tv_sec + ru->ru_stime.tv_sec) X + hz * (ru->ru_utime.tv_usec + ru->ru_stime.tv_usec) / 1000000; X /* Note that most BSD code will dump if ticks == 0. */ X sprintf(t,"%ld+%ldk " X ,!ticks ? 0 : (ru->ru_ixrss/ticks) X ,!ticks ? 0 : (ru->ru_idrss/ticks) X ); X t += strlen(t); X X sprintf(t,"%ld+%ldio ",ru->ru_inblock,ru->ru_oublock); X t += strlen(t); X X /* XXX: ru_minflt? (``pr'') */ X sprintf(t,"%ldpf+%ldw ",ru->ru_majflt,ru->ru_nswap); X t += strlen(t); X X /* X sprintf(t,"%ld+%ldmsg ",ru->ru_msgsnd,ru->ru_msgrcv); X t += strlen(t); X */ X X sprintf(t,"%ld+%ldcsw ",ru->ru_nvcsw,ru->ru_nivcsw); X t += strlen(t); X X sprintf(t,"%ldsig",ru->ru_nsignals); X t += strlen(t); X X return result; X} END_OF_FILE if test 1440 -ne `wc -c <'printrusage.c'`; then echo shar: \"'printrusage.c'\" unpacked with wrong size! fi # end of 'printrusage.c' fi if test -f 'printsocktype.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printsocktype.c'\" else echo shar: Extracting \"'printsocktype.c'\" \(581 characters\) sed "s/^X//" >'printsocktype.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printsocktype(t) int t; returns a string representation of the Xgiven socket type, or 0 if the type is unrecognized. The string returned Xmight not be malloced but will not be overwritten on separate calls. X X*/ X X#include "structsocket.h" X#include "printsocktype.h" X Xchar *printsocktype(t) Xint t; X{ X switch(t) X { X case SOCK_STREAM: return "stream"; X case SOCK_DGRAM: return "dgram"; X case SOCK_RAW: return "raw"; X case SOCK_RDM: return "rdm"; X case SOCK_SEQPACKET: return "seqpacket"; X default: return 0; X } X} END_OF_FILE if test 581 -ne `wc -c <'printsocktype.c'`; then echo shar: \"'printsocktype.c'\" unpacked with wrong size! fi # end of 'printsocktype.c' fi if test -f 'revnamei.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'revnamei.c'\" else echo shar: Extracting \"'revnamei.c'\" \(1572 characters\) sed "s/^X//" >'revnamei.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X#include "revnamei.h" X X/* XXX: closing? wait()? etc. */ X Xstatic int fdfidread = -1; Xstatic int fdfidwrite = -1; X Xrevnameiinit() X{ X int pio[2]; X int pii[2]; X X pipe(pio); X pipe(pii); X X#ifdef NO_FINDINODE X switch(-1) X#else X switch(fork()) X#endif X { X case -1: /*XXX*/ X fdfidwrite = pii[1]; X fdfidread = pio[0]; X close(pii[0]); X close(pio[1]); X break; X case 0: X close(pii[1]); X close(pio[0]); X dup2(pii[0],0); X dup2(pio[1],1); X execlp("findinode","findinode","-A",(char *) 0); X exit(1); X default: X fdfidwrite = pii[1]; X fdfidread = pio[0]; X close(pii[0]); X close(pio[1]); X break; X } X} X Xrevnamei(ino,dev) Xunsigned long ino; Xunsigned long dev; X{ X if (fdfidwrite == -1) X revnameiinit(); X if (fdfidwrite != -1) X { X char buf[50]; X int r; X int out; X int i; X sprintf(buf,"%lu %lx\n",ino,dev); X write(fdfidwrite,buf,strlen(buf)); X /* XXX: worry about blocking? not if findinode works */ X out = 0; X while ((r = read(fdfidread,buf,30)) != -1) X { X if (!r) X { X /* EOF, child must have died or never started up */ X close(fdfidwrite); X close(fdfidread); X fdfidread = fdfidwrite = -1; X break; X } X for (i = 0;i < r;++i) X { X if (buf[i] == '\n') X goto breakbreak; X if (out == 2) X putchar(buf[i]); X else X { X if (out == 1) X if (buf[i] == ' ') X out = 2; X else X out = 0; X if (!out) X if (buf[i] == ':') X out = 1; X } X } X } X breakbreak: ; X } X} END_OF_FILE if test 1572 -ne `wc -c <'revnamei.c'`; then echo shar: \"'revnamei.c'\" unpacked with wrong size! fi # end of 'revnamei.c' fi if test -f 'rpcnfs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rpcnfs.h'\" else echo shar: Extracting \"'rpcnfs.h'\" \(739 characters\) sed "s/^X//" >'rpcnfs.h' <<'END_OF_FILE' X#ifndef RPCNFS_H /*XXX this entire include file*/ X#define RPCNFS_H X X#include <sys/types.h> X#ifndef ITIMER_REAL X#include <sys/time.h> X#endif X#include <errno.h> X X#include "confnfs.h" X#include "confconvexrpcnfs.h" X#include "confultrixrpcnfs.h" X#ifdef CONVEXRPCNFS X#include <sys/param.h> X#include <sys/ucred.h> X#endif X#ifdef ULTRIXRPCNFS X#include <rpc/types.h> X#include <sys/param.h> /* dorks */ X#include "structsockaddrin.h" /* dorks */ X#ifndef NFS_RETRIES X#include <nfs/nfs.h> X#include <nfs/vnode.h> X#endif X#include <nfs/nfs_clnt.h> X#include <nfs/vfs.h> X#else X#ifdef NFS X#include <sys/vfs.h> X#include <rpc/rpc.h> X#include <nfs/nfs.h> X#include <nfs/nfs_clnt.h> X#include "structxnode.h" /* sigh */ X#include <nfs/rnode.h> X#endif X#endif X X#endif END_OF_FILE if test 739 -ne `wc -c <'rpcnfs.h'`; then echo shar: \"'rpcnfs.h'\" unpacked with wrong size! fi # end of 'rpcnfs.h' fi if test -f 'smem.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'smem.c'\" else echo shar: Extracting \"'smem.c'\" \(1467 characters\) sed "s/^X//" >'smem.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X XSee kmem.c for documentation. X X*/ X X#include <sys/types.h> X#include <sys/file.h> X#include "smem.h" X#include "strerr.h" X X#define SMEM "/dev/drum" X X#define LSEEKFROMSTART 0 X Xstatic int smemfd = -1; Xstatic int smemerrno = 0; X Xstatic char *smemerrprk(ke) strerrfun *ke; { *ke = strerrsys; return SMEM; } X Xchar *smemstrerr(ke) Xstrerrfun *ke; X{ X *ke = 0; X switch(smemerrno) X { X case 0: X return "drum error 0"; X#define SMEM_OPEN 1 X case SMEM_OPEN: X *ke = smemerrprk; X return "cannot open "; X#define SMEM_LSEEK 2 X case SMEM_LSEEK: X *ke = strerrsys; X return "cannot lseek drum"; X#define SMEM_READ 3 X case SMEM_READ: X *ke = strerrsys; X return "cannot read drum"; X#define SMEM_READZERO 4 X case SMEM_READZERO: X return "drum read 0 bytes"; X default: X return "unknown drum error"; X } X} X Xint smeminit() X{ X smemfd = open(SMEM,O_RDONLY); X if (smemfd == -1) X RETERN(-1,smemerrno,SMEM_OPEN) X return 0; X} X Xint smemcpy(buf,pos,n) Xchar *buf; Xchar *pos; Xint n; X{ X int r; X X if (!n) X return 0; X if (smemfd == -1) X if (smeminit() == -1) X return -1; X if (lseek(smemfd,(long) pos,LSEEKFROMSTART) == -1) X RETERN(-1,smemerrno,SMEM_LSEEK) X while ((r = read(smemfd,buf,n)) < n) X if (r == -1) X RETERN(-1,smemerrno,SMEM_READ) X else if (r == 0) /* XXX: this can never happen */ X RETERN(-1,smemerrno,SMEM_READZERO) X else X { X buf += r; X n -= r; X } X return 0; X} END_OF_FILE if test 1467 -ne `wc -c <'smem.c'`; then echo shar: \"'smem.c'\" unpacked with wrong size! fi # end of 'smem.c' fi if test -f 'stattimeout.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stattimeout.c'\" else echo shar: Extracting \"'stattimeout.c'\" \(948 characters\) sed "s/^X//" >'stattimeout.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline X3/15/91 DJB Extracted into separate library, added timeout arg XStolen from safe_stat in Dupuy ofiles. X*/ X X/* XXX: There are all sorts of race conditions here. DJB */ X X#include <sys/types.h> X#include <sys/stat.h> X#include <signal.h> X#include <setjmp.h> X#include <errno.h> Xextern int errno; Xstatic jmp_buf jmpbuf; X X/* ARGSUSED */ Xstatic int wakeup() X{ X (void) alarm(0); X (void) signal(SIGALRM,SIG_IGN); X longjmp(jmpbuf,1); X} X Xint stattimeout(path,buf,timeout) Xchar *path; Xstruct stat *buf; Xint timeout; X{ X int err; X static int saveerrno; X X if (!timeout) X return stat(path,buf); X X saveerrno = errno; X if (setjmp(jmpbuf)) X { X (void) alarm(0); X (void) signal(SIGALRM,SIG_IGN); X errno = ETIMEDOUT; X return -1; X } X (void) signal(SIGALRM,wakeup); X (void) alarm(timeout); X err = stat(path,buf); X if (err) X saveerrno = errno; X (void) alarm(0); X (void) signal(SIGALRM,SIG_IGN); X errno = saveerrno; X return err; X} END_OF_FILE if test 948 -ne `wc -c <'stattimeout.c'`; then echo shar: \"'stattimeout.c'\" unpacked with wrong size! fi # end of 'stattimeout.c' fi if test -f 'structfile.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structfile.h'\" else echo shar: Extracting \"'structfile.h'\" \(1256 characters\) sed "s/^X//" >'structfile.h' <<'END_OF_FILE' X#ifndef STRUCT_FILE_H X#define STRUCT_FILE_H X X/* On any supported system, you can #include "structfile.h" any number */ X/* of times safely to get a complete definition of struct file. */ X X/* On an optimal system, this file would contain solely: */ X/* #include <sys/file.h> */ X X#include "confconvexsysfile.h" X#include "confetcconfhfileh.h" X#include <sys/types.h> X#include <sys/param.h> /* ultrix lock_t dorks */ X#define KERNEL X#ifdef ETCCONFHFILEH X#include "/etc/conf/h/file.h" X#else X#ifdef CONVEXSYSFILE X#include <sys/ucred.h> /* fer cryin' out loud... */ X#ifndef FHLOCAL X#include <sys/dmonfh.h> /* idiots */ X#endif X#endif X#include <sys/file.h> X#endif X#undef KERNEL X#include "confodofe.h" X#ifdef ODOFE X/* XXX X * This is from sys/user.h. It's ifdef KERNEL, though, and defining X * KERNEL for user.h breaks other things. X * Open-file table extension object structure. X */ Xstruct ofile_ext { X struct ofile_ext *oe_next; /* list of unused entries */ X short oe_nofile; /* # ofile entries */ X short oe_refcnt; /* # proc's sharing this ext */ X short oe_ccount; /* # sharing proc's in memory */ X swblk_t oe_swaddr; /* disk address when swapped */ X sema_t oe_mutex; /* misc mutex */ X struct ofile *oe_ofile; /* array of open files */ X}; X#endif X X#endif END_OF_FILE if test 1256 -ne `wc -c <'structfile.h'`; then echo shar: \"'structfile.h'\" unpacked with wrong size! fi # end of 'structfile.h' fi if test -f 'structinpcb.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structinpcb.h'\" else echo shar: Extracting \"'structinpcb.h'\" \(581 characters\) sed "s/^X//" >'structinpcb.h' <<'END_OF_FILE' X#ifndef STRUCT_INPCB_H X#define STRUCT_INPCB_H X X/* On an optimal system, this file would contain solely: */ X/* #include <netinet/in_pcb.h> */ X X#include "structsocket.h" /* sigh... dynix */ X#include "confsyncsema.h" X#include <sys/types.h> X#ifndef SOCK_STREAM X#include <sys/socket.h> X#endif X#ifdef SYNCSEMA X#include <sync/queue.h> X#include <sync/sema.h> X#ifndef MSIZE X#include <sys/mbuf.h> /* dorks */ X#endif X#endif X#ifndef RTF_UP X#include <net/route.h> X#endif X#ifndef IPPROTO_TCP X#include <netinet/in.h> X#endif X#include <netinet/in_pcb.h> /* XXX: any way to bracket this? */ X X#endif END_OF_FILE if test 581 -ne `wc -c <'structinpcb.h'`; then echo shar: \"'structinpcb.h'\" unpacked with wrong size! fi # end of 'structinpcb.h' fi if test -f 'structmtab.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structmtab.h'\" else echo shar: Extracting \"'structmtab.h'\" \(746 characters\) sed "s/^X//" >'structmtab.h' <<'END_OF_FILE' X#ifndef STRUCT_MTAB_H X#define STRUCT_MTAB_H X X#include "confmntent.h" X#include "confmntult.h" X#ifdef MNTENT X#ifndef FILE X#include <stdio.h> X#endif X#include <mntent.h> X#else X#ifdef MNTULT X#include <sys/param.h> X#include <sys/mount.h> X#undef m_path /* dorks */ X#endif X#include <mtab.h> X#ifndef MNTMAXSTR X#define MNTMAXSTR (sizeof ((struct mtab *)0)->m_path) X/* A big problem here is that Ultrix 4.1, at least, defines m_path in two */ X/* DIFFERENT ways in sys/mount.h and mtab.h. Dorks. Fortunately, they */ X/* do define MNTMAXSTR in nfs/nfs_clnt.h, so we arrange to include that */ X/* whenever this file is used. A better solution would be to bomb DEC. */ X#endif X#define mntent mtab X#define mnt_dir m_path X#define mnt_fsname m_dname X#endif X X#endif END_OF_FILE if test 746 -ne `wc -c <'structmtab.h'`; then echo shar: \"'structmtab.h'\" unpacked with wrong size! fi # end of 'structmtab.h' fi if test -f 'structpte.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structpte.h'\" else echo shar: Extracting \"'structpte.h'\" \(624 characters\) sed "s/^X//" >'structpte.h' <<'END_OF_FILE' X#ifndef STRUCT_PTE_H X#define STRUCT_PTE_H X X#include "confneedartospte.h" X#ifdef NEED_ARTOS_PTE_H X#include <artos/pte.h> X#include <sys/vm.h> X#define ctob PAGEtoBYTES X/*XXX: usrpt? */ X#define Usrptma Sysmap X#define btokmx(b) (((caddr_t)(b) - (caddr_t)SYSBASE) / ZS_PAGESIZE) X#define p_p0br p_p0b /* XXX: belongs in structproc */ X#define p_szpt p_szst /* XXX: belongs in structproc */ X#undef MIN X#undef MAX X#undef NBPG X#undef PGOFSET X#undef PGSHIFT X#include <artos/param.h> X#define NPTEPG (NBPG/sizeof(long)) X#define dtob(x) ((x) << 10) X#include <artos/pte.h> X#else X#include <machine/pte.h> /* PG_V? PG_TYPE? */ X#endif X X#endif END_OF_FILE if test 624 -ne `wc -c <'structpte.h'`; then echo shar: \"'structpte.h'\" unpacked with wrong size! fi # end of 'structpte.h' fi if test -f 'structxnode.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'structxnode.h'\" else echo shar: Extracting \"'structxnode.h'\" \(1328 characters\) sed "s/^X//" >'structxnode.h' <<'END_OF_FILE' X#ifndef STRUCT_XNODE_H X#define STRUCT_XNODE_H X X/* In an optimal system, this file would consist of solely: */ X/* #include <sys/inode.h> */ X X#include <sys/types.h> X#ifndef ITIMER_REAL X#include <sys/time.h> X#endif X#include <errno.h> X X#include "confnfs.h" X#include "confgnode.h" X#include "confconvexfilegarbage.h" X#ifdef CONVEXFILEGARBAGE /* This is almost embarassing. */ X#include <sys/param.h> X#ifndef FHLOCAL X#include <sys/dmonfh.h> X#endif X#define KERNEL X#include <sys/cmap.h> X#include <sys/dmon.h> X#undef KERNEL X#include <sys/object.h> X#include <sync/queue.h> X#include <sync/sema.h> X#include <sys/ucred.h> X#endif X#ifdef GNODE X#include <sys/gnode.h> X#define Xnode gnode X#define unp_Xnode unp_inode X#define x_Xptr x_gptr X#ifdef NFS X#ifndef bool_t /*XXXX*/ X#include <rpc/types.h> X#endif X#include <sys/param.h> /* dorks */ X#ifndef NFS_RETRIES X#include <nfs/nfs.h> X#include <nfs/vnode.h> X#endif X#endif X#else X#ifndef NFS X#define Xnode inode X#define unp_Xnode unp_inode X#define x_Xptr x_iptr X#endif X#ifdef NFS X#include <sys/vnode.h> X#define Xnode vnode X#define unp_Xnode unp_vnode X#define x_Xptr x_vptr X#define DTYPE_INODE DTYPE_VNODE X#define KERNEL /*XXX: dynix */ X#include <ufs/inode.h> X#undef KERNEL X#if defined(S_IFIFO) && defined(GET_FIFOS) X#include </sys/specfs/snode.h> X#endif X#else X#include <sys/inode.h> X#endif X#endif X#endif END_OF_FILE if test 1328 -ne `wc -c <'structxnode.h'`; then echo shar: \"'structxnode.h'\" unpacked with wrong size! fi # end of 'structxnode.h' fi if test -f 'tcpuid.8' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tcpuid.8'\" else echo shar: Extracting \"'tcpuid.8'\" \(618 characters\) sed "s/^X//" >'tcpuid.8' <<'END_OF_FILE' X.TH tcpuid 8 X.SH NAME Xtcpuid \- show the user id that created a network connection X.SH SYNTAX Xtcpuid X.I rem.ote.in.addr X.I remport X.I loc.al.in.addr X.I locport X.SH DESCRIPTION X.I tcpuid Xprints the numeric user id of Xthe user who created Xthe network connection specified by its arguments. X.PP X.SH DIAGNOSTICS X.TP XLots, none of which should happen if the specified Xconnection is valid. X.SH BUGS XNone known. X.SH VERSION Xtcpuid version 3.5 alpha, May 1, 1991. X.SH AUTHOR XPlaced into the public domain by Daniel J. Bernstein. XPartially inspired by code written by Vic Abell for ofiles. X.SH "SEE ALSO" Xauthd(8), Xtcpuname(8) END_OF_FILE if test 618 -ne `wc -c <'tcpuid.8'`; then echo shar: \"'tcpuid.8'\" unpacked with wrong size! fi # end of 'tcpuid.8' fi if test -f 'tcpuname.8' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tcpuname.8'\" else echo shar: Extracting \"'tcpuname.8'\" \(615 characters\) sed "s/^X//" >'tcpuname.8' <<'END_OF_FILE' X.TH tcpuname 8 X.SH NAME Xtcpuname \- show the user name that created a network connection X.SH SYNTAX Xtcpuname X.I rem.ote.in.addr X.I remport X.I loc.al.in.addr X.I locport X.SH DESCRIPTION X.I tcpuname Xprints the username of Xthe user who created Xthe network connection specified by its arguments. X.PP X.SH DIAGNOSTICS X.TP XLots, none of which should happen if the specified Xconnection is valid. X.SH BUGS XNone known. X.SH VERSION Xtcpuname version 3.5, May 1, 1991. X.SH AUTHOR XPlaced into the public domain by Daniel J. Bernstein. XPartially inspired by code written by Vic Abell for ofiles. X.SH "SEE ALSO" Xauthd(8), Xtcpuid(8) END_OF_FILE if test 615 -ne `wc -c <'tcpuname.8'`; then echo shar: \"'tcpuname.8'\" unpacked with wrong size! fi # end of 'tcpuname.8' fi if test -f 'username.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'username.c'\" else echo shar: Extracting \"'username.c'\" \(593 characters\) sed "s/^X//" >'username.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X XSee groupname.c for documentation. X X*/ X X#include <pwd.h> X#include "username.h" X#include "numeric.h" X X/*XXX: cache */ X Xint uid2username(uid,unp) Xint uid; Xchar **unp; X{ X struct passwd *pw; X static char un[20]; X X if (pw = getpwuid(uid)) X { X *unp = pw->pw_name; X return 0; X } X sprintf(un,"%d",uid); X *unp = un; X return 1; X} X Xint username2uid(un,uid) Xchar *un; Xint *uid; X{ X struct passwd *pw; X X if (numeric(un)) X { X *uid = atoi(un); X return 1; X } X pw = getpwnam(un); X if (!pw) X return -1; /*XXX*/ X *uid = pw->pw_uid; X return 0; X} END_OF_FILE if test 593 -ne `wc -c <'username.c'`; then echo shar: \"'username.c'\" unpacked with wrong size! fi # end of 'username.c' fi if test -f 'virtype.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'virtype.c'\" else echo shar: Extracting \"'virtype.c'\" \(1674 characters\) sed "s/^X//" >'virtype.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline XDerived from Dupuy ofiles. X*/ X X#include <sys/types.h> X#include <sys/stat.h> X#include "structxnode.h" X#include "rpcnfs.h" X#include "virtype.h" X Xstatic char *regular = "reg"; Xstatic char *directory = "dir"; Xstatic char *block = "blk"; Xstatic char *character = "chr"; Xstatic char *symbolic = "sym"; Xstatic char *unixsocket = "sck"; X#ifdef S_IFIFO Xstatic char *fifo = "pip"; X#endif X X#ifdef V_TYPE Xstatic char *none = "non"; Xstatic char *badvtype = "bad"; Xstatic char *unknownvtype = "unk"; X Xchar *vtype(type) Xenum vtype type; X{ X switch(type) X { X case VNON: return none; X case VREG: return regular; X case VDIR: return directory; X case VBLK: return block; X case VCHR: return character; X case VLNK: return symbolic; X case VSOCK: return unixsocket; X case VBAD: return badvtype; X#ifdef S_IFIFO X case VFIFO: return fifo; X#endif X default: return unknownvtype; X } X} X X#endif X X#ifdef R_TYPE Xstatic char *unknownrnode = "unk"; X Xchar *rtype(type) Xenum nfsftype type; X{ X switch(type) X { X case NFNON: return none; X case NFREG: return regular; X case NFDIR: return directory; X case NFBLK: return block; X case NFCHR: return character; X case NFLNK: return symbolic; X default: return unknownrnode; X } X} X X#endif X X#ifdef I_TYPE Xstatic char *unknownitype = "unk"; X Xchar *itype(mode) Xunsigned mode; X{ X switch(mode & S_IFMT) X { X case S_IFREG: return regular; X case S_IFDIR: return directory; X case S_IFBLK: return block; X case S_IFCHR: return character; X case S_IFLNK: return symbolic; X case S_IFSOCK: return unixsocket; X#ifdef S_IFIFO X case S_IFIFO: return fifo; X#endif X default: return unknownitype; X } X} X#endif END_OF_FILE if test 1674 -ne `wc -c <'virtype.c'`; then echo shar: \"'virtype.c'\" unpacked with wrong size! fi # end of 'virtype.c' fi echo shar: End of archive 2 \(of 6\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (05/07/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 6)." # Contents: BLURB.authd FILES authuser.3 authuser.c avenrun.c # filetable.c findinode/findinode.c findinode/updatefid.c # getdevicename.c kmem.c netinp.c netstatuids.c nlistlist.c # printpstat.c printucred.c proctable.c strerr.c testauthd.c # Wrapped by brnstnd@kramden on Mon May 6 23:58:58 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'BLURB.authd' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'BLURB.authd'\" else echo shar: Extracting \"'BLURB.authd'\" \(2201 characters\) sed "s/^X//" >'BLURB.authd' <<'END_OF_FILE' XIf host X supports RFC 931, and if joe@X and sally@Y are connected Xthrough TCP, then sally can find out the name of joe. This package Xincludes authd, an RFC 931 server---the program that X runs to tell Xsally who joe is. Once you've installed it, your users can't escape the Xauthentication: if they telnet or rlogin or send mail or do whatever to Xanother host, that host can find out the username. X XThis package also includes a library that acts as an RFC 931 client--- Xthe routines that sally uses to ask X's server who joe is. You don't Xneed privileges to use the library, which should compile and run without Xtrouble on any BSD-derived system. (authd is not so portable; although Xit works without changes under SunOS and Ultrix, it might not work on Xother systems. The package includes testauthd to make sure it works.) X XThe previous version of authd was reported to work on the following Xsystems: X X Sun 2/170, SunOS 4.0 X Sun 4/280, SunOS 4.0.3 X Sun 3/80, SunOS 4.1 X Sun 3/160, SunOS 4.1 X Sun 3/180, SunOS 4.1 X Sun 4/60, SunOS 4.1 X Sun 4/330, SunOS 4.1 X DECsystem-5820, Ultrix 4.0 X DECsystem-5820, Ultrix 4.1 X DECStation-5400, Ultrix 4.1 X VAX 8650, Ultrix 4.1 X MicroVAX III, BSD 4.3+NFS X HP9000 Series 300, HP-UX 7.0 X HP9000 Series 400, HP-UX 7.0 X HP9000 Series 800, HP-UX 7.0 X Convex C210, Convex UNIX 8.0 X XI've placed this code into the public domain because I think that Xeveryone should support at least this level of security. I'm sick of Xseeing people forge mail and spoof NNTP and attack systems anonymously Xthrough the network. Now they won't be able to, because every connection Xwill be tagged with the username with at least as much security as the XTCP host address in each packet. I hope that every site will do its part Xto contribute to network security (and to help CERT trace intruders). X XIt should take approximately 10 minutes to read the instructions and Xcompile, install, and test authd on a new machine. It should take Xapproximately 2 minutes on each new machine once you're familiar with Xthe instructions. Send comments on these estimates to brnstnd@nyu.edu, Xcc the Office of Management and Budget, Paperwork Reduction Division. X X---Dan Bernstein, brnstnd@nyu.edu END_OF_FILE if test 2201 -ne `wc -c <'BLURB.authd'`; then echo shar: \"'BLURB.authd'\" unpacked with wrong size! fi # end of 'BLURB.authd' fi if test -f 'FILES' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'FILES'\" else echo shar: Extracting \"'FILES'\" \(2483 characters\) sed "s/^X//" >'FILES' <<'END_OF_FILE' XBLURB XREADME XCHANGES XFORMLETTER XFILES XMakefile XINSTALL XBLURB.authd XREADME.authd Xload.1 Xauthuser.3 Xauthd.8 Xtcpuid.8 Xtcpuname.8 Xpff.doc XOFILES.hist Xrfc931 Xauread.h Xauthuser.h Xavenrun.h Xboottime.h Xconfclonedev.h Xconfconvexfilegarbage.h Xconfconvexrpcnfs.h Xconfconvexsysfile.h Xconfdevt.h Xconfdomain.h Xconfetcconfhfileh.h Xconffcredptr.h Xconffree.h Xconfgetuserconvex.h Xconfgetuserdynix.h Xconfgetusermips.h Xconfgetusersupport.h Xconfgnode.h Xconfhavepflag.h Xconfhaveppid.h Xconfhavepsuid.h Xconfhaveucred.h Xconfhaveusigintr.h Xconfhavevmseg.h Xconfitype.h Xconfkvm.h Xconfloadavglong.h Xconfmajorminor.h Xconfmalloc.h Xconfmntent.h Xconfmntult.h Xconfneedartospte.h Xconfneedmachparam.h Xconfneedmntinfo.h Xconfnfs.h Xconfnlistknlist.h Xconfnlistmeaning.h Xconfnlistunder.h Xconfnlname.h Xconfnonsfinet.h Xconfnounpaddr.h Xconfodofe.h Xconfopalf.h Xconfpcredinproc.h Xconfpcredunderproc.h Xconfpsess.h Xconfregion.h Xconfrtype.h Xconfslowstat.h Xconfsocketneedsxnode.h Xconfsyncsema.h Xconfsysucred.h Xconftcpnlist.h Xconftext.h Xconftextneedsvmparam.h Xconfttyvp.h Xconfultrixrpcnfs.h Xconfundefstdcbeforedir.h Xconfuofile.h Xconfusrptnlist.h Xconfvmunix.h Xconfvtype.h Xfiletable.h Xgetdevicename.h Xgetfcred.h Xgetnode.h Xgetopt.h Xgetpcred.h Xgetsocket.h Xgetuser.h Xgetvmseg.h Xgroupname.h Xinpcblist.h Xkmem.h Xmallocfree.h Xmmem.h Xmntops.h Xnetinp.h Xnlistlist.h Xnumeric.h Xportname.h Xprintfamily.h Xprintfflag.h Xprintftype.h Xprintprotoinet.h Xprintpstat.h Xprintrlimits.h Xprintrusage.h Xprintsocktype.h Xprintucred.h Xproctable.h Xrevnamei.h Xrpcnfs.h Xsmem.h Xstattimeout.h Xstrerr.h Xstructfile.h Xstructinpcb.h Xstructmbuf.h Xstructmtab.h Xstructproc.h Xstructprotosw.h Xstructpte.h Xstructsockaddrin.h Xstructsocket.h Xstructtcp.h Xstructtext.h Xstructucred.h Xstructunpcb.h Xstructuser.h Xstructxnode.h Xusername.h Xvirtype.h Xvmstuff.h Xauread.c Xauthd.c Xauthuser.c Xavenrun.c Xboottime.c Xfiletable.c Xgetdevicename.c Xgetfcred.c Xgetnode.c Xgetpcred.c Xgetsocket.c Xgetuser.c Xgetvmseg.c Xgroupname.c Xinpcblist.c Xkmem.c Xload.c Xmmem.c Xmntops.c Xnetinp.c Xnetstatuids.c Xnlistlist.c Xnumeric.c Xpff.c Xportname.c Xprintfamily.c Xprintfflag.c Xprintftype.c Xprintprotoinet.c Xprintpstat.c Xprintrlimits.c Xprintrusage.c Xprintsocktype.c Xprintucred.c Xproctable.c Xrevnamei.c Xsmem.c Xstattimeout.c Xstrerr.c Xtestauthd.c Xusername.c Xvirtype.c Xfindinode Xfindinode/README Xfindinode/FILES Xfindinode/Makefile Xfindinode/FIDDIR Xfindinode/INSTALL Xfindinode/fsupdatefid Xfindinode/fid.h Xfindinode/fid.c Xfindinode/updatefid.c Xfindinode/findinode.c Xfindinode/updatefid.8 Xfindinode/findinode.1 Xfindinode/getopt.h END_OF_FILE if test 2483 -ne `wc -c <'FILES'`; then echo shar: \"'FILES'\" unpacked with wrong size! fi # end of 'FILES' fi if test -f 'authuser.3' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'authuser.3'\" else echo shar: Extracting \"'authuser.3'\" \(3350 characters\) sed "s/^X//" >'authuser.3' <<'END_OF_FILE' X.TH authuser 3 X.SH NAME Xauthuser \- library to get information from a remote Authentication Server X.SH SYNTAX X.B #include <authuser.h> X.PP X.B unsigned short auth_tcpport; X.PP X.B char *auth_xline(user,fd,&in); X.PP X.B int auth_fd(fd,&in,&local,&remote); X.PP X.B char *auth_tcpuser(in,local,remote); X.PP X.B char *user; X.br X.B int fd; X.br X.B unsigned long in; X.br X.B unsigned short local; X.br X.B unsigned short remote; X.SH DESCRIPTION XThe X.I authuser Xlibrary provides a simple interface for Xfinding out the remote identity Xof a connection through the XAuthentication Server Xas specified by RFC 931. XUse the -lauthuser loader option Xto compile a program with this library. X.PP X.B auth_xline(user,fd,&in) Xreturns a line of the form X-Auth-User: user or X-Forgery-By: username, Xdepending upon what the host on the other side of X.B fd Xthinks of the user. XThis is particularly appropriate for Xmail and news headers. X.PP XIf the remote host reports that X.B user Xowns the connection on that side, X.B auth_xline Xwill return X-Auth-User: user. XIf the remote host reports that a different X.B username Xowns the connection, X.B auth_xline Xwill return X-Forgery-By: username. XIf user is NULL, Xit returns X-Auth-User: username Xwith the username reported by the remote host. XIf X.B fd Xis not a TCP connection Xor authentication is impossible, X.B auth_xline Xreturns NULL, setting errno appropriately. X.PP XThe line is not cr-lf terminated. XIt is stored in a static area Xwhich is overwritten on each call to X.B auth_xline. X.B auth_xline Xplaces the Internet address of the other host into in. X.PP X.B auth_fd(fd,&in,&local,&remote) Xretrieves address information from the connection in socket X.B fd. XIt places the XInternet address of the host on other side into X.B in Xand the local and remote XTCP ports into X.B local Xand X.B remote. X.B auth_fd Xreturns -1 upon error, setting errno appropriately. X.PP X.B auth_tcpuser(in,local,remote) Xreturns the name of the user on the other end of the TCP connection Xbetween X.B remote@in Xand X.B local. XIf authentication is impossible, X.B auth_tcpuser Xreturns XNULL, setting errno appropriately. XThe user name is stored in a static area Xwhich is overwritten on each call to X.B auth_tcpuser Xand X.B auth_xline. X.PP XThe authentication routines check with the Xremote Authentication Server on port X.B auth_tcpport, Xwhich defaults to 113 Xas specified by RFC 931. XYou can set X.B auth_tcpport Xto other values Xfor nonstandard implementations. X.PP X.SH RESTRICTIONS X.I authuser Xdoes no backslash interpretation Xupon the remote user name. XHopefully the next revision of RFC 931 Xwill make clear exactly what backslash Xinterpretation should be going on. X.PP X.I authuser Xdoes not use the operating system type Xinformation provided by the Authentication Server. X.SH VERSION Xauthuser version 3.1, May 6, 1991. X.SH AUTHOR XPlaced into the public domain by Daniel J. Bernstein. X.SH REFERENCES XThe authentication server is more secure than passwords Xin some ways, but less secure than passwords in many ways. X(It's certainly better than no password at all---e.g., for Xmail or news.) XIt is not the final solution. XFor an excellent discussion of security problems within Xthe TCP/IP protocol suite, see XSteve Bellovin's article X``Security Problems in the TCP/IP Protocol Suite.'' X.SH "SEE ALSO" Xauthtcp(1), Xattachport(1), Xgetpeername(3), Xgetsockname(3), Xtcp(4), Xauthd(8) END_OF_FILE if test 3350 -ne `wc -c <'authuser.3'`; then echo shar: \"'authuser.3'\" unpacked with wrong size! fi # end of 'authuser.3' fi if test -f 'authuser.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'authuser.c'\" else echo shar: Extracting \"'authuser.c'\" \(3622 characters\) sed "s/^X//" >'authuser.c' <<'END_OF_FILE' X/* X5/6/91 DJB baseline authuser 3.1. Public domain. X*/ X X#include <stdio.h> X#include <sys/types.h> X#include <sys/socket.h> X#include <netinet/in.h> X#include <arpa/inet.h> X#include <netdb.h> X#include <errno.h> X#include <ctype.h> Xextern int errno; X#include "authuser.h" X Xunsigned short auth_tcpport = 113; X X#define SIZ 500 /* various buffers */ X Xstatic int usercmp(u,v) Xregister char *u; Xregister char *v; X{ X /* is it correct to consider Foo and fOo the same user? yes */ X /* but the function of this routine may change later */ X while (*u && *v) X if (tolower(*u) != tolower(*v)) X return tolower(*u) - tolower(*v); X else X ++u,++v; X return *u || *v; X} X Xstatic char authline[SIZ]; X Xchar *auth_xline(user,fd,in) Xregister char *user; /* the supposed name of the user, NULL if unknown */ Xregister int fd; /* the file descriptor of the connection */ Xregister unsigned long *in; X{ X unsigned short local; X unsigned short remote; X register char *ruser; X X if (auth_fd(fd,in,&local,&remote) == -1) X return 0; X ruser = auth_tcpuser(*in,local,remote); X if (!ruser) X return 0; X if (!user) X user = ruser; /* forces X-Auth-User */ X (void) sprintf(authline, X (usercmp(ruser,user) ? "X-Forgery-By: %s" : "X-Auth-User: %s"), X ruser); X return authline; X} X Xint auth_fd(fd,in,local,remote) Xregister int fd; Xregister unsigned long *in; Xregister unsigned short *local; Xregister unsigned short *remote; X{ X struct sockaddr_in sa; X int dummy; X X dummy = sizeof(sa); X if (getsockname(fd,&sa,&dummy) == -1) X return -1; X if (sa.sin_family != AF_INET) X { X errno = EAFNOSUPPORT; X return -1; X } X *local = ntohs(sa.sin_port); X dummy = sizeof(sa); X if (getpeername(fd,&sa,&dummy) == -1) X return -1; X *remote = ntohs(sa.sin_port); X *in = sa.sin_addr.s_addr; X return 0; X} X Xstatic char ruser[SIZ]; Xstatic char realbuf[SIZ]; Xstatic char *buf; X Xchar *auth_tcpuser(in,local,remote) Xregister unsigned long in; Xregister unsigned short local; Xregister unsigned short remote; X{ X struct sockaddr_in sa; X register int s; X register int buflen; X register int w; X register int saveerrno; X char ch; X unsigned short rlocal; X unsigned short rremote; X X if ((s = socket(AF_INET,SOCK_STREAM,0)) == -1) X return 0; X sa.sin_family = AF_INET; X sa.sin_port = htons(auth_tcpport); X sa.sin_addr.s_addr = in; X if (connect(s,&sa,sizeof(sa)) == -1) X { X saveerrno = errno; X (void) close(s); X errno = saveerrno; X return 0; X } X X buf = realbuf; X (void) sprintf(buf,"%u , %u\r\n",(unsigned int) remote,(unsigned int) local); X /* note the reversed order---the example in the RFC is misleading */ X buflen = strlen(buf); X while ((w = write(s,buf,buflen)) < buflen) X if (w == -1) /* should we worry about 0 as well? */ X { X saveerrno = errno; X (void) close(s); X errno = saveerrno; X return 0; X } X else X { X buf += w; X buflen -= w; X } X buf = realbuf; X while ((w = read(s,&ch,1)) == 1) X { X *buf = ch; X if ((ch != ' ') && (ch != '\t') && (ch != '\r')) X ++buf; X if ((buf - realbuf == sizeof(realbuf) - 1) || (ch == '\n')) X break; X } X if (w == -1) X { X saveerrno = errno; X (void) close(s); X errno = saveerrno; X return 0; X } X *buf = '\0'; X X if (sscanf(realbuf,"%hd,%hd: USERID :%*[^:]:%s",&rremote,&rlocal,ruser) < 3) X { X (void) close(s); X errno = EIO; X /* makes sense, right? well, not when USERID failed to match ERROR */ X /* but there's no good error to return in that case */ X return 0; X } X if ((remote != rremote) || (local != rlocal)) X { X (void) close(s); X errno = EIO; X return 0; X } X /* XXX: we're not going to do any backslash processing */ X (void) close(s); X return ruser; X} END_OF_FILE if test 3622 -ne `wc -c <'authuser.c'`; then echo shar: \"'authuser.c'\" unpacked with wrong size! fi # end of 'authuser.c' fi if test -f 'avenrun.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'avenrun.c'\" else echo shar: Extracting \"'avenrun.c'\" \(2091 characters\) sed "s/^X//" >'avenrun.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* getavenrun() returns a pointer into an array of 3 doubles giving the */ X/* current load average (i.e., AVErage Number of RUNning jobs). The first */ X/* is typically the 1-minute average, the second is the 5-minute average, */ X/* and the third is the 15-minute average. getavenrun returns 0 on error. */ X X/* avenruninit() does optional initialization to cooperate with other */ X/* libraries that use nlistlist. avenruninit returns -1 on error. */ X X/* avenrunstrerr is a strerrfun for use with the strerr library. */ X X#include "avenrun.h" X#include "kmem.h" X#include "nlistlist.h" X#include "strerr.h" X#include "confloadavglong.h" X X#define AVENRUNNLIST "_avenrun" X Xstatic int avinit = 0; X Xstatic double av[3]; Xstatic short avtype; Xstatic unsigned long avvalue; Xstatic int avenrunerrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "avenrun error 0", 0 } X#define AV_INIT 1 X, { AV_INIT, "cannot init avenrun: ", nliststrerr } X#define AV_NLIST 2 X, { AV_NLIST, "cannot nlist: ", nliststrerr } X#define AV_NLISTFOUND 3 X, { AV_NLISTFOUND, AVENRUNNLIST, nlistnotin } X#define AV_KMEM 4 X, { AV_KMEM, "cannot read avenrun: ", kmemstrerr } X}; X Xchar *avenrunstrerr(ke) Xstrerrfun *ke; X{ X return strerrtaberr(ke,avenrunerrno,e,sizeof(e)/sizeof(*e),"unknown avenrun error"); X} X Xint avenruninit() X{ X if (nlistadd(AVENRUNNLIST,&avtype,&avvalue) == -1) X RETERN(-1,avenrunerrno,AV_INIT) X avinit = 1; X return 0; X} X X#ifdef LOADAVGISLONG Xstatic long avd[3]; X#endif X Xdouble *getavenrun() X{ X if (!avinit) X if (avenruninit() == -1) X return 0; X if (avtype == -1) X if (nlistdo() == -1) X RETERN(0,avenrunerrno,AV_NLIST) X if (!avtype) X RETERN(0,avenrunerrno,AV_NLISTFOUND) X#ifdef LOADAVGISLONG X if (kmemcpy((char *) &(avd[0]),(char *) avvalue,sizeof(avd)) == -1) X RETERN(0,avenrunerrno,AV_KMEM) X av[0] = ((double) avd[0]) / LOADAVGISLONG; X av[1] = ((double) avd[1]) / LOADAVGISLONG; X av[2] = ((double) avd[2]) / LOADAVGISLONG; X#else X if (kmemcpy((char *) &(av[0]),(char *) avvalue,sizeof(av)) == -1) X RETERN(0,avenrunerrno,AV_KMEM) X#endif X return av; X} END_OF_FILE if test 2091 -ne `wc -c <'avenrun.c'`; then echo shar: \"'avenrun.c'\" unpacked with wrong size! fi # end of 'avenrun.c' fi if test -f 'filetable.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'filetable.c'\" else echo shar: Extracting \"'filetable.c'\" \(2666 characters\) sed "s/^X//" >'filetable.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xstruct file *getfiletable() returns a pointer to a not necessarily Xatomic copy of the file table. myfile is the base of the file table in Xreal kernel memory, i.e., _file. mynfile is the number of entries in the Xfile table, i.e., _nfile. X Xfiletableinit() does optional initialization to cooperate with other Xlibraries. X Xfiletablestrerr is a strerrfun for filetableinit() and getfiletable(). X X*/ X X#include "mallocfree.h" X#include "structfile.h" X#include "filetable.h" X#include "kmem.h" X#include "nlistlist.h" X#include "strerr.h" X X#define FILENLIST "_file" X#define NFILENLIST "_nfile" X Xstatic int finit = 0; Xstatic struct file *filetable = 0; Xstatic short ftype; Xstatic short nftype; Xstatic unsigned long fvalue; Xstatic unsigned long nfvalue; Xstruct file *myfile; Xint mynfile; Xstatic int filetableerrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "filetable error 0", 0 } X#define FT_INIT 1 X, { FT_INIT, "cannot init filetable: ", nliststrerr } X#define FT_NLIST 2 X, { FT_NLIST, "cannot nlist: ", nliststrerr } X#define FT_NLFFOUND 3 X, { FT_NLFFOUND, FILENLIST, nlistnotin } X#define FT_NLNFFOUND 4 X, { FT_NLNFFOUND, NFILENLIST, nlistnotin } X#define FT_NLFREAD 5 X, { FT_NLFREAD, "cannot read file table pointer: ", kmemstrerr } X#define FT_NLNFREAD 6 X, { FT_NLNFREAD, "cannot read nfile: ", kmemstrerr } X#define FT_FTREAD 7 X, { FT_FTREAD, "cannot read file table: ", kmemstrerr } X#define FT_ALLOC 8 X, { FT_ALLOC, "out of memory", 0 } X} ; X Xchar *filetablestrerr(ke) Xstrerrfun *ke; X{ X return strerrtaberr(ke,filetableerrno,e,sizeof(e)/sizeof(*e),"unknown filetable error"); X} X Xint filetableinit() X{ X if (nlistadd(FILENLIST,&ftype,&fvalue) == -1) X RETERN(-1,filetableerrno,FT_INIT) X if (nlistadd(NFILENLIST,&nftype,&nfvalue) == -1) X RETERN(-1,filetableerrno,FT_INIT) X finit = 1; X return 0; X} X Xstruct file *getfiletable() X{ X if (!finit) X if (filetableinit() == -1) X return 0; X if (ftype == -1) X if (nlistdo() == -1) X RETERN(0,filetableerrno,FT_NLIST) X if (!ftype) X RETERN(0,filetableerrno,FT_NLFFOUND) X if (!nftype) X RETERN(0,filetableerrno,FT_NLNFFOUND) X if (kmemcpy((char *) &mynfile,(char *) nfvalue,sizeof(mynfile)) == -1) X RETERN(0,filetableerrno,FT_NLFREAD) X if (kmemcpy((char *) &myfile,(char *) fvalue,sizeof(myfile)) == -1) X RETERN(0,filetableerrno,FT_NLNFREAD) X X if (filetable) X free((char *) filetable); X filetable = (struct file *) malloc((unsigned) (sizeof(struct file) * mynfile)); X if (!filetable) X RETERN(0,filetableerrno,FT_ALLOC) X X if (kmemcpy((char *) filetable,(char *) myfile,sizeof(struct file) * mynfile) == -1) X RETERN(0,filetableerrno,FT_FTREAD) X X return filetable; X} END_OF_FILE if test 2666 -ne `wc -c <'filetable.c'`; then echo shar: \"'filetable.c'\" unpacked with wrong size! fi # end of 'filetable.c' fi if test -f 'findinode/findinode.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/findinode.c'\" else echo shar: Extracting \"'findinode/findinode.c'\" \(3687 characters\) sed "s/^X//" >'findinode/findinode.c' <<'END_OF_FILE' X#include <sys/types.h> X#include <sys/file.h> X#include <sys/stat.h> X#include <sys/dir.h> X#include <stdio.h> X#include "getopt.h" X#include "fid.h" X X/* XXX: This has really shoddy error checking. */ X Xint nonl(s) Xchar *s; X{ X while (*s) X { X if (*s == '\n') X return 0; X ++s; X } X return 1; X} X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X struct node f; X struct nodenum fn; X struct dnodenum dn; X struct stat st; X int i; X int j; X static struct dnodenum dnarr[100]; X struct stat stroot; X DIR *dirp; X struct direct *dp; X static char line[1000]; X int flagjustone; X int opt; X int uid; X X uid = getuid(); X X if (fidinit() == -1) X { X fprintf(stderr,"findinode: fatal: cannot open fid database\n"); X exit(1); X } X X if (lstat("/",&stroot) == -1) X { X fprintf(stderr,"findinode: fatal: cannot lstat /\n"); X exit(1); X } X X flagjustone = 0; X X while ((opt = getopt(argc,argv,"aA")) != EOF) X switch(opt) X { X case 'a': flagjustone = 0; break; X case 'A': flagjustone = 1; break; X case '?': ; /*XXX*/ X } X X while (fgets(line,sizeof(line),stdin)) /* XXX: truncation */ X { X line[strlen(line) - 1] = 0; X if (sscanf(line,"%lu %lx",&f.i,&f.d) < 2) X if (lstat(line,&st) == -1) X { X printf("<nonexistent>: %s\n",line); X fflush(stdout); X continue; X } X else X { X f.i = st.st_ino; X f.d = st.st_dev; X } X f.i = (unsigned long) (ino_t) f.i; X f.d = (unsigned long) (dev_t) f.d; X i = fidfilesget(f); X /* XXX: put all this searching stuff into a function returning a string? */ X#ifdef notdef X printf("file %s (%lu %lx) links %u\n",argv[1],f.i,f.d,i); X#endif X if (!i) X if (f.i == stroot.st_ino && f.d == stroot.st_dev) X printf("%lu %lx: /\n",f.i,f.d); X else X printf("%lu %lx: <unknown>\n",f.i,f.d); X if (i > 1 && flagjustone) X i = 1; X for (;i;--i) X { X /* Get the directories. */ X fidlock(); X if (i > fidfilesget(f)) X { X fidunlock(); X continue; /* just in case database changed */ X } X fn.x = f; fn.n = i; X dnarr[0].x.i = fn.x.i; dnarr[0].x.d = fn.x.d; X dnarr[j = 1] = dn = fidf2dget(fn); X printf("%lu %lx: ",f.i,f.d); X while (fn.x.i = dn.x.i, fn.x.d = dn.x.d, fidfilesget(fn.x) > 0) X { X /* XXX: could report an error if fidfilesget() > 1 */ X fn.n = 1; X dn = dnarr[++j] = fidf2dget(fn); X if (j == 99) X break; /*XXX*/ X } X fidunlock(); X X if (dnarr[j].x.i == stroot.st_ino && dnarr[j].x.d == stroot.st_dev) X { X chdir("/"); X do X { X printf("/"); X dirp = opendir("."); X --j; X while (dp = readdir(dirp)) X { X if (dp->d_name[0] == 0) X continue; X if (dp->d_name[0] == '.' && dp->d_name[1] == 0) X continue; X if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 0) X continue; X if (lstat(dp->d_name,&st) != -1) X if (dnarr[j].x.i == st.st_ino && dnarr[j].x.d == st.st_dev) X if (!j || (chdir(dp->d_name) != -1)) X { X if (nonl(dp->d_name)) X printf("%s",dp->d_name); X else X printf("/<newline>"); /* XXX: should have -0 option */ X if (j) X { X /* XXX: maybe access(".",R_OK) would work ok here. */ X /* and X_OK---this is too blunt but easier than */ X /* doing it right */ X if (uid && (st.st_uid != uid) && !(st.st_mode & 0005)) X { X j = 0; X printf("//<protected>"); X } X } X break; X } X } X closedir(dirp); X if (!dp) /* XXX: gee, is this valid under ANSI? :-) */ X { X printf("/<gone>"); X break; X } X } X while (j); X } X else X printf("<unknown>"); /*XXX*/ X putchar('\n'); X /*XXX: -0?*/ X } X fflush(stdout); X } X} END_OF_FILE if test 3687 -ne `wc -c <'findinode/findinode.c'`; then echo shar: \"'findinode/findinode.c'\" unpacked with wrong size! fi # end of 'findinode/findinode.c' fi if test -f 'findinode/updatefid.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/updatefid.c'\" else echo shar: Extracting \"'findinode/updatefid.c'\" \(2654 characters\) sed "s/^X//" >'findinode/updatefid.c' <<'END_OF_FILE' X#include <sys/types.h> X#include <sys/file.h> X#include <sys/stat.h> X#include <sys/dir.h> X#include "fid.h" X X/* XXX: error checks? */ X X/* XXX: should we periodically seek out and destroy files/dirs with 0 links? */ X Xremove(f,linknum,d,entnum) Xstruct node f; Xint linknum; Xstruct dnode d; Xint entnum; X{ X int linkmax; X int entmax; X struct nodenum fn; X struct dnodenum dn; X X fn.x = f; fn.n = linknum; fidf2ddel(fn); X dn.x = d; dn.n = entnum; fidd2fdel(dn); X linkmax = fidfilesget(f); X if (linknum < linkmax) X { X fn.x = f; fn.n = linkmax; X dn = fidf2dget(fn); fidf2ddel(fn); fidd2fdel(dn); X fn.n = linknum; fidf2dput(fn,dn); fidd2fput(dn,fn); X } X entmax = fiddirsget(d); X if (entnum < entmax) X { X dn.x = d; dn.n = entmax; X fn = fidd2fget(dn); fidd2fdel(dn); fidf2ddel(fn); X dn.n = entnum; fidd2fput(dn,fn); fidf2dput(fn,dn); X } X if (--linkmax) fidfilesput(f,linkmax); else fidfilesdel(f); X if (--entmax) fiddirsput(d,entmax); else fiddirsdel(d); X} X Xadd(f,d) Xstruct node f; Xstruct dnode d; X{ X int linkmax; X int entmax; X struct nodenum fn; X struct dnodenum dn; X X linkmax = fidfilesget(f); ++linkmax; fidfilesput(f,linkmax); X entmax = fiddirsget(d); ++entmax; fiddirsput(d,entmax); X fn.x = f; fn.n = linkmax; X dn.x = d; dn.n = entmax; X fidf2dput(fn,dn); X fidd2fput(dn,fn); X} X Xint dodir() X{ X struct node f; X struct dnode d; X struct nodenum fn; X struct dnodenum dn; X DIR *dirp; X struct direct *dp; X struct stat st; X int i; X long t; X long modt; X X if (lstat(".",&st) == -1) X return -1; X dirp = opendir("."); X if (!dirp) X return -1; X fidlock(); X d.i = st.st_ino; d.d = st.st_dev; X modt = st.st_mtime; if (modt < st.st_ctime) modt = st.st_ctime; X t = fiddirtimesget(d); /* XXX: should have flag to skip this test */ X if (t == modt) X { X fidunlock(); X return 0; X } X fiddirtimesput(d,0); /* marking dir for update */ X i = fiddirsget(d); X dn.x = d; X while (i) /* wipe out old entries */ X { X dn.n = i; X fn = fidd2fget(dn); X#ifdef notdef X printf("[- %u %u %u %u] ",fn.x.i,fn.x.d,dn.x.i,dn.x.d); X#endif X remove(fn.x,fn.n,dn.x,dn.n); X --i; X } X while (dp = readdir(dirp)) /* put in new entries */ X { X if (dp->d_name[0] == 0) X continue; X if (dp->d_name[0] == '.' && dp->d_name[1] == 0) X continue; X if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 0) X continue; X if (lstat(dp->d_name,&st) != -1) X { X f.i = st.st_ino; f.d = st.st_dev; X#ifdef notdef X printf("[+ %u %u %u %u] ",f.i,f.d,d.i,d.d); X#endif X add(f,d); X } X } X fidunlock(); X fiddirtimesput(d,modt); X return 0; X} X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X fidinit(); X X while (*++argv) X if (chdir(*argv) == 0) X dodir(); X} END_OF_FILE if test 2654 -ne `wc -c <'findinode/updatefid.c'`; then echo shar: \"'findinode/updatefid.c'\" unpacked with wrong size! fi # end of 'findinode/updatefid.c' fi if test -f 'getdevicename.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getdevicename.c'\" else echo shar: Extracting \"'getdevicename.c'\" \(3848 characters\) sed "s/^X//" >'getdevicename.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline. todo: hash device names. X3/15/91 DJB separated into library function XOriginally stolen from printdevice() in Dupuy ofiles. X*/ X X/* X Xchar *getdevicename(node) struct Xnode *node; returns the name of a Xdevice in /dev (e.g., /dev/kmem) with the same remote device as node, or X0 if no such device exists. X Xchar *getttydevname(dev) dev_t dev; returns the name of a character Xdevice with the given remote device, or 0 if no such device exists. XXX Xfor the name and modularization: this is used to find the ctty of a Xprocess given u_ttyd, but that doesn't make it logical. X X*/ X X#include <stdio.h> X#include <sys/types.h> X#include <sys/stat.h> X#include "confnfs.h" X#include "confundefstdcbeforedir.h" X#ifdef UNDEFSTDCBEFOREDIR /* stupid features don't deserve short names */ X#undef __stdc__ /* dorks */ X#endif X#include <sys/dir.h> X#include <errno.h> Xextern int errno; X#include "mallocfree.h" X#include "structxnode.h" X#include "confgnode.h" X#include "confclonedev.h" X#include "confmajorminor.h" X Xstatic char dev[] = "/dev/"; X Xstatic int scanned = 0; X Xstruct devname X { X struct devname *next; X char *name; X unsigned mode; X dev_t rdev; X#ifdef CLONEDEV X short clonedev; X#endif X#ifndef NFS X unsigned ino; X#endif X } X; X Xstatic struct devname *devnamelist = 0; X Xstatic int scandev() X{ X struct stat status; X register struct direct *entry; X register DIR *devdir; X register struct devname *dvent; X X scanned = 1; X X errno = 0; X if (!(devdir = opendir(dev))) X return -1; /*XXX*/ X X if (dvent = (struct devname *) malloc(sizeof(struct devname))) X { X while (entry = readdir(devdir)) X { X if (!(dvent->name = malloc(sizeof(dev) + strlen(entry->d_name)))) X break; X (void) strcpy(dvent->name,dev); X (void) strcat(dvent->name,entry->d_name); X if (stat(dvent->name, &status) < 0 X || ((status.st_mode & S_IFMT) != S_IFBLK X && (status.st_mode & S_IFMT) != S_IFCHR)) X { X free((char *) dvent->name); X continue; X } X X dvent->mode = status.st_mode & S_IFMT; X dvent->rdev = status.st_rdev; X#ifdef CLONEDEV X if (dvent->mode == S_IFCHR && major(dvent->rdev) == CLONEDEV) X dvent->clonedev = minor(dvent->rdev); X else X dvent->clonedev = -1; X#endif X#ifndef NFS X dvent->ino = status.st_ino; X#endif X dvent->next = devnamelist; X devnamelist = dvent; X if (!(dvent = (struct devname *) malloc(sizeof(struct devname)))) X break; X } X free ((char *) dvent); X } X closedir(devdir); X return 0; X} X Xchar *getdevicename(node) Xstruct Xnode *node; X{ X register struct devname *dvent; X X if (!scanned) X if (scandev() == -1) X return 0; /*XXX*/ X X for (dvent = devnamelist;dvent;dvent = dvent->next) X { X#ifdef NFS X if (dvent->rdev == node->v_rdev X && (dvent->mode == ((node->v_type == VBLK) ? S_IFBLK : S_IFCHR))) X#else X#ifdef GNODE X if (dvent->rdev == node->g_rdev && dvent->ino == node->g_number X && (dvent->mode == (((node->g_mode & GFMT) == GFBLK) ? S_IFBLK : S_IFCHR))) X#else X if (dvent->rdev == node->i_rdev && dvent->ino == node->i_number X && (dvent->mode == (((node->i_mode & IFMT) == IFBLK) ? S_IFBLK : S_IFCHR))) X#endif X#endif X return dvent->name; X#ifdef CLONEDEV X if (node->v_type == VCHR && dvent->clonedev > 0 X && major(node->v_rdev) == dvent->clonedev) X return dvent->name; X#endif X } X return 0; /*XXX*/ X} X Xchar *getttydevname(dev) Xdev_t dev; X{ X register struct devname *dvent; X X if (!scanned) X if (scandev() == -1) X return 0; /*XXX*/ X X for (dvent = devnamelist;dvent;dvent = dvent->next) X { X /*XXX: is this right normally? */ X if (dvent->rdev == dev X && (dvent->mode == S_IFCHR)) X return dvent->name; X#ifdef notdef /* XXX: CLONEDEV */ X if (node->v_type == VCHR && dvent->clonedev > 0 X && major(node->v_rdev) == dvent->clonedev) X return dvent->name; X#endif X } X return 0; /*XXX*/ X} END_OF_FILE if test 3848 -ne `wc -c <'getdevicename.c'`; then echo shar: \"'getdevicename.c'\" unpacked with wrong size! fi # end of 'getdevicename.c' fi if test -f 'kmem.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'kmem.c'\" else echo shar: Extracting \"'kmem.c'\" \(1753 characters\) sed "s/^X//" >'kmem.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xint kmemcpy(buf,pos,n) char *buf; char *pos; int n; copies n bytes from Xposition pos in kernel memory into buffer buf (in user memory). It Xreturns 0 on success, -1 on error. X Xkmeminit() is an optional initialization routine to cooperate with other Xlibraries. X Xkmemstrerr is a strerrfun for kmeminit() and kmemcpy(). X X*/ X X#include <sys/types.h> X#include <sys/file.h> X#include "kmem.h" X#include "strerr.h" X X#define KMEM "/dev/kmem" X X#define LSEEKFROMSTART 0 X Xstatic int kmemfd = -1; Xstatic int kmemerrno = 0; X Xstatic char *kmemerrprk(ke) strerrfun *ke; { *ke = strerrsys; return KMEM; } X Xchar *kmemstrerr(ke) Xstrerrfun *ke; X{ X *ke = 0; X switch(kmemerrno) X { X case 0: X return "kmem error 0"; X#define KMEM_OPEN 1 X case KMEM_OPEN: X *ke = kmemerrprk; X return "cannot open "; X#define KMEM_LSEEK 2 X case KMEM_LSEEK: X *ke = strerrsys; X return "cannot lseek kmem"; X#define KMEM_READ 3 X case KMEM_READ: X *ke = strerrsys; X return "cannot read kmem"; X#define KMEM_READZERO 4 X case KMEM_READZERO: X return "kmem read 0 bytes"; X default: X return "unknown kmem error"; X } X} X Xint kmeminit() X{ X kmemfd = open(KMEM,O_RDONLY); X if (kmemfd == -1) X RETERN(-1,kmemerrno,KMEM_OPEN) X return 0; X} X Xint kmemcpy(buf,pos,n) Xchar *buf; Xchar *pos; Xint n; X{ X int r; X X if (!n) X return 0; X if (kmemfd == -1) X if (kmeminit() == -1) X return -1; X if (lseek(kmemfd,(long) pos,LSEEKFROMSTART) == -1) X RETERN(-1,kmemerrno,KMEM_LSEEK) X while ((r = read(kmemfd,buf,n)) < n) X if (r == -1) X RETERN(-1,kmemerrno,KMEM_READ) X else if (r == 0) /* XXX: this can never happen */ X RETERN(-1,kmemerrno,KMEM_READZERO) X else X { X buf += r; X n -= r; X } X return 0; X} END_OF_FILE if test 1753 -ne `wc -c <'kmem.c'`; then echo shar: \"'kmem.c'\" unpacked with wrong size! fi # end of 'kmem.c' fi if test -f 'netinp.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'netinp.c'\" else echo shar: Extracting \"'netinp.c'\" \(2170 characters\) sed "s/^X//" >'netinp.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain. todo: eliminate this file. XDerived from authd 3.01, DJB. X*/ X X#ifdef USENETSTAT X X#include "confnonsfinet.h" X#ifdef NONSFINET X#define NETSTAT "/usr/bin/netstat -n -A" X#endif X X/* End of machine define-mod section. */ X X#ifndef NETSTAT X#define NETSTAT "/usr/ucb/netstat -n -A -f inet" X#endif X#ifndef NETSTATBUF X#define NETSTATBUF 200 /* 80 would suffice */ X#endif X#ifndef NETSTATREMOTE X#define NETSTATREMOTE 49 /* has to be 53 for SunOS 4.1.1, I think */ X#endif X#ifndef NETSTATWIDTH X#define NETSTATWIDTH 17 X#endif X#ifndef REMOTESIZE X#define REMOTESIZE 100 /* guaranteed to be enough */ X#endif X X#endif X X#include <stdio.h> XFILE *popen(); /* grrrr */ X#include "kmem.h" X#include "structinpcb.h" X#ifdef USENETSTAT X#include "structtcp.h" X#else X#include "inpcblist.h" X#endif X#include "netinp.h" X X#ifdef USENETSTAT Xstatic FILE *fi; Xstatic char remote[REMOTESIZE]; Xstatic char s[NETSTATBUF]; Xstatic int header; Xstatic int pcb; Xstatic struct tcpcb tcp; Xstatic struct inpcb inp; X Xchar *inploc; X Xint netinpinit(r1,r2,r3,r4,rp) Xint r1; Xint r2; Xint r3; Xint r4; Xint rp; X{ X fi = popen(NETSTAT,"r"); X if (!fi) X return -1; X (void) sprintf(remote,"%d.%d.%d.%d.%d ",r1,r2,r3,r4,rp); X header = 0; X return 0; X} X Xstruct inpcb *nextnetinp() X{ X if (!header) X { X header = 1; X if (!fgets(s,sizeof(s),fi)) X return 0; X if (!fgets(s,sizeof(s),fi)) X return 0; X } X do X { X if (!fgets(s,sizeof(s),fi)) X return 0; /* XXX: cannot distinguish from error */ X if (sscanf(s,"%8x",&pcb) != 1) X return 0; X } X while (strncmp(s + NETSTATREMOTE,remote,NETSTATWIDTH)); X if (kmemcpy((char *) &tcp,(char *) pcb,sizeof(tcp)) == -1) X return 0; X if (!tcp.t_inpcb) X return 0; X if (kmemcpy((char *) &inp,(char *) tcp.t_inpcb,sizeof(inp)) == -1) X return 0; X if (inp.inp_ppcb != (char *) pcb) X return 0; X inploc = tcp.t_inpcb; X return &inp; X} X X#else X Xchar *inploc; Xstatic struct inpcb *inp; X Xint netinpinit(r1,r2,r3,r4,rp) Xint r1; Xint r2; Xint r3; Xint r4; Xint rp; X{ X if (inpcblistinit() == -1) X return -1; X inp = 0; X} X Xstruct inpcb *nextnetinp() X{ X inp = nextinpcb(inp); X inploc = (char *) inpcbloc; X return inp; X} X X#endif END_OF_FILE if test 2170 -ne `wc -c <'netinp.c'`; then echo shar: \"'netinp.c'\" unpacked with wrong size! fi # end of 'netinp.c' fi if test -f 'netstatuids.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'netstatuids.c'\" else echo shar: Extracting \"'netstatuids.c'\" \(2453 characters\) sed "s/^X//" >'netstatuids.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB modified to not compile without HAVE_UCRED X5/1/91 DJB baseline public domain X*/ X X#include "confhaveucred.h" X#ifndef HAVE_UCRED Xerror! error! error! XXX Xnetstatuids will not work on a system without struct ucred. X#endif X X#include <stdio.h> X#include "structfile.h" X#include "structucred.h" X#include "structinpcb.h" X#include "inpcblist.h" X#include "filetable.h" X#include "getfcred.h" X#include "strerr.h" X#include "authuser.h" X#include <pwd.h> X#include "mallocfree.h" X Xchar *pw(u) Xint u; X{ X struct passwd *pw; X char buf[20]; X X pw = getpwuid(u); X if (pw) X return pw->pw_name; X sprintf(buf,"%d",u); X return buf; X} X Xmain() X{ X struct inpcb *inp; X struct file *ft; X struct file *fp; X struct ucred *uc; X int *sfs; X int numsfs; X int i; X unsigned char *fa; X unsigned char *la; X char *user; X X if (filetableinit() == -1) X { X fprintf(stderr,"ns5: %s\n",strerr(filetablestrerr)); X exit(1); X } X if (inpcblistinit() == -1) X { X fprintf(stderr,"ns5: %s\n",strerr(inpcbliststrerr)); X exit(1); X } X X ft = getfiletable(); X if (!ft) X { X fprintf(stderr,"ns5: %s\n",strerr(filetablestrerr)); X exit(1); X } X sfs = (int *) malloc((unsigned) (sizeof(int) * mynfile)); X if (!sfs) X { X fprintf(stderr,"ns5: out of memory\n"); X exit(1); X } X numsfs = 0; X X for (fp = ft;fp < ft + mynfile;++fp) X if (fp->f_count && fp->f_type == DTYPE_SOCKET) X sfs[numsfs++] = fp - ft; X X inp = 0; X while (inp = nextinpcb(inp)) X for (i = 0;i < numsfs;++i) X if ((fp = ft + sfs[i])->f_data == (char *) inp->inp_socket) X { X sfs[i] = sfs[--numsfs]; X uc = getfcred(fp); X if (!uc) X { X fprintf(stderr,"ns5: warning: %s\n",strerr(getfcredstrerr)); X break; X } X fa = (unsigned char *) &(inp->inp_faddr); X la = (unsigned char *) &(inp->inp_laddr); X user = 0; X if (inp->inp_fport) X user = auth_tcpuser(inp->inp_faddr.s_addr X ,ntohs(inp->inp_lport) X ,ntohs(inp->inp_fport)); X else X break; /*XXX: unconnected server*/ X if (!user) X user = "?"; X printf("%s@%d.%d.%d.%d:%d\t%s@%d.%d.%d.%d:%d\n" X ,user X ,(unsigned) fa[0],(unsigned) fa[1],(unsigned) fa[2],(unsigned) fa[3] X ,ntohs(inp->inp_fport) X ,pw(uc->cr_ruid) X ,(unsigned) la[0],(unsigned) la[1],(unsigned) la[2],(unsigned) la[3] X ,ntohs(inp->inp_lport) X ); X fflush(stdout); /*XXX*/ X break; X } X X if (inperrno) X { X fprintf(stderr,"ns5: %s\n",strerr(inpcbliststrerr)); X exit(1); X } X exit(0); X} END_OF_FILE if test 2453 -ne `wc -c <'netstatuids.c'`; then echo shar: \"'netstatuids.c'\" unpacked with wrong size! fi # end of 'netstatuids.c' fi if test -f 'nlistlist.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'nlistlist.c'\" else echo shar: Extracting \"'nlistlist.c'\" \(3961 characters\) sed "s/^X//" >'nlistlist.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X XThe problem: Independent libraries want to access a shared resource, Xthe kernel name list. Normally, if those libraries were written Xindependently, they would each do a separate nlist(). This is Xunacceptably inefficient. X XThe solution: nlistlist. Other libraries can call nlistadd() in their Xinitialization routines, then nlistdo() before they need the data. Xnlistlist buffers all nlistadd()ed names and only looks them up on an Xnlistdo(). So independent libraries can cooperate merely by providing Xinitialization routines. X Xint nlistadd(name,type,value) char *name; short *type; unsigned long *value; Xsets *type to -1 and returns 0. Upon the next call to nlistdo(), name X(which should always begin with an underscore) will be looked up in the Xkernel's name list (typically /vmunix). The type of the returned address Xwill be stored in *type, and the value will be stored in *value. If Xthere is some problem, nlistadd returns -1, and the above operations Xwill not occur. The meaning of *type on a successful lookup varies from Xsystem to system, but a zero *type indicates that name is not in the Xname list. X Xnlistdo() handles all previous nlistadd()s as mentioned above. It Xreturns 0 on success, -1 on error. X Xnliststrerr is a strerrfun for nlistadd() and nlistdo(). X Xnlistnotin is a strerrfun for use by libraries using nlistlist. It Xprints a message like " not in nlist", and is appropriate after a type Xis returned as 0. X X*/ X X#include <nlist.h> X#include "mallocfree.h" X#include "nlistlist.h" X#include "strerr.h" X#include "confnlistknlist.h" X#include "confnlistunder.h" X#include "confnlistmeaning.h" X#include "confvmunix.h" X#include "confnlname.h" X Xchar *nlistnotin(ke) Xstrerrfun *ke; X{ X return strerrstr(ke," not in nlist"); X} X Xstatic int nlisterrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "nlist error 0", 0 } X#define NLIST_ALLOC 1 X, { NLIST_ALLOC, "cannot malloc for nlist", 0 } X#define NLIST_NLIST 2 X, { NLIST_NLIST, "nlist() failed", 0 } X} ; X Xchar *nliststrerr(ke) Xstrerrfun *ke; X{ X return strerrtaberr(ke,nlisterrno,e,sizeof(e)/sizeof(*e),"unknown nlist error"); X} X Xstatic struct nlistlist X { X char *name; X short *type; X unsigned long *value; X struct nlistlist *next; X } Xhead = { 0 , 0 }; X Xstatic int nlistnum = 0; X Xint nlistadd(name,type,value) Xchar *name; Xshort *type; Xunsigned long *value; X{ X struct nlistlist *t; X X t = head.next; X head.next = (struct nlistlist *) malloc(sizeof(struct nlistlist)); X if (!head.next) X { X head.next = t; X nlisterrno = NLIST_ALLOC; X return -1; X } X head.next->next = t; X head.next->name = name; X head.next->type = type; X head.next->value = value; X *type = -1; X ++nlistnum; X return 0; X} X Xint nlistdo() X{ X struct nlist *nl; X struct nlistlist *t; X struct nlistlist *tnext; X int i; X X if (!nlistnum) X return 0; X nl = (struct nlist *) malloc((unsigned) (sizeof(struct nlist) * (nlistnum + 1))); X if (!nl) X RETERN(-1,nlisterrno,NLIST_ALLOC) X i = 0; X for (t = head.next;t;t = t->next) X { X#ifdef FORGET_UNDERSCORES X NLNAME(nl[i]) = t->name + 1; X#else X NLNAME(nl[i]) = t->name; X#endif X ++i; X } X NLNAME(nl[i]) = ""; X#ifdef KNLIST X knlist(nl); X /* XXX: This appears to fail in some cases. So... */ X for (i = 0;i < nlistnum;++i) X if (!nl[i].n_value) X { X nlist(VMUNIX,nl); /*XXX*/ X break; X } X#else X#ifdef MEANINGLESS_NLIST X nlist(VMUNIX,nl); X#else X if (nlist(VMUNIX,nl) == -1) X { X free((char *) nl); X nlisterrno = NLIST_NLIST; X return -1; X } X#endif X#endif X#ifdef notdef /*XXX: debugging */ X printf("[nlist"); X while (i) { --i; printf(" %s:%x",NLNAME(nl[i]),nl[i].n_value); } X printf("]"); X#endif X i = 0; X for (t = head.next;t;t = tnext) X { X *(t->type) = nl[i].n_type; X /* XXX: force some uniformity on the types? */ X *(t->value) = nl[i].n_value; X /* XXX: let user give us a function to free t->name? */ X tnext = t->next; X free((char *) t); X ++i; X } X nlistnum = 0; X free((char *) nl); X head.next = 0; X return 0; X} END_OF_FILE if test 3961 -ne `wc -c <'nlistlist.c'`; then echo shar: \"'nlistlist.c'\" unpacked with wrong size! fi # end of 'nlistlist.c' fi if test -f 'printpstat.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printpstat.c'\" else echo shar: Extracting \"'printpstat.c'\" \(1996 characters\) sed "s/^X//" >'printpstat.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printpstat(p) struct proc *p; returns a string representing Xvarious basic information about p's status (with p in user memory). XNot well defined. X X*/ X X#include <stdio.h> X#include <strings.h> X#include "printpstat.h" X#include "structproc.h" X#include "confhavepflag.h" X Xstatic char result[300]; X/* XXX: 300 is guaranteed safe for the current code, but if you add */ X/* more printing flags, you may have to bring the number up. */ X Xchar *printpstat(p) Xstruct proc *p; X{ X int pstat; X int pflag; X char *t; X X pstat = p->p_stat; X#ifndef HAVE_PFLAG X pflag = p->p_select | p->p_sched | p->p_vm; /*XXX: annoying*/ X#else X pflag = p->p_flag; X#endif X X switch(pstat) X { X#ifdef SSLEEP X case SSLEEP: strcpy(result,"S "); break; X#endif X#ifdef SWAIT X case SWAIT: strcpy(result,"D "); break; X#endif X#ifdef SRUN X case SRUN: strcpy(result,"R "); break; X#endif X#ifdef SIDL X case SIDL: strcpy(result,"X "); break; X#endif X#ifdef SZOMB X case SZOMB: strcpy(result,"Z "); break; X#endif X#ifdef SSTOP X case SSTOP: strcpy(result,"T "); break; X#endif X default: strcpy(result,"? "); X } X t = result + 2; X X#define PFLAG(S,X) if (pflag & S) { strcpy(t,X); t += strlen(t); pflag &= ~S; } X X#ifdef SLOAD X PFLAG(SLOAD,"load ") X#endif X#ifdef SSYS X PFLAG(SSYS,"sys ") X#endif X#ifdef SLOCK X PFLAG(SLOCK,"lock ") X#endif X#ifdef SSWAP X PFLAG(SSWAP,"swap ") X#endif X#ifdef SOMASK X PFLAG(SOMASK,"omask ") X#endif X#ifdef SWEXIT X PFLAG(SWEXIT,"wexit ") X#endif X#ifdef SWTED X PFLAG(SWTED,"wted ") X#endif X#ifdef SULOCK X PFLAG(SULOCK,"ulock ") X#endif X#ifdef STRC X PFLAG(STRC,"traced ") X#endif X#ifdef SPAGI X PFLAG(SPAGI,"ipage ") X#endif X#ifdef SSEL X PFLAG(SSEL,"sel! ") X#endif X#ifdef SPTECHG X PFLAG(SPTECHG,"ptechg ") X#endif X#ifdef SEXECDN X PFLAG(SEXECDN,"execdn ") X#endif X#ifdef SVFORK X PFLAG(SVFORK,"vfork ") X#endif X#ifdef SVFDONE X PFLAG(SVFDONE,"vfdone ") X#endif X#ifdef SNOVM X PFLAG(SNOVM,"novm ") X#endif X if (pflag) X { X sprintf(t,"flag %x ",pflag); X } X return result; X} END_OF_FILE if test 1996 -ne `wc -c <'printpstat.c'`; then echo shar: \"'printpstat.c'\" unpacked with wrong size! fi # end of 'printpstat.c' fi if test -f 'printucred.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printucred.c'\" else echo shar: Extracting \"'printucred.c'\" \(3161 characters\) sed "s/^X//" >'printucred.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB modified to print something sensible under !HAVE_UCRED X5/1/91 DJB baseline public domain X*/ X X/* X Xchar *printucred(uc,style,ruids,tags,uns) struct ucred *uc; int style; Xint ruids; int tags; int uns; prints uc in a variety of styles. X Xstyle is not yet officially defined. XXX this whole interface X XIf ruids is 0, the effective uid is printed, and the real uid is printed Xif different. If ruids is 1, only the effective uid is printed. If ruids Xis 2, only the real uid is printed. X XIf tags is 1, information is tagged with inline labels. If tags is 0, it Xis assumed that labels are placed at the top of columns. X XIf uns is 1, uids are printed as usernames if possible. If uns is 0, Xuids are always printed as uids. X X*/ X X#include <stdio.h> X#include <strings.h> X#include "structucred.h" X#include "printucred.h" X#include "username.h" X#include "groupname.h" X#include "confhaveucred.h" X/* XXX: should provide for string group names! */ X Xstatic char result[50 + NGROUPS * 8]; X/* XXX: assumes uids and gids are at most 8 (really 5) characters */ X/* XXX: assumes uids and gids are short */ X/* XXX: string representation? */ X/* XXX: under newer Suns, auid? audit? label? */ X Xchar *printucred(uc,style,ruids,tags,uns) Xstruct ucred *uc; Xint style; Xint ruids; Xint tags; Xint uns; X{ X int i; X char *t; X unsigned gid; X unsigned rgid; X unsigned uid; X unsigned ruid; X unsigned puid; X X#ifdef HAVE_UCRED X uid = uc->cr_uid; X ruid = uc->cr_ruid; X#else X uid = uc->uid; X ruid = uc->uid; X#endif X puid = (ruids == 2) ? ruid : uid; X if (uns) X { X char *pun; X uid2username(puid,&pun); /* XXX: care about return value? */ X if (style == 1) X sprintf(result,"%s%8s",tags ? "uid " : "",pun); X else X sprintf(result,"%s%s",tags ? "uid " : "",pun); X } X else X if (style == 1) X sprintf(result,"%s%5u",tags ? "uid " : "",puid); X else X sprintf(result,"%s%u",tags ? "uid " : "",puid); X t = result + strlen(result); X if (!ruids && (uid != ruid)) X { X if (uns) X { X char *pun; X uid2username(ruid,&pun); /* XXX: care about return value? */ X if (style == 1) X sprintf(t,"/%8u",ruid); X else X sprintf(t,"/%u",ruid); X } X else X if (style == 1) X sprintf(t,"/%5u",ruid); X else X sprintf(t,"/%u",ruid); X t += strlen(t); X } X if (style == 1 && !ruids && (uid == ruid)) X { X if (uns) { sprintf(t," "); t += 9; } X else { sprintf(t," "); t += 6; } X } X if (style == 2) X { X sprintf(t," "); X t = result + (tags ? 4 : 0) + (!ruids ? 6 : 0) + 5 + (uns ? 6 : 0); X *t = 0; X } X#ifdef HAVE_UCRED /*XXX*/ X if (style == 3) X { X gid = (unsigned short) uc->cr_gid; X rgid = (unsigned short) uc->cr_rgid; X sprintf(t," %s%u",tags ? "gid " : "",gid); t += strlen(t); X if (gid != rgid) X { X sprintf(t,"/%u",rgid); t += strlen(t); X } X for (i = 0;i < NGROUPS;++i) X { X register short g; X g = uc->cr_groups[i]; X if (g == -1) X break; /* XXX: is this right? */ X if (g != gid && g != rgid) X sprintf(t," %u",(unsigned) (unsigned short) g); X t += strlen(t); X if (!g) X break; /* XXX: is this right? */ X } X } X#endif X return result; X} END_OF_FILE if test 3161 -ne `wc -c <'printucred.c'`; then echo shar: \"'printucred.c'\" unpacked with wrong size! fi # end of 'printucred.c' fi if test -f 'proctable.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'proctable.c'\" else echo shar: Extracting \"'proctable.c'\" \(2453 characters\) sed "s/^X//" >'proctable.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X#include "mallocfree.h" X#include "proctable.h" X#include "structproc.h" X#include "kmem.h" X#include "nlistlist.h" X#include "strerr.h" X X#define PROCNLIST "_proc" X#define NPROCNLIST "_nproc" X Xstatic int pinit = 0; Xstatic struct proc *proctable = 0; Xstatic short ptype; Xstatic short nptype; Xstatic unsigned long pvalue; Xstatic unsigned long npvalue; Xstruct proc *myproc; Xint mynproc; Xstatic int proctableerrno = 0; X Xchar *proctablestrerr(ke) Xstrerrfun *ke; X{ X *ke = 0; X switch(proctableerrno) X { X case 0: X return "proctable error 0"; X#define PT_INIT 1 X case PT_INIT: X *ke = nliststrerr; X return "cannot init proctable: "; X#define PT_NLIST 2 X case PT_NLIST: X *ke = nliststrerr; X return "cannot nlist: "; X#define PT_NLPFOUND 3 X case PT_NLPFOUND: X *ke = nlistnotin; X return PROCNLIST; X#define PT_NLNPFOUND 4 X case PT_NLNPFOUND: X *ke = nlistnotin; X return NPROCNLIST; X#define PT_NLPREAD 5 X case PT_NLPREAD: X *ke = kmemstrerr; X return "cannot read proc table pointer: "; X#define PT_NLNPREAD 6 X case PT_NLNPREAD: X *ke = kmemstrerr; X return "cannot read nproc: "; X#define PT_FTREAD 7 X case PT_FTREAD: X *ke = kmemstrerr; X return "cannot read proc table: "; X#define PT_ALLOC 8 X case PT_ALLOC: X *ke = 0; X return "out of memory"; X default: X return "unknown proctable error"; X } X} X Xint proctableinit() X{ X if (nlistadd(PROCNLIST,&ptype,&pvalue) == -1) X RETERN(-1,proctableerrno,PT_INIT) X if (nlistadd(NPROCNLIST,&nptype,&npvalue) == -1) X RETERN(-1,proctableerrno,PT_INIT) X pinit = 1; X return 0; X} X Xstruct proc *getproctable() X{ X if (!pinit) X if (proctableinit() == -1) X return 0; X if (ptype == -1) X if (nlistdo() == -1) X RETERN(0,proctableerrno,PT_NLIST) X if (!ptype) X RETERN(0,proctableerrno,PT_NLPFOUND) X if (!nptype) X RETERN(0,proctableerrno,PT_NLNPFOUND) X if (kmemcpy((char *) &mynproc,(char *) npvalue,sizeof(mynproc)) == -1) X RETERN(0,proctableerrno,PT_NLPREAD) X if (kmemcpy((char *) &myproc,(char *) pvalue,sizeof(myproc)) == -1) X RETERN(0,proctableerrno,PT_NLNPREAD) X X if (proctable) X free((char *) proctable); X proctable = (struct proc *) malloc((unsigned) (sizeof(struct proc) * mynproc)); X if (!proctable) X RETERN(0,proctableerrno,PT_ALLOC) X X if (kmemcpy((char *) proctable,(char *) myproc,sizeof(struct proc) * mynproc) == -1) X RETERN(0,proctableerrno,PT_FTREAD) X X return proctable; X} END_OF_FILE if test 2453 -ne `wc -c <'proctable.c'`; then echo shar: \"'proctable.c'\" unpacked with wrong size! fi # end of 'proctable.c' fi if test -f 'strerr.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'strerr.c'\" else echo shar: Extracting \"'strerr.c'\" \(2183 characters\) sed "s/^X//" >'strerr.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline public domain X*/ X X#include <stdio.h> X#include <errno.h> Xextern int errno; Xextern int sys_nerr; Xextern char *sys_errlist[]; X#include <strings.h> X#include "mallocfree.h" X#include "strerr.h" X Xchar *strerrtaberr(ke,err,tab,n,dfl) Xstrerrfun *ke; Xint err; /* error number */ Xstruct strerrtab *tab; /* error table */ Xint n; /* size of tab */ Xchar *dfl; /* what to say if err isn't in tab */ X{ X int i; X if ((err < 0) || (err >= n)) X { X *ke = 0; X return dfl; X } X if (tab[err].err != err) X { X for (i = 0;i < n;++i) X if (tab[i].err == err) X break; X if (i == n) X { X *ke = 0; X return dfl; X } X } X else X i = err; /* fastest this way */ X /* So now tab[i].err == err. */ X *ke = tab[i].next; X return tab[i].s; X} X Xchar *strerrstr(ke,s) Xstrerrfun *ke; Xchar *s; X{ X *ke = 0; X return s; X} X Xchar *strerrsys(ke) Xstrerrfun *ke; X{ X *ke = strerrno; X return ": "; X} X Xstatic char unk[30]; X Xchar *strerrno(ke) Xstrerrfun *ke; X{ X *ke = 0; X if ((errno < 0) || (errno > sys_nerr)) X { X (void) sprintf(unk,"unknown error %d",errno); X return unk; X } X return sys_errlist[errno]; X} X Xstruct sel { struct sel *next; char *s; unsigned len; } ; X Xchar *strerr(ke) Xstrerrfun ke; X{ X char *s; X char *t; X struct sel head; X struct sel *sel; X struct sel *temp; X int saveerrno; /*XXX: what if malloc messes up other errors? */ X unsigned len; X X head.next = 0; X sel = &head; X X /* Note that *sel is always allocated. We do this so that we can */ X /* better handle malloc errors. */ X X while (ke) X { X s = ke(&ke); X saveerrno = errno; X temp = (struct sel *) malloc(sizeof(struct sel)); X if (!temp) X { X sel->s = "aack! malloc error"; X sel->len = strlen(sel->s); X break; X } X errno = saveerrno; X sel->next = temp; X temp->next = 0; X sel->s = s; X sel->len = strlen(s); X sel = temp; X } X X len = 1; X for (sel = &head;temp = sel->next;sel = temp) X len += sel->len; X X s = malloc(len); X if (!s) X return "aack! malloc error"; /*XXX*/ X X t = s; X for (sel = &head;temp = sel->next;sel = temp) X { X (void) strcpy(t,sel->s); X t += sel->len; X if (sel != &head) /*XXX*/ X free((char *) sel); X } X free((char *) sel); X X return s; X} END_OF_FILE if test 2183 -ne `wc -c <'strerr.c'`; then echo shar: \"'strerr.c'\" unpacked with wrong size! fi # end of 'strerr.c' fi if test -f 'testauthd.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'testauthd.c'\" else echo shar: Extracting \"'testauthd.c'\" \(2704 characters\) sed "s/^X//" >'testauthd.c' <<'END_OF_FILE' X#include <stdio.h> X#include <sys/types.h> X#include <sys/file.h> X#ifdef sun X#include <sys/fcntl.h> X#endif X#include <sys/socket.h> X#include <netinet/in.h> X#include <arpa/inet.h> X#include <pwd.h> X#include <errno.h> Xextern int errno; X#include "authuser.h" X Xmain() X{ X int s; X int t; X int u; X struct sockaddr_in sa; X int salen; X int localport; X unsigned long in; X unsigned short local; X unsigned short remote; X char *user; X struct passwd *pw; X int ok; X X ok = 1; X X#define ZOT(x) { fprintf(stderr,"test: fatal: %s\n",x); exit(37); } X X printf("connecting to myself through loopback (127.1)...\n"); X X s = socket(AF_INET,SOCK_STREAM,0); X if (s == -1) X ZOT("cannot create server socket") X X localport = 0; /* meaning pick a port, we don't care which */ X X sa.sin_family = AF_INET; X sa.sin_port = htons(localport); X sa.sin_addr.s_addr = INADDR_ANY; X X if (bind(s,&sa,sizeof(sa)) == -1) X ZOT("cannot bind server socket") X X salen = sizeof(sa); X if (getsockname(s,&sa,&salen) == -1) X ZOT("cannot get name of server socket") X X if (listen(s,5) == -1) X ZOT("cannot listen for connections") /* XXX: impossible */ X X u = socket(AF_INET,SOCK_STREAM,0); X if (u == -1) X ZOT("cannot create client socket") X X /* we could bind now if we wanted to pick a local port, or to know */ X /* our local port before connection */ X X /* if connect() blocked then we'd never get a chance to accept() */ X if (fcntl(u,F_SETFL,O_NDELAY) == -1) /* XXX: FNDELAY? */ X ZOT("cannot set client socket to non-blocking mode") X X /* sa is already initialized above to the address we want to connect to */ X if (connect(u,&sa,sizeof(sa)) != -1) X ; /* XXX: this is slightly screwy, though common, behavior */ X else X if (errno != EINPROGRESS) X ZOT("connect failed") /* XXX: should retry if EINTR */ X X salen = sizeof(sa); X if ((t = accept(s,&sa,&salen)) == -1) X ZOT("cannot accept connection") X X printf("system says host is %s\n",inet_ntoa(sa.sin_addr)); X X /* now let's see what the server can figure out about the client */ X X if (auth_fd(t,&in,&local,&remote) == -1) X ZOT("authuser cannot figure out connection information") X X if (sa.sin_addr.s_addr != in) X { X ok = 0; X sa.sin_addr.s_addr = in; X } X printf("authuser says host is %s\n",inet_ntoa(sa.sin_addr)); X X pw = getpwuid(getuid()); X if (pw) X printf("system says username is %s\n",pw->pw_name); X else X { X ok = 0; X printf("system cannot figure out your username\n"); X } X X user = auth_tcpuser(in,local,remote); X if (user) X printf("authd says username is %s\n",user); X else X { X ok = 0; X printf("authd cannot figure out your username\n"); X } X X if (ok) X if (!strcmp(user,pw->pw_name)) X printf("Everything looks okay to me.\n"); X else X ok = 1; X X exit(!ok); X} END_OF_FILE if test 2704 -ne `wc -c <'testauthd.c'`; then echo shar: \"'testauthd.c'\" unpacked with wrong size! fi # end of 'testauthd.c' fi echo shar: End of archive 3 \(of 6\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (05/07/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 4 (of 6)." # Contents: INSTALL OFILES.hist authd.c findinode/README # findinode/fid.c getnode.c getsocket.c getuser.c mntops.c # Wrapped by brnstnd@kramden on Mon May 6 23:59:01 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'INSTALL' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'INSTALL'\" else echo shar: Extracting \"'INSTALL'\" \(5717 characters\) sed "s/^X//" >'INSTALL' <<'END_OF_FILE' X#!/bin/sh X X# Actions. X# Change kmem to anything and mode to 0755 if you don't have a kmem group, X# or change kmem to anything and mode to 0700 if you don't want normal X# users to be able to use these utilities. XMODE=02755 # load, pff XSYSMODE=02755 # authd, tcpuid, tcpuname, netstatuids XGROUP=kmem XINSTALL="install -c" XPROGINSTALL="$INSTALL -g $GROUP -m $MODE" XSYSINSTALL="$INSTALL -g $GROUP -m $SYSMODE" XLIBINSTALL="$INSTALL -m 0444" # really ends up 0644 XMANINSTALL="$INSTALL -m 0444" X X# Directories. XBIN=/usr/local/bin XETC=/etc XLIB=/usr/lib XINCLUDE=/usr/include XMAN=/usr/man X X# Programs. XPFF="$BIN"/pff XLOAD="$BIN"/load XAUTHD="$ETC"/authd XTCPUID="$ETC"/tcpuid # must be on same filesystem as authd XTCPUNAME="$ETC"/tcpuname # ditto XNETSTATUIDS="$ETC"/netstatuids XAUTHUSER="$LIB"/libauthuser.a XAUTHUSERH="$INCLUDE"/authuser.h X X# Man pages. XMPFF="$MAN"/man1/pff.1 # XXX: not used XMLOAD="$MAN"/man1/load.1 XMAUTHUSER="$MAN"/man3/authuser.3 XMAUTHD="$MAN"/man8/authd.8 XMTCPUID="$MAN"/man8/tcpuid.8 XMTCPUNAME="$MAN"/man8/tcpuname.8 XMNETSTATUIDS="$MAN"/man8/netstatuids.8 # XXX: not used X X# Name of port 113 in /etc/services. XPORTNAME=auth X Xecho "Each action will be printed before it is run. Press return to proceed." Xecho "Type skip (or anything starting with an s) to skip a step." Xecho "(To see all actions, do something like % yes skip | sh INSTALL.)" X Xecho "1. Install load and pff." Xecho "! $PROGINSTALL pff $PFF: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$PROGINSTALL" pff "$PFF" ;; Xesac X Xecho "! $PROGINSTALL load $LOAD: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$PROGINSTALL" load "$LOAD" ;; Xesac X Xecho "2. Install authd, tcpuid, tcpuname, and netstatuids." Xecho "! $SYSINSTALL authd $AUTHD: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$SYSINSTALL" authd "$AUTHD" ;; Xesac X Xecho "! rm -f $TCPUID; ln $AUTHD $TCPUID: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) rm -f "$TCPUID"; ln "$AUTHD" "$TCPUID" ;; Xesac X Xecho "! rm -f $TCPUNAME; ln $AUTHD $TCPUNAME: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) rm -f "$TCPUNAME"; ln "$AUTHD" "$TCPUNAME" ;; Xesac X Xecho "! $SYSINSTALL netstatuids $NETSTATUIDS: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$SYSINSTALL" netstatuids "$NETSTATUIDS" ;; Xesac X Xecho "3. Install the authuser library." Xecho "! $LIBINSTALL authuser.h $AUTHUSERH: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$LIBINSTALL" authuser.h "$AUTHUSERH" ;; Xesac X Xecho "! ar rv $AUTHUSER authuser.o: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) ar rv "$AUTHUSER" authuser.o ;; Xesac X Xecho "! ranlib $AUTHUSER: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) ranlib "$AUTHUSER" ;; Xesac X Xecho "! chmod 644 $AUTHUSER: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) chmod 644 "$AUTHUSER" ;; Xesac X Xecho "4. Make the man pages available." Xecho "! $MANINSTALL authuser.3 $MAUTHUSER: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$MANINSTALL" authuser.3 "$MAUTHUSER" ;; Xesac X Xecho "! $MANINSTALL load.1 $MLOAD: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$MANINSTALL" load.1 "$MLOAD" ;; Xesac X Xecho "! $MANINSTALL authd.8 $MAUTHD: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$MANINSTALL" authd.8 "$MAUTHD" ;; Xesac X Xecho "! $MANINSTALL tcpuid.8 $MTCPUID: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$MANINSTALL" tcpuid.8 "$MTCPUID" ;; Xesac X Xecho "! $MANINSTALL tcpuname.8 $MTCPUNAME: " | tr -d '\012' Xread line; case "$line" in Xs*) echo "[skipped]" ;; X*) eval "$MANINSTALL" tcpuname.8 "$MTCPUNAME" ;; Xesac X Xecho "5. Make sure an auth port is in /etc/services." Xecho "Let me glance at /etc/services for you..." Xif grep '^'$PORTNAME'[ ]*113/tcp' /etc/services >/dev/null 2>&1 Xthen echo "Okay, you have it already. Let's continue." Xelse echo "Nope, it's not there." X echo "Let me check that you don't have a different auth port..." X if grep '^'$PORTNAME'[ ][ ]*' /etc/services >/dev/null 2>&1 X then echo "Aaack! $PORTNAME is already used in /etc/services. Exiting." X exit 1 X fi X echo "! echo $PORTNAME' 113/tcp' >> /etc/services: " | tr -d '\012' X read line; case "$line" in X s*) echo "[skipped]" ;; X *) echo "$PORTNAME"' 113/tcp' >> /etc/services ;; X esac Xfi X Xecho "6. Enable auth in /etc/inetd.conf." Xecho "Let me glance at /etc/inetd.conf for you..." Xif grep '^'"$PORTNAME"'[ ]' /etc/inetd.conf >/dev/null 2>&1 Xthen echo "Okay, it's already there. That's it!" X exit 0 Xfi Xif grep 'telnet.*root' /etc/inetd.conf >/dev/null 2>&1 Xthen echo "It's not there yet. Hmmm, looks like you have a Sun-style inetd." X echo "! echo $PORTNAME' stream tcp nowait root '$AUTHD' authd' >> /etc/inetd.conf: " | tr -d '\012' X read line; case "$line" in X s*) echo "[skipped]" ;; X *) echo "$PORTNAME"' stream tcp nowait root '"$AUTHD"' authd' >> /etc/inetd.conf ;; X esac Xelse echo "It's not there yet." X echo "! echo $PORTNAME' stream tcp nowait '$AUTHD' authd' >> /etc/inetd.conf: " | tr -d '\012' X read line; case "$line" in X s*) echo "[skipped]" ;; X *) echo "$PORTNAME"' stream tcp nowait '"$AUTHD"' authd' >> /etc/inetd.conf ;; X esac Xfi X Xecho "7. Let inetd know about the new service." Xecho "On most machines you have to % kill -HUP nn" Xecho "where nn is the number of the inetd process." Xecho "Here's what ps acugx shows about inetd:" Xps acugx | sed -n -e 1p -e /inetd/p Xecho "I'll leave this step to you. That's it!" X Xexit 0 END_OF_FILE if test 5717 -ne `wc -c <'INSTALL'`; then echo shar: \"'INSTALL'\" unpacked with wrong size! fi chmod +x 'INSTALL' # end of 'INSTALL' fi if test -f 'OFILES.hist' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'OFILES.hist'\" else echo shar: Extracting \"'OFILES.hist'\" \(6101 characters\) sed "s/^X//" >'OFILES.hist' <<'END_OF_FILE' XA history of ofiles XDan Bernstein X4/6/91 X X X1. Contributors to ofiles/fstat/pff X XC. Spencer <??? at BBN> was the original author of ofiles. X XVic Abell <abe@mace.cc.purdue.edu> XDan Bernstein <brnstnd@nyu.edu> XWill Crowder <willcr@ism.isc.com> XTom Christiansen <tchrist@convex.com> XMichael Ditto <???> XViktor Dukhovni <viktor@shearson.com> XTom Dunigan <dunigan@msr.epm.ornl.gov> XAlexander Dupuy <dupuy@cs.columbia.edu> XVik Lall <???> XCraig Leres <leres@helios.ee.lbl.gov> XRay Moody <Ray.Moody@timbuk.cray.com> XGary Nebbett <grn@stl.stc.co.uk last known address> XTim Rosmus <tim@pilchuck.data-io.com> XMike Spitzer <???> XRichard Tobin <richard@aiai.ed.ac.uk> X XParticular thanks to Vic Abell, Alexander Dupuy, and Craig Leres for a Xlot of the information contained here. Thanks also to Eduardo Krell X<ekrell@ulysses.att.com> for bringing the Dupuy version of ofiles to my Xattention. X X X2. The ofiles/fstat/pff tree X X original ofiles X | X modified original ofiles find-fs BSD 4.3-Tahoe fstat X | \ | | X Abell ofiles Dupuy ofiles Abell fstat X | | | X modified Abell ofiles | Christiansen fstat X \ | / X ---------pff-------- X XThe lines here trace ideas, not just code. pff does not use any fstat Xcode, but it borrows heavily from the fstat output format, for example. X X X3. Who, what, when X XC. Spencer <??? at BBN> wrote the original ofiles for BSD 4.2, around XMay 1985. This is the ``original ofiles'' node above. X XAlexander Dupuy <dupuy@cs.columbia.edu> maintained ofiles in September Xand October 1988. He integrated a vnode version with DYNIX support from XTom Dunigan <dunigan@msr.epm.ornl.gov>, modified it to work with remote Xfiles and filesystems, added support for examining the descriptor tables Xof selected processes, added text segment support, merged enhancements Xto the vnode version with the inode version, added socket-printing Xoptions done in August 1988 by Craig Leres <leres@helios.ee.lbl.gov>, Xand ported ofiles to Ultrix 2.0. X XAt some point (viz., ``modified original ofiles''), another version of Xofiles---the ``Abell ofiles'', maintained by Vic Abell X<abe@mace.cc.purdue.edu>---split off the above branch. See below for Xfurther details. X XIn July 1990 Dupuy eliminated the DYNIX support but integrated several Xfurther versions, including an initial SunOS 4.0 port by Gary Nebbett X<last known address grn@stl.stc.co.uk> and socket-searching enhancements Xby Viktor Dukhovni <viktor@shearson.com>. He then ported ofiles to a VAX Xrunning 4.3+NFS and finished integrating Dukhovni's May 1990 SunOS 4.1 Xport. This version was distributed. In late June 1990 Dupuy integrated a Xpatch from Tim Rosmus <tim@pilchuck.data-io.com> to distinguish between XNFS4 vnodes and SunOS 4's NFS, to handle Mt. XINU systems. That version Xis the ``Dupuy ofiles'' node in the tree. X XThe Abell ofiles gives credit to Dunigan, Dupuy, Nebbett, Michael Ditto X<???>, and Richard Tobin <richard@aiai.ed.ac.uk>. It is not clear when Xthis version split off; it may have been directly from the original Xofiles, as it does not support NFS. Abell tracked down the above names; Xthey did not (necessarily) contribute to that version. (In fact, Tobin Xapparently did not work on ofiles; Dupuy took the text segment search Xcode from Tobin's find-fs, which he posted to Sun-Spots at some point.) X XAt the Purdue University Computer Center, Mike Spitzer <???> ported Xofiles to BSD 4.3 and DYNIX 3.0.1[24], Ray Moody <ray@mace.cc.purdue.edu> Xadded code to report on shared and exclusive locks, Vik Lall <???> Xapparently did some ports, somebody ported it to SunOS 4.0 and Ultrix X2.2, and Abell added an option to look up network connections by Xprotocol control block address. This became the Abell ofiles, which Xappeared on comp.sources.unix in volume 18. Will Crowder X<willcr@ism.isc.com> patched the Abell ofiles for SunOS 4.1; this, and Xany other modifications to that version after the comp.sources.unix Xrelease, appear at the ``modified Abell ofiles'' node. X XIn the meantime, an independent fstat program appeared in BSD 4.3-Tahoe X(when?). fstat performs much of the same function as ofiles in a Xsomewhat different way. The 4.3-Tahoe version does not support NFS. XAbell ported fstat to various systems and sent it to comp.sources.unix Xvolume 18. Tom Christiansen <tchrist@convex.com> ported it to the Convex Xand added partial NFS support (his version didn't decode the filesystem Xfrom /etc/mtab as the Dupuy ofiles does); note that source to this Xversion is not available because Convex is, well, um, stingy. X XIn March and April 1991, Dan Bernstein <brnstnd@nyu.edu---that's me> Xintegrated the various versions of ofiles, stole some ideas (though not Xcode) from fstat, and rewrote most of the program (the easy parts) from Xscratch. ``pff'' (process-file-file) has getuser() and various other Xpieces of the Abell ofiles, mmap and text segment support from the Dupuy Xofiles, Convex support as in the Christiansen fstat, offset reporting as Xin fstat, controlling ttys, open file flags (like rwa for read, write, Xappend), vnode and device printing mostly from the Dupuy ofiles, NFS Xsupport as in the Dupuy ofiles and the Christiansen fstat, socket Xsearching similar to the Dupuy ofiles, and several output formats Ximitating the output formats of the older programs. pff can also report Xprocess status, including resource usage and signal handling. X Xpff does *not* support the DYNIX core file reading from the Abell ofiles, Xany sort of debugging output, file size reporting as in fstat, various Xname lookups (e.g., hostnames, services), and socket searches by Xprotocol. It's also rather shoddy on error-checking. Other than this, pff Xappears to provide all the features of its ancestors. It works so far Xunder Ultrix 4.1, SunOS 4.0.3, SunOS 4.1, and Convex UNIX 9.0. X XI do not know what interest Spencer, Ditto, Dunigan, Lall, Nebbett, XRosmus, or Spitzer currently have in the code, so as noted in README Xcertain parts of pff might not be freely distributable. The code I wrote Xfor this package is all public-domain. END_OF_FILE if test 6101 -ne `wc -c <'OFILES.hist'`; then echo shar: \"'OFILES.hist'\" unpacked with wrong size! fi # end of 'OFILES.hist' fi if test -f 'authd.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'authd.c'\" else echo shar: Extracting \"'authd.c'\" \(4355 characters\) sed "s/^X//" >'authd.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB authd version 3.5 alpha. X5/3/91 DJB modified to not compile without HAVE_UCRED X5/1/91 DJB baseline public domain XDerived from authd 3.01, DJB. X*/ X X#include "confhaveucred.h" X#ifndef HAVE_UCRED Xerror! error! error! XXX Xauthd will not work on a system without struct ucred. X#endif X X#include <stdio.h> X#ifdef USE_SYSLOG X#include <syslog.h> X#endif X#include "structfile.h" X#include "structucred.h" X#include "structinpcb.h" X#include "getfcred.h" X#include "filetable.h" X#include "netinp.h" X#include "auread.h" X#include "username.h" X Xint flagpwnam = 0; Xint flagauthd = 0; Xchar localport[10]; Xchar remoteport[10]; X Xzap(err,argv0) Xchar *err; Xchar *argv0; X{ X if (flagauthd) X /* Reporting errors honestly to a remote host could damage security. */ X printf("%s, %s: ERROR: UNKNOWN-ERROR\r\n",localport,remoteport); X else X fprintf(stderr,"%s: fatal: %s\n",argv0,err); X exit(37); /*XXX*/ X} X X#define ZAP(err) zap(err,argv[0]) X Xint loc4[4]; Xint rem4[4]; X#define l1 loc4[0] X#define l2 loc4[1] X#define l3 loc4[2] X#define l4 loc4[3] X#define r1 rem4[0] X#define r2 rem4[1] X#define r3 rem4[2] X#define r4 rem4[3] X Xint doit(fp) Xregister struct file *fp; X{ X register struct ucred *uc; X register int uid; X char *un; X X uc = getfcred(fp); X if (!uc) X return -1; X uid = (int) uc->cr_ruid; X if (flagpwnam) X { X if (uid2username(uid,&un) == 1) X /* XXX: We don't give out userids that don't have usernames. */ X return -1; X if (flagauthd) X /* UNIX is a trademark of AT&T. :-) */ X /* XXX: We could try to report UNIX variants here. */ X printf("%s, %s: USERID: %s: %s\r\n",localport,remoteport,"UNIX",un); X else X printf("%s\n",un); X } X else X printf("%d\n",uid); X return 0; X} X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X register struct file *xfile; X register struct file *fp; X register struct inpcb *inp; X int lp; X int rp; X X if ((!strcmp(argv[0],"authd")) X || ((strlen(argv[0]) >= 6) X && (!strcmp(argv[0] + strlen(argv[0]) - 6,"/authd")))) X flagauthd = flagpwnam = 1; X else X if ((!strcmp(argv[0],"tcpuname")) X || ((strlen(argv[0]) >= 9) X && (!strcmp(argv[0] + strlen(argv[0]) - 9,"/tcpuname")))) X flagpwnam = 1; X X if (flagauthd) X { X if (readlr(localport,remoteport,loc4,rem4,&lp,&rp) == -1) X exit(1); /*XXX*/ X#ifdef USE_SYSLOG X /* This isn't worth the time for the procedure call, but if you want... */ X syslog(LOG_DEBUG,"authd: checking up on %d.%d.%d.%d %d %d.%d.%d.%d %d\n", X r1,r2,r3,r4,rp,l1,l2,l3,l4,lp); X#endif X } X else X { X if (argc < 4) X ZAP("need four arguments"); X if (sscanf(argv[1],"%d.%d.%d.%d",&r1,&r2,&r3,&r4) < 4) X ZAP("arg 1 must be a.b.c.d"); X if (sscanf(argv[2],"%d",&rp) < 1) X ZAP("arg 2 must be integer"); X if (sscanf(argv[3],"%d.%d.%d.%d",&l1,&l2,&l3,&l4) < 4) X ZAP("arg 3 must be a.b.c.d"); X if (sscanf(argv[4],"%d",&lp) < 1) X ZAP("arg 4 must be integer"); X } X X if (netinpinit(r1,r2,r3,r4,rp) == -1) X ZAP("cannot init netstat"); X if (filetableinit() == -1) X ZAP("cannot init space for file table"); X X xfile = getfiletable(); X if (!xfile) X ZAP("cannot get file table"); X X while (inp = nextnetinp()) X { X/* Cursed be Convex and the other manufacturers who make this code */ X/* nearly impossible to write with any pretense of portability. */ X if((((char *) &inp->inp_faddr)[3] == (char) r4) X &&(((char *) &inp->inp_laddr)[3] == (char) l4) X &&(((char *) &inp->inp_faddr)[2] == (char) r3) X &&(((char *) &inp->inp_laddr)[2] == (char) l3) X &&(((char *) &inp->inp_faddr)[1] == (char) r2) X &&(((char *) &inp->inp_laddr)[1] == (char) l2) X &&(((char *) &inp->inp_faddr)[0] == (char) r1) X &&(((char *) &inp->inp_laddr)[0] == (char) l1) X &&(inp->inp_fport == htons((unsigned short) rp)) X &&(inp->inp_lport == htons((unsigned short) lp)) X ) X /* Is it worth snarfing the socket and checking that it points back */ X /* to inp? No, because then we have to worry about sys/socketvar.h, */ X /* including sys/mbuf.h on a Convex and maybe other machines, etc. */ X /* Sometimes portability gets in the way of everything else. */ X for (fp = xfile;fp < xfile + mynfile;++fp) X if (fp->f_count && (fp->f_type == DTYPE_SOCKET)) X if ((char *) fp->f_data == (char *) inp->inp_socket) X { X if (doit(fp) == -1) X ZAP("cannot get userid"); X exit(0); X } X } X ZAP("no such TCP connection"); X exit(1); X} END_OF_FILE if test 4355 -ne `wc -c <'authd.c'`; then echo shar: \"'authd.c'\" unpacked with wrong size! fi # end of 'authd.c' fi if test -f 'findinode/README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/README'\" else echo shar: Extracting \"'findinode/README'\" \(4270 characters\) sed "s/^X//" >'findinode/README' <<'END_OF_FILE' Xfindinode - find all filenames with a given (dev,inode) pair X XThe entire purpose of this package is to give you a fast mapping from Xdevice and inode number to filename(s), i.e., a reverse namei. It works Xby keeping a database showing all directories containing each inode. A Xdaemon runs continuously to maintain this database. The accuracy of Xfindinode's answers depends on how much CPU time you give the daemon. XNote that findinode will always detect when it cannot provide an Xaccurate answer. It also refuses to divulge filenames inside protected Xdirectories to anyone except the owner (or root, of course). X XExample: One system here has about 1.8GB disk space with 1.4GB used (and X0.2GB reserved for the system as usual), spread over 49000 inodes in X2400 directories. The findinode database takes a mere 6.1MB, or under Xhalf a percent of the total disk space. find / -type d takes 90 seconds; Xthe initial fsupdatefid sweep used just 200 user seconds and 600 system Xseconds. A typical update sweep takes only a few minutes, automatically Xspread out by fsupdatefid over a few hours so that the CPU and disks do Xnot carry a significant extra load. Since the entire database is Xrecycled several times a day, findinode almost never misses a file. X XMore precise documentation: Run findinode and give it a line of the form X X 2065 300 Xor X /usr/ucb/w X XThe first form means ``find pathnames referring to inode 2065 (decimal) Xon device 300 (hexadecimal).'' The second means ``find pathnames Xreferring to the same file as /usr/ucb/w''; such a pathname may be Xtruncated to 1000 characters. The second form is redundant but useful. X Xfindinode will print (and flush, before waiting for further input) one Xor more lines in the following form: X X 2065 300: /etc/hosts.equiv X XThe first two numbers will always be the inode and device numbers of the Xfile, no matter what the input line format was. The rest of the line is Xa filename. A printed pathname of /foo/bar/blah guarantees the following: XSometime after findinode read the input line, / contained directory foo, Xwhich sometime after that contained directory bar, which sometime after Xthat contained file blah, which had the stated (inode,device) pair Xsometime before the filename was printed. X XNote that findinode does not guarantee that it will find all links, or Xthat it will find as many or as few links as the file has, or that it Xwill print distinct pathnames. In particular, if a file has a dozen Xlinks in one directory, findinode will typically print a dozen lines Xreferring to the first link. X XNone of the path components printed by findinode will be empty or Xcontain a newline. If findinode cannot make these guarantees, it will Xprint a line in one of the following formats: X X 2065 300: <unknown> (no guarantees, but chances are that X findinode's never seen that inode-device) X 2065 300: /etc//<gone> (no guarantees, but chances are that at X some time in the past, the inode was X contained in some sub[sub...]directory of X a directory with the same inode-device X numbers as what /etc had sometime while X findinode was running) X 2065 300: /home/shmoe//<protected> X (no guarantees, but your real uid probably X does not have permission to read the X /home/shmoe directory, and whatever's X true about <gone> is probably true here) X 2065 300: /tmp/joe//<newline> X (findinode detected that it was about to X print a path component containing a X newline) X XAdditional error formats may be defined in future versions of findinode; Xthey will always begin with a character other than a slash, or contain a Xdouble slash in the printed pathname. X Xfindinode -A suppresses the multiple-line output; it will print exactly Xone line for each line of input. -a turns multiple-line output back on. X XCompiling: You may have to change direct to dirent throughout, or change X<sys/dir.h> to something like <dirent.h>. X XTODO: Xclean out directories and files with 0 links Xkeep statistics on findinode success rate Xafter a failure, have updatefid check some directory again? Xdo something better with multiple links in one directory? Xwrite some real documentation! get this into beta! END_OF_FILE if test 4270 -ne `wc -c <'findinode/README'`; then echo shar: \"'findinode/README'\" unpacked with wrong size! fi # end of 'findinode/README' fi if test -f 'findinode/fid.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'findinode/fid.c'\" else echo shar: Extracting \"'findinode/fid.c'\" \(5425 characters\) sed "s/^X//" >'findinode/fid.c' <<'END_OF_FILE' X#include <sys/types.h> X#include <sys/file.h> X#include <sys/stat.h> X#include <sys/dir.h> X#include <stdio.h> X#include <ndbm.h> X#include "fid.h" X Xstatic int fdlock; Xstatic DBM *dbfiles; Xstatic DBM *dbdirs; Xstatic DBM *dbdirtimes; Xstatic DBM *dbf2d; Xstatic DBM *dbd2f; X Xint fidinit() X{ X fdlock = open(DBLOCK,O_RDWR | O_CREAT,0600); X if (fdlock == -1) return -1; X dbfiles = dbm_open(DBFILES,O_RDWR | O_CREAT,0600); X if (!dbfiles) return -1; X dbdirs = dbm_open(DBDIRS,O_RDWR | O_CREAT,0600); X if (!dbdirs) return -1; X dbdirtimes = dbm_open(DBDIRTIMES,O_RDWR | O_CREAT,0600); X if (!dbdirtimes) return -1; X dbf2d = dbm_open(DBF2D,O_RDWR | O_CREAT,0600); X if (!dbf2d) return -1; X dbd2f = dbm_open(DBD2F,O_RDWR | O_CREAT,0600); X if (!dbd2f) return -1; X return 0; X} X Xint fidlock() X{ X return flock(fdlock,LOCK_EX); X} X Xint fidunlock() X{ X return flock(fdlock,LOCK_UN); X} X X/*XXX these routines*/ Xstatic datum f2key(f) struct node f; { datum key; X static char buf[8]; unsigned long fi = f.i; unsigned long fd = f.d; X buf[0] = fi & 255; fi /= 256; buf[1] = fi & 255; fi /= 256; X buf[2] = fi & 255; fi /= 256; buf[3] = fi & 255; X buf[4] = fd & 255; fd /= 256; buf[5] = fd & 255; fd /= 256; X buf[6] = fd & 255; fd /= 256; buf[7] = fd & 255; X key.dptr = buf; key.dsize = 8; return key; } X Xstatic datum d2key(d) struct dnode d; { datum key; X static char buf[8]; unsigned long di = d.i; unsigned long dd = d.d; X buf[0] = di & 255; di /= 256; buf[1] = di & 255; di /= 256; X buf[2] = di & 255; di /= 256; buf[3] = di & 255; X buf[4] = dd & 255; dd /= 256; buf[5] = dd & 255; dd /= 256; X buf[6] = dd & 255; dd /= 256; buf[7] = dd & 255; X key.dptr = buf; key.dsize = 8; return key; } X Xstatic datum fn2key(fn) struct nodenum fn; { datum key; X static char buf[12]; X unsigned long fni = fn.x.i; unsigned long fnd = fn.x.d; X unsigned long fnn = fn.n; X buf[0] = fni & 255; fni /= 256; buf[1] = fni & 255; fni /= 256; X buf[2] = fni & 255; fni /= 256; buf[3] = fni & 255; X buf[4] = fnd & 255; fnd /= 256; buf[5] = fnd & 255; fnd /= 256; X buf[6] = fnd & 255; fnd /= 256; buf[7] = fnd & 255; X buf[8] = fnn & 255; fnn /= 256; buf[9] = fnn & 255; fnn /= 256; X buf[10] = fnn & 255; fnn /= 256; buf[11] = fnn & 255; X key.dptr = buf; key.dsize = 12; return key; } X Xstatic struct nodenum key2fn(d) datum d; { struct nodenum fn; X unsigned char *buf = (unsigned char *) d.dptr; X fn.x.i = ((buf[3] * 256 + buf[2]) * 256 + buf[1]) * 256 + buf[0]; X fn.x.d = ((buf[7] * 256 + buf[6]) * 256 + buf[5]) * 256 + buf[4]; X fn.n = ((buf[11] * 256 + buf[10]) * 256 + buf[9]) * 256 + buf[8]; X return fn; X} X Xstatic datum dn2key(dn) struct dnodenum dn; { datum key; X static char buf[12]; X unsigned long dni = dn.x.i; unsigned long dnd = dn.x.d; X unsigned long dnn = dn.n; X buf[0] = dni & 255; dni /= 256; buf[1] = dni & 255; dni /= 256; X buf[2] = dni & 255; dni /= 256; buf[3] = dni & 255; X buf[4] = dnd & 255; dnd /= 256; buf[5] = dnd & 255; dnd /= 256; X buf[6] = dnd & 255; dnd /= 256; buf[7] = dnd & 255; X buf[8] = dnn & 255; dnn /= 256; buf[9] = dnn & 255; dnn /= 256; X buf[10] = dnn & 255; dnn /= 256; buf[11] = dnn & 255; X key.dptr = buf; key.dsize = 12; return key; } X Xstatic struct dnodenum key2dn(d) datum d; { struct dnodenum dn; X unsigned char *buf = (unsigned char *) d.dptr; X dn.x.i = ((buf[3] * 256 + buf[2]) * 256 + buf[1]) * 256 + buf[0]; X dn.x.d = ((buf[7] * 256 + buf[6]) * 256 + buf[5]) * 256 + buf[4]; X dn.n = ((buf[11] * 256 + buf[10]) * 256 + buf[9]) * 256 + buf[8]; X return dn; X} X Xint fidfilesput(f,n) struct node f; int n; { datum content; X content.dptr = (char *)&n; content.dsize = sizeof(n); X return dbm_store(dbfiles,f2key(f),content,DBM_REPLACE); } X Xint fidfilesdel(f) struct node f; { X return dbm_delete(dbfiles,f2key(f)); } X Xint fidfilesget(f) struct node f; { datum content; X content = dbm_fetch(dbfiles,f2key(f)); X if (!content.dptr) return 0; X return *((int *) content.dptr); } X Xint fiddirsput(d,n) struct dnode d; int n; { datum content; X content.dptr = (char *)&n; content.dsize = sizeof(n); X return dbm_store(dbdirs,d2key(d),content,DBM_REPLACE); } X Xint fiddirsdel(d) struct dnode d; { X return dbm_delete(dbdirs,d2key(d)); } X Xint fiddirsget(d) struct dnode d; { datum content; X content = dbm_fetch(dbdirs,d2key(d)); X if (!content.dptr) return 0; X return *((int *) content.dptr); } X Xint fiddirtimesput(d,n) struct dnode d; long n; { datum content; X content.dptr = (char *)&n; content.dsize = sizeof(n); X return dbm_store(dbdirtimes,d2key(d),content,DBM_REPLACE); } X Xint fiddirtimesdel(d) struct dnode d; { X return dbm_delete(dbdirtimes,d2key(d)); } X Xlong fiddirtimesget(d) struct dnode d; { datum content; X content = dbm_fetch(dbdirtimes,d2key(d)); X if (!content.dptr) return 0; X return *((long *) content.dptr); } X Xint fidf2dput(f,d) struct nodenum f; struct dnodenum d; { X return dbm_store(dbf2d,fn2key(f),dn2key(d),DBM_REPLACE); } X Xint fidf2ddel(f) struct nodenum f; { X return dbm_delete(dbf2d,fn2key(f)); } X Xstruct dnodenum fidf2dget(f) struct nodenum f; { datum content; X content = dbm_fetch(dbf2d,fn2key(f)); X /* XXX: what if content.dptr is 0? */ X return key2dn(content); } X Xint fidd2fput(d,f) struct dnodenum d; struct nodenum f; { X return dbm_store(dbd2f,dn2key(d),fn2key(f),DBM_REPLACE); } X Xint fidd2fdel(d) struct dnodenum d; { X return dbm_delete(dbd2f,dn2key(d)); } X Xstruct nodenum fidd2fget(d) struct dnodenum d; { datum content; X content = dbm_fetch(dbd2f,dn2key(d)); X /* XXX: what if content.dptr is 0? */ X return key2fn(content); } END_OF_FILE if test 5425 -ne `wc -c <'findinode/fid.c'`; then echo shar: \"'findinode/fid.c'\" unpacked with wrong size! fi # end of 'findinode/fid.c' fi if test -f 'getnode.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getnode.c'\" else echo shar: Extracting \"'getnode.c'\" \(5893 characters\) sed "s/^X//" >'getnode.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB various modifications X5/1/91 DJB baseline XRewritten by DJB to store rather than print information. XOriginally stolen from Dupuy ofiles. X*/ X X/* XXX: error checks! support strerr! */ X X/* X Xint getnode(node,buf) struct Xnode *node; struct nodebuf *buf; looks up Xthe filesystem node (in kernel memory) and places its vital statistics Xinto buf. buf->type is a three-character file type as defined by the Xvirtype library. buf->flagdev is NODE_ID_INO if node is a regular inode, XNODE_ID_DEV if it is a device, NODE_ID_FIFO if it is a fifo, and XNODE_ID_FIFOINO if it is a fifo but the regular inode information is Xalso filled in. (Some systems do not support type NODE_ID_FIFOINO.) X XIf buf->flagdev is NODE_ID_INO, buf->id.ino has the following elements: Xinum is the file serial number; dev is the file device number; name is Xthe filename of the device, or 0 if it is unknown; flagnfs is 0 for a Xlocal file and 1 for a remote file. X XIf buf->flagdev is NODE_ID_DEV, buf->id.dev has the following elements: Xmaj is the major number of the remote device; min is the minor number; Xand name is the filename, or 0 if it is unknown. X Xgetnode() returns 0 on success, -1 on error. XXX: need getnodestrerr. X Xgetnodeinit() does optional initialization to cooperate with other Xlibraries. X X*/ X X#ifdef NFS X#define NL_NFS "_nfs_vnodeops" Xstatic unsigned long nlnfsv; Xstatic short nlnfst; X#define NL_UFS "_ufs_vnodeops" Xstatic unsigned long nlufsv; Xstatic short nlufst; X#endif X X#include <stdio.h> X#include <sys/types.h> X#include <sys/stat.h> X#include "confnfs.h" X#include "structxnode.h" X#include "nlistlist.h" X#include "stattimeout.h" X#include "rpcnfs.h" X#include "virtype.h" X#include "mntops.h" X#include "getdevicename.h" X#include "getnode.h" X#include "confneedmntinfo.h" X#include "confgnode.h" X#include "confmajorminor.h" X X#define istype(mode,type) (((mode) & S_IFMT) == (type)) X#define ispecial(mode) (istype((mode),S_IFBLK) || istype((mode),S_IFCHR)) X#ifdef NFS X#define vspecial(vtype) ((vtype) == VCHR || (vtype) == VBLK) X#endif X Xstatic int init = 0; X X#ifdef GNODE X Xint getnode(node,buf) Xstruct gnode *node; Xstruct nodebuf *buf; X{ X struct gnode g; X struct statlist *fsstats; X X if (!node) X return -1; X kmemcpy(&g,node,sizeof(g)); X buf->type = itype(g.g_mode); X if (ispecial(g.g_mode)) X { X buf->flagdev = NODE_ID_DEV; X buf->id.dev.maj = major(g.g_rdev); X buf->id.dev.min = minor(g.g_rdev); X buf->id.dev.name = getdevicename(&g); X return 0; X } X if (!init) X pervn(); X fsstats = stats; X X buf->flagdev = NODE_ID_INO; X buf->id.ino.inum = g.g_number; X buf->id.ino.dev = g.g_dev; X X while (fsstats) /* XXX: hash! */ X { X if (fsstats->device == g.g_dev) X { X buf->id.ino.name = fsstats->filename; X /* another iffy test for nfs */ X if (itype(g.g_mode) == vtype(((struct vnode *) &g)->v_type)) X buf->id.ino.flagnfs = 1; X else X buf->id.ino.flagnfs = 0; X return 0; X } X fsstats = fsstats->next; X } X X buf->id.ino.name = 0; X return 0; X} X X#else X Xint getnode(node,buf) Xstruct Xnode *node; Xstruct nodebuf *buf; X{ X#ifdef NFS X struct vnode v; X#endif X static union xnode X { X struct inode i; X#ifdef NFS X struct rnode r; X#endif X } X x; X struct statlist *fsstats; X X if (!init) X pervn(); X fsstats = stats; X X if (!node) X return -1; X X#ifdef NFS X kmemcpy(&v,node,sizeof(v)); X X buf->type = vtype(v.v_type); X X if (vspecial(v.v_type)) X { X buf->flagdev = NODE_ID_DEV; X buf->id.dev.maj = major(v.v_rdev); X buf->id.dev.min = minor(v.v_rdev); X buf->id.dev.name = getdevicename(&v); X return 0; X } X X buf->flagdev = NODE_ID_INO; X#ifdef S_IFIFO X if (v.v_type == VFIFO) X { X#ifdef GET_FIFOS X struct snode sn; X buf->flagdev = NODE_ID_FIFOINO; X kmemcpy(&sn,v.v_data,sizeof(sn)); X kmemcpy(&v,sn.s_realvp,sizeof(v)); X#else X buf->flagdev = NODE_ID_FIFO; X return 0; X#endif X } X#endif X X kmemcpy(&x,v.v_data,sizeof(x)); X X if ((unsigned long) v.v_op == nlnfsv) X { X#ifndef NEED_MNTINFO X buf->id.ino.flagnfs = 1; X buf->id.ino.inum = x.r.r_attr.va_nodeid; X buf->id.ino.dev = x.r.r_attr.va_fsid; X X while (fsstats) X { X if (fsstats->device == (dev_t) x.r.r_attr.va_fsid) X { X buf->id.ino.name = fsstats->filename; X return 0; X } X fsstats = fsstats->next; X } X buf->id.ino.name = 0; X return 0; X#else X struct vfs vf; X struct mntinfo mi; X dev_t fsdev; X X kmemcpy(&vf,v.v_vfsp,sizeof(vf)); X kmemcpy(&mi,vf.vfs_data,sizeof(mi)); X fsdev = makedev(0xff,mi.mi_mntno); X X buf->id.ino.flagnfs = 1; X buf->id.ino.inum = x.r.r_nfsattr.na_nodeid; X X while (fsstats) X { X if (fsstats->device == fsdev) X { X buf->id.ino.dev = mi.mi_mntno; X buf->id.ino.name = fsstats->filename; X return 0; X } X fsstats = fsstats->next; X } X X buf->id.ino.dev = x.r.r_nfsattr.na_fsid; /* XXX: is this right? */ X buf->id.ino.name = 0; X return 0; X#endif X } X else if ((unsigned long) v.v_op == nlufsv) X { X /* XXX: Yes, this *is* a confusing interaction between {} and #ifdef. */ X#else X kmemcpy(&x.i,node,sizeof(x.i)); X buf->type = itype(x.i.i_mode); X X if (ispecial(x.i.i_mode)) X { X buf->flagdev = NODE_ID_DEV; X buf->id.dev.maj = major(x.i.i_rdev); X buf->id.dev.min = minor(x.i.i_rdev); X buf->id.dev.name = getdevicename(&x.i); X return 0; X } X#endif X X buf->flagdev = NODE_ID_INO; X buf->id.ino.inum = x.i.i_number; X buf->id.ino.dev = x.i.i_dev; X buf->id.ino.flagnfs = 0; X while (fsstats) X { X if (fsstats->device == x.i.i_dev) X { X buf->id.ino.name = fsstats->filename; X return 0; X } X fsstats = fsstats->next; X } X buf->id.ino.name = 0; X#ifdef NFS X } X else X return -1; /* XXX: inode unrecognized fs type */ X#endif X return 0; X} X X#endif X Xstatic pervn() X{ X if (!init) X getnodeinit(); X#ifdef NFS X if (!nlnfst) X nlistdo(); X#endif X} X Xgetnodeinit() X{ X#ifdef NFS X nlistadd(NL_NFS,&nlnfst,&nlnfsv); /*XXX*/ X nlistadd(NL_UFS,&nlufst,&nlufsv); X#endif X init = 1; X} END_OF_FILE if test 5893 -ne `wc -c <'getnode.c'`; then echo shar: \"'getnode.c'\" unpacked with wrong size! fi # end of 'getnode.c' fi if test -f 'getsocket.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getsocket.c'\" else echo shar: Extracting \"'getsocket.c'\" \(4398 characters\) sed "s/^X//" >'getsocket.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB various modifications X5/1/91 DJB baseline public domain X*/ X X/* X Xint getsocket(f,sbuf) struct socket *f; struct socketbuf *sbuf; looks up Xsocket f (in kernel memory) and places its vital statistics into sbuf. Xsbuf->socktype is the general socket type, such as SOCK_STREAM. Xsbuf->strsockt is the name of the socket type, or 0 if the type is Xunknown. sbuf->flag{accept,reuse,head} are the accept, reuse, and head Xflags on the socket respectively. sbuf->family is the socket's address Xfamily, such as AF_INET; sbuf->famname is the name of the family, or 0 Xif the family is unknown. sbuf->famname may be truncated to 30 Xcharacters. X Xsbuf->fsw is a family switch to control sbuf->fu: FSW_INET for AF_INET, XFSW_UNIX for AF_UNIX, and FSW_UNK for other types. X XIf sbuf->fsw is FSW_INET: sbuf->fu.inet has several members. proto is Xthe Internet protocol, such as IPPROTO_TCP. strpro is the name for Xproto, or 0 if it is unknown. r0, r1, r2, r3 are the bytes (from network Xdown to host) of the IP address of the remote host; rp is the remote Xport, for protocols where that is meaningful. l0, l1, l2, l3 and lp form Xthe local address. X XIf sbuf->fsw is FSW_UNIX: sbuf->fu.un has several members. node is the Xaddress of the filesystem node associated with the socket, if any. conn Xis the address of the connected node, if any. path is the bound pathname Xof the socket, if applicable; it may be either a character array or a Xpointer in future releases of this library. unpcb is the address of the Xsocket's protocol control block. X Xgetsocket() returns 0 upon success, -1 upon error. X X*/ X X#include <stdio.h> X#include "structinpcb.h" X#include "structmbuf.h" X#include "structprotosw.h" X#include "structsocket.h" X#include "structunpcb.h" X#include "structxnode.h" X#include "printfamily.h" X#include "printprotoinet.h" X#include "printsocktype.h" X#include "kmem.h" X#include <sys/un.h> X#include "getsocket.h" X#include "confdomain.h" X Xgetsocket(f,sbuf) Xstruct socket *f; Xstruct socketbuf *sbuf; X{ X struct socket s; X struct protosw psw; X#ifdef DOMAIN X struct domain dom; X#endif X int family; X X kmemcpy(&s,f,sizeof(s)); X X /* XXX: state, follow head, error, pgrp */ X kmemcpy(&psw,s.so_proto,sizeof(psw)); X#ifdef DOMAIN X kmemcpy(&dom,psw.pr_domain,sizeof(dom)); X family = dom.dom_family; X#else X family = psw.pr_family; X#endif X X sbuf->socktype = s.so_type; X sbuf->strsockt = printsocktype(s.so_type); X sbuf->flagaccept = !!(s.so_options & SO_ACCEPTCONN); X sbuf->flagreuse = !!(s.so_options & SO_REUSEADDR); X sbuf->flaghead = !!(s.so_head); X /* N.B. psw.pr_type always equals s.so_type */ X sbuf->family = family; X#ifdef DOMAIN X if (dom.dom_name && (family >= 0) && (family < 50)) X { X char domname[50][30]; /* XXX: so I'm scum. so sue me. */ X kmemcpy(domname[family],dom.dom_name,sizeof(domname[family])); X domname[family][29] = 0; X sbuf->famname = domname[family]; X } X else X#endif X sbuf->famname = printfamily(family); X sbuf->fsw = FSW_UNK; X X if (family == AF_INET) X { X struct inpcb inp; X unsigned char *a; X X sbuf->fsw = FSW_INET; X sbuf->fu.inet.proto = psw.pr_protocol; X sbuf->fu.inet.strpro = printprotoinet(psw.pr_protocol); X X /*XXX: do port lookups? */ X /*XXX: do host lookups? */ X kmemcpy(&inp,s.so_pcb,sizeof(inp)); X a = (unsigned char *) &inp.inp_faddr; X sbuf->fu.inet.r0 = a[0]; sbuf->fu.inet.r1 = a[1]; X sbuf->fu.inet.r2 = a[2]; sbuf->fu.inet.r3 = a[3]; X a = (unsigned char *) &inp.inp_fport; X sbuf->fu.inet.rp = a[0] * 256 + a[1]; X a = (unsigned char *) &inp.inp_laddr; X sbuf->fu.inet.l0 = a[0]; sbuf->fu.inet.l1 = a[1]; X sbuf->fu.inet.l2 = a[2]; sbuf->fu.inet.l3 = a[3]; X a = (unsigned char *) &inp.inp_lport; X sbuf->fu.inet.lp = a[0] * 256 + a[1]; X } X else if (family == AF_UNIX) X { X struct unpcb unp; X X sbuf->fsw = FSW_UNIX; X kmemcpy(&unp,s.so_pcb,sizeof(unp)); X sbuf->fu.un.unpcb = (char *) s.so_pcb; X sbuf->fu.un.node = (char *) unp.unp_Xnode; X sbuf->fu.un.conn = (char *) unp.unp_conn; X sbuf->fu.un.path[0] = 0; X if (unp.unp_addr) X { X struct sockaddr_un *sa; X struct mbuf mb; X kmemcpy((char *) &mb,(char *) unp.unp_addr,sizeof(mb)); X sa = (struct sockaddr_un *) (((char *) &mb) + mb.m_off); X /* XXX: check that length is less than 108 */ X sprintf(sbuf->fu.un.path, X " %.*s",mb.m_len - sizeof(sa->sun_family),sa->sun_path); /*XXX*/ X } X } X else X ; /* XXX: other s.so_pcb's? */ X return 0; X} END_OF_FILE if test 4398 -ne `wc -c <'getsocket.c'`; then echo shar: \"'getsocket.c'\" unpacked with wrong size! fi # end of 'getsocket.c' fi if test -f 'getuser.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getuser.c'\" else echo shar: Extracting \"'getuser.c'\" \(6695 characters\) sed "s/^X//" >'getuser.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline XConvex support added by Dan Bernstein. XTranslated to independent library with strerr support by Dan Bernstein. XCode for this library derived from Abell version of ofiles. XContributors and possible contributors: C. Spencer, Michael Ditto, XTom Dunigan, Alexander Dupuy, Greg Nebbett, Richart Tobin, Mike Spitzer, XRay Moody, Vik Lall, Vic Abell. X*/ X X/* X Xstruct user *getuser(p) struct proc *p; returns a pointer to a (not Xnecessarily atomic) copy in user memory of the u area for process p. XUpon errors it returns 0. X XThis is one of the nastiest, most machine-dependent pieces of code I've Xever had the pleasure of working with to achieve an essentially Xmachine-independent result. X Xint getuserinit() does optional initialization to cooperate with other Xlibraries. X Xgetuserstrerr is a strerrfun for getuser() and getuserinit(). X X*/ X X#include "getuser.h" X#include "confgetusersupport.h" X#include "confusrptnlist.h" X#include "structuser.h" X#include "structpte.h" X#include "structproc.h" X#include "confneedmachparam.h" X#ifdef NEED_MACHPARAM X#include <machine/machparam.h> X#endif X#include <sys/vmmac.h> X#include "confgetuserdynix.h" X#include "confgetusermips.h" X#include "confgetuserconvex.h" X#include "confkvm.h" X#ifdef KVM X#include <kvm.h> X#include <fcntl.h> /* XXX: really under KVM? */ X#endif X#include "nlistlist.h" X#include "kmem.h" X#include "mmem.h" X#include "smem.h" X#include "strerr.h" X#include "confhavepflag.h" X Xstatic int getusererrno = 0; X Xstatic struct strerrtab e[] = { X { 0, "getuser error 0", 0 } X#define GU_INIT 1 X, { GU_INIT, "cannot init getuser: ", nliststrerr } X#define GU_NLIST 2 X, { GU_NLIST, "cannot nlist: ", nliststrerr } X#ifndef GETUSERSUPPORT X#define GU_NLPFOUND 3 X, { GU_NLPFOUND, NLISTPAGES, nlistnotin } X#define GU_NLBFOUND 4 X, { GU_NLBFOUND, NLISTBASE, nlistnotin } X#endif X#define GU_KVM 5 /* stupid kvm library, no error reporting */ X, { GU_KVM, "vendor kvm library failed", 0 } /* credit where due :-) */ X#define GU_ALLOC 6 X, { GU_ALLOC, "out of memory", 0 } X#define GU_SLOAD 7 X, { GU_SLOAD, "cannot swap in u area: ", smemstrerr } X#define GU_UAREA 8 X, { GU_UAREA, "cannot read u area: ", kmemstrerr } X#define GU_DMAP 9 X, { GU_DMAP, "cannot read dmap: ", kmemstrerr } X#define GU_BLKNO 10 X, { GU_BLKNO, "cannot read blkno: ", kmemstrerr } X#define GU_PTE 11 X, { GU_PTE, "cannot read pte: ", kmemstrerr } X#define GU_UPGTBL 12 X, { GU_UPGTBL, "cannot read upgtbl: ", mmemstrerr } X#define GU_UPAGE 13 X, { GU_UPAGE, "cannot read upage: ", mmemstrerr } X}; X Xchar *getuserstrerr(ke) strerrfun *ke; X{ X return strerrtaberr(ke,getusererrno,e,sizeof(e)/sizeof(*e),"unknown getuser error"); X} X X#ifndef GETUSERSUPPORT Xstatic short nlpagest; Xstatic unsigned long nlpagesv; Xstatic short nlbaset; Xstatic unsigned long nlbasev; Xstruct pte *usrpt, *Usrptma; X#endif X Xstatic int init = 0; X Xint getuserinit() X{ X#ifndef GETUSERSUPPORT X if (nlistadd(NLISTPAGES,&nlpagest,&nlpagesv) == -1) X RETERN(-1,getusererrno,GU_INIT) X if (nlistadd(NLISTBASE,&nlbaset,&nlbasev) == -1) X RETERN(-1,getusererrno,GU_INIT) X#endif X init = 1; X return 0; X} X Xstatic int pergu() X{ X if (!init) X if (getuserinit() == -1) X return -1; X#ifndef GETUSERSUPPORT X if (nlpagest == -1) X { X if (nlistdo() == -1) X RETERN(-1,getusererrno,GU_NLIST) X if (!nlpagest) X RETERN(-1,getusererrno,GU_NLPFOUND) X if (!nlbaset) X RETERN(-1,getusererrno,GU_NLBFOUND) X } X Usrptma = (struct pte *) nlpagesv; X usrpt = (struct pte *) nlbasev; /* used by <vmmac.h> */ X#endif X return 0; X} X X#ifdef KVM Xstatic kvm_t *kd = 0; X Xstruct user *getuser(p) Xstruct proc *p; X{ X if (pergu() == -1) X return 0; X if (!kd) X if (!(kd = kvm_open((char *)0,(char *)0,(char *)0,O_RDONLY))) X RETERN(0,getusererrno,GU_KVM) X return kvm_getu(kd,p); X} X#else X#ifdef GETUSER_CONVEX Xstruct user *getuser(p) Xstruct proc *p; X{ X static struct user u; X if (pergu() == -1) X return 0; X Getprocu(p,&u,sizeof(struct user)); /*XXX*/ X return &u; X} X#else X#ifdef GETUSER_DYNIX Xstruct user *getuser(p) Xstruct proc *p; X{ X int btr; X static struct user *u; X char *valloc(); X X u = 0; X if (pergu() == -1) X return 0; X if (!u) X if (!(u = (struct user *) valloc(ctob(UPAGES)))) X RETERN(0,getusererrno,GU_ALLOC) X btr = ctob(UPAGES); X if ((p->p_flag & SLOAD) == 0) X { X if (smemcpy((char *)u,(char *) dtob(p->p_swaddr),btr) == -1) X { X free((char *) u); X getusererrno = GU_SLOAD; X return 0; X } X } X else X if (kmemcpy((char *)u,(char *)p->p_uarea,btr) == -1) X { X free((char *) u); X getusererrno = GU_UAREA; X return 0; X } X return u; X} X#else Xstruct user *getuser(p) Xstruct proc *p; X{ X struct pte *ptep, apte; X#ifdef GETUSER_MIPS X struct pte wpte[UPAGES]; X int ncl; X#endif X struct pte mypgtbl[NBPG/sizeof(struct pte)]; X int upage; X char *up; X static struct user user; X X if (pergu() == -1) X return 0; X /* easy way */ X#ifndef HAVE_PFLAG X if ((p->p_sched & SLOAD) == 0) X { X struct dmap l_dmap; X int ublkno; X /* code adapted from ps.c (or so says ofiles.c) */ X if (kmemcpy(&l_dmap,(char *)(p->p_smap),sizeof(struct dmap)) == -1) X RETERN(0,getusererrno,GU_DMAP) X if (kmemcpy(&ublkno,(char *)(l_dmap.dm_ptdaddr),sizeof(int)) == -1) X RETERN(0,getusererrno,GU_BLKNO) X if (kmemcpy((char *)&user,(char *)dtob(ublkno),sizeof(struct user)) == -1) X RETERN(0,getusererrno,GU_UAREA) X /* that's it? wow ---DJB */ X } X#else X if ((p->p_flag & SLOAD) == 0) X { X if (kmemcpy((char *)&user,(char *)dtob(p->p_swaddr),sizeof(struct user)) == -1) X RETERN(0,getusererrno,GU_UAREA) X } X#endif X else X { /* boo */ X#ifdef GETUSER_MIPS X if (kmemcpy((char *)wpte,(char *)p->p_addr,sizeof(wpte)) == -1) X RETERN(0,getusererrno,GU_PTE) X X /* now collect various pages of u area */ X ncl = (sizeof(struct user) + NBPG*CLSIZE - 1)/(NBPG*CLSIZE); X up = (char *) &user; X for (upage = 0; upage < ncl; upage += CLSIZE) X { X if (mmemcpy(up,(char *)ctob(wpte[upage].pg_pfnum),NBPG*CLSIZE) == -1) X RETERN(0,getusererrno,GU_UPAGE) X up += (NBPG*CLSIZE); X } X#else X ptep = &Usrptma[btokmx(p->p_p0br) + p->p_szpt - 1]; X X /* get the page table for the user page */ X if (kmemcpy((char *)&apte,(char *)ptep,sizeof(apte)) == -1) X RETERN(0,getusererrno,GU_PTE) X X /* now get this user's page table */ X if (mmemcpy((char *)mypgtbl,(char *)ctob(apte.pg_pfnum),sizeof(mypgtbl)) == -1) X RETERN(0,getusererrno,GU_UPGTBL) X /* now collect various pages of u area */ X up = (char *) &user; X for (upage = 0; upage < sizeof(struct user)/NBPG; upage++) X { X if (mmemcpy(up,(char *)ctob(mypgtbl[NPTEPG-UPAGES+upage].pg_pfnum),NBPG) == -1) X RETERN(0,getusererrno,GU_UPAGE) X up += NBPG; X } X#endif X } X return &user; X} X#endif X X#endif X#endif END_OF_FILE if test 6695 -ne `wc -c <'getuser.c'`; then echo shar: \"'getuser.c'\" unpacked with wrong size! fi # end of 'getuser.c' fi if test -f 'mntops.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mntops.c'\" else echo shar: Extracting \"'mntops.c'\" \(4124 characters\) sed "s/^X//" >'mntops.c' <<'END_OF_FILE' X/* History: X5/1/91 DJB baseline XOriginally stolen from Dupuy ofiles. X*/ X X#include <stdio.h> X#include <sys/types.h> X#include <sys/stat.h> X#include "rpcnfs.h" /* XXX: see structmtab.h */ X#include "structmtab.h" X#include "stattimeout.h" X#include "mallocfree.h" X#include "mntops.h" X#include "confslowstat.h" X#include "confmntent.h" X#include "confmntult.h" X X#ifdef SLOWSTAT X#define STAT_TIMEOUT 5 /* time out stat() calls after 5 sec */ X#endif X#ifndef STAT_TIMEOUT X#define STAT_TIMEOUT 0 X#endif X X#ifdef MNTULT Xstatic struct fs_data mntdata; X#else Xstatic FILE *mnttab; X#endif X Xstruct statlist *stats = 0; X X#ifdef MNTULT X Xint get_mntlist() X{ X register struct statlist *statp; X int mnt = 0; X int result; X X#ifdef NOSTAT_MANY X while (result = getmnt(&mnt,&mntdata,sizeof(mntdata),NOSTAT_MANY,0)) X#else X while (result = getmnt(&mnt,&mntdata,sizeof(mntdata),mnt)) X#endif X { X if (!(statp = (struct statlist *) malloc(sizeof(struct statlist)))) X break; X statp->next = stats; X stats = statp; X X (void) strcpy(statp->filename,mntdata.fd_path); X (void) strcpy(statp->fsname,mntdata.fd_devname); X statp->device = mntdata.fd_dev; X } X X if (result < 0) X return -1; X return 0; X} X Xstruct mounted *getmntname(name) Xchar *name; X{ X static struct mounted mounted; X int result; X X#ifdef NOSTAT_ONE X if (!(result = getmnt(0,&mntdata,0,NOSTAT_ONE,name))) X return 0; X#else X int mnt = 0; X X while (result = getmnt(&mnt,&mntdata,sizeof(mntdata),mnt)) X { X if (strcmp(name,mntdata.fd_devname) == 0) X break; X if (strcmp(name,mntdata.fd_path) == 0) X break; X } X X if (mnt == 0) X return 0; X#endif X X if (result < 0) X return 0; X X mounted.mountpoint = mntdata.fd_path; X mounted.filesystem = mntdata.fd_devname; X return &mounted; X} X Xstruct mounted *getmntfile(filestats) Xstruct stat *filestats; X{ X static struct mounted mounted; X int context; X X while (getmnt(&context,&mntdata,sizeof(mntdata)),context) X if (filestats->st_dev == mntdata.fd_dev) X break; X X if (!context) X return 0; X X mounted.mountpoint = mntdata.fd_path; X mounted.filesystem = mntdata.fd_devname; X return &mounted; X} X X#else X X#ifndef MNTENT X Xstruct mtab *getmntent(mntfile) XFILE *mntfile; X{ X static struct mtab mtab; X char devname[MNTMAXSTR]; X X if (fread((char *) &mtab,sizeof(mtab),1,mntfile) != 1) X return 0; X strncpy(devname,mtab.m_dname,MNTMAXSTR); X strcpy(mtab.m_dname,"/dev/"); X strncat(mtab.m_dname,devname,MNTMAXSTR - 5); X return &mtab; X} X X#endif X Xint get_mntlist() X{ X register struct statlist *statp; X struct stat status; X struct mntent *mnt; X X#ifdef MNTENT X mnttab = setmntent(MOUNTED,"r"); X#else X mnttab = fopen("/etc/mtab","r"); X#endif X X if (!mnttab) X return -1; X X while (mnt = getmntent(mnttab)) X { X if (!(statp = (struct statlist *) malloc(sizeof(struct statlist)))) X break; X statp->next = stats; X stats = statp; X X (void) strncpy(statp->filename,mnt->mnt_dir,MNTMAXSTR); X (void) strncpy(statp->fsname,mnt->mnt_fsname,MNTMAXSTR); X statp->filename[MNTMAXSTR - 1] = '\0'; X statp->fsname[MNTMAXSTR - 1] = '\0'; X X if (stattimeout(statp->filename,&status,STAT_TIMEOUT)) X { /* find out what it is */ X /*XXX: report error on statp->filename */ X stats = statp->next; X free((char *) statp); X continue; X } X statp->device = status.st_dev; X } X} X Xstruct mounted *getmntname(name) Xchar *name; X{ X static struct mounted mounted; X register struct mntent *mnt; X X rewind(mnttab); X while ((mnt = getmntent(mnttab))) X { X if (strncmp(name,mnt->mnt_fsname,MNTMAXSTR) == 0) X break; X if (strncmp(name,mnt->mnt_dir,MNTMAXSTR) == 0) X break; X } X X if (!mnt) X return 0; X X mounted.mountpoint = mnt->mnt_dir; X mounted.filesystem = mnt->mnt_fsname; X return &mounted; X} X Xstruct mounted *getmntfile(filestats) Xstruct stat *filestats; X{ X static struct mounted mounted; X register struct mntent *mnt; X struct stat dirstats; X X rewind(mnttab); X while (mnt = getmntent(mnttab)) X if ((stat(mnt->mnt_dir,&dirstats) >= 0) && X (filestats->st_dev == dirstats.st_dev)) X break; X X if (!mnt) X return 0; X X mounted.mountpoint = mnt->mnt_dir; X mounted.filesystem = mnt->mnt_fsname; X return &mounted; X} X X#endif END_OF_FILE if test 4124 -ne `wc -c <'mntops.c'`; then echo shar: \"'mntops.c'\" unpacked with wrong size! fi # end of 'mntops.c' fi echo shar: End of archive 4 \(of 6\). cp /dev/null ark4isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (05/07/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 5 (of 6)." # Contents: CHANGES Makefile pff.doc rfc931 # Wrapped by brnstnd@kramden on Mon May 6 23:59:03 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'CHANGES' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'CHANGES'\" else echo shar: Extracting \"'CHANGES'\" \(9479 characters\) sed "s/^X//" >'CHANGES' <<'END_OF_FILE' XChanges since first distributed version X XSR is Seth Robertson <seth@sirius.ctr.columbia.edu>. XMK is Michael P. Kiernan <kiernan@fjord.berkeley.edu>. XVA is Vic Abell <abe@mace.cc.purdue.edu>. XTC is Tom Christiansen <tchrist@convex.com>. XGR is Gary Rosenblum <rosenblg@nyu.edu>. X X5/6/91: Reorganized FILES. X5/6/91: Added note about 127.1 to testauthd's output. X5/6/91: Added skips to INSTALL. X5/6/91: Updated netstatuids to #include "authuser.h". X5/6/91: Revised BLURB.authd, chopped most of README.authd. X5/6/91: Added authd question to FORMLETTER. X5/6/91: Updated authuser to version 3.1. X5/6/91: Added install and tests targets to Makefile. X5/6/91: Rewrote most of INSTALL again, including -lauthuser installation. X5/6/91: Replaced -lauthuser with authuser.o in Makefile. X5/6/91: Added testauthd as a Makefile target. X5/6/91: Included everything else from authd package. X5/6/91: Included authuser from authd package. Tnx SR. X X5/3/91: kstuff 0.17. X X5/3/91: Included a whole bunch of stuff in INSTALL. X5/3/91: Added getsocket caching. Speedup around 5-10%. X5/3/91: Added getnode caching. Speedup around 10-15% total, 3/4 of getnode()s. X5/3/91: Corrected sbuf->fu.un.me to sbuf->fu.un.unpcb. X5/3/91: Introduced FSW_* defines for fsw in getsocket and pff.c. X5/3/91: Introduced NODE_ID_* defines for flagdev in getnode and pff.c. X5/3/91: Moved ppflags/offlags/pnflags settings into style switch. X5/3/91: Introduced STYLE_* defines, converted pff.c for it. X5/3/91: Added INSTALL. X5/3/91: Unhid inperrno. Aargh. X5/3/91: Fixed DYNIX bug when ofile_ext was in action. Tnx VA. X5/3/91: Split BSD43STRAIGHT into BSD43TAHOE and BSD43CLASSIC. X5/3/91: Included various new compile options sets. Tnx VA. X5/3/91: Added MACHOPTS in Makefile, rewrote instructions. X5/3/91: Changed *ucred* to do something more sensible without HAVE_UCRED. X5/3/91: Modified authd.c and netstatuids.c to not compile without HAVE_UCRED. X5/3/91: Added definition of struct ucred for systems without it. X5/3/91: Added address-of-UNIX-domain-socket to sbuf->fu.un, printed it. X5/3/91: Fixed bug in pff.c guess code when i && !mt. Tnx VA. X5/2/91: Renamed pf as pff (process-file-file, emphasis on the ff). Tnx GR. X5/2/91: Changed -sshort to -sbrief, updated pf.doc. X5/2/91: Added ULTRIX=22 test to confdomain.h. Tnx VA. X X5/1/91: Included the findinode package in a subdirectory. X5/1/91: Replaced FDEFER in printfflag with FASYNC. Tnx VA. X X4/30/91: Copied authd.8, tcpuid.8, tcpuname.8 from authd 3.01 distribution. X4/30/91: Added load.1. X4/30/91: Disabled warning on getuser() failure. [sigh] X4/30/91: Added history to all .c files. X4/30/91: Documented nlistlist (whee!). X4/30/91: Changed nlistlist to use strerrtab. X4/30/91: Documented print*.c. X4/30/91: Hid inperrno, nlistlisterrno, proctableerrno. All errnos now hidden. X4/30/91: Documented kmem. X4/30/91: Hid mmemerrno, smemerrno, kmemerrno. X X4/29/91: Added missing newline on getuser warning. Tnx VA. X4/29/91: Fixed u.u_nofile in pf.c. Tnx VA. X4/29/91: Added documentation to some of the conf*.h. X4/29/91: Pointed smem and mmem documentation at kmem.c. X4/29/91: Pointed portname and username documentation at groupname.c. X4/29/91: Documented numeric. :-) X4/29/91: Documented groupname. X4/29/91: Documented getuser. X4/29/91: Converted getuser to use strerrtab. X4/29/91: Documented getsocket. X4/29/91: Hid getpcrederrno, documented getpcred, used strerrtab in getpcred. X4/29/91: Documented getnode, changed vninit() to getnodeinit(). X4/29/91: Hid getfcrederrno, documented getfcred, used strerrtab in getfcred. X4/29/91: Documented getdevicename. X4/29/91: Documented filetable inside filetable.c. X4/29/91: Hid filetableerrno. X4/29/91: Moved boottime documentation to boottime.c. X4/29/91: Moved avenrun documentation to avenrun.c. X X4/28/91: Added -sn filename format. Also added filenames to -sf. X4/28/91: Added EOF check to revnamei.c. X4/27/91: Added revnamei.c, revnamei.h, pf.c use of them. X X4/23/91: kstuff 0.16. X X4/23/91: Added error check at critical getuser() in pf.c. X4/23/91: Fixed a dozen other visibility errors found by quacko. X4/23/91: Hid pervn inside getnode.c, blared vninit. X4/23/91: Hid devnamelist inside getdevicename.c. X4/23/91: Hid avenrunerrno, boottimeerrno. X4/23/91: Fixed groupname.h. X4/23/91: Changed filetable.c to use strerrtab. X4/23/91: Used nlistnotin in filetable.c getuser.c inpcblist.c proctable.c. X4/23/91: Documented boottime.c in boottime.h. X4/23/91: Simplified avenrun.c, boottime.c to use nlistnotin. X4/23/91: Added nlistnotin to nlistlist.h. X4/23/91: Added strerrtab use to boottime.c. X4/23/91: Replaced AV_ with BT_ in boottime.c. X4/23/91: Documented avenrun.c in avenrun.h. X4/23/91: Added strerrtab use to avenrun.c. Wow, it even works. X4/23/91: Added strerrtaberr. X4/23/91: Added strerrstr. X4/23/91: Added strerrtab. X4/23/91: Introduced DYNIX, DYNIXOLD so that ODOFE might work. X4/23/91: Replaced invisible zs ifdef with ZS config. X4/23/91: Fixed #ifdef IGMP use ND. Tnx VA. X4/23/91: Fixed domname[50][29]. Tnx VA. X X4/20/91: Added DTYPE_SPU, DTYPE_PROCESS to keep Tom happy. Tnx TC. X4/20/91: Reintroduced ODOFE special case, with file-at-a-time copying. X4/20/91: Eliminated dof and some other ODOFE kludges. Tnx VA. X4/20/91: Fixed sizeof(ofile_ext). Tnx VA. X4/20/91: Copied oe.oe_nofile into u->u_nofile under ODOFE. Tnx VA. X4/20/91: Removed ODOFE special case from confuofile.h. Tnx VA. X4/20/91: Fixed getuser.c nlpagest bug under !GETUSERSUPPORT. Tnx VA. X4/20/91: Changed confhaveucred.h to exclude BSD43STRAIGHT. Tnx VA. X4/20/91: Extended confusrptnlist.h for Usrptma etc. Tnx VA. X4/20/91: Added confusrptnlist.h. X4/20/91: Changed confhavepsuid.h to be SunOS-Convex-DYNIX-Ultrix 4. Tnx VA. X4/20/91: Bracketed sys/time.h in pf.c. Tnx VA. X4/20/91: Changed confmntent.h to be SunOS-Convex-DYNIX. X X4/20/91: Integrated pf.c from ZS version. X4/20/91: Integrated printucred.c from ZS version. X4/20/91: Integrated mntops.c from ZS version. X4/20/91: Integrated getnode.c from ZS version. X4/20/91: Integrated getfcred.c from ZS version. X4/20/91: Integrated getpcred.c from ZS version. X4/20/91: Integrated getdevicename.c from ZS version. X4/20/91: Integrated avenrun.c from ZS version. X4/20/91: Added confmajorminor.h from ZS version. X4/20/91: Added confhaveucred.h from ZS version. X4/20/91: Integrated confloadavglong.h from ZS version. X4/20/91: Integrated structpte.h from ZS version. X4/20/91: Added confneedmachparam.h from ZS version. X4/20/91: Added confneedartospte.h from ZS version. X4/20/91: Added confhaveppid.h from ZS version. X4/20/91: Integrated confhavepsuid.h from ZS version. X4/20/91: Integrated structtext.h from ZS version. X4/20/91: Added conftextneedsvmparam.h from ZS version. X4/20/91: Integrated confmntent.h from ZS version. X4/19/91: Ported parts of pf to the ZS. X X4/14/91: kstuff 0.15. X X4/14/91: Works under Convex UNIX 9.0. X4/14/91: Added confdevt.h for the Convex. Aargh. X4/14/91: Works under Ultrix 4.1. X4/14/91: Fixed HAVEPSUID typo in structproc.h. X4/14/91: Added notes on derivation to ofiles-derived files. X X4/13/91: Added initblahtable's in pf.c to get back down to one nlist(). X4/13/91: Changed getvmseg.c to export usable seginit(), added that to pf.c. X4/13/91: Added confodofe.h, changed confuofile.h, structfile.h for it. X4/13/91: Tried to integrate new DYNIX ofile_ext stuff. Tnx VA. X4/13/91: Moved sys/user includes above sys/time includes. Tnx VA. X4/13/91: Bracketed <sys/time.h> with ITIMER_REAL. X4/13/91: Oops, forgot to steal getmntent() clone for mntops.c. Tnx VA. X X4/11/91: Fixed typo in Convex regiontab processing. It might even still work. X4/11/91: Added error checking for argument processing. X4/11/91: Added portname.c, port lookups. X4/11/91: Right-justified REF header. X4/11/91: Added username lookups. X4/11/91: Convex knlist() failure on ufs_vnodeops is Convex's fault. Tnx TC. X4/11/91: Added -sh, -sH. X4/11/91: Changed style types to be by name instead of number. X X4/11/91: Added KERNEL around ufs/inode.h in structxnode.h for DYNIX. Tnx VA. X4/11/91: Added #include "structsocket.h" to structinpcb.h. Tnx VA. X4/11/91: Added confhavesigintr.h, changed pf.c for it. Tnx VA. X4/11/91: Fixed DYNIX bugs in confvmunix.h. Tnx VA. X4/11/91: Added !DYNIX to conftext.h. (Any way to get the text?) Tnx VA. X4/11/91: Added DYNIX to confdomain.h. Tnx VA. X4/11/91: Added confnounpaddr.h, changed structunpcb.h for it. Tnx VA. X4/11/91: Changed structucred.h to include structuser.h. Tnx VA. X4/11/91: Added confhavepsuid.h, changed structproc.h for it. Tnx VA. X4/11/91: Changed confmalloc.h to look for ULTRIX >= 40. Tnx VA. X4/11/91: Made -DULTRIX into a numeric #define. Tnx VA. X4/11/91: Added missing braces in DYNIX getuser.c. Tnx VA. X4/11/91: Changed #ifdef to #ifndef lines 94 and 109 of getuser.c. Tnx MK. X4/11/91: Okay, so not everything works. Fixed confgetusersupport.h. Tnx MK. X X4/6/91: Everything works. Not bad for a thousand-line reorganization. X4/6/91: Ah, 'twas a sixth typo. Three minutes with dbx. X4/6/91: Compiles after five typos fixed, doesn't work. X4/6/91: Finished conf*.h, only 47 new files. Will it compile? X4/6/91: Introduced conf*.h. Fun fun fun. X4/6/91: Added #ifdefs throughout printpstat.c. X4/6/91: Added VOID_FREE and integrated mallocfree.h. Whoops. X4/6/91: Took struct proc description out of printpstat.c. X4/6/91: Added #ifdefs throughout printfamily.c. X X4/6/91: kstuff 0.13. X X4/6/91: Added CHANGES and OF to distribution. X4/6/91: Added notes to struct*.h about what the files should look like. X4/5/91: Ported to SunOS 4.1, added -DPSESS. Tnx SR. X X4/2/91: kstuff 0.12. END_OF_FILE if test 9479 -ne `wc -c <'CHANGES'`; then echo shar: \"'CHANGES'\" unpacked with wrong size! fi # end of 'CHANGES' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(6717 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' XCC=cc XCCOPTS=-g -DSECURITY XLIBS= X# -lvm for Convex XGETULIBS=-lkvm X# -lkvm for Suns XMACHOPTS=-DSUNOS4 -DBSD43 -DNFS X# SunOS 4.0.3: -DSUNOS4 -DBSD43 -DNFS X# tested on Sun 4/280 X# some testing on Sun 3/280, thanks to Vic Abell X# SunOS 4.1: -DSUNOS4 -DSUNOS41 -DBSD43 -DNFS X# tested on various Sun 3s and Sun 4s, thanks to Seth Robertson X# Ultrix 4.1: -DULTRIX=41 -DBSD43 -DNFS X# tested on DECsystem 5820 X# Ultrix 2.2: -DULTRIX=22 -DNFS X# some testing on VAX 8800, tnx VA X# Straight BSD 4.3-Tahoe: -DBSD43TAHOE -DBSD43 X# some testing on VAX 11/780, tnx VA X# Straight BSD 4.3 original: -DBSD43CLASSIC -DBSD43 X# Convex UNIX 9.0: -DCONVEX -DBSD43 -DNFS X# tested on Convex-C1-XP X# ZSUnix: -DZS -DBSD43 X# limited testing on Astronautics ZS, can't make getuser() work right X# DYNIX with struct ofile_ext: -DDYNIX -DNFS X# some testing on Symmetry S81 with locally modified DYNIX 3.0.17, tnx VA X# DYNIX without struct ofile_ext: -DDYNIXOLD X# X# You must have exactly one of the following defined in MACHOPTS: X# SUNOS4, ULTRIX=nn, CONVEX, DYNIXOLD, DYNIX, ZS, BSD43TAHOE, X# BSD43CLASSIC X# X# in CCOPTS: to enable old authd behavior, -DUSENETSTAT (deprecated) X# and, believe it or not, a real configuration option: -DUSE_SYSLOG X# -DSECURITY to enable the security behavior for pff X# also -DGET_FIFOS if you have the /sys files option on a Sun and X# want to see the inode behind a FIFO X# also -DNO_FINDINODE if you don't want pff to try executing X# findinode to figure out filenames (do this if you have a different X# program named findinode). Nothing bad will happen if findinode can't X# be executed; you just won't get filenames. X# X# invisible #ifdefs: __hp9000s800 sun386i mips sun __hpux P_DYING X Xdefault: load netstatuids authd pff testauthd X Xload: load.o kmem.o nlistlist.o avenrun.o boottime.o strerr.o X $(CC) $(CCOPTS) $(MACHOPTS) -o load load.o kmem.o nlistlist.o avenrun.o boottime.o strerr.o $(LIBS) X Xpff: pff.o proctable.o strerr.o nlistlist.o kmem.o getuser.o smem.o mmem.o getnode.o getdevicename.o mntops.o stattimeout.o virtype.o filetable.o getfcred.o printpstat.o printucred.o getpcred.o printfamily.o printprotoinet.o printrusage.o printrlimits.o getvmseg.o printfflag.o printftype.o printsocktype.o getsocket.o groupname.o username.o numeric.o portname.o revnamei.o X $(CC) $(CCOPTS) $(MACHOPTS) -o pff pff.o proctable.o strerr.o nlistlist.o kmem.o getuser.o smem.o mmem.o getnode.o getdevicename.o mntops.o stattimeout.o virtype.o filetable.o getfcred.o printpstat.o printucred.o getpcred.o printfamily.o printprotoinet.o printrusage.o printrlimits.o getvmseg.o printfflag.o printftype.o printsocktype.o getsocket.o groupname.o username.o numeric.o portname.o revnamei.o $(LIBS) $(GETULIBS) X Xauthd: authd.o auread.o netinp.o kmem.o strerr.o nlistlist.o inpcblist.o filetable.o getfcred.o username.o numeric.o X $(CC) $(CCOPTS) $(MACHOPTS) -o authd authd.o auread.o netinp.o kmem.o strerr.o nlistlist.o inpcblist.o filetable.o getfcred.o username.o numeric.o $(LIBS) X Xnetstatuids: netstatuids.o inpcblist.o kmem.o nlistlist.o filetable.o getfcred.o strerr.o authuser.o X $(CC) $(CCOPTS) $(MACHOPTS) -o netstatuids netstatuids.o inpcblist.o kmem.o nlistlist.o filetable.o getfcred.o strerr.o authuser.o $(LIBS) X Xtestauthd: testauthd.o authuser.o X $(CC) $(CCOPTS) $(MACHOPTS) -o testauthd testauthd.o authuser.o $(LIBS) X Xnetstatuids.o: netstatuids.c inpcblist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c netstatuids.c X Xload.o: load.c boottime.h avenrun.h X $(CC) $(CCOPTS) $(MACHOPTS) -c load.c X Xgetfcred.o: getfcred.c getfcred.h kmem.h filetable.h X $(CC) $(CCOPTS) $(MACHOPTS) -c getfcred.c X Xboottime.o: boottime.c boottime.h kmem.h nlistlist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c boottime.c X Xstrerr.o: strerr.c strerr.h X $(CC) $(CCOPTS) $(MACHOPTS) -c strerr.c X Xavenrun.o: avenrun.c avenrun.h kmem.h nlistlist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c avenrun.c X Xkmem.o: kmem.c kmem.h X $(CC) $(CCOPTS) $(MACHOPTS) -c kmem.c X Xsmem.o: smem.c smem.h X $(CC) $(CCOPTS) $(MACHOPTS) -c smem.c X Xmmem.o: mmem.c mmem.h X $(CC) $(CCOPTS) $(MACHOPTS) -c mmem.c X Xnlistlist.o: nlistlist.c nlistlist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c nlistlist.c X Xproctable.o: proctable.c proctable.h kmem.h nlistlist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c proctable.c X Xfiletable.o: filetable.c filetable.h kmem.h nlistlist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c filetable.c X Xinpcblist.o: inpcblist.c inpcblist.h kmem.h nlistlist.h X $(CC) $(CCOPTS) $(MACHOPTS) -c inpcblist.c X Xgetuser.o: getuser.c X $(CC) $(CCOPTS) $(MACHOPTS) -c getuser.c X Xnetinp.o: netinp.c X $(CC) $(CCOPTS) $(MACHOPTS) -c netinp.c X Xauthd.o: authd.c X $(CC) $(CCOPTS) $(MACHOPTS) -c authd.c X Xauread.o: auread.c X $(CC) $(CCOPTS) $(MACHOPTS) -c auread.c X Xgetnode.o: getnode.c X $(CC) $(CCOPTS) $(MACHOPTS) -c getnode.c X Xvirtype.o: virtype.c X $(CC) $(CCOPTS) $(MACHOPTS) -c virtype.c X Xstattimeout.o: stattimeout.c X $(CC) $(CCOPTS) $(MACHOPTS) -c stattimeout.c X Xgetdevicename.o: getdevicename.c X $(CC) $(CCOPTS) $(MACHOPTS) -c getdevicename.c X Xmntops.o: mntops.c X $(CC) $(CCOPTS) $(MACHOPTS) -c mntops.c X Xpff.o: pff.c X $(CC) $(CCOPTS) $(MACHOPTS) -c pff.c X Xgetpcred.o: getpcred.c X $(CC) $(CCOPTS) $(MACHOPTS) -c getpcred.c X Xgetvmseg.o: getvmseg.c X $(CC) $(CCOPTS) $(MACHOPTS) -c getvmseg.c X Xprintpstat.o: printpstat.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printpstat.c X Xprintucred.o: printucred.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printucred.c X Xprintfamily.o: printfamily.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printfamily.c X Xprintprotoinet.o: printprotoinet.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printprotoinet.c X Xprintrlimits.o: printrlimits.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printrlimits.c X Xprintftype.o: printftype.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printftype.c X Xprintrusage.o: printrusage.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printrusage.c X Xprintfflag.o: printfflag.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printfflag.c X Xprintsocktype.o: printsocktype.c X $(CC) $(CCOPTS) $(MACHOPTS) -c printsocktype.c X Xgetsocket.o: getsocket.c X $(CC) $(CCOPTS) $(MACHOPTS) -c getsocket.c X Xgroupname.o: groupname.c X $(CC) $(CCOPTS) $(MACHOPTS) -c groupname.c X Xnumeric.o: numeric.c X $(CC) $(CCOPTS) $(MACHOPTS) -c numeric.c X Xusername.o: username.c X $(CC) $(CCOPTS) $(MACHOPTS) -c username.c X Xportname.o: portname.c X $(CC) $(CCOPTS) $(MACHOPTS) -c portname.c X Xrevnamei.o: revnamei.c X $(CC) $(CCOPTS) $(MACHOPTS) -c revnamei.c X Xauthuser.o: authuser.c X $(CC) $(CCOPTS) $(MACHOPTS) -c authuser.c X Xtestauthd.o: testauthd.c X $(CC) $(CCOPTS) $(MACHOPTS) -c testauthd.c X Xinstall: X @echo 'Run the INSTALL shell script from a root shell.' X Xtests: X @echo 'No tests currently implemented except testauthd. Running...' X ./testauthd X Xclean: X rm *.o pff load authd netstatuids testauthd X Xshar: X shar `cat FILES` > kstuff.shar X chmod 400 kstuff.shar END_OF_FILE if test 6717 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'pff.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pff.doc'\" else echo shar: Extracting \"'pff.doc'\" \(7153 characters\) sed "s/^X//" >'pff.doc' <<'END_OF_FILE' Xpff (process-file-file, with emphasis on the ff) shows running processes Xand their open files. X XExamples are worth a million words, so here's a sampling of how I've Xused pff (updated to reflect the latest option set). -swhatever can be Xabbreviated as -sw. X Xpff -asfull > ~/log X Full report on everything pff can see. Useful when the X system is dying and you want to know what's going on. Xpff -astiny One line per process that has anything open, with each X open file noted but not explained. Xpff #221 #17484 All files those processes have open. (# is redundant.) Xpff -aspids All active pids. (This isn't as fast as it could be.) Xpff -a | more All open files, in my favorite format. Xpff /etc/passwd Who's snooping? Xpff /etc/telnetd.old X Who's running the telnetd.old program? (Useful after X you've installed a new telnetd and want to make sure X nobody's using the old one. Might not work on Sun 4s, X where processes don't have their programs open except X possibly as mmaps.) Xpff -d/nfs.vlsi1 X Who's keeping that filesystem busy? (-d is redundant.) X If this doesn't show anything, and the filesystem in X question doesn't contain another mounted filesystem, X then you should always be able to unmount it. Xpff -f/usr/dead Who's in that directory? (-f redundant.) Xpff -stiny /acf5.h X Short report on who's using my filesystem. Xpff /dev/ttyp7 All open files---including cttys---giving access to my tty. Xpff -sbrief -ujoe X All files open by user joe. (This does not show X files *opened* by user joe, or files *owned* by user X joe, or processes with a different effective uid, though X I suppose pff could be adapted to handle those cases.) X You can use uids, like pff -u195. Xpff -slong /tmp/. /tmp/* X How are people using /tmp? (Somewhat detailed report.) Xpff -i0 Who's using the Internet? Xpff -ismtp Who has the SMTP port open? (Compare to fstat.) You can X use numeric port ids, like pff -i25. Xpff -sbrief `pff -spids ./data` X All files open by all processes accessing ./data. Xpff -snames All files open, with pathnames. (Only works if you have X findinode installed.) X XAlthough pff can handle any number of options at once---e.g., ``show me Xevery open file on /acf5.h, or on /usr, or on Internet port 25, not to Xmention /dev/null''---I rarely want to see a combined view. X XAnd now, the options: X X-u uid tells pff to show all processes running with a given effective uid. X-p pid tells pff to show the processes with that pid. X XIf pff is not given any -u or -p options, it shows all processes. (This Xdoesn't mean it will actually print anything, since by default it only Xshows open files, which are controlled by the following options.) X XNote that pff can be compiled with a security option (-DSECURITY) which Xcurrently restricts the report to processes with the same real uid as Xthe invoker of pff. This restriction is not applied if the real uid is Xroot or if pff is not setgid. (If you only want to see root processes as Xroot, use -x.) X X-f foo tells pff to show every open file referring to file foo. X Note that all devices with the same remote device are X considered to be the same file, even when they are not. X-d fs tells pff to show every open file on the given filesystem. X-i port tells pff to show every inet connection to the given local port. X Port 0 refers to all inet connections. X X-a tells pff to show all open files for the selected processes. X This option is automatically turned on under -p and -u. X It is ignored under -f, -d, and -i. In other words, the only X time it makes a difference is when you have no other options X (except maybe -s), and I hate having a program spew mounds of X garbage at me just because I forgot to specify which particular X mound to spew. X X-s style tells pff to use a particular output style. Only the first X letter of the style matters. Style brief is close to fstat and X the Abell ofiles; style uidlong includes file flags, offset, X credentials, etc., and style long prints users by name if possible. X Style default, in the middle, is my favorite. Style full has the X most information (including per-process information) but is X relatively unstructured. Style tiny is close to the Dupuy ofiles. X Style pids prints pids only. Style names includes filenames. X -shelp shows all styles available; -sHelp shows all styles X available and gives descriptions. X XAny further arguments are interpreted as follows: any that start with / Xor . are taken to be files; any that start with # are taken to be pids; Xany that are entirely numeric are taken to be pids; and the rest are Xtaken to be files. ``Files'' means -f *and* -d here; ``pids'' means -p. X X XNotes on #ifdefs (possibly out of date): X XSTAT_TIMEOUT in mntops.c, fine. X*_H in *.h to handle repeated inclusion. X XIPPROTO_* in printprotoinet.c to handle different IP protocol support. XRLIMIT_* in printrlimits.c to handle different rlimit support. XDTYPE_* in printftype.c to handle different descriptor type support. XAF_* in printfamily.c to handle different address family support. XS* in printpstat.c to handle different process status support. X XUTMP_FILE used in load.c. Hmm. XSIDL used for a bit of SIDL-specific stuff in pff.c. Hmm. XS_IFIFO enables some FIFO-specific stuff in various files. Hmm. X XREMOTESIZE, NETSTAT* in netinp.c for various internal purposes. Ungood. XNOSTAT_* in getmnt.c for various internal purposes. Ungood. X XFILE, IPPROTO_TCP, FHLOCAL, MSIZE, MNTMAXSTR, NFS_RETRIES, SOCK_STREAM, XRTF_UP, SS_ISCONNECTED, RLIM_NLIMITS, bool_t: wrappers around #include Xfiles. It is disgusting that any of these are necessary. X X XTODO: X XDO ERROR CHECKING! pff.c, getnode.c, and getvmseg.c are ridiculously Xfragile. X XMove printbuf and printsbuf into getnode.c and getsocket.c... X Xsecurity: what about reporting on files owned by user? X Xgive better reports on pipes on Ultrix? other file types? X Xfix up include files in Makefile! aargh, should've used mick X XAllow more socket selection options? X XAutomatically put in names when they're known from multiple -f? X XMake sure all characters are printable? Option? Don't print sock name? X X:port arg? nah X Xdeal with mount points to catch non-unmountable /usr/spool because X/usr/spool/mail is mounted? nah X Xput back numeric styles as undocumented/deprecated? nah X Xdo something about scandev slowness? cache info? X Xdo something about stat'ing downed filesystems? cache info? X Xcache usernames, portnames, etc.? X X X XSome notes on typical execution profile on a Sun: X X57% of the time is in read(), most of that from kmemcpy(), an Xobnoxiously large amount from Sun's kvm library. Of the kmemcpys, 40% Xare from getsocket, 40% are from getvmseg, 15% are from getnode, and 5% Xare from getpcred. X X18% goes to stat()s from scandev(). Hmmm. There are 243 entries in /dev, Xbut only 38 unique devices in the pf output, and only 7 of those are Xanything but pseudo-ttys. (On another machine, there are 800 entries in X/dev. Ugh!) X X11% of the time is in _doprnt(). It would be worthwhile to replace all Xprintf's in pff.c with calls to a simpler string/number format package. Xstdio and printf really are too complex for typical output programs. X X7% goes to nlist(), half of that from Sun's kvm library. END_OF_FILE if test 7153 -ne `wc -c <'pff.doc'`; then echo shar: \"'pff.doc'\" unpacked with wrong size! fi # end of 'pff.doc' fi if test -f 'rfc931' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rfc931'\" else echo shar: Extracting \"'rfc931'\" \(9196 characters\) sed "s/^X//" >'rfc931' <<'END_OF_FILE' X X X X X X--------- X X X< INC-PROJECT, AUTH-RFC-VER-2.NLS.5, >, 7-Jan-85 17:18-PST JBP X;;;; X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X XStJohns [Page 0] X X XNetwork Working Group Mike StJohns XRequest for Comments: 931 TPSC XSupersedes: RFC 912 January 1985 X X Authentication Server X X XSTATUS OF THIS MEMO X X This RFC suggests a proposed protocol for the ARPA-Internet X community, and requests discussion and suggestions for improvements. X This is the second draft of this proposal (superseding RFC 912) and X incorporates a more formal description of the syntax for the request X and response dialog, as well as a change to specify the type of user X identification returned. Distribution of this memo is unlimited. X XINTRODUCTION X X The Authentication Server Protocol provides a means to determine the X identity of a user of a particular TCP connection. Given a TCP port X number pair, it returns a character string which identifies the owner X of that connection on the server's system. Suggested uses include X automatic identification and verification of a user during an FTP X session, additional verification of a TAC dial up user, and access X verification for a generalized network file server. X XOVERVIEW X X This is a connection based application on TCP. A server listens for X TCP connections on TCP port 113 (decimal). Once a connection is X established, the server reads one line of data which specifies the X connection of interest. If it exists, the system dependent user X identifier of the connection of interest is sent out the connection. X The service closes the connection after sending the user identifier. X XRESTRICTIONS X X Queries are permitted only for fully specified connections. The X local/foreign host pair used to fully specify the connection are X taken from the query connection. This means a user on Host A may X only query the server on Host B about connections between A and B. X X X X X X X X X X X X XStJohns [Page 1] X X XRFC 931 January 1985 XAuthentication Server X X XQUERY/RESPONSE FORMAT X X The server accepts simple text query requests of the form X X <local-port>, <foreign-port> X X where <local-port> is the TCP port (decimal) on the target (server) X system, and <foreign-port> is the TCP port (decimal) on the source X (user) system. X X For example: X X 23, 6191 X X The response is of the form X X <local-port>, <foreign-port> : <response-type> : <additional-info> X X where <local-port>,<foreign-port> are the same pair as the query, X <response-type> is a keyword identifying the type of response, and X <additional info> is context dependent. X X For example: X X 23, 6191 : USERID : MULTICS : StJohns.DODCSC.a X 23, 6193 : USERID : TAC : MCSJ-MITMUL X 23, 6195 : ERROR : NO-USER X XRESPONSE TYPES X X A response can be one of two types: X X USERID X X In this case, <additional-info> is a string consisting of an X operating system name, followed by a ":", followed by user X identification string in a format peculiar to the operating system X indicated. Permitted operating system names are specified in X RFC-923, "Assigned Numbers" or its successors. The only other X names permitted are "TAC" to specify a BBN Terminal Access X Controller, and "OTHER" to specify any other operating system not X yet registered with the NIC. X X X X X X X XStJohns [Page 2] X X XRFC 931 January 1985 XAuthentication Server X X X ERROR X X For some reason the owner of <TCP-port> could not be determined, X <additional-info> tells why. The following are suggested values X of <additional-info> and their meanings. X X INVALID-PORT X X Either the local or foreign port was improperly specified. X X NO-USER X X The connection specified by the port pair is not currently in X use. X X UNKNOWN-ERROR X X Can't determine connection owner; reason unknown. Other values X may be specified as necessary. X XCAVEATS X X Unfortunately, the trustworthiness of the various host systems that X might implement an authentication server will vary quite a bit. It X is up to the various applications that will use the server to X determine the amount of trust they will place in the returned X information. It may be appropriate in some cases restrict the use of X the server to within a locally controlled subnet. X XAPPLICATIONS X X 1) Automatic user authentication for FTP X X A user-FTP may send a USER command with no argument to the X server-FTP to request automatic authentication. The server-FTP X will reply with a 230 (user logged in) if it can use the X authentication. It will reply with a 530 (not logged in) if it X cannot authenticate the user. It will reply with a 500 or 501 X (syntax or parameter problem) if it does not implement automatic X authentication. Please note that no change is needed to currently X implemented servers to handle the request for authentication; they X will reject it normally as a parameter problem. This is a X suggested implementation for experimental use only. X X 2) Verification for privileged network operations. For example, X having the server start or stop special purpose servers. X X X XStJohns [Page 3] X X XRFC 931 January 1985 XAuthentication Server X X X 3) Elimination of "double login" for TAC and other TELNET users. X X This will be implemented as a TELNET option. X XFORMAL SYNTAX X X <request> ::= <port-pair> <CR> <LF> X X <port-pair> ::= <integer-number> "," <integer-number> X X <reply> ::= <reply-text> <CR> <LF> X X <reply-text> ::= <error-reply> | <auth-reply> X X <error-reply> ::= <port-pair> ":" ERROR ":" <error-type> X X <auth-reply> ::= <port-pair> ":" USERID ":" <opsys> ":" <user-id> X X <error-type> ::= INVALID-PORT | NO-USER | UNKNOWN-ERROR X X <opsys> ::= TAC | OTHER | MULTICS | UNIX ...etc. X (See "Assigned Numbers") X X Notes on Syntax: X X 1) White space (blanks and tab characters) between tokens is not X important and may be ignored. X X 2) White space, the token separator character (":"), and the port X pair separator character (",") must be quoted if used within a X token. The quote character is a back-slash, ASCII 92 (decimal) X ("\"). For example, a quoted colon is "\:". The back-slash must X also be quoted if its needed to represent itself ("\\"). X XNotes on User Identification Format: X X The user identifier returned by the server should be the standard one X for the system. For example, the standard Multics identifier X consists of a PERSONID followed by a ".", followed by a PROJECTID, X followed by a ".", followed by an INSTANCE TAG of one character. An X instance tag of "a" identifies an interactive user, and instance tag X of "m" identifies an absentee job (batch job) user, and an instance X tag of "z" identifies a daemon (background) user. X X Each set of operating system users must come to a consensus as to X X X X XStJohns [Page 4] X X XRFC 931 January 1985 XAuthentication Server X X X what the OFFICIAL user identification for their systems will be. X Until they register this information, they must use the "OTHER" tag X to specify their user identification. X XNotes on User Identification Translation: X X Once you have a user identifier from a remote system, you must then X have a way of translating it into an identifier that meaningful on X the local system. The following is a sketchy outline of table driven X scheme for doing this. X X The table consists of four columns, the first three are used to match X against, the fourth is the result. X X USERID Opsys Address Result X MCSJ-MITMUL TAC 26.*.*.* StJohns X * MULTICS 192.5.42.* = X * OTHER 10.0.0.42 anonymous X MSJ ITS 10.3.0.44 StJohns X X The above table is a sample one for a Multics system on MILNET at the X Pentagon. When an authentication is returned, the particular X application using the userid simply looks for the first match in the X table. Notice the second line. It says that any authentication X coming from a Multics system on Net 192.5.42 is accepted in the same X format. X X Obviously, various users will have to be registered to use this X facility, but the registration can be done at the same time the use X receives his login identity from the system. X X X X X X X X X X X X X X X X X X X XStJohns [Page 5] END_OF_FILE if test 9196 -ne `wc -c <'rfc931'`; then echo shar: \"'rfc931'\" unpacked with wrong size! fi # end of 'rfc931' fi echo shar: End of archive 5 \(of 6\). cp /dev/null ark5isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (05/07/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 6 (of 6)." # Contents: pff.c # Wrapped by brnstnd@kramden on Mon May 6 23:59:04 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'pff.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pff.c'\" else echo shar: Extracting \"'pff.c'\" \(27865 characters\) sed "s/^X//" >'pff.c' <<'END_OF_FILE' X/* History: X5/3/91 DJB various changes X5/1/91 DJB baseline public domain X*/ X/* XXX: Should allow for process gids... */ X X#include <stdio.h> X#include "structfile.h" X#include "structtext.h" X#include "structucred.h" X#include "structuser.h" X#include "structproc.h" /*XXX: must be after structuser for BSD-Tahoe dorks*/ X#include "structxnode.h" X#include "printfflag.h" X#include "printftype.h" X#include "printpstat.h" X#include "printrlimits.h" X#include "printrusage.h" X#include "printucred.h" X#include "getdevicename.h" X#include "getfcred.h" X#include "getnode.h" X#include "getopt.h" X#include "getpcred.h" X#include "getsocket.h" X#include "getuser.h" X#include "getvmseg.h" X#include "confhaveppid.h" X#include "confhaveusigintr.h" X#include "confmajorminor.h" X#include "confnfs.h" X#include "confodofe.h" X#include "confopalf.h" X#include "confpsess.h" X#include "confregion.h" X#include "conftext.h" X#include "confttyvp.h" X#include "confuofile.h" X#include "filetable.h" X#include "proctable.h" X#include "revnamei.h" X#include "portname.h" X#include "username.h" X#include "mallocfree.h" X#include "numeric.h" X#include "mntops.h" X#include "strerr.h" X#include "kmem.h" X#include <signal.h> X#ifndef ITIMER_REAL X#include <sys/time.h> X#endif X#ifndef RLIM_NLIMITS X#include <sys/resource.h> X#endif X#include <sys/stat.h> X X#define STYLE_BRIEF 0 X#define STYLE_DEFAULT 1 X#define STYLE_LONG 2 X#define STYLE_UIDLONG 3 X#define STYLE_FULL 4 X#define STYLE_TINY 5 X#define STYLE_PIDS 6 X#define STYLE_NAME 7 X X#define two(i) (1 << i) /* table if necessary */ X Xchar progname[] = "pff"; X Xstatic int flagall = 0; X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X struct proc *pt; X struct file *ft; X struct nodebuf buf; X struct socketbuf sbuf; X int i; X int style; X int opt; X struct stat st; X struct mounted *mt; X struct statlist *fsstats; X int security; X int uid; X int ppflags; X int offlags; X int pnflags; X X#ifdef SECURITY X security = 1; X#else X security = 0; X#endif X uid = getuid(); X if (!uid) X security = 0; X if (getgid() == getegid()) X security = 0; X X getnodeinit(); X seginit(); X get_mntlist(); X proctableinit(); X filetableinit(); X pt = getproctable(); X if (!pt) X { fprintf(stderr,"%s: cannot get process table: %s\n", X progname,strerr(proctablestrerr)); exit(1); } X ft = getfiletable(); X if (!ft) X { fprintf(stderr,"%s: cannot get file table: %s\n", X progname,strerr(filetablestrerr)); exit(1); } X X style = STYLE_DEFAULT; X while ((opt = getopt(argc,argv,"as:f:d:i:u:p:xX")) != EOF) X switch(opt) X { X case 'a': flagall = 1; break; /*XXX: inverse?*/ X case 's': switch(*optarg) X { X case 'd': style = STYLE_DEFAULT; break; X case 'f': style = STYLE_FULL; break; X case 'b': style = STYLE_BRIEF; break; X case 'p': style = STYLE_PIDS; break; X case 'u': style = STYLE_UIDLONG; break; X case 'l': style = STYLE_LONG; break; X case 't': style = STYLE_TINY; break; X case 'n': style = STYLE_NAME; break; X case 'A': style = STYLE_BRIEF; break; /* <censored>: deprecated */ X case 'D': style = STYLE_TINY; break; /* Dupuy: deprecated */ X case 'F': style = STYLE_LONG; break; /* Fstat: deprecated */ X case 'h': fprintf(stderr, X"full\nuidlong\nlong\nname\ndefault\nbrief\ntiny\npids\n"); exit(1); X case 'H': fprintf(stderr,"\ Xfull: all information available, in a relatively unstructured format\n\ Xuidlong: like long, but prints users by name where possible\n\ Xlong: like default, but includes file reference count, offset, credentials\n\ Xname: like default, but prints filenames instead of device/inode\n\ Xdefault: like short, but includes file descriptor type and flags\n\ Xbrief: one open file per line, basic information\n\ Xtiny: all open files for one process per line\n\ Xpids: process ids only\n\ X" X ); exit(1); X default: ; /*XXX*/ X } X break; X case 'p': if (!numeric(optarg)) X { X fprintf(stderr,"%s: fatal: pid %s not numeric\n" X ,progname,optarg); X exit(1); X } X procaddpid(atoi(optarg)); flagall = 1; X break; X case 'u': if (username2uid(optarg,&i) == -1) X { X fprintf(stderr,"%s: fatal: username %s not found\n" X ,progname,optarg); X exit(1); X } X procadduid(i); flagall = 1; X break; X case 'f': if (stat(optarg,&st) == -1) X { X fprintf(stderr,"%s: fatal: cannot stat %s: %s\n" X ,progname,optarg,strerr(strerrno)); X exit(1); X } X /* XXX: keep track of filename? */ X /* XXX: print filename? */ X if (((st.st_mode & S_IFMT) == S_IFBLK) X ||((st.st_mode & S_IFMT) == S_IFCHR)) X { X buf.flagdev = NODE_ID_DEV; X buf.id.dev.maj = major(st.st_rdev); X buf.id.dev.min = minor(st.st_rdev); X } X else X { X buf.flagdev = NODE_ID_INO; X buf.id.ino.inum = st.st_ino; X buf.id.ino.dev = st.st_dev; X } X validadd(&buf); X break; X case 'd': mt = getmntname(optarg); X if (!mt) X { X fprintf(stderr,"%s: fatal: cannot find mount of %s\n" X ,progname,optarg); X exit(1); X } X for (fsstats = stats;fsstats;fsstats = fsstats->next) X if (!strncmp(mt->filesystem,fsstats->fsname,MNTMAXSTR)) X { X buf.flagdev = NODE_ID_INO; X buf.id.ino.inum = 0; X buf.id.ino.dev = fsstats->device; X validadd(&buf); X break; X } X break; X case 'i': sbuf.fsw = FSW_INET; X if (portname2port(optarg,&sbuf.fu.inet.lp) == -1) X { X fprintf(stderr,"%s: fatal: port %s not found\n" X ,progname,optarg); X exit(1); X } X validsadd(&sbuf); X break; X case 'x': if (!uid) security = 1; break; X case 'X': if (!uid) security = 0; break; X case '?': exit(1); /*XXX*/ X } X argc -= optind; argv += optind; X X for (;*argv;++argv) X { X int guess; X /* ambiguity time */ X guess = 1; X if (((*argv)[0] == '/') || ((*argv)[0] == '.')) X guess = 1; X else if (argv[0][0] == '#') X { X guess = 2; X ++*argv; X } X else if (numeric(*argv)) X guess = 2; X /* XXX: any other choices? */ X X if (guess == 1) X { X i = 0; /* becomes 1 if we shouldn't warn about failing getmntname */ X if (stat(*argv,&st) == -1) X fprintf(stderr,"%s: warning: cannot stat %s: %s\n" X ,progname,*argv,strerr(strerrno)); X else X { X i = 1; X if (((st.st_mode & S_IFMT) == S_IFBLK) X ||((st.st_mode & S_IFMT) == S_IFCHR)) X { X buf.flagdev = NODE_ID_DEV; X buf.id.dev.maj = major(st.st_rdev); X buf.id.dev.min = minor(st.st_rdev); X } X else X { X buf.flagdev = NODE_ID_INO; X buf.id.ino.inum = st.st_ino; X buf.id.ino.dev = st.st_dev; X } X validadd(&buf); X } X mt = getmntname(*argv); X if (!mt) X { X if (!i) X fprintf(stderr,"%s: warning: cannot find mount of %s\n" X ,progname,*argv); X } X else X { X for (fsstats = stats;fsstats;fsstats = fsstats->next) X if (!strncmp(mt->filesystem,fsstats->fsname,MNTMAXSTR)) X { X buf.flagdev = NODE_ID_INO; X buf.id.ino.inum = 0; X buf.id.ino.dev = fsstats->device; X validadd(&buf); X break; X } X } X } X else if (guess == 2) X { X flagall = 1; X if (!numeric(*argv)) X { X /* this can never happen with the current guess structure */ X fprintf(stderr,"%s: fatal: pid %s not numeric\n",progname,*argv); X exit(1); X } X procaddpid(atoi(*argv)); X } X } X X ppflags = 8064; X offlags = 64; X pnflags = 0; X X /* XXX: use 128 for fd creds by name? */ X X switch(style) X { X case STYLE_BRIEF: X puts(" CMD PID UID FD TYPE INODE FS"); X ppflags += 1; X offlags += 0; X pnflags += 0; X break; X case STYLE_DEFAULT: X puts(" CMD PID UID FD D FLAGS TYPE INODE FS"); X ppflags += 1; X offlags += 16 + 4; X pnflags += 0; X break; X case STYLE_LONG: X puts(" CMD PID UID FD REF D OFFSET FLAGS CRED TYPE INODE FS"); X ppflags += 16384 + 1; X offlags += 16 + 4 + 2 + 8 + 32; X pnflags += 0; X break; X case STYLE_UIDLONG: X puts(" CMD PID USERNAME FD REF D OFFSET FLAGS CRED TYPE INODE FS"); X ppflags += 32768 + 1; X offlags += 16 + 4 + 2 + 8 + 32; X pnflags += 0; X break; X case STYLE_FULL: X ppflags += 8192 + 126; X offlags += 16 + 4 + 2 + 8 + 32; X pnflags += 0; X break; X case STYLE_TINY: X puts(" CMD PID USERNAME OFILES"); X ppflags += 8192 + 32768 + 65536 + 131072 + 262144 + 1048576 + 1; X offlags += 16 + 4 + 2 + 8 + 32; X pnflags += 0; X break; X case STYLE_NAME: X puts(" CMD PID UID FD D FLAGS TYP FILENAME"); X ppflags += 1; X offlags += 16 + 4; X pnflags += 6; X break; X case STYLE_PIDS: X default: /* default should never happen */ X style = STYLE_PIDS; X ppflags += 524288; X offlags += 16 + 4 + 2 + 8 + 32; X pnflags += 2; X break; X } X X for (i = 0;i < mynproc;++i) X if (pt[i].p_pid) /*XXX*/ X if (!security || (uid == pt[i].p_uid)) X if (procmatch(&(pt[i]))) X printproc(&(pt[i]),&(myproc[i]),ft,ppflags,offlags,pnflags); X if (style == STYLE_PIDS) X putchar('\n'); X exit(0); X} X X/* flags: X1 put process identification before each fd line X 16384 allow 17 chars rather than 12 for command name X2 print basic process information X4 print process status X8 print process resource usage X16 print process limits X32 print process credentials X64 print process signal handling X128 show text segment as fd, when it exists X256 show controlling tty as fd, when it exists X512 show cwd as fd X1024 show root dir as fd, when it exists X2048 show all open file descriptors X4096 show all mmap segments X8192 print extra newline X32768 show uids as usernames wherever possible X65536 don't space-fill fd labels (like cwd, 0, 1, 2, etc.) X131072 don't actually print fd descriptions with newline X262144 print preliminary prefd at most once before all fds X524288 print just pid, return as fast as possible XXX: how interact w/others? X1048576 under 1 + 8192 + 262144, don't print newline unless prefd has been used X*/ X Xprintproc(p,preal,ft,flags,offlags,pnflags) Xstruct proc *p; Xstruct proc *preal; Xstruct file *ft; Xint flags; Xint offlags; Xint pnflags; X{ X#ifdef OPALF X static struct file *(fof[NOFILE]); X#endif X#ifdef ODOFE X static struct ofile_ext oe; X#endif X static struct nodebuf buf; X static struct socketbuf sbuf; X static char prefd[80]; X struct user *u; X struct ucred *uc; X int i; X X /* printf("xstat %d ",p->p_xstat); */ X /* printf("pri %d %d ",p->p_usrpri,p->p_pri); */ X /* printf("time %d %d %d",p->p_slptime,p->p_time,(int) p->p_pctcpu); */ X /* XXX: handle pctcpu? */ X /* char *p_wchan */ X /* XXX: u_timer[] */ X /* XXX: u_start, on machines that have it */ X /*XXX:p_tsize,p_dsize,p_ssize,p_rssize, p_maxrss===u.u_limit[MAXRSS],p_swrss*/ X X if (p->p_stat == 0) X return; X if (p->p_stat == SZOMB) X return; X#ifdef SIDL X if (p->p_stat == SIDL) X return; X#endif X X u = getuser(p); X if (!u) X { X#ifdef notdef /* sigh */ X fprintf(stderr,"%s: warning: getuser failed on proc %d: %s\n" X ,progname X ,p->p_pid X ,strerr(getuserstrerr) X ); X#endif X return; X } X if (u->u_procp != preal) X { X /* XXX: warn? */ X return; X } X X uc = getpcred(p,u); X if (!uc) X return; X X if (flags & 1) X { X sprintf(prefd X ,((flags & 16384) ? "%17.17s %5d %s " : "%12.12s %5d %s ") X ,u->u_comm X ,p->p_pid X ,printucred(uc,1,2,0,(flags & 32768) ? 1 : 0) /* XXX: should use names here */ X ); X } X X if (flags & 2) X { X printf("proc %8x ",preal); X printf("pid %d ",p->p_pid); X#ifdef HAVE_PPID X printf("ppid %d ",p->p_ppid); X#endif X printf("pgrp %d ",p->p_pgrp); /* XXX: p_sgid under POSIX */ X printf("uid %d",p->p_suid); X if (p->p_uid != p->p_suid) printf("/%d",p->p_uid); X printf(" nice %d ",p->p_nice); X printf("umask %o ",u->u_cmask); X puts(u->u_comm); X } X X if (flags & 4) X printf("status: %s\n",printpstat(p)); X X if (flags & 8) X { X printf("self: %s\n",printrusage(&(u->u_ru))); X printf("kids: %s\n",printrusage(&(u->u_cru))); X } X if (flags & 16) X printf("rlimits: %s\n",printrlimits(u->u_rlimit)); X X if (flags & 32) X { X if (uc) printf("cred: %s\n",printucred(uc,0,0,1,(flags & 32768) ? 1 : 0)); X } X X if (flags & 64) X { X printf("signals:"); X for (i = 0;i < NSIG;++i) X { X if (!(i % 8)) putchar(' '); X if (u->u_signal[i] == SIG_DFL) putchar('d'); X else if (u->u_signal[i] == SIG_IGN) putchar('i'); X else putchar('C'); X#ifdef HAVE_USIGINTR X if (u->u_sigintr & two(i)) X if (p->p_sigmask & two(i)) putchar(';'); else putchar(','); X else X#endif X if (p->p_sigmask & two(i)) putchar(':'); else putchar('.'); X /* any other flags to include? */ X } X putchar('\n'); X } X X#ifdef REGION X if (flags & 128) X { X /* XXX: This is totally, absolutely undocumented to work. */ X struct vm_vspace vs; X struct vm_object vo; X int i; X for (i = 0;i < sizeof(vs.vs_regiontab) / sizeof(vs.vs_regiontab[0]);++i) X { X kmemcpy(&vs,p->p_vspace,sizeof(vs)); X kmemcpy(&vo,vs.vs_regiontab[i].re_object,sizeof(vo)); X if (vo.ob_vp && validnode(vo.ob_vp,&buf,0)) X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X printf("text "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X break; X } X } X } X#else X#ifdef TEXT X if (flags & 128) X { X struct text text; X kmemcpy(&text,p->p_textp,sizeof(text)); X if (validnode(text.x_Xptr,&buf,0)) X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X printf("text "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X } X } X#endif X#endif X X if (flags & 256) X { X#ifdef TTYVP X#ifdef PSESS X static struct sess pse; X kmemcpy(&pse,p->p_sessp,sizeof(pse)); X if (pse.s_vp && validnode(pse.s_vp,&buf,0)) X#else X if (u->u_ttyvp && validnode(u->u_ttyvp,&buf,0)) X#endif X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X printf("ctty "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X } X#else X if (u->u_ttyd) X { X char *s; X s = getttydevname(u->u_ttyd); X if (s) X { X buf.type = "chr"; /*XXX: breaks virtype encapsulation */ X buf.flagdev = NODE_ID_DEV; X buf.id.dev.maj = 0; /*XXX*/ X buf.id.dev.min = 0; /*XXX*/ X buf.id.dev.name = s; X if (validnode(0,&buf,1)) /* XXX: does this work? */ X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X printf("ctty "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X } X } X } X#endif X } X X if (flags & 512) X if (u->u_cdir && validnode(u->u_cdir,&buf,0)) X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X if (flags & 65536) X printf("cwd "); X else X printf(" cwd "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X } X if (flags & 1024) X if (u->u_rdir && validnode(u->u_rdir,&buf,0)) X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X printf("rdir "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X } X X if (flags & 2048) X { X#ifdef OPALF X if (u->u_lastfile >= NOFILE) /* XXX: ever? */ X kmemcpy(fof,u->u_ofile,sizeof(struct file *) * NOFILE); X else X kmemcpy(fof,u->u_ofile,sizeof(struct file *) * (u->u_lastfile + 1)); X u->u_ofile = fof; /* ensures that we're dealing with a pointer */ X#endif X#ifdef ODOFE X if (u->u_ofile_ext) X { X kmemcpy(&oe,u->u_ofile_ext,sizeof(oe)); X u->u_nofile = oe.oe_nofile; X } X#endif X for (i = 0;i < NUOFILE(u);++i) X { X#ifdef ODOFE X if (u->u_ofile_ext) X kmemcpy(u->u_lofile,oe.oe_ofile + i,sizeof(struct ofile)); X /* XXX: this is slow as molasses */ X else X u->u_lofile[0] = u->u_lofile[i]; /* XXX: structure copying */ X#endif X if (UOFILE(u,i)) X if (ft[UOFILE(u,i) - myfile].f_data) X { X switch(ft[UOFILE(u,i) - myfile].f_type) X { X case DTYPE_INODE: X if (!validnode(ft[UOFILE(u,i) - myfile].f_data,&buf,0)) X continue; X break; X case DTYPE_SOCKET: X if (!validsocket(ft[UOFILE(u,i) - myfile].f_data,&sbuf)) X continue; X break; X default: /* including SPU, PROCESS */ X if (!validother(ft[UOFILE(u,i) - myfile].f_data)) X continue; X } X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X if (flags & 65536) X printf("%d ",i); X else X printf("%4d ",i); X if (!(flags & 131072)) X printfile(ft + (UOFILE(u,i) - myfile),offlags,pnflags,&buf,&sbuf); X } X } X } X X if (flags & 4096) X { X struct vnode **segvns; X segvns = getvmseg(p); X for (i = 0;segvns[i] && (i < vmsegmax);++i) X { X if (validnode(segvns[i],&buf,0)) X { X if (flags & 524288) X { X printf("%d ",p->p_pid); X return; X } X if (flags & 1) X fputs(prefd,stdout); X if (flags & 262144) X prefd[0] = 0; X printf("mmap "); X if (!(flags & 131072)) X { X spacenode(offlags); X printbuf(&buf,pnflags); X } X } X } X } X X if (flags & 8192) X if (!prefd[0] || !(flags & 1) || !(flags & 1048576) || !(flags & 262144)) X putchar('\n'); X} X X/* offlags: X1 print file data location, 9 chars X2 print reference count, 6 chars X4 print file type, 2 chars X8 print file offset, 11 chars X16 print file flags, 9 chars X32 print file credentials as uids, 12 chars (or 18 chars with usernames) X64 print extended file information, free format X128 use usernames rather than uids X*/ X Xint printfile(f,offlags,pnflags,buf,sbuf) Xstruct file *f; Xint offlags; Xint pnflags; Xstruct nodebuf *buf; Xstruct socketbuf *sbuf; /*XXX*/ X{ X struct ucred *uc; X /* XXX: f_ops? f_msgcount? */ X if (offlags & 1) X printf("%8x ",f->f_data); X if (offlags & 2) X printf("%5d ",(int) f->f_count); X if (offlags & 4) X printf("%s ",printftype(f)); /* could also do numeric */ X if (offlags & 8) X printf("%10lu ",(unsigned long) f->f_offset); X if (offlags & 16) X printf("%s ",printfflag(f,4)); /* XXX: could also use 1,2,3 */ X if (offlags & 32) X { X uc = getfcred(f); X if (uc) printf("%s ",printucred(uc,1,0,0,(offlags & 128) ? 1 : 0)); X } X if (offlags & 64) X if (f->f_type == DTYPE_SOCKET) X printsbuf(sbuf); X else if (f->f_type == DTYPE_INODE) X printbuf(buf,pnflags); X#ifdef DTYPE_SPU X else if (f->f_type == DTYPE_SPU) X printf("(spu io)"); X#endif X#ifdef DTYPE_PROCESS X else if (f->f_type == DTYPE_PROCESS) X { X static struct proc p; X kmemcpy(&p,f->f_data,sizeof(p)); X printf("(process %d)",p.p_pid); X } X#endif X /* XXX: other types? */ X else X printf("unk type %d %8x\n",f->f_type,f->f_data); X else X putchar('\n'); X} X Xint spacenode(offlags) /*XXX this whole routine */ Xint offlags; X{ X if (offlags & 1) X printf("%8s ",""); X if (offlags & 2) X printf("%5s ",""); X if (offlags & 4) X printf("I "); /*XXX*/ X if (offlags & 8) X printf("%10s ",""); X if (offlags & 16) X printf("%s ","---------"); /*XXX*/ X if (offlags & 32) X printf("%s ",(offlags & 128) ? " " : " "); /*XXX*/ X} X Xprintbuf(buf,pnflags) Xstruct nodebuf *buf; Xint pnflags; X{ X printf("%s",buf->type); X switch(buf->flagdev) X { X case NODE_ID_FIFO: X printf(" (named pipe)\n"); X break; X case NODE_ID_FIFOINO: X printf(" (named pipe)"); X case NODE_ID_INO: X if (!(pnflags & 4)) X { X printf((pnflags & 1) ? " inode %d" : " ino %7d",buf->id.ino.inum); X if (buf->id.ino.name) X if ((pnflags & 1)) X printf(" %s fs %x (%s)",buf->id.ino.flagnfs ? "nfs" : "local" X ,buf->id.ino.dev,buf->id.ino.name); X else X printf(" %5x (%s)",buf->id.ino.dev,buf->id.ino.name); X else X if ((pnflags & 1)) X printf(" block dev %x",buf->id.ino.dev); X else X printf(" %5x",buf->id.ino.dev); X } X if (pnflags & 2) X { X putchar(' '); if (!(pnflags & 4)) putchar('('); X revnamei((unsigned long) buf->id.ino.inum,(unsigned long) buf->id.ino.dev); X if (!(pnflags & 4)) putchar(')'); X /* XXX: should do the printing right here */ X } X putchar('\n'); X break; X case NODE_ID_DEV: X if (pnflags & 4) X { X if (buf->id.dev.name) X printf(" %s\n",buf->id.dev.name); X else X printf(" dev (%d,%d)\n",buf->id.dev.maj,buf->id.dev.min); X } X else X { X if (buf->id.dev.name) X printf(" dev (%s)\n",buf->id.dev.name); X else X printf(" dev (%d,%d)\n",buf->id.dev.maj,buf->id.dev.min); X } X break; X default: X printf(" \n"); /*XXX*/ X } X return; X} X Xprintsbuf(sbuf) Xstruct socketbuf *sbuf; X{ X printf("("); X X if (sbuf->strsockt) printf("%s ",sbuf->strsockt); X else printf("unknown socket type %d ",sbuf->socktype); X X if (sbuf->flagaccept) printf("accept "); X if (sbuf->flagreuse) printf("reuse "); X if (sbuf->flaghead) printf("head "); X X if (sbuf->famname) printf("%s",sbuf->famname); X else printf("unknown family %d",sbuf->family); X X switch(sbuf->fsw) X { X case FSW_UNK: X break; X case FSW_INET: X if (sbuf->fu.inet.strpro) printf(" %s ",sbuf->fu.inet.strpro); X else printf(" protocol %d ",sbuf->fu.inet.proto); X if (sbuf->fu.inet.r0 || sbuf->fu.inet.r1 || sbuf->fu.inet.r2 || sbuf->fu.inet.r3) X printf("%u.%u.%u.%u",sbuf->fu.inet.r0,sbuf->fu.inet.r1,sbuf->fu.inet.r2,sbuf->fu.inet.r3); X else printf("*"); X if (sbuf->fu.inet.rp) printf(":%d",sbuf->fu.inet.rp); X else printf(":*"); X if (sbuf->fu.inet.l0 || sbuf->fu.inet.l1 || sbuf->fu.inet.l2 || sbuf->fu.inet.l3) X printf(" %u.%u.%u.%u",sbuf->fu.inet.l0,sbuf->fu.inet.l1,sbuf->fu.inet.l2,sbuf->fu.inet.l3); X /* XXX: always print local host as uname? */ X else printf(" *"); X if (sbuf->fu.inet.lp) printf(":%d",sbuf->fu.inet.lp); X else printf(":*"); X break; X case FSW_UNIX: X printf(" unpcb %x inode %x conn %x",sbuf->fu.un.unpcb,sbuf->fu.un.node,sbuf->fu.un.conn); X /* XXX: print that vnode? print that unpcb? */ X printf("%s",sbuf->fu.un.path); X break; X default: X break; /*XXX*/ X } X X printf(")\n"); X} X Xstruct validlist X { X struct validlist *next; X int type; /* 1 for node, 2 for socket */ X union X { X struct nodebuf n; X struct socketbuf s; X } X v; X } X; X Xstatic struct validlist *validhead = 0; X Xint validsmatch(v,sbuf) Xstruct socketbuf *v; Xstruct socketbuf *sbuf; X{ X /* XXX: many more match types are possible */ X /* socktype, family, fsw */ X X if (v->fsw == FSW_UNK) /* no sockets at all */ X return 0; X if (sbuf->fsw != v->fsw) /* must match nonzero fsw */ X return 0; X if (v->fsw == FSW_INET) X if (v->fu.inet.lp && (v->fu.inet.lp != sbuf->fu.inet.lp)) X return 0; X return 1; X} X Xint validmatch(v,buf) Xstruct nodebuf *v; Xstruct nodebuf *buf; X{ X if (v->flagdev == NODE_ID_DEV) X if (buf->flagdev == NODE_ID_DEV) X return (v->id.dev.maj == buf->id.dev.maj) && (v->id.dev.min == buf->id.dev.min); X else X return 0; X if ((buf->flagdev == NODE_ID_INO) || (buf->flagdev == NODE_ID_FIFOINO)) X { X /* It would be wrong to check NFS here: stat doesn't indicate NFS. */ X if (v->id.ino.inum) X if (v->id.ino.inum != buf->id.ino.inum) X return 0; X if (v->id.ino.dev != buf->id.ino.dev) X return 0; X return 1; X } X return 0; X} X Xstatic struct socketbuf sockcache[256]; Xstatic int sockcacheok[256]; /* had better be initialized to 0 */ Xstatic char *sockcachepos[256]; X Xint cachegetsocket(sock,buf) Xchar *sock; Xstruct socketbuf *buf; X{ X int hash; X hash = ((char *) &sock)[0] + ((char *) &sock)[3]; X /* XXX: major XXX: we had better have 4-byte addresses here */ X hash = hash & 255; /* okay, at least this is in the right range */ X if (sockcacheok[hash]) X if (sockcachepos[hash] == sock) X { X *buf = sockcache[hash]; /* XXX: structure copying */ X return 0; X } X if (getsocket(sock,buf) == -1) X return -1; X sockcache[hash] = *buf; /* XXX: structure copying */ X sockcacheok[hash] = 1; X sockcachepos[hash] = sock; X return 0; X} X Xint validsocket(sock,sbuf) Xchar *sock; Xstruct socketbuf *sbuf; X{ X struct validlist *v; X if (getsocket(sock,sbuf) == -1) X return 0; X if (!validhead) X return flagall; X for (v = validhead;v;v = v->next) X if (v->type == 2) X if (validsmatch(&(v->v.s),sbuf)) X return 1; X return 0; X} X Xstatic struct nodebuf nodecache[256]; Xstatic int nodecacheok[256]; /* had better be initialized to 0 */ Xstatic char *nodecachepos[256]; X Xint cachegetnode(node,buf) Xchar *node; Xstruct nodebuf *buf; X{ X int hash; X hash = ((char *) &node)[0] + ((char *) &node)[3]; X /* XXX: major XXX: we had better have 4-byte addresses here */ X hash = hash & 255; /* okay, at least this is in the right range */ X if (nodecacheok[hash]) X if (nodecachepos[hash] == node) X { X *buf = nodecache[hash]; /* XXX: structure copying */ X return 0; X } X if (getnode(node,buf) == -1) X return -1; X nodecache[hash] = *buf; /* XXX: structure copying */ X nodecacheok[hash] = 1; X nodecachepos[hash] = node; X return 0; X} X Xint validnode(node,buf,gndone) Xchar *node; Xstruct nodebuf *buf; Xint gndone; X{ X struct validlist *v; X if (!gndone) X if (cachegetnode(node,buf) == -1) X return 0; X if (!validhead) X return flagall; X for (v = validhead;v;v = v->next) X if (v->type == 1) X if (validmatch(&(v->v.n),buf)) X return 1; X return 0; X} X Xint validsadd(sbuf) Xstruct socketbuf *sbuf; X{ X struct validlist *v; X v = (struct validlist *) malloc(sizeof(struct validlist)); X if (!v) X return -1; X v->next = validhead; X v->type = 2; X v->v.s = *sbuf; /* XXX: requires struct copying */ X validhead = v; X return 0; X} X Xint validadd(buf) Xstruct nodebuf *buf; X{ X struct validlist *v; X v = (struct validlist *) malloc(sizeof(struct validlist)); X if (!v) X return -1; X v->next = validhead; X v->type = 1; X v->v.n = *buf; /* XXX: requires struct copying */ X validhead = v; X return 0; X} X Xint validother(node) Xchar *node; X{ X if (validhead) X return 0; X return flagall; X} X Xstruct proclist X { X struct proclist *next; X int type; /* 1 for pid, 2 for uid */ X union X { X int pid; X int uid; X } X u; X } X; X Xstatic struct proclist *prochead = 0; X Xint procmatch(proc) Xstruct proc *proc; X{ X struct proclist *p; X if (!prochead) X return 1; X for (p = prochead;p;p = p->next) X { X if (p->type == 1) X if (proc->p_pid == p->u.pid) X return 1; X if (p->type == 2) X if (proc->p_uid == p->u.uid) X return 1; X /*XXX: more types? */ X } X return 0; X} X Xint procaddpid(pid) Xint pid; X{ X struct proclist *p; X p = (struct proclist *) malloc(sizeof(struct proclist)); X if (!p) X return -1; X p->next = prochead; X p->type = 1; X p->u.pid = pid; X prochead = p; X return 0; X} X Xint procadduid(uid) Xint uid; X{ X struct proclist *p; X p = (struct proclist *) malloc(sizeof(struct proclist)); X if (!p) X return -1; X p->next = prochead; X p->type = 2; X p->u.uid = uid; X prochead = p; X return 0; X} END_OF_FILE if test 27865 -ne `wc -c <'pff.c'`; then echo shar: \"'pff.c'\" unpacked with wrong size! fi # end of 'pff.c' fi echo shar: End of archive 6 \(of 6\). cp /dev/null ark6isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0