Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

v29i124: pidentd-2.7 - Portable Ident Daemon, V2.7, Part01/09

21 views
Skip to first unread message

Peter Eriksson

unread,
Sep 8, 1996, 3:00:00 AM9/8/96
to

Submitted-By: pe...@ifm.liu.se (Peter Eriksson)
Posting-Number: Volume 29, Issue 124
Archive-Name: pidentd-2.7/part01

DESCRIPTION

This is a program that implements the RFC1413 identification server. It
was very much inspired by Dan Bernstein's original 'authd' (but unlike
that program doesn't use 'netstat' to get some of the information) It
uses the kernel information directly. (And is due to that fact a lot
faster). Dan has now written another version of the 'authd' daemon that
uses his 'kstuff' to read the kernel information. Unlike that daemon,
this will use only normally available kernel access functions (and is due
to that more limited in the different machines it support). Please note
that this daemon used to be called pauthd but has changed name to better
reflect what it does (and to conform to the new RFC).

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1996-09-06 22:53 MET DST by <pen@tina>.
# Source directory was `/home/u4/pen/tmp'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3390 -rw-r--r-- pidentd-2.7/CREDITS
# 7279 -rw-r--r-- pidentd-2.7/ChangeLog
# 632 -rw-r--r-- pidentd-2.7/FAQ
# 4005 -rw-r--r-- pidentd-2.7/INSTALL
# 20336 -rw-r--r-- pidentd-2.7/Makefile
# 3031 -rw-r--r-- pidentd-2.7/README
# 8238 -rw-r--r-- pidentd-2.7/READMEs/README.DES
# 775 -rw-r--r-- pidentd-2.7/READMEs/README.aix
# 645 -rw-r--r-- pidentd-2.7/READMEs/README.dynix3
# 660 -rw-r--r-- pidentd-2.7/READMEs/README.irix4
# 595 -rw-r--r-- pidentd-2.7/READMEs/README.irix5
# 1062 -rw-r--r-- pidentd-2.7/READMEs/README.next
# 1580 -rw-r--r-- pidentd-2.7/READMEs/README.next31-m68k-i486
# 832 -rw-r--r-- pidentd-2.7/READMEs/README.ptx
# 500 -rw-r--r-- pidentd-2.7/READMEs/README.riscos4
# 1375 -rw-r--r-- pidentd-2.7/READMEs/README.sunos3
# 504 -rw-r--r-- pidentd-2.7/READMEs/README.sunos4
# 1473 -rw-r--r-- pidentd-2.7/READMEs/README.sunos5
# 3112 -rw-r--r-- pidentd-2.7/READMEs/README.ultrix
# 674 -rw-r--r-- pidentd-2.7/READMEs/README.unicos6
# 710 -rw-r--r-- pidentd-2.7/TODO
# 16292 -rw-r--r-- pidentd-2.7/doc/RFC1413
# 13719 -rw-r--r-- pidentd-2.7/doc/TAP.doc
# 424 -rw-r--r-- pidentd-2.7/doc/TAPvsIDENT
# 3157 -rw-r--r-- pidentd-2.7/doc/TESTRESULTS
# 7046 -rw-r--r-- pidentd-2.7/doc/why-encrypt.txt
# 393 -rw-r--r-- pidentd-2.7/doc/why-ident.txt
# 6404 -rw-r--r-- pidentd-2.7/doc/why-tap.txt
# 9915 -rw-r--r-- pidentd-2.7/identd.man
# 2907 -rw-r--r-- pidentd-2.7/idecrypt.man
# 1167 -rw-r--r-- pidentd-2.7/src/Makefile
# 769 -rw-r--r-- pidentd-2.7/src/config.c
# 5598 -rw-r--r-- pidentd-2.7/src/crypto.c
# 260 -rw-r--r-- pidentd-2.7/src/crypto.h
# 1416 -rw-r--r-- pidentd-2.7/src/error.h
# 2220 -rw-r--r-- pidentd-2.7/src/idecrypt.c
# 16394 -rw-r--r-- pidentd-2.7/src/identd.c
# 16271 -rw-r--r-- pidentd-2.7/src/parse.c
# 910 -rw-r--r-- pidentd-2.7/src/identd.h
# 3541 -rw-r--r-- pidentd-2.7/src/itest.c
# 4742 -rw-r--r-- pidentd-2.7/src/kernel/386bsd.c
# 5106 -rw-r--r-- pidentd-2.7/src/kernel/4.3bsd.c
# 5074 -rw-r--r-- pidentd-2.7/src/kernel/aix.c
# 13380 -rw-r--r-- pidentd-2.7/src/kernel/alpha3.c
# 4698 -rw-r--r-- pidentd-2.7/src/kernel/netbsd.c
# 27026 -rw-r--r-- pidentd-2.7/src/kernel/apollo.c
# 7394 -rw-r--r-- pidentd-2.7/src/kernel/irix5.c
# 4240 -rw-r--r-- pidentd-2.7/src/kernel/aux.c
# 9954 -rw-r--r-- pidentd-2.7/src/kernel/aux301.c
# 5056 -rw-r--r-- pidentd-2.7/src/kernel/bsdi.c
# 5444 -rw-r--r-- pidentd-2.7/src/kernel/freebsd.c
# 4769 -rw-r--r-- pidentd-2.7/src/kernel/hpux.c
# 5810 -rw-r--r-- pidentd-2.7/src/kernel/irix4.c
# 786 -rw-r--r-- pidentd-2.7/src/kernel/kvm.h
# 1350 -rw-r--r-- pidentd-2.7/src/kernel/linux.c
# 4462 -rw-r--r-- pidentd-2.7/src/kernel/next_mach.c
# 5671 -rw-r--r-- pidentd-2.7/src/kernel/other.c
# 5635 -rw-r--r-- pidentd-2.7/src/kernel/ptx2.c
# 5607 -rw-r--r-- pidentd-2.7/src/kernel/ptx4.c
# 10406 -rw-r--r-- pidentd-2.7/src/kernel/sco324.c
# 11768 -rw-r--r-- pidentd-2.7/src/kernel/sco32_42+5.c
# 4380 -rw-r--r-- pidentd-2.7/src/kernel/sunos4.c
# 8786 -rw-r--r-- pidentd-2.7/src/kernel/sunos5.c
# 7316 -rw-r--r-- pidentd-2.7/src/kernel/svr4.c
# 3462 -rw-r--r-- pidentd-2.7/src/kernel/unicos6.c
# 4615 -rw-r--r-- pidentd-2.7/src/kernel/freebsd.c.old
# 4575 -rw-r--r-- pidentd-2.7/src/kernel/machten.c
# 4742 -rw-r--r-- pidentd-2.7/src/kernel/uw2.c
# 6918 -rw-r--r-- pidentd-2.7/src/kvm.c
# 1259 -rw-r--r-- pidentd-2.7/src/paths.h
# 2408 -rw-r--r-- pidentd-2.7/src/proxy.c
# 27 -rw-r--r-- pidentd-2.7/src/version.c
# 266 -rw-r--r-- pidentd-2.7/testdir/Makefile
# 2750 -rw-r--r-- pidentd-2.7/testdir/test1.c
# 44 -rw-r--r-- pidentd-2.7/.cvsignore
# 107 -rwxr-xr-x pidentd-2.7/identconn.sh
# 4773 -rwxr-xr-x pidentd-2.7/install-sh
# 9931 -rw-r--r-- pidentd-2.7/identd.8
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh08724; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= pidentd-2.7/CREDITS ==============
if test ! -d 'pidentd-2.7'; then
$echo 'x -' 'creating directory' 'pidentd-2.7'
mkdir 'pidentd-2.7'
fi
if test -f 'pidentd-2.7/CREDITS' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/CREDITS' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/CREDITS' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/CREDITS' &&
Credits go to (I've probably forgot someone - please don't hesitate
to tell me!) for helping making Pidentd what it is:
X
Vic Abell <a...@vic.cc.purdue.edu>, Purdue University, USA
X (Added support for SCO Unix 3.2V5)
X
Tim Wright <ti...@sequent.com>, Sequent Inc, USA
X (Added support for Sequent PTX/2 and PTX/4)
X
Harlan Stenn <har...@pfcs.com>, USA
X (Added support for AIX 3.2 (based on the aixident by C.M. Hannum)
X
Torsten Blum <tors...@Ramsey.Saar.DE>, Germany
X (Added support for FreeBSD 2)
X
Allan E Johannesen <a...@WPI.EDU>, WPI, USA
X (Added support for DEC Alpha OSF/1 3.0 and later)
X
Rob Banz <ba...@umbc.edu>, UMBC Academic Computing Services, USA
X (Added support for IRIX 5 & 6)
X
Damien Doligez <dol...@lix.polytechnique.fr>, Polytechnique, FR
X (Added support for DES encryption)
X
Casper Dik <cas...@fwi.uva.nl>, Math & CS Faculty, U. of Amsterdam, NL
X (Added support for SunOS 5 (Solaris 2), and the "itest" program)
X
Dave Shield <D.T.S...@compsci.liverpool.ac.uk>, CS Dept. Liverpool U., UK
X (Added support for HP9K HPUX 8.*)
X
Jan L. Peterson <j...@phred.math.byu.edu>, Math Dept. BYU, USA
X (Added support for MIPS RISC/os and fixed a few other things)
X
Fletcher Mattox <flet...@cs.utexas.edu>, University of Texas, USA
X (Added support for HP9K HP-UX 7.*)
X
Mark Monnin <mgr...@nextwork.rose-hulman.edu>, Rose-Hulman Inst. of Tech, USA
X (Added support for DEC Ultrix 4.*)
X
Simon Leinen <si...@lia.di.epfl.ch>, Switzerland
X (Added support for Silicon Graphics IRIX 4.*)
X
Frank Maas <ma...@wi.leidenuniv.nl>, Leiden University, The Netherlands
X (Added support for Sequent Dynix 3.*)
X
Andrew Herbert <and...@molly.cs.monash.edu.au>, Monash University, Australia
X (Added support for System V/Release 4)
X
David Bennet <d...@gu.uwa.edu.au>, Australia
X (Added support for 386BSD)
X
Fishman M. Shmuel <f...@ccgr.technion.ac.il>, Technion Inst. of Tech., Israel
X (Added support for Convex & 4.3BSDtahoe (then heavily hacked by me))
X
Bradley E. Smith <br...@bradley.bradley.edu>, Bradley University, USA
X (Added support for AT&T's own version of SVR4)
X
RenE J.V. Bertin <ber...@neuretD.biol.ruu.nl>, Uni. of Utrecht, The Netherlands
X (Added support for Apple A/UX 2.*)
X
Douglas Lee Schales <Doug.S...@sc.tamu.edu>, Texas A&M University, USA
X (Added support for Cray UNICOS 6.*)
X
Don Hazlewood <h...@dali.math.swt.edu>, SW Texas State U., USA
X (Added support for A/UX 3.*)
X
Nigel Metheringham <nig...@ohm.york.ac.uk>, University of York, UK
X (Added support for NeXT 2 & 3.0, SunOS 3.*, corrections for MIPS)
X
Peter Wemm <pe...@DIALix.oz.au>, Australia
X (Added support for SCO UNIX System V Release 3.2)
X
Bruce Gingery <br...@TotSysSoft.com>, USA
Michael Kuch <ku...@mailserv.zdv.uni-tuebingen.de>, Uni. Tuebingen, Germany.
X (Added/modified the NeXT support to handle 3.1 and FAT binaries)
X
Terry Kennedy <TE...@spcvxa.spc.edu>, St. Peter's College, USA
X (Added support for BSDI's BSD/386)
X
Shigeru Yamamoto <shi...@itc.aist-nara.ac.jp>, Japan
X (Added more support for BSDI's BSD/386)
X
Adrian Hall <adr...@cursci.com>, The Current Science Group, USA
X (Added support for NetBSD)
X
Pauline Middelink <midd...@calvin.iaf.nl>, NL
X (Wrote the Linux support, adopted to Pidentd 2 by me)
X
----------------------------------------------------------------------------
Peter Eriksson <p...@lysator.liu.se>, Lysator, Linkoping University, Sweden.
X (Original code for Sun SunOS 4.* and Sequent Dynix 2.*)
X
SHAR_EOF
$shar_touch -am 0605195095 'pidentd-2.7/CREDITS' &&
chmod 0644 'pidentd-2.7/CREDITS' ||
$echo 'restore of' 'pidentd-2.7/CREDITS' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'pidentd-2.7/CREDITS:' 'MD5 check failed'
95807fb02c5974d36252a1862350f1a8 pidentd-2.7/CREDITS
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/CREDITS'`"
test 3390 -eq "$shar_count" ||
$echo 'pidentd-2.7/CREDITS:' 'original size' '3390,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/ChangeLog ==============
if test -f 'pidentd-2.7/ChangeLog' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/ChangeLog' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/ChangeLog' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/ChangeLog' &&
Fri Sep 6 22:23:40 1996 Peter Eriksson <p...@lysator.liu.se>
X
X * Released version 2.7
X
Wed Jun 12 20:18:26 1996 Alan Barrett <a...@iafrica.com>
X
X * New man page for "idecrypt"
X
X * Additions to the identd man page to document the -C option
X
X * Fixes for some nits in the identd man page
X
X * src/kernel/netbsd.c as used in NetBSD-1.1B
X
X * Makefile modifications for NetBSD
X
X * Makefile modifications for idecrypt
X
Sun Aug 11 22:18:34 1996 Peter Eriksson <pe...@ifm.liu.se>
X
X * Use $(INSTALL) (== install) instead of "cp" to install files.
X
Sun Aug 11 22:12:12 1996 Paul F. Wells <pa...@wellserv.com>
X
X * UnixWare 2 support added.
X
Sun Aug 11 22:02:19 1996 MURAYAMA Fumitaka <um...@nn.solan.chubu.ac.jp>
X
X * Fix to SunOS 4 to avoid infinite loops.
X
Mon Mar 4 18:41:00 1996 Greg A. Woods <wo...@planix.com>
X
X * Makefile: - add a new rule set for identconn
X
X * src/kernel/bsdi.c: - back-port to BSDI-1.1 again...
X
X * identconn.sh: - set local bin from DESTROOT (sed in Makefile)
X
X * src/Makefile, Makefile: - re-write patches from local-2_7a1-v0
X
X * identd.man: - make pathnames a bit more configurable...
X
X * .cvsignore: - new target -- man page intermediate...
X
X * src/parse.c: - reduce some syslog levels to a more resonable priority
X
Fri Aug 11 22:07:06 1995 Greg A. Woods <wo...@planix.com>
X
X * Makefile: - add SHARE, SBIN, PREFIX, and MANEXT config options
X - add -lident to default GLIBS (you'll need it anyway)
X - add LDFLAGS with default -L$(DESTROOT)/lib (where -lident likely is)
X - add -DSTRONG_LOG to default GDEFS
X - build ident.man from ident.8 using sed
X - build itest by default
X - add an identconn target and build it by default
X - fix up install target to be a bit more powerful (probably should include
X GNU install.sh too though).
X - use $(MAKE) for clean
X - add identconn and itest to cleanup
X
X * Attic/identd.8: - make some pathanmes configurable from the makefile
X - add a FILES section
X - quotes needed around multi-word .SH's
X
X * src/Makefile:
X - support the use of $(PREFIX) to specify an "in." prefix only if desired
X
Thu Jun 29 17:18:33 1995 Greg A. Woods <wo...@planix.com>
X
X * Makefile: - cleanup and localisations
X
X * identconn.sh: - first time in
X
X * .cvsignore: - first time in with default targets
X
Sun Aug 11 20:54:51 1996 James Carlson <car...@xylogics.com>
X
X * Bugfix for AIX (didn't support the ALLOW_FORMAT stuff)
X
Sun Aug 11 20:54:49 1996 Peter Eriksson <pe...@laphroaig.ifm.liu.se>
X
X * Added some fixes to the OSF/1 support based on a bug report
X from Anne Bennett <an...@alcor.concordia.ca>.
X
Sun Aug 11 20:42:43 1996 Trevor Strohman <tr...@tenon.com>
X
X * Support for Tenon's MachTen 4.0.x added.
X
Sun Aug 11 20:26:17 1996 Peter Wemm <pe...@freefall.freebsd.org>
X
X * New and updated FreeBSD kernel module.
X
Sun Aug 11 20:18:20 1996 Dave Blob <bl...@syl.dl.nec.com>
X
X * Support for IRIX 6.2 added.
X
Sun Aug 11 20:11:12 1996 David L Stevens <d...@icd.cc.purdue.edu>
X
X * Makefile changes for AIX3 and AIX4 (-DSVR4 added)
X
Thu May 16 09:10:16 1996 Paul Szabo <p...@maths.usyd.edu.au>
X
X * Moved k_open call from parent to child process so
X simultaneous identd queries can work
X
X * Fixed typo in parse.c (seen only with INCLUDE_EXTESIONS)
X
Fri Apr 12 09:30:01 1996 Paul Szabo <p...@maths.usyd.edu.au>
X
X * Added support for Apollos (running Domain/OS SR10.x)
X
Tue Apr 9 20:13:59 1996 Peter Eriksson <p...@lysator.liu.se>
X
X * Fixes from Casper for Solaris 2.5 and 2.5.1
X
Mon Apr 1 10:49:43 1996 Paul Szabo <p...@maths.usyd.edu.au>
X
X * Added random sleep between k_getuid retries
X * Added sanity (error?) checks in kernel/alpha3.c
X
Thu Mar 28 11:21:59 1996 Paul Szabo <p...@maths.usyd.edu.au>
X
X * Fixed bug in kernel/alpha3.c with k_getuid returning
X bad value (or is the bug in parse.c ?)
X
Fri Nov 24 13:43:07 1995 Paul Szabo <sza...@maths.su.oz.au>
X
X * Added option for format of info returned (generalizing and
X replacing -n option)
X
Fri Oct 13 14:19:29 1995 Peter Eriksson <p...@lysator.liu.se>
X
X * Fixed the BSDI 2.0 support (from Dave Blob <bl...@syl.dl.nec.com>
X
X * Default to "-b" mode if started from the command line.
X
Mon Oct 9 08:40:05 1995 Peter Eriksson <p...@lysator.liu.se>
X
X * Added support for Apple A/UX 3.0.1 (Herb Weiner <he...@wiskit.com>)
X
Wed Oct 4 19:32:45 1995 Peter Eriksson <p...@lysator.liu.se>
X
X * Fixed a #ifdef for SGI in identd.c
X
X * Fixed some syslog calls for Solaris 2.
X
X * Added support for HP-UX 10 (simple kernel location path change)
X
X * Fixed aix.c:k_getuid() so that it won't return without
X returning a proper value.
X
Tue Aug 8 07:34:21 1995 Peter Eriksson <pe...@ifm.liu.se>
X
X * Fixed the name of the sco32_42+5.c file to be just that :-)
X
Thu Aug 3 17:30:54 1995 Peter Eriksson <p...@lysator.liu.se>
X
X * Added Bela Lubkin & Vic Abell's SCO Unix patches.
X
X * Added Vic Abell's AIX 4 patch.
X
X * Added Andrey A. Chernov`s FreeBSD patch.
X
X * Added patches from 'der Mouse <mo...@Collatz.McRCIM.McGill.EDU>':
X Removed the space between the ":" and the username in the
X returned information.
X
Mon Jun 5 15:30:09 1995 Peter Eriksson <pe...@ifm.liu.se>
X
X * Release version 2.6.1
X
X * Made the Solaris 2.4 workaround conditional with a:
X (#ifdef SOLARIS24_WORKAROUND)
X
X * Added support for IRIX 6 (Rob Banz)
X
X * Released version 2.6
X
X * Added support for SCO Unix 3.2v4.2 and v5 (Vic Abell)
X
X * Added support for Sequent PTX/2 and PTX/4 (Tim Wright)
X
X * Updated the FreeBSD support (Torsten Blum)
X
X * some Solaris cosmetic changes.
X
X * Added a STRONG_LOG compile-time option.
X
X * Added SO_REUSEADDR socket option before bind()
X
X * Made the daemon not fork()-and-detach from controlling TTY
X if started in debug mode (-d)
X
X * Added a workaround to the Solaris 2.4 problem with running
X the daemon in standalone or "wait" modes (that the Solaris KVM
X library caches more information than it should). The workaround
X is that it opens/rescans and closes the KVM for every call. Slow
X but...
X
X * Added compile time&date output to the VERSION request.
X
Wed Feb 1 13:25:56 1995 Peter Eriksson <p...@lysator.liu.se>
X
X * Released version 2.5.1
X
Wed Feb 1 13:25:56 1995 Casper Dik <cas...@fwi.uva.nl>
X
X * Fixed a Solaris 2.4 bug in "-w" and "-b" modes.
X
Wed Feb 1 13:25:56 1995 Peter Eriksson <p...@lysator.liu.se>
X
X * Released version 2.5
X
X * Added support for Irix 5.3
X
Thu Dec 15 18:34:20 1994 Peter Eriksson <p...@lysator.liu.se>
X
X * Released version 2.4.1.
X
Thu Dec 15 18:33:48 1994 Casper Dik <cas...@fwi.uva.nl>
X
X * src/kernel/sunos5.c (k_getuid): Added fix for Sol2.4/x86
X
Tue Dec 13 14:03:20 1994 Peter Eriksson <p...@lysator.liu.se>
X
X * Released version 2.4.
X
Thu Oct 27 10:36:09 1994 Peter Eriksson <p...@lysator.liu.se>
X
X * Added support for IBM AIX 3.2
X
Thu Oct 27 10:36:08 1994 Peter Eriksson <p...@lysator.liu.se>
X
X * Use "ChangeLog" instead of "WHATSNEW".
X
X * Released version 2.4alpha.4
X
X * Added support for FreeBSD 2.
X
X * Released version 2.4alpha.3
X
X * Some minor fixes
X
X * Released version 2.4alpha.2
X
X * Bug fix for the Solaris 2.4 support.
X
X * Added the "itest" program.
X
X * Released version 2.4alpha.1:
X
X * Support for Solaris 2.4 added.
X
X * src/kvm.h moved to src/kernel/kvm.h
X
Thu Oct 27 10:36:07 1994 Peter Eriksson <p...@lysator.liu.se>
X
X * WHATSNEW/ChangeLog truncated (see pidentd-2.3 for old news)
SHAR_EOF
$shar_touch -am 0906222396 'pidentd-2.7/ChangeLog' &&
chmod 0644 'pidentd-2.7/ChangeLog' ||
$echo 'restore of' 'pidentd-2.7/ChangeLog' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'pidentd-2.7/ChangeLog:' 'MD5 check failed'
d8608d93161ce8fda947a0768ac37b19 pidentd-2.7/ChangeLog
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/ChangeLog'`"
test 7279 -eq "$shar_count" ||
$echo 'pidentd-2.7/ChangeLog:' 'original size' '7279,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/FAQ ==============
if test -f 'pidentd-2.7/FAQ' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/FAQ' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/FAQ' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/FAQ' &&
Q: Pidentd stopped working for some reason - help!
X
A: Always as a first step get the latest version of Pidentd from:
X
X ftp.lysator.liu.se:pub/ident/servers
X
X and install that one.
X
X
X
Q: I just upgraded to Solaris 2.x from Solaris 2.(x-1), now Pidentd
X doesn't work anymore - why?
X
A1: You did recompile Pidentd _on_ a machine running the new OS did you?
X
A2: If you used Gcc to compile it: You did recompile and install a new
X version of Gcc configured for the new OS version, didn't you?
X (Gcc builds fixed include files which are used instead of the
X system ones - and they are _not_ portable between OS releases).
X
SHAR_EOF
$shar_touch -am 0906221596 'pidentd-2.7/FAQ' &&
chmod 0644 'pidentd-2.7/FAQ' ||
$echo 'restore of' 'pidentd-2.7/FAQ' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'pidentd-2.7/FAQ:' 'MD5 check failed'
54ef72d4dfc394ba48e6dde5121b0290 pidentd-2.7/FAQ
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/FAQ'`"
test 632 -eq "$shar_count" ||
$echo 'pidentd-2.7/FAQ:' 'original size' '632,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/INSTALL ==============
if test -f 'pidentd-2.7/INSTALL' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/INSTALL' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/INSTALL' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/INSTALL' &&
To build the "in.identd" daemon, do the following steps:
X
0. Make sure you have the _latest_ version of Pidentd!! The latest
X version can always be FTP'd from ftp.lysator.liu.se in the directory
X pub/ident/servers. If Pidentd doesn't work for you - always make
X sure you have a current version!
X
1. Type "make" and see if your machine is among one of those
X listed. If so, goto step 5.
X
2. Copy the entry for "other" in the top-level Makefile into a
X new one and edit it for your system.
X
3. If your machine/OS has the "KVM" routines (you can find out by
X typing "man kvm_open"), then add "-lkvm" (or whatever it's called
X on your system) to your newly created entry.
X
4. Edit the file "paths.h" to contain valid definitions for
X your system.
X
5. Type "make <systype>", where <systype> is one from the list
X displayed when you type "make" without arguments. Then watch it
X build nicely (hopefully).
X
6. As "root", type "make install". This will copy the executable
X daemon "in.identd" into the destination directory as specified in
X the Makefile (normally /usr/local/sbin) and the man page into the
X specified man directory (normally /usr/local/man/man8).
X
X Please make sure that it is executable for the user you specify below
X in step 8! Otherwise it will fail for obvious reasons.
X
7. Edit /etc/services to contain a line "ident 113/tcp auth tap".
X
X If your system is running SunOS, or some other system with NIS (or YP)
X then make sure you edit the /etc/services file on the machine running
X the _master_ YP server, and then cd to your YP directory and type "make".
X (On SunOS 4.*: "cd /var/yp; make").
X
8. Edit the file /etc/inetd.conf to contain a line (replace "sys" with
X a user with enough rights to READ the kernel memory. Under SunOS 4.*,
X user "sys" is a member of the "kmem" group and is a good choice. If
X you have no "kmem" or "sys" user, then I suggest you create one and
X assign read rights for the group "kmem" to the /vmunix and /dev/kmem
X and /dev/mem "files" - you might also have to modify the group id of
X other programs that read the kernel, like "netstat", "ps" and more):
X
X ident stream tcp nowait sys /usr/local/sbin/in.identd in.identd
X
X If you're running A/UX 2.0*, inetd reads from /etc/servers. This contains
X an archaic(?) form of the above:
X
X ident tcp /usr/local/sbin/in.identd
X
X Hint: Some unixes requires the daemon to run as user "root" even though
X it is setgid to a group that can read /dev/kmem.
X
9. Restart the "inetd" daemon. (Can normally be done with a "SIGHUP" signal).
X
10. Test the daemon by TELNET:ing to "130.236.254.1" port 114 and verify
X that the information displayed is correct. (It should give your user
X name, "UNIX" as operating system and no character set). The program on
X port 114 will connect to your newly installed daemon and try to retrieve
X the identity of you.
X
X Another way to test the daemon is by TELNET:ing to "localhost" port
X 113 and then escape to the command level temporarily (normally you can
X do this by keying "Ctrl-] z". Then type "netstat -n | egrep 113" and
X remember the other port number that you will see. Now return to your
X TELNET session and enter "4711 , 113", where you replace 4711 with the
X number you got from "netstat". If things work out ok you should see a
X response like:
X
X 4711 , 113 : USERID : UNIX : foobar
X
X Where "foobar" should be your user name. If it doesn't work then
X please send me a bug report at <p...@lysator.liu.se>.
X
X You may also find the "itest" program useful to verify that the
X internal kernel-accessing routines in the Ident daemon is working
X correctly.
X
X Use it like this:
X
X netstat -n | grep ESTAB | ./itest
X
X And the output should be a list of username and the TCP connections
X they own. This program must be run as root (or be setgid just like
X the pidentd daemon).
X
11. Else all is done and your server should be ready for real world usage.
SHAR_EOF
$shar_touch -am 0811212096 'pidentd-2.7/INSTALL' &&
chmod 0644 'pidentd-2.7/INSTALL' ||
$echo 'restore of' 'pidentd-2.7/INSTALL' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'pidentd-2.7/INSTALL:' 'MD5 check failed'
c7aaed48744cd7360426b0a80af5d2fc pidentd-2.7/INSTALL
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/INSTALL'`"
test 4005 -eq "$shar_count" ||
$echo 'pidentd-2.7/INSTALL:' 'original size' '4005,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/Makefile ==============
if test -f 'pidentd-2.7/Makefile' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/Makefile' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/Makefile' '(binary)'
sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 pidentd-2.7/Makefile
<uuencoded_portion_removed>
I)%!!0TM.04U%('P@9WII<"`M.2`^)"1004-+3D%-12YT87(N9WHI"@H@
`
end
SHAR_EOF
$shar_touch -am 0812000896 'pidentd-2.7/Makefile' &&
chmod 0644 'pidentd-2.7/Makefile' ||
$echo 'restore of' 'pidentd-2.7/Makefile' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'pidentd-2.7/Makefile:' 'MD5 check failed'
a7b4e08f49166ef46994608f94072d23 pidentd-2.7/Makefile
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/Makefile'`"
test 20336 -eq "$shar_count" ||
$echo 'pidentd-2.7/Makefile:' 'original size' '20336,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/README ==============
if test -f 'pidentd-2.7/README' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/README' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/README' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/README' &&
X Pidentd, version 2
X
X ("Peter's Ident Daemon" or is it "Portable Ident Daemon"?)
X
X Peter Eriksson <p...@lysator.liu.se>
X
X
LICENSE/LEGALESE
X
This program is released into the public domain and can be used by
anyone who wants to. Vendors may include it into their distributions
if they want to without any restrictions. (Although it would be nice
to be notified by email if someone decides to do that, and/or a note
somewhere about who wrote this program. Like in the man-page or so.. :-)
X
X
X
DESCRIPTION
X
This is a program that implements the RFC1413 identification server. It
was very much inspired by Dan Bernstein's original 'authd' (but unlike
that program doesn't use 'netstat' to get some of the information) It
uses the kernel information directly. (And is due to that fact a lot
faster). Dan has now written another version of the 'authd' daemon that
uses his 'kstuff' to read the kernel information. Unlike that daemon,
this will use only normally available kernel access functions (and is due
to that more limited in the different machines it support). Please note
that this daemon used to be called pauthd but has changed name to better
reflect what it does (and to conform to the new RFC).
X
X
X
LATEST VERSIONS
X
The latest version of Pidentd can always be FTP'd from:
X
X ftp://ftp.lysator.liu.se/pub/ident/servers
X
Some of the mirrors (that I know of):
X
X ftp://ftp.ntua.gr/pub/ident/servers
X ftp://ftp.uu.net/networking/ident/servers
X
X
X
COMMAND LINE OPTIONS
X
See the manual page for information about the various command line
options that are available.
X
NOTE: One should NOT use the -d option when using it for normal use!
X
X
X
CLIENT LIBRARIES
X
If you intend to create or modify daemons that use the IDENT protocol
then you may wish to get the "libident" library that contains some
functions to implement the client side of this protocol. It is available
as "libident-*.tar.Z" in "pub/ident/libs" at "ftp.lysator.liu.se".
X
X
X
MAILING LISTS
X
There is a mailing list for users of the IDENT(RFC1413)/TAP protocol called
'ident...@lysator.liu.se' that you may want to consider joining.
Send mail to the address 'ident-use...@lysator.liu.se' to
join it. This list is intended for generic discussions on using this
protocol and it's associated tools.
X
If you only want to receive news about new (non-alpha/beta) releases of
Pidentd then you can join the 'ident-a...@lysator.liu.se' mailing
list. Send mail to the address 'ident-annou...@lysator.liu.se' to
join it. No discussions will take place on this list.
X
I also run a small mailing list for people who wants to act as testers
of new alpha/beta-versions of Pidentd. If you wish to join, please send
mail to the address 'pidentd-tes...@lysator.liu.se'. (I can always
use more testers, so don't hesitate :-)
X
X
X
INFORMATION REQUEST
X
Please let me know if you find any bugs, or have ported it to other
machines (and care to share the changes with me and the world!).
X
X Peter Eriksson <p...@lysator.liu.se>, 11 Aug 1996
SHAR_EOF
$shar_touch -am 0811213096 'pidentd-2.7/README' &&
chmod 0644 'pidentd-2.7/README' ||
$echo 'restore of' 'pidentd-2.7/README' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'pidentd-2.7/README:' 'MD5 check failed'
6e4e333c1651c0263fac6d72dc8618c7 pidentd-2.7/README
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/README'`"
test 3031 -eq "$shar_count" ||
$echo 'pidentd-2.7/README:' 'original size' '3031,' 'current size' "$shar_count!"
fi
fi
: || $echo 'restore of' 'pidentd-2.7/READMEs/README.DES' 'failed'
$echo 'End of part' '1,' 'continue with part' '2'
exit 0

Peter Eriksson

unread,
Sep 8, 1996, 3:00:00 AM9/8/96
to

Submitted-By: pe...@ifm.liu.se (Peter Eriksson)
Posting-Number: Volume 29, Issue 130
Archive-Name: pidentd-2.7/part07

#!/bin/sh
# This is part 07 of a multipart archive.

# ============= pidentd-2.7/src/kernel/other.c ==============


if test ! -d 'pidentd-2.7'; then
$echo 'x -' 'creating directory' 'pidentd-2.7'
mkdir 'pidentd-2.7'
fi

if test ! -d 'pidentd-2.7/src'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/src'
mkdir 'pidentd-2.7/src'
fi
if test ! -d 'pidentd-2.7/src/kernel'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/src/kernel'
mkdir 'pidentd-2.7/src/kernel'
fi
if test -f 'pidentd-2.7/src/kernel/other.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/other.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/other.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/other.c' &&
/*
** kernel/other.c Low level kernel access functions for a number of
** similar Unixes (all more or less based of 4.2BSD)
**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#ifdef HAVE_KVM
# include <kvm.h>
#else
# include "kvm.h"
#endif
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#ifdef __convex__
# define _KERN_UTIL
#endif
X
#include <sys/socketvar.h>
X
#ifdef __convex__
# undef _KERN_UTIL
#endif
X
#define KERNEL
X
#if defined(SUNOS35) || defined(__alpha)
# define nfile SOME_OTHER_VARIABLE_NAME
# define _KERNEL
#endif
X
#include <sys/file.h>
X
#if defined(SUNOS35) || defined(__alpha)
# undef nfile
# undef _KERNEL
#endif
X
#include <fcntl.h>
X
#if defined(ultrix)
# include <sys/dir.h>
# undef KERNEL
#endif
X
#if defined(sequent)
# undef KERNEL
#endif
X
#include <sys/user.h>
#include <sys/wait.h>
X
#ifdef KERNEL
# undef KERNEL
#endif
X
#ifdef __convex__
# include <sys/mbuf.h>
#endif
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#ifdef __alpha
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#endif
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
X
#ifdef __alpha
#include <netinet/tcpip.h>
#endif
X
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#ifdef MIPS
# include <sysv/sys/var.h>
extern int errno;
#endif
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#if (defined(ultrix) && defined(mips))
X /* Ultrix on DEC's MIPS machines */
X
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X
X { "file" },
X { "nfile" },
X { "tcb" },
X
#else
#ifdef MIPS /* MIPS RISC/OS */
X
#define N_FILE 0
#define N_V 1
#define N_TCB 2
X
X { "_file" },
X { "_v" },
X { "_tcb" },
X
#else
X
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X
X { "_file" },
X { "_nfile" },
X { "_tcb" },
X
#endif
#endif
X { "" }
};
X
static kvm_t *kd;
X
static struct file *xfile;
X
#ifndef ultrix
static int nfile;
#endif
X
#if defined(MIPS)
static struct var v;
#endif
X
static struct inpcb tcb;
X
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
#ifdef __alpha
X caddr_t addr;
#else
X long addr;
#endif
X char *buf;
X int len;
X char *what;
{
X
X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static struct socket *
X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X struct inpcb *head;
X
X if (!pcbp)
X return NULL;
X
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X return pcbp->inp_socket;
X } while (pcbp->inp_next != head &&
#ifdef __alpha
X getbuf((caddr_t) pcbp->inp_next,
#else
X getbuf((long) pcbp->inp_next,
#endif
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
#ifdef __alpha
X caddr_t addr;
#else
X long addr;
#endif
X struct socket *sockp;
X int i;
X struct ucred ucb;
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
#if defined(MIPS)
X if (!getbuf(nl[N_V].n_value, &v, sizeof(v), "v"))
X return -1;
X
X nfile = v.v_file;
X addr = nl[N_FILE].n_value;
#else /* not MIPS */
X if (!getbuf(nl[N_NFILE].n_value, &nfile, sizeof(nfile), "nfile"))
X return -1;
X
X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
#endif
X
X xfile = (struct file *) calloc(nfile, sizeof(struct file));
X if (!xfile)
X ERROR2("k_getuid: calloc(%d,%d)", nfile, sizeof(struct file));
X
X if (!getbuf(addr, xfile, sizeof(struct file)*nfile, "file[]"))
X return -1;
X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X /*
X ** Locate the file descriptor that has the socket in question
X ** open so that we can get the 'ucred' information
X */
X for (i = 0; i < nfile; i++)
X {
X if (xfile[i].f_count == 0)
X continue;
X
X if (xfile[i].f_type == DTYPE_SOCKET &&
X (struct socket *) xfile[i].f_data == sockp)
X {
#ifdef __convex__
X *uid = xfile[i].f_cred.cr_uid;
#else
X if (!getbuf(xfile[i].f_cred, &ucb, sizeof(ucb), "ucb"))
X return -1;
X
X *uid = ucb.cr_ruid;
#endif
X
X return 0;
X }
X }
X
X return -1;
}
X
SHAR_EOF
$shar_touch -am 0605150895 'pidentd-2.7/src/kernel/other.c' &&
chmod 0644 'pidentd-2.7/src/kernel/other.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/other.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/other.c:' 'MD5 check failed'
427a9b908ec303a46d387ad7169b3632 pidentd-2.7/src/kernel/other.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/other.c'`"
test 5671 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/other.c:' 'original size' '5671,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/ptx2.c ==============
if test -f 'pidentd-2.7/src/kernel/ptx2.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/ptx2.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/ptx2.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/ptx2.c' &&
/*
** kernel/ptx4.c PTX4 specific kernel access functions
**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
# include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>
X
#define _INKERNEL
#include <sys/file.h>
#include <sys/var.h>
#undef _INKERNEL
X
#include <fcntl.h>
X
#include <unistd.h>
#include <sys/fcntl.h>
#include <sys/stream.h>
#include <sys/stat.h>
#include <sys/user.h>
#include <sys/vnode.h>
#include <sys/sysmacros.h>
X
#include <sys/wait.h>
X
#undef _KMEMUSER
X
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/route.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_TCP_NHDRS 0
#define N_TCP_HASH 1
#define N_FILE 2
#define N_V 3
X
X { "tcp_nhdrs" },
X { "tcp_hash" },
X { "file" },
X { "v" },
X { "" }
};
X
static kvm_t *kd;
X
static struct inpcb_hdr *k_tcp_hash;
static struct inpcb_hdr *tcp_hash;
static int tcp_nhdrs;
static struct var v;
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static short
X getlist(faddr, fport, laddr, lport)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X int i;
X struct inpcb cur_pcb;
X struct inpcb *inp;
X
X for (i = 0; i < tcp_nhdrs; i++) {
X inp = tcp_hash[i].inph_next;
X /* Linked list on this hash chain ends when points to hash header */
X while (inp != (struct inpcb *) &k_tcp_hash[i]) {
X /* Can we get this PCB ? */
X if (!getbuf((long) inp, &cur_pcb, sizeof(struct inpcb), "tcblist"))
X break;
X
X if ( cur_pcb.inp_faddr == faddr->s_addr &&
X cur_pcb.inp_laddr == laddr->s_addr &&
X cur_pcb.inp_fport == fport &&
X cur_pcb.inp_lport == lport )
X return cur_pcb.inp_minordev;
X inp = cur_pcb.inp_next;
X }
X }
X
X return -1;
}
X
X
X
/*
** Return the user number for the connection owner in the int pointed
** at in the uid argument.
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;
X struct stat s;
X short tcpmajor; /* Major number of the tcp device */
X short sockp; /* Really a device minor number */
X struct file *filehead, file;
X int nfile;
X struct ucred ucb;
X int i;
X
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
X
X /* we just need to determine the major number of the tcp module, which
X is the minor number of the tcp clone device /dev/tcp */
X if (stat("/dev/tcp", &s))
X ERROR("stat(\"/dev/tcp\")");
X
X tcpmajor = minor(s.st_rdev);
X
X /* -------------------- TCP PCB LIST -------------------- */
X /* Get count of TCP hash headers */
X if (!getbuf(nl[N_TCP_NHDRS].n_value,
X &tcp_nhdrs, sizeof(tcp_nhdrs), "tcp_nhdrs"))
X return(-1);
X if ((tcp_hash = calloc(tcp_nhdrs, sizeof(struct inpcb_hdr))) == NULL)
X return(-1);
X k_tcp_hash = (struct inpcb_hdr *) nl[N_TCP_HASH].n_value;
X if (!getbuf(nl[N_TCP_HASH].n_value,
X tcp_hash, tcp_nhdrs * sizeof(struct inpcb_hdr), "tcp_hash"))
X return -1;
X
X sockp = getlist(faddr, fport, laddr, lport);
X
X if (sockp == -1)
X return -1;
X
X
X /*
X * Get the pointer to the head of the file list
X */
X if (!getbuf(nl[N_FILE].n_value, &filehead, sizeof(struct file *)))
X return -1;
X
X /* Get size of file array */
X if (!getbuf(nl[N_V].n_value, &v, sizeof(struct var )))
X return -1;
X
X nfile = v.v_file;
X
X for (i = 0; i < nfile ; i++) {
X struct vnode vnode;
X
X /*
X ** Grab a file record
X */
X if (!getbuf((long) &filehead[i], &file, sizeof(struct file), "file"))
X return -1;
X
X /* In use ? */
X if (file.f_count == 0)
X continue;
X
X /*
X ** Grab the vnode information to check whether this file is the
X ** correct major & minor char device
X */
X /* Extra check */
X if (!file.f_vnode)
X continue;
X if (!getbuf((off_t)file.f_vnode, &vnode, sizeof(struct vnode), "vnode"))
X return -1;
X
X if ((vnode.v_type == VCHR) && (major(vnode.v_rdev) == tcpmajor) &&
X (minor(vnode.v_rdev) == sockp))
X {
X /*
X ** We've found it!
X */
X if (!getbuf((off_t)file.f_cred, &ucb, sizeof(struct ucred), "cred"))
X return -1;
X
X *uid = ucb.cr_ruid;
X return 0;
X }
X
X }
X
X return -1;
}
SHAR_EOF
$shar_touch -am 0605150895 'pidentd-2.7/src/kernel/ptx2.c' &&
chmod 0644 'pidentd-2.7/src/kernel/ptx2.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/ptx2.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/ptx2.c:' 'MD5 check failed'
ff9a35aec4539f1c4bafe87e29ccdd1a pidentd-2.7/src/kernel/ptx2.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/ptx2.c'`"
test 5635 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/ptx2.c:' 'original size' '5635,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/ptx4.c ==============
if test -f 'pidentd-2.7/src/kernel/ptx4.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/ptx4.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/ptx4.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/ptx4.c' &&
/*
** kernel/ptx4.c PTX4 specific kernel access functions
**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#define _KMEMUSER
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
# include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>
X
#include <sys/file.h>
#include <sys/var.h>
X
#include <fcntl.h>
X
#include <unistd.h>
#include <sys/fcntl.h>
#include <sys/stream.h>
#include <sys/stat.h>
#include <sys/cred.h>
#include <sys/vnode.h>
#include <sys/sysmacros.h>
X
#include <sys/wait.h>
X
#undef _KMEMUSER
X
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/route.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_TCP_NHDRS 0
#define N_TCP_HASH 1
#define N_FILE 2
#define N_V 3
X
X { "tcp_nhdrs" },
X { "tcp_hash" },
X { "file" },
X { "v" },
X { "" }
};
X
static kvm_t *kd;
X
static struct inpcb_hdr *k_tcp_hash;
static struct inpcb_hdr *tcp_hash;
static int tcp_nhdrs;
static struct var v;
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static short
X getlist(faddr, fport, laddr, lport)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X int i;
X struct inpcb cur_pcb;
X struct inpcb *inp;
X
X for (i = 0; i < tcp_nhdrs; i++) {
X inp = tcp_hash[i].inph_next;
X /* Linked list on this hash chain ends when points to hash header */
X while (inp != (struct inpcb *) &k_tcp_hash[i]) {
X /* Can we get this PCB ? */
X if (!getbuf((long) inp, &cur_pcb, sizeof(struct inpcb), "tcblist"))
X break;
X
X if ( cur_pcb.inp_faddr == faddr->s_addr &&
X cur_pcb.inp_laddr == laddr->s_addr &&
X cur_pcb.inp_fport == fport &&
X cur_pcb.inp_lport == lport )
X return cur_pcb.inp_minordev;
X inp = cur_pcb.inp_next;
X }
X }
X
X return -1;
}
X
X
X
/*
** Return the user number for the connection owner in the int pointed
** at in the uid argument.
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;
X struct stat s;
X short tcpmajor; /* Major number of the tcp device */
X short sockp; /* Really a device minor number */
X struct file *filehead, file;
X int nfile;
X cred_t ucb;
X int i;
X
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
X
X /* we just need to determine the major number of the tcp module, which
X is the minor number of the tcp clone device /dev/tcp */
X if (stat("/dev/tcp", &s))
X ERROR("stat(\"/dev/tcp\")");
X
X tcpmajor = minor(s.st_rdev);
X
X /* -------------------- TCP PCB LIST -------------------- */
X /* Get count of TCP hash headers */
X if (!getbuf(nl[N_TCP_NHDRS].n_value,
X &tcp_nhdrs, sizeof(tcp_nhdrs), "tcp_nhdrs"))
X return(-1);
X if ((tcp_hash = calloc(tcp_nhdrs, sizeof(struct inpcb_hdr))) == NULL)
X return(-1);
X k_tcp_hash = (struct inpcb_hdr *) nl[N_TCP_HASH].n_value;
X if (!getbuf(nl[N_TCP_HASH].n_value,
X tcp_hash, tcp_nhdrs * sizeof(struct inpcb_hdr), "tcp_hash"))
X return -1;
X
X sockp = getlist(faddr, fport, laddr, lport);
X
X if (sockp == -1)
X return -1;
X
X
X /*
X * Get the pointer to the head of the file list
X */
X if (!getbuf(nl[N_FILE].n_value, &filehead, sizeof(struct file *)))
X return -1;
X
X /* Get size of file array */
X if (!getbuf(nl[N_V].n_value, &v, sizeof(struct var )))
X return -1;
X
X nfile = v.v_file;
X
X for (i = 0; i < nfile ; i++) {
X struct vnode vnode;
X
X /*
X ** Grab a file record
X */
X if (!getbuf((long) &filehead[i], &file, sizeof(struct file), "file"))
X return -1;
X
X /* In use ? */
X if (file.f_count == 0)
X continue;
X
X /*
X ** Grab the vnode information to check whether this file is the
X ** correct major & minor char device
X */
X /* Extra check */
X if (!file.f_vnode)
X continue;
X if (!getbuf((off_t)file.f_vnode, &vnode, sizeof(struct vnode), "vnode"))
X return -1;
X
X if ((vnode.v_type == VCHR) && (major(vnode.v_rdev) == tcpmajor) &&
X (minor(vnode.v_rdev) == sockp))
X {
X /*
X ** We've found it!
X */
X if (!getbuf((off_t)file.f_cred, &ucb, sizeof(cred_t), "cred"))
X return -1;
X
X *uid = ucb.cr_ruid;
X return 0;
X }
X
X }
X
X return -1;
}
SHAR_EOF
$shar_touch -am 0605150895 'pidentd-2.7/src/kernel/ptx4.c' &&
chmod 0644 'pidentd-2.7/src/kernel/ptx4.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/ptx4.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/ptx4.c:' 'MD5 check failed'
2e88f1770cd29713086a623626c87636 pidentd-2.7/src/kernel/ptx4.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/ptx4.c'`"
test 5607 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/ptx4.c:' 'original size' '5607,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/sco324.c ==============
if test -f 'pidentd-2.7/src/kernel/sco324.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/sco324.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/sco324.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/sco324.c' &&
/*
** kernel/sco324.c Kernel access functions to retrieve user number
**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
**
** fast COFF nlist() code written by Peter Wemm <pe...@DIALix.oz.au>
** This is up to 100 times faster than 3.2v1.0 to 3.2v4.1's nlist().
** This is slightly faster than the 3.2v4.2 nlist().
**
** Preliminary SCO support by Peter Wemm <pe...@DIALix.oz.au>
** Known Limitations:
** 1: Can only get *effective* UID of a socket. This is a real
** serious problem, as it looks like all rlogins, and rcp'c
** come from root. Any volunteers to emulate the fuser command
** and grope around the kernel user structs for file pointers
** to get the *real* uid?
** 2: THIS WILL NOT (YET!) WORK WITH SCO TCP 1.2.1 and hence ODT 3.0
*/
X
#include <stdio.h>
X
#include <filehdr.h>
#include <syms.h>
X
/* Name space collision */
#undef n_name
X
#include <nlist.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
#include <string.h>
X
/* how much buffer space to allocate to the symbol scanning */
/* Make this at least 4096, but much more than 8192 is a waste */
#define CHUNKSIZE 8192
X
int nlist(const char *filename, struct nlist *nl)
{
X FILHDR fh; /* COFF file header */
X SYMENT *se; /* pointer to a SYMENT */
X
X int i, n; /* iterative variables */
X
X long strsect; /* seek pos of extended string table */
X long strsize; /* byte size of extended string table*/
X
X int mchunk; /* max number of syments per chunk */
X int p; /* Symbol entry cache */
X int slotnum; /* Symbol entry cache */
X int chunknum; /* Symbol entry cache */
X int oldchunknum; /* Symbol entry cache */
X
X char *strtab = NULL; /* malloc'ed extended string table buffer */
X char *symchunk = NULL; /* malloc'ed SYMENT symbol entry cache */
X
X int fd = -1; /* File descriptor we are dealing with */
X
X int nument = 0; /* How many symbols in the array */
X int numremaining; /* Counter for symbols not found yet */
X struct nlist *nptr; /* Pointer to current struct nlist entry */
X
X /* a check from sanity claus */
X if (filename == NULL || nl == NULL)
X goto cleanup;
X
X /* count the entries in the request table */
X nptr = nl;
X while (nptr->n_name && strlen(nptr->n_name) > 0) {
X /* clear out the values as per the man-page */
X nptr->n_value = 0;
X nptr->n_scnum = 0;
X nptr->n_type = 0;
X nptr->n_sclass = 0;
X nptr->n_numaux = 0;
X nptr++;
X nument++;
X }
X
X /* early exit if nothing wanted.. return success */
X if (nument == 0)
X return 0;
X
X /* no point scanning whole list if we've found'em all */
X numremaining = nument;
X
X /* open the COFF file */
X fd = open(filename, O_RDONLY, 0);
X
X if (fd < 0)
X goto cleanup;
X
X /* read the COFF file header */
X if (read(fd, &fh, FILHSZ) < FILHSZ)
X goto cleanup;
X
X /* calcualte the starting offset of the string table */
X strsect = fh.f_symptr + (fh.f_nsyms * SYMESZ);
X
X /* read the length of the string table */
X if (lseek(fd, strsect, SEEK_SET) < 0)
X goto cleanup;
X if (read(fd, &strsize, sizeof(strsize)) < sizeof(strsize))
X goto cleanup;
X
X /* allocate a buffer for the string table */
X strtab = malloc(strsize);
X if (strtab == NULL)
X goto cleanup;
X
X /* allocate a buffer for the string table */
X mchunk = CHUNKSIZE / SYMESZ;
X symchunk = malloc(mchunk * SYMESZ);
X if (symchunk == NULL)
X goto cleanup;
X
X /* read the string table */
X if (lseek(fd, strsect, SEEK_SET) < 0)
X goto cleanup;
X if (read(fd, strtab, strsize) < strsize)
X goto cleanup;
X
X /* step through the symbol table */
X if (lseek(fd, fh.f_symptr, SEEK_SET) < 0)
X goto cleanup;
X
X oldchunknum = -1;
X p = 0; /* symbol slot number */
X for (i = 0; i < fh.f_nsyms; i++) {
X
X /* which "chunk" of the symbol table we want */
X chunknum = p / mchunk;
X
X /* Where in the chunk is the SYMENT we are up to? */
X slotnum = p % mchunk;
X
X /* load the chunk buffer if needed */
X if (chunknum != oldchunknum) {
X if (read(fd, symchunk, mchunk * SYMESZ) <= 0)
X goto cleanup;
X oldchunknum = chunknum;
X }
X
X /* and of course.. Get a pointer.. */
X se = (SYMENT *) (symchunk + slotnum * SYMESZ);
X
X /* next entry */
X p++;
X
X /* is it a long string? */
X if (se->n_zeroes == 0) {
X
X /* check table */
X for (n = 0; n < nument; n++) {
X if (strcmp(strtab + se->n_offset, nl[n].n_name) == 0) {
X /* load the requested table */
X nl[n].n_value = se->n_value;
X nl[n].n_scnum = se->n_scnum;
X nl[n].n_type = se->n_type;
X nl[n].n_sclass = se->n_sclass;
X nl[n].n_numaux = se->n_numaux;
X numremaining--;
X break;
X }
X }
X if (numremaining == 0)
X break; /* drop the for loop */
X
X } else {
X
X /* check table */
X for (n = 0; n < nument; n++) {
X
X if (strncmp(se->_n._n_name, nl[n].n_name, sizeof(se->_n._n_name)) == 0) {
X /* since we stopped at the 8th char, make sure that's all we want */
X if ((int)strlen(nl[n].n_name) <= 8) {
X /* load the requested table */
X nl[n].n_value = se->n_value;
X nl[n].n_scnum = se->n_scnum;
X nl[n].n_type = se->n_type;
X nl[n].n_sclass = se->n_sclass;
X nl[n].n_numaux = se->n_numaux;
X numremaining--;
X break;
X }
X }
X }
X if (numremaining == 0)
X break; /* drop the for loop */
X
X }
X
X /* does it have auxillary entries? */
X p += se->n_numaux;
X
X }
X
X free(strtab);
X free(symchunk);
X close(fd);
X
X return numremaining;
X
cleanup:
X if (fd >= 0)
X close(fd);
X if (strtab)
X free(strtab);
X if (symchunk)
X free(symchunk);
X return -1;
X
}
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/sysmacros.h>
#include <sys/ioctl.h>
X
#define _KERNEL
X
#include <sys/file.h>
#include <sys/dir.h>
X
#include <sys/inode.h>
X
#include <fcntl.h>
X
#include <sys/user.h>
#include <sys/wait.h>
X
#include <sys/var.h>
X
#undef _KERNEL
X
#include <sys/socket.h>
#include <sys/stream.h>
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_systm.h>
#include <netinet/in_pcb.h>
X
#include <netinet/ip_var.h>
X
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_debug.h>
X
#include <arpa/inet.h>
X
#include <sys/net/protosw.h>
#include <sys/net/socketvar.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
struct nlist nl[] =
{
#define N_V 0
#define N_TCB 1
X
X { "v" },
X { "tcb" },
X { "" }
};
X
static kvm_t *kd;
X
static struct var v;
X
static struct inpcb tcb;
X
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static struct inpcb *
X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X struct inpcb *head;
X
X if (!pcbp)
X return NULL;
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X {
X return pcbp;
X }
X
X } while (pcbp->inp_next != head &&
X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
static caddr_t
X followqueue(pcbp)
X struct inpcb *pcbp;
{
X queue_t *q;
X queue_t qbuf;
X int n = 1;
X
X if (!pcbp)
X return NULL;
X
X q = pcbp->inp_q;
X
X while (getbuf((long) q, &qbuf, sizeof(qbuf), "queue_t inp_q"))
X {
X q = qbuf.q_next;
X n++;
X if (qbuf.q_next == NULL)
X return qbuf.q_ptr;
X }
X
X return NULL;
}
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X int i;
X struct inode inode;
X struct stat s;
X struct inpcb *sockp;
X caddr_t cad;
X struct socket socket;
X struct file file;
X short sockmajor;
X short sockminor;
X
X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X if (sockp->inp_protoopt & SO_IMASOCKET)
X {
X
X cad = followqueue(sockp); /* socket pointer */
X
X if (!getbuf((long)cad, &socket, sizeof(struct socket), "socket"))
X return -1;
X
X if (!getbuf((long)socket.so_fp, &file, sizeof(struct file), "file"))
X return -1;
X
X if (!getbuf((long)file.f_inode, &inode, sizeof(struct inode), "inode"))
X return -1;
X
X *uid = inode.i_uid;
X return 0;
X } else {
X
X /* we just need to determine the major number of the tcp module, which
X is the minor number of the tcp clone device /dev/tcp */
X if (stat("/dev/inet/tcp", &s))
X ERROR("stat(\"/dev/inet/tcp\")");
X
X sockmajor = major(s.st_rdev);
X sockminor = sockp->inp_minor;
X
X if (!getbuf(nl[N_V].n_value, &v, sizeof(struct var), "var"))
X return -1;
X
X for (i = 0; i < v.v_inode; i++) {
X
X if (!getbuf(((long) v.ve_inode) + i * sizeof(struct inode),
X &inode, sizeof(struct inode), "inode"))
X return -1;
X
X if (((inode.i_ftype & IFMT) == IFCHR) &&
X (major(inode.i_rdev) == sockmajor) &&
X (minor(inode.i_rdev) == sockminor))
X {
X *uid = inode.i_uid;
X return 0;
X }
X }
X return -1;
X }
}
X
X
SHAR_EOF
$shar_touch -am 0812010593 'pidentd-2.7/src/kernel/sco324.c' &&
chmod 0644 'pidentd-2.7/src/kernel/sco324.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/sco324.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/sco324.c:' 'MD5 check failed'
c61593cf3cdcdff689b4bfbec7a678cc pidentd-2.7/src/kernel/sco324.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/sco324.c'`"
test 10406 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/sco324.c:' 'original size' '10406,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/sco32_42+5.c ==============
if test -f 'pidentd-2.7/src/kernel/sco32_42+5.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/sco32_42+5.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/sco32_42+5.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/sco32_42+5.c' &&
/*
X * kernel/sco3242_325.c - kernel access functions for SCO 3.2v4.2
X * and 3.2v5.0.0
X */
X
X
/*
X * Copyright 1995 Purdue Research Foundation, West Lafayette, Indiana
X * 47907. All rights reserved.
X *
X * Written by Victor A. Abell <a...@cc.purdue.edu>
X *
X * This software is not subject to any license of the American Telephone
X * and Telegraph Company or the Regents of the University of California.
X *
X * Permission is granted to anyone to use this software for any purpose on
X * any computer system, and to alter it and redistribute it freely, subject
X * to the following restrictions:
X *
X * 1. Neither the authors nor Purdue University are responsible for any
X * consequences of the use of this software.
X *
X * 2. The origin of this software must not be misrepresented, either by
X * explicit claim or by omission. Credit to the authors and Purdue
X * University must appear in documentation and sources.
X *
X * 3. Altered versions must be plainly marked as such, and must not be
X * misrepresented as being the original software.
X *
X * 4. This notice may not be removed or altered.
X */
X
/*
X * MODIFICATION HISTORY
X *
X * 95/06/05 created by Victor A. Abell <a...@cc.purdue.edu>
X *
X *
X * 95/07/30 modified by Bela Lubkin <be...@sco.com>
X * -- Added code to find the real socket head, which may be hidden
X * behind an in-kernel rlogind/telnetd stream head.
X *
X * 95/07/31 modified by Victor A. Abell <a...@cc.purdue.edu>
X * -- Moved reading of TCP control block into k_getuid() so it will
X * be initialized at each call of k_getuid(), thus enabling the
X * -b abd -w modes to function properly.
X */
X
#include <stdio.h>
#include <fcntl.h>
#include <nlist.h>
#include <malloc.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
X
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stream.h>
#include <sys/file.h>
#include <sys/immu.h>
#include <sys/inode.h>
#include <sys/region.h>
#include <sys/proc.h>
#include <sys/socket.h>
X
#if sco<500
#include <sys/net/protosw.h>
#include <sys/net/socketvar.h>
#else /* sco>=500 */
#include <sys/protosw.h>
#include <sys/socketvar.h>
#endif /* sco<500 */
X
#include <sys/sysi86.h>
#include <sys/dir.h>
#include <sys/user.h>
#include <sys/var.h>
X
#include <sys/netinet/in.h>
#include <sys/net/route.h>
#include <sys/netinet/in_pcb.h>
X
#if sco>=500
#define _INKERNEL
#include <sys/net/iknt.h>
#undef _INKERNEL
#endif /* sco>=500 */
X
/*
X * This confusing sequence of redefinitions of xdevmap allows the sizing
X * of the copy of the kernel's xdevmap[] table to be dynamic, based on the
X * kernel's nxdevmaps value.
X *
X * The net result is that there is a dummy struct XDEVMAP[1] that is never
X * used. The copy of the kernel's xdevmap[] table is stored in the space
X * malloc()'d in k_open() and addressed by Xdevmap. The last redefinition
X * of xdevmap to Xdevmap causes the macroes of <sys/sysmacros.h> to use
X * Xdevmap.
X *
X * All this is done: 1) to avoid having to allocate a large amount of fixed
X * space in advance to a copy of the kernel's xdevmap; and 2) to keep CC from
X * complaining about the absence of a "struct xdevmap xdevmap[]," matching
X * the "extern struct xdevmap xdevmap[]" declaration in <sys/sysmacros.h>,
X * while still allowing the use of the equivalent of a "struct xdevmap *"
X * construct instead, particularly with the kernel forms of the major() and
X * minor() macroes.
X */
X
#define xdevmap XDEVMAP
#define _INKERNEL
#include <sys/sysmacros.h>
#undef _INKERNEL
static struct XDEVMAP XDEVMAP[1], *Xdevmap;
#undef xdevmap
#define xdevmap Xdevmap
X
#include "identd.h"
#include "error.h"
X
X
/*
X * Local definitions
X */
X
#define KMEM "/dev/kmem" /* kernel memory device */
#define N_UNIX "/unix" /* kernel image */
#define PROCBFRD 32 /* proc structure buffer size */
X
X
/*
X * Local variables
X */
X
static int Kmem = -1; /* kernel memory file descriptor */
static off_t Kp = (off_t)NULL; /* proc table address */
static int nxdevmaps = -1; /* maximum kernel xdevmap[] index */
X
struct nlist Nl[] = { /* kernel image name list */
X
X { "nxdevmaps", 0, 0, 0, 0, 0 },
#define X_NXD 0
X
X { "proc", 0, 0, 0, 0, 0 },
#define X_PROC 1
X
X { "sockdev", 0, 0, 0, 0, 0 },
#define X_SDEV 2
X
X { "socktab", 0, 0, 0, 0, 0 },
#define X_STAB 3
X
X { "tcb", 0, 0, 0, 0, 0 },
#define X_TCB 4
X
X { "v", 0, 0, 0, 0, 0 },
#define X_VAR 5
X
X { "xdevmap", 0, 0, 0, 0, 0 },
#define X_XDEV 6
X
#if sco>=500
X { "ikntrinit", 0, 0, 0, 0, 0 },
#define X_IKNTR 7
#endif /* sco>=500 */
X
X { NULL, 0, 0, 0, 0, 0 }
};
X
static char *Psb; /* proc structure buffer */
static int Sdev; /* kernel's socket device */
static off_t Stab; /* kernel's socket table address */
static char *Uab; /* user area buffer */
static struct var Var; /* kernel var struct */
X
X
/*
X * k_open() - open access to kernel memory
X */
X
int
k_open()
{
X int err, i;
X size_t len;
X
X if ((Kmem = open(KMEM, O_RDONLY, 0)) < 0)
X ERROR1("main: open(%s)", KMEM);
/*
X * Get the kernel name list and check it.
X */
X if (nlist(N_UNIX, Nl) < 0)
X ERROR1("main: nlist(%s)", N_UNIX);
X for (err = i = 0; Nl[i].n_name; i++) {
X if (Nl[i].n_value == (long)NULL) {
X
#if sco>=500
X if (i == X_IKNTR)
X
X /*
X * The ikntrinit kernel entry point is optional, so
X * it's OK if nlist() fails to find its address.
X */
X continue;
#endif /* sco>=500 */
X
X if (syslog_flag)
X syslog(LOG_ERR, "no kernel address for %s",
X Nl[i].n_name);
X (void) fprintf(stderr, "no kernel address for %s\n",
X Nl[i].n_value);
X err++;
X }
X }
X if (err)
X
k_open_err_exit:
X
X ERROR("main: k_open");
/*
X * Read or set kernel values:
X *
X * Kp = process table address;
X * Sdev = socket device major number;
X * Stab = socket table address;
X * Var = kernel environment structure.
X */
X Kp = (off_t)Nl[X_PROC].n_value;
X if (kread((off_t)Nl[X_SDEV].n_value, (char *)&Sdev, sizeof(Sdev))) {
X if (syslog_flag)
X syslog(LOG_ERR, "sockdev read (%#x)",
X Nl[X_SDEV].n_name);
X (void) fprintf(stderr, "sockdev read (%#x)\n",
X Nl[X_SDEV].n_name);
X err++;
X }
X Stab = (off_t)Nl[X_STAB].n_value;
X if (kread((off_t)Nl[X_VAR].n_value, (char *)&Var, sizeof(Var))) {
X if (syslog_flag)
X syslog(LOG_ERR, "var struct read (%#x)",
X Nl[X_VAR].n_name);
X (void) fprintf(stderr, "var struct read (%#x)\n",
X Nl[X_VAR].n_name);
X err++;
X }
X if (err)
X goto k_open_err_exit;
/*
X * Get extended device table parameters. These are needed by the kernel
X * versions of the major() and minor() device numbers; they identify socket
X * devices and assist in the conversion of socket device numbers to socket
X * table addresses.
X */
X if (kread((off_t)Nl[X_NXD].n_value, (char *)&nxdevmaps,
X sizeof(nxdevmaps))
X )
X ERROR1("main: k_open nxdevmaps read (%#x)", Nl[X_NXD].n_name);
X if (nxdevmaps < 0)
X ERROR1("main: k_open nxdevmaps size (%d)", nxdevmaps);
X len = (size_t)((nxdevmaps + 1) * sizeof(struct XDEVMAP));
X if ((Xdevmap = (struct XDEVMAP *)malloc(len)) == (struct XDEVMAP *)NULL)
X ERROR1("main: xdevmap malloc (%d)", len);
X if (kread((off_t)Nl[X_XDEV].n_value, (char *)Xdevmap, len))
X ERROR1("main: xdevmap read (%#x)", Nl[X_XDEV].n_value);
/*
X * Allocate user area and proc structure buffers.
X */
X if ((Uab = (char *)malloc(MAXUSIZE * NBPC)) == (char *)NULL)
X ERROR1("main: k_open user struct size (%d)", MAXUSIZE * NBPC);
X if ((Psb = (char *)malloc(sizeof(struct proc) * PROCBFRD)) == NULL)
X ERROR1("main: k_open proc stuct size (%d)",
X sizeof(struct proc) * PROCBFRD);
X return(0);
}
X
X
/*
X * k_getuid() - get User ID for local and foreign TCP address combination
X *
X * returns: -1 if address combination not found
X * 0 if address combination found and:
X * *uid = User ID of process with open socket file
X * having the address combination
X */
X
int
k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr; /* foreign network address */
X int fport; /* foreign port */
X struct in_addr *laddr; /* local network address */
X int lport; /* local port */
X int *uid; /* returned UID pointer */
{
X struct file f;
X int i, j, nf, pbc, px;
X struct inode in;
X struct proc *p;
X struct inpcb pcb, tcb;
X struct queue *q, qb;
X off_t sa, spa;
X struct user *u;
X
#if sco>=500
X iknt_t ikb;
#endif /* sco>=500 */
X
/*
X * Search the kernel's TCP control block chain for one whose local and foreign
X * addresses match.
X */
X if (kread((off_t)Nl[X_TCB].n_value, (char *)&tcb, sizeof(tcb))) {
X if (syslog_flag)
X syslog(LOG_ERR, "TCP struct read (%#x)",
X Nl[X_TCB].n_name);
X (void) fprintf(stderr, "TCB struct read (%#x)\n",
X Nl[X_TCB].n_name);
X ERROR("k_getuid: no TCP control block head");
X }
X i = 0;
X pcb = tcb;
X do {
X if (pcb.inp_faddr.s_addr == faddr->s_addr
X && pcb.inp_laddr.s_addr == laddr->s_addr
X && pcb.inp_fport == fport && pcb.inp_lport == lport) {
X i = 1;
X break;
X }
X } while (pcb.inp_next != (struct inpcb *)NULL
X && pcb.inp_next != tcb.inp_prev
X && kread((off_t)pcb.inp_next, (char *)&pcb, sizeof(pcb)) == 0);
X if ( ! i)
X return(-1);
/*
X * Follow the stream input queue for the TCP control block to its end
X * to get the socket address.
X */
X for (q = pcb.inp_q, qb.q_ptr = (caddr_t)NULL; q; q = qb.q_next) {
X if (kread((off_t)q, (char *)&qb, sizeof(qb)))
X return(-1);
X }
X
#if sco>=500
/*
X * If this is an in-kernel rlogind/telnetd stream head, follow its private
X * pointer back to the original stream head where the socket address may
X * be found.
X */
X if (Nl[X_IKNTR].n_value && qb.q_qinfo
X && qb.q_qinfo == (struct qinit *)Nl[X_IKNTR].n_value) {
X if (kread((off_t)qb.q_ptr, (char *)&ikb, sizeof(ikb)))
X return(-1);
X qb.q_ptr = ikb.ik_oqptr;
X }
#endif /* sco>=500 */
X
X if (qb.q_ptr == (caddr_t)NULL)
X return(-1);
/*
X * Search the process table, the user structures associated with its proc
X * structures, and the open file structures associated with the user structs
X * to find an inode whose major device is Sdev and whose socket structure's
X * address matches the address identified from the TCB control block scan.
X */
X for (pbc = px = 0, u = (struct user *)Uab; px < Var.v_proc; px++) {
X if (px >= pbc) {
X
X /*
X * Refill the proc struct buffer.
X */
X i = Var.v_proc - px;
X if (i > PROCBFRD)
X i = PROCBFRD;
X j = kread((off_t)(Kp + (px * sizeof(struct proc))),
X Psb, sizeof(struct proc) * i);
X pbc = px + i;
X if (j) {
X px += i;
X continue;
X }
X p = (struct proc *)Psb;
X } else
X p++;
X if (p->p_stat == 0 || p->p_stat == SZOMB)
X continue;
X /*
X * Get the user area for the process and follow its file structure
X * pointers to their inodes. Compare the addresses of socket
X * structures to the address located in the TCP control block scan
X * and return the User ID of the first process that has a match.
X */
X if (sysi86(RDUBLK, (int)p->p_pid, Uab, MAXUSIZE * NBPC) == -1)
X continue;
X nf = u->u_nofiles ? u->u_nofiles : Var.v_nofiles;
X for (i = 0; i < nf; i++) {
X if (u->u_ofile[i] == (struct file *)NULL
X || kread((off_t)u->u_ofile[i], (char *)&f, sizeof(f))
X || f.f_count == 0
X || f.f_inode == (struct inode *)NULL
X || kread((off_t)f.f_inode, (char *)&in, sizeof(in)))
X continue;
X if ((in.i_ftype & IFMT) != IFCHR
X || major(in.i_rdev) != Sdev)
X continue;
X spa = Stab + (minor(in.i_rdev)*sizeof(struct socket *));
X if (kread(spa, (char *)&sa, sizeof(sa)))
X continue;
X if ((caddr_t)sa == qb.q_ptr) {
X *uid = (int)p->p_uid;
X return(0);
X }
X }
X }
X return(-1);
}
X
X
/*
X * kread() - read from kernel memory
X */
X
int
kread(addr, buf, len)
X off_t addr; /* kernel memory address */
X char *buf; /* buffer to receive data */
X unsigned len; /* length to read */
{
X int br;
X
X if (lseek(Kmem, (off_t)addr, SEEK_SET) == (off_t)-1L)
X return(1);
X if ((br = read(Kmem, buf, len)) < 0)
X return(1);
X return(((unsigned)br == len) ? 0 : 1);
}
X
SHAR_EOF
$shar_touch -am 0803172795 'pidentd-2.7/src/kernel/sco32_42+5.c' &&
chmod 0644 'pidentd-2.7/src/kernel/sco32_42+5.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/sco32_42+5.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/sco32_42+5.c:' 'MD5 check failed'
90fe831c853b8a1375398832ecb68276 pidentd-2.7/src/kernel/sco32_42+5.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/sco32_42+5.c'`"
test 11768 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/sco32_42+5.c:' 'original size' '11768,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/sunos4.c ==============
if test -f 'pidentd-2.7/src/kernel/sunos4.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/sunos4.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/sunos4.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/sunos4.c' &&
/*
** kernel/sunos4.c SunOS 4 kernel access fnctions
**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 8 Mar 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include <kvm.h>
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>
X
#define KERNEL
#include <sys/file.h>
X
#include <fcntl.h>
X
#include <sys/user.h>
#include <sys/wait.h>
X
#undef KERNEL
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X
#ifdef i386
X { "file" },
X { "nfile" },
X { "tcb" },
#else
X { "_file" },
X { "_nfile" },
X { "_tcb" },
#endif
X { "" }
};
X
static kvm_t *kd;
X
static struct file *xfile;
X
static struct inpcb tcb;
X
X
int k_open()
{
X int rcode;
X
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if ((rcode = kvm_nlist(kd, nl)) != 0)
X if (rcode != 3)
X ERROR1("main: kvm_nlist, rcode = %d", rcode);
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X
X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static struct socket *
X getlist(pcbp, faddr, fport, laddr, lport)
struct inpcb *pcbp;
struct in_addr *faddr;
int fport;
struct in_addr *laddr;
int lport;
{
X struct inpcb *head;
X int limiter = 65536; /* avoid infinite loop <um...@nn.solan.chubu.ac.jp> */
X
X if (!pcbp)
X return NULL;
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X return pcbp->inp_socket;
X if (--limiter <= 0) /* avoid infinite loop <um...@nn.solan.chubu.ac.jp> */
X break;
X
X } while (pcbp->inp_next != head &&
X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;
X
X struct socket *sockp;
X int i;
X struct ucred ucb;
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
X if (!getbuf(nl[N_NFILE].n_value, &nfile, sizeof(nfile), "nfile"))
X return -1;
X
X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
X
X xfile = (struct file *) calloc(nfile, sizeof(struct file));
X if (!xfile)
X ERROR2("k_getuid: calloc(%d,%d)", nfile, sizeof(struct file));
X
X if (!getbuf(addr, xfile, sizeof(struct file)*nfile, "file[]"))
X return -1;
X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X /*
X ** Locate the file descriptor that has the socket in question
X ** open so that we can get the 'ucred' information
X */
X for (i = 0; i < nfile; i++)
X {
X if (xfile[i].f_count == 0)
X continue;
X
X if (xfile[i].f_type == DTYPE_SOCKET &&
X (struct socket *) xfile[i].f_data == sockp)
X {
X if (!getbuf(xfile[i].f_cred, &ucb, sizeof(ucb), "ucb"))
X return -1;
X
X *uid = ucb.cr_ruid;
X return 0;
X }
X }
X
X return -1;
}
X
SHAR_EOF
$shar_touch -am 0811220196 'pidentd-2.7/src/kernel/sunos4.c' &&
chmod 0644 'pidentd-2.7/src/kernel/sunos4.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/sunos4.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/sunos4.c:' 'MD5 check failed'
deb34dffa469fe9166586b4ecd09ed0e pidentd-2.7/src/kernel/sunos4.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/sunos4.c'`"
test 4380 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/sunos4.c:' 'original size' '4380,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/sunos5.c ==============
if test -f 'pidentd-2.7/src/kernel/sunos5.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/sunos5.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/sunos5.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/sunos5.c' &&
/*
** kernel/sunos5.c SunOS 5 kernel access functions
**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Author: Casper Dik <cas...@fwi.uva.nl>
**
** Last update: 13 Oct 1994
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#if 0
#define DEBUGHASH
#endif
X
#define _KMEMUSER
#define _KERNEL
X
/* some definition conflicts. but we must define _KERNEL */
X
#define exit kernel_exit
#define strsignal kernel_strsignal
X
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/signal.h>
#include <sys/param.h>
#include <netinet/in.h>
X
#include <stdio.h>
#include <kvm.h>
#include <nlist.h>
#include <math.h>
#include <sys/fcntl.h>
#include <sys/cred.h>
#include <sys/file.h>
#include <sys/stream.h>
#include <inet/common.h>
#include <inet/ip.h>
X
#ifdef ipc_tcp_laddr
#define SOLARIS24 1
#define BROKEN_HASH
/*
X * In Solaris 2.4 there have been a number of changes:
X * - the ipc_s structure had its field names changed
X * - the file global no longer exists in the kernel.
X * (this sort of makes sense for MP machines: having to go through
X * one global lock for all file opens/closes doesn't scale
X * very well)
X */
#endif
X
#undef exit
#undef strsignal
X
#include <unistd.h>
#include <string.h>
#include <stddef.h>
X
#include "identd.h"
#include "error.h"
X
#define N_FANOUT 0
#ifndef SOLARIS24
#define N_FILE 1
#endif
X
struct nlist nl[] = {
X { "ipc_tcp_fanout" },
#ifndef SOLARIS24
X { "file" },
#endif
X { 0 },
};
X
X
static kvm_t *kd;
X
X
int k_open()
#ifdef SOLARIS24_WORKAROUND
{
X return 0;
}
X
static int local_k_open()
#endif
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
#ifdef SOLARIS24_WORKAROUND
static void local_k_close()
{
X kvm_close(kd);
}
#endif
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X int i, status;
X
X
X i = 0;
X while (i < 10 && (status = kvm_read(kd, addr, buf, len)) < 0)
X ++i;
X
X if (status < 0)
X return 0;
X
X return 1;
}
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
#ifdef SOLARIS24_WORKAROUND
{
X extern int local_k_getuid();
X int result;
X
X
X local_k_open();
X result = local_k_getuid(faddr, fport, laddr, lport, uid);
X local_k_close();
X
X return result;
}
X
X
static int local_k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
#endif
{
X queue_t sqr
#ifndef SOLARIS24
X ,*qp, *pq
#endif
X ;
X ipc_t ic, *icp;
X unsigned short uslp, usfp;
X unsigned int offset;
#ifndef SOLARIS24
X unsigned long fp;
#endif
X file_t tf;
X unsigned long zero = 0;
X u16 *ports;
X u32 *locaddr, *raddr;
#ifdef DEBUGHASH
X int i;
#endif
#ifdef SOLARIS24
X struct proc *procp;
#endif
#ifdef BROKEN_HASH
X ipc_t *alticp = 0;
X unsigned int altoffset;
#endif
X
X usfp = fport;
X uslp = lport;
X
#ifdef BROKEN_HASH
X /* code used (ports > 8) instead of (ports >> 8)
X /* low byte of local port number not used, low byte of
X local addres is used
X ip_bind in the kernel (+ approx 0x4c0)
X srl %i3, 0x18, %o0
X xor %i2, %o0, %o0
X srl %i3, 0x10, %o1
X xor %o0, %o1, %o0
X xor %o0, %l0, %o0
X xor %o0, %i3, %o0
X and %o0, 0xff, %o0
X sethi %hi(0xfc1d9c00), %o2
X or %o2, 0x1c0, %o2 ! ipc_tcp_fanout
X
X */
#if (defined(BIG_ENDIAN) || defined(_BIG_ENDIAN))
X altoffset = usfp >> 8;
#else
X altoffset = uslp >> 8;
#endif
X altoffset ^= usfp ^ uslp;
X altoffset ^= faddr->S_un.S_un_b.s_b4;
X if (uslp > 8 || usfp != 0)
X altoffset ^= 1;
X altoffset &= 0xff;
X if (!getbuf(nl[N_FANOUT].n_value + sizeof(ipc_t *) * altoffset,
X (char *) &alticp,
X sizeof(ipc_t *),
X "ipc_tcp_fanout[altoffset]"))
X alticp = 0;
#endif
X offset = usfp ^ uslp;
X offset ^= (unsigned) faddr->S_un.S_un_b.s_b4 ^ (offset >> 8);
X offset &= 0xff;
X
X if (!getbuf(nl[N_FANOUT].n_value + sizeof(ipc_t *) * offset,
X (char *) &icp,
X sizeof(ipc_t *),
X "ipc_tcp_fanout[offset]"))
X return -1;
X
#ifdef BROKEN_HASH
X if (icp == 0 && alticp != 0) {
X icp = alticp;
X alticp = 0;
X }
#endif
#ifndef DEBUGHASH
X if (icp == 0) {
X syslog(LOG_INFO, "k_getuid: Hash miss");
X return -1;
X }
#endif
X
#ifdef SOLARIS24
X locaddr = &ic.ipc_tcp_laddr;
X raddr = &ic.ipc_tcp_faddr;
X ports = (u16*) &ic.ipc_tcp_ports;
#else
X locaddr = (u32*) &ic.ipc_tcp_addr[0];
X raddr = (u32*) &ic.ipc_tcp_addr[2];
X ports = &ic.ipc_tcp_addr[4];
#endif
X
#ifdef DEBUGHASH
X for (i = 0; i < 256; i++) {
X if (!getbuf(nl[N_FANOUT].n_value + sizeof(ipc_t *) * i,
X (char *) &icp,
X sizeof(ipc_t *),
X "ipc_tcp_fanout[offset]"))
X return -1;
X if (icp == 0)
X continue;
#endif
X
X while (icp) {
X if (!getbuf((unsigned long) icp,
X (char *) &ic,
X sizeof(ic),
X "hash entry"))
X return -1;
X
#if 0
X printf("E: %s:%d -> ", inet_ntoa(*laddr), ntohs(ports[1]));
X printf("%s:%d\n", inet_ntoa(*faddr), ntohs(ports[0]));
#endif
X if (usfp == ports[0] && /* remote port */
X uslp == ports[1] && /* local port */
#if 0
X memcmp(&laddr->s_addr, locaddr, 4) == 0 && /* local */
#else
X (memcmp(&laddr->s_addr, locaddr, 4) == 0 ||
X /* In SunOS 5.3, the local part can be all zeros */
X memcmp(&zero, locaddr, 4) == 0) /* local */ &&
#endif
X memcmp(&faddr->s_addr, raddr, 4) == 0)
X break;
X icp = ic.ipc_hash_next;
#ifdef BROKEN_HASH
X if (icp == 0 && alticp != 0) {
X icp = alticp;
X alticp = 0;
X }
#endif
X }
#ifdef DEBUGHASH
X if (icp)
X break;
X } /* for i */
X if (icp)
X printf("found, offset = %x, i = %x, i ^ offset = %x\n", offset,i,
X offset ^ i);
#endif
X
X if (!icp) {
X syslog(LOG_INFO, "k_getuid: Port not found");
X return -1;
X }
X
X if (!getbuf((unsigned long) ic.ipc_rq+offsetof(queue_t, q_stream),
X (char *) &sqr.q_stream,
X sizeof(sqr.q_stream),
X "queue.q_stream"))
X return -1;
X
X /* at this point sqr.q_stream holds the pointer to the stream we're
X interested in. Now we're going to find the file pointer
X that refers to the vnode that refers to this stream stream */
X
#ifdef SOLARIS24
X /* Solaris 2.4 no longer links all file pointers together with
X * f_next, the only way seems to be scrounging them from
X * the proc/user structure, ugh.
X */
X
X if (kvm_setproc(kd) != 0)
X return -1;
X
X while ((procp = kvm_nextproc(kd)) != NULL) {
X struct uf_entry files[NFPCHUNK];
X int nfiles = procp->p_user.u_nofiles;
X unsigned long addr = (unsigned long) procp->p_user.u_flist;
X
X while (nfiles > 0) {
X int nread = nfiles > NFPCHUNK ? NFPCHUNK : nfiles;
X int size = nread * sizeof(struct uf_entry);
X int i;
X struct file *last = 0;
X vnode_t vp;
X
X if (!getbuf(addr, (char*) &files[0], size, "ufentries")) {
X return -1;
X }
X for (i = 0; i < nread; i++) {
X if (files[i].uf_ofile == 0 || files[i].uf_ofile == last)
X continue;
X if (!getbuf((unsigned long) (last = files[i].uf_ofile),
X (char*) &tf, sizeof(tf), "file pointer")) {
X return -1;
X }
X
X if (!tf.f_vnode)
X continue;
X
X if (!getbuf((unsigned long) tf.f_vnode +
X offsetof(vnode_t,v_stream),
X (char *) &vp.v_stream,
X sizeof(vp.v_stream),"vnode.v_stream"))
X return -1;
X
X if (vp.v_stream == sqr.q_stream) {
X cred_t cr;
X if (!getbuf((unsigned long) tf.f_cred +
X offsetof(cred_t, cr_ruid),
X (char *) &cr.cr_ruid,
X sizeof(cr.cr_ruid),
X "cred.cr_ruid"))
X return -1;
X *uid = cr.cr_ruid;
X return 0;
X }
X }
X nfiles -= nread;
X addr += size;
X }
X }
#else
X fp = nl[N_FILE].n_value;
X for (;fp;fp = (unsigned long) tf.f_next) {
X vnode_t vp;
X
X if (!getbuf(fp, (char *) &tf, sizeof(file_t),"file pointer"))
X return -1;
X
X if (!tf.f_vnode)
X continue;
X
X if (!getbuf((unsigned long) tf.f_vnode + offsetof(vnode_t,v_stream),
X (char *) &vp.v_stream,
X sizeof(vp.v_stream),"vnode.v_stream"))
X return -1;
X
X if (vp.v_stream == sqr.q_stream) {
X cred_t cr;
X if (!getbuf((unsigned long) tf.f_cred + offsetof(cred_t, cr_ruid),
X (char *) &cr.cr_ruid,
X sizeof(cr.cr_ruid),
X "cred.cr_ruid"))
X return -1;
X *uid = cr.cr_ruid;
X return 0;
X }
X }
#endif
X return -1;
}
SHAR_EOF
$shar_touch -am 0811235996 'pidentd-2.7/src/kernel/sunos5.c' &&
chmod 0644 'pidentd-2.7/src/kernel/sunos5.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/sunos5.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/sunos5.c:' 'MD5 check failed'
c8d846f2cf55a956dd629bb28cc9b347 pidentd-2.7/src/kernel/sunos5.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/sunos5.c'`"
test 8786 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/sunos5.c:' 'original size' '8786,' 'current size' "$shar_count!"
fi
fi
: || $echo 'restore of' 'pidentd-2.7/src/kernel/svr4.c' 'failed'
$echo 'End of part' '7,' 'continue with part' '8'
exit 0

Peter Eriksson

unread,
Sep 8, 1996, 3:00:00 AM9/8/96
to

Submitted-By: pe...@ifm.liu.se (Peter Eriksson)
Posting-Number: Volume 29, Issue 129
Archive-Name: pidentd-2.7/part06

#!/bin/sh
# This is part 06 of a multipart archive.

# ============= pidentd-2.7/src/kernel/irix5.c ==============


if test ! -d 'pidentd-2.7'; then
$echo 'x -' 'creating directory' 'pidentd-2.7'
mkdir 'pidentd-2.7'
fi

if test ! -d 'pidentd-2.7/src'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/src'
mkdir 'pidentd-2.7/src'
fi
if test ! -d 'pidentd-2.7/src/kernel'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/src/kernel'
mkdir 'pidentd-2.7/src/kernel'
fi

if test -f 'pidentd-2.7/src/kernel/irix5.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/irix5.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/irix5.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/irix5.c' &&
/*
** kernel/irix5.c Kernel access functions to retrieve user number


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 26 Jan 1995


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
**
**

** Hacked to work with irix5, 27 May 1994 by
** Robert Banz (ba...@umbc.edu) Univ. of Maryland, Baltimore County
**
** does some things the irix4 way, some the svr4 way, and some just the
** silly irix5 way.
**
** Hacked to work with irix5.3, 26 Jan 1995 by
** Frank Maas (ma...@wi.leidenuniv.nl) Leiden University, The Netherlands
** but all the credits go to Robert Banz (again), who found out about the
** hacks and included them in sources for pidentd-2.3.
**
*/


#define _KMEMUSER
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>

#include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>

#include <sys/cred.h>
#include <sys/socketvar.h>
#ifdef IRIX53
/** hack 1: IRIX 5.3 uses 64bit int's for file offsets in the kernel **/
/** but a 32bit int is used in user programs. sadly though, **/
/** there is no way of using <sys/file.h> properly, so we **/
/** create our own struct. **/
typedef struct file {
X struct file *f_next;
X struct file *f_prev;
X int f_flag; /* ushort in <sys/file.h> */
X cnt_t f_count;
X unsigned short f_lock; /* lock_t (uint) in <sys/file.h> */
X struct vnode *f_vnode;
X __uint64_t f_offset; /* off_t (long) in <sys/file.h> */
X struct cred *f_cred;
X cnt_t f_msgcount;
} file_t;
#elif defined(IRIX62)
typedef struct file {
X struct file *f_next;
X struct file *f_prev;
X __uint64_t f_offset; /* off_t (long) in <sys/file.h> */
X lock_t f_lock; /* lock_t (uint) in <sys/file.h> */
X ushort f_flag; /* ushort in <sys/file.h> */
X cnt_t f_count;
X cnt_t f_msgcount;
X mutex_t f_offlock;
X struct vnode *f_vnode;
X struct cred *f_cred;
} file_t;
#else
#include <sys/file.h>
#endif /* IRIX53 */
X
#if defined(IRIX6) || (defined(IRIX62) && (_MIPS_SZPTR == 64))
#define nlist nlist64
#endif
X
/** Well... here some problems begin: when upgrading IRIX to 5.3 the **/
/** `inst' program shows one of its peculiar bugs: the file vnode.h **/
/** has changed location in between versions and now the file is up- **/
/** grade first (new package) and then deleted (old package). So if **/
/** you have problems finding this file: reinstall eoe1.sw.unix. **/
#include <sys/vnode.h>
X
#include <fcntl.h>
X


#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X

#ifdef IRIX62


#include <netinet/in_systm.h>
#include <netinet/ip.h>
#endif
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>

#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_FILE 0

#define N_TCB 1
X
X { "file" },


X { "tcb" },
X { "" }
};
X
static kvm_t *kd;
X

static struct file *xfile;
static int nfile;


X
static struct inpcb tcb;
X

X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X

/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.

** (this is basically the same as the irix4 code)


*/
static struct socket *
X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{

#ifdef IRIX62
X int num = pcbp->inp_u.pcb_u2.u2_tablesz;
X struct inpcb **u2_cache;
X
X u2_cache = malloc(num * sizeof(struct inpcb *));
X if (!u2_cache) return NULL;
X
X getbuf((long)pcbp->inp_u.pcb_u2.u2_cache, u2_cache, num * sizeof(struct inpcb *), "tcblist");
X
X for (num-- ; num >= 0; num--) {
X if (!u2_cache[num]) continue;
X if (!getbuf((long)u2_cache[num], pcbp, sizeof(struct inpcb), "tcbcacheentry")) break;
X if (pcbp->inp_faddr.s_addr != faddr->s_addr) continue;
X if (pcbp->inp_laddr.s_addr != laddr->s_addr) continue;
X if (pcbp->inp_fport != fport) continue;
X if (pcbp->inp_lport != lport) continue;
X free(u2_cache);


X return pcbp->inp_socket;
X }

X
X free(u2_cache);
X return NULL;
#else
X struct inpcb *head;
/** hack 2: there is a slight problem when scanning through lists that **/
/** change while identd scans; to prevent infinite loops a **/
/** counter is introduced **/
X int count = 0xffff;


X
X if (!pcbp)
X return NULL;
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport ) {
X return pcbp->inp_socket;
X }

X } while ((count--) && pcbp->inp_next != head &&


X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));

X return NULL;
#endif


}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{

X struct socket *sockp;
X struct file *fp;
X struct file file;
X int count = 0xffff; /** Yep, it's hack 2 again **/


X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb")) {
X return -1;
X }
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X

X /* -------------------- OPEN FILE TABLE ----------------- */
X
X fp = (struct file *) nl[N_FILE].n_value;
X
X if (!getbuf(fp,&file,sizeof(struct file), "file"))
X return -1;
X
X do {
X struct vnode tvnode;
X struct cred creds;
X
X if (getbuf(file.f_vnode,&tvnode,sizeof(struct vnode),"vnode")){
X if ((void *) sockp == (void *) tvnode.v_data) {
X /* have a match! return the user information! */
X if (getbuf(file.f_cred,&creds,sizeof(struct cred),"cred")) {
X *uid = creds.cr_ruid;
X return 0;
X }
X break;
X }
X }
X /* if it's the end of the list _or_ we can't get the next
X entry, then get out of here...*/
X if ((!file.f_next) ||
X (!getbuf(file.f_next,&file,sizeof(struct file), "file")))
X break;
X
X } while (file.f_next != fp && (count--));
X /* heck, if we ever get here, something is really messed up.*/
X
X syslog(LOG_ERR,"ident: k_getuid: lookup failure.");
X return -1;
}
SHAR_EOF
$shar_touch -am 0812011596 'pidentd-2.7/src/kernel/irix5.c' &&
chmod 0644 'pidentd-2.7/src/kernel/irix5.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/irix5.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/irix5.c:' 'MD5 check failed'
4f45a00bdc50defbcd816c8cfc904baa pidentd-2.7/src/kernel/irix5.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/irix5.c'`"
test 7394 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/irix5.c:' 'original size' '7394,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/aux.c ==============
if test -f 'pidentd-2.7/src/kernel/aux.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/aux.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/aux.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/aux.c' &&
/*
** kernel/aux.c Low level kernel access functions for A/UX


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 20 April 1993


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X

#include <sys/config.h>


X
#include <sys/socketvar.h>
X
#define KERNEL

X

struct nlist nl[3];


X
static kvm_t *kd;
X
static struct file *xfile;
X

static int nfile;


X
static struct inpcb tcb;
X
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X

X /* Kludge - have to do it here or A/UX 3 will barf */
#define N_FILE 0
#define N_TCB 1
#ifdef n_name
X strcpy(nl[N_FILE].n_name,"file");
X strcpy(nl[N_TCB].n_name,"tcb");
X strcpy(nl[2].n_name,"");
#else
X nl[N_FILE].n_name = "file";
X nl[N_TCB].n_name = "tcb";
X nl[2].n_name = "";
#endif


X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X

X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;
X struct socket *sockp;
X int i;
X struct ucred ucb;
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */

X nfile = NFILE;

$shar_touch -am 0425230193 'pidentd-2.7/src/kernel/aux.c' &&
chmod 0644 'pidentd-2.7/src/kernel/aux.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/aux.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/aux.c:' 'MD5 check failed'
67b839b4c00419e8b9b1ae7d7591b706 pidentd-2.7/src/kernel/aux.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/aux.c'`"
test 4240 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/aux.c:' 'original size' '4240,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/aux301.c ==============
if test -f 'pidentd-2.7/src/kernel/aux301.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/aux301.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/aux301.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/aux301.c' &&
/*
** kernel/aux301.c Low level kernel access functions for
** A/UX 3.0.1 and newer


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 17 September 1995 by Herb Weiner <he...@wiskit.com>


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>

#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X

#include <sys/config.h>


X
#include <sys/socketvar.h>
X
#define KERNEL

X


#include <sys/file.h>
X
#include <fcntl.h>
X
#include <sys/user.h>
#include <sys/wait.h>
X
#undef KERNEL
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>

#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X

#include <a.out.h>
X
#include <sys/mmu.h>
#include <sys/var.h>
X
/*--------------------------------------------------------------
X * The Apple-supplied nlist(3c) function is seriously broken.
X * Here's a replacement.
X *--------------------------------------------------------------
X */
X
/*
X * Copyright (c) 1989 The Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X * must display the following acknowledgement:
X * This product includes software developed by the University of
X * California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X * may be used to endorse or promote products derived from this software
X * without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
/*--------------------------------------------------------------------------
X * Ported to Apple A/UX by Herb Weiner <he...@wiskit.com> September 16, 1995
X *--------------------------------------------------------------------------
X */
X
typedef struct nlist NLIST;
#define ISVALID(p) (p->n_nptr && p->n_nptr[0])
X
int nlist(name, list)
X char *name;
X NLIST *list;
{
X register NLIST *p;
X register NLIST *s;
X struct filehdr ebuf;
X FILE *fstr;
X FILE *fsym;
X NLIST nbuf;
X off_t strings_offset;
X off_t symbol_offset;
X off_t symbol_size;
X int entries;
X int len;
X int maxlen;
X char sbuf [256];
X char *np;
X
X entries = -1;
X
X if (!(fsym = fopen (name, "r")))
X return(-1);
X
X if (fread((char *)&ebuf, sizeof(struct filehdr), 1, fsym) != 1
X || BADMAG(&ebuf))
X goto done1;
X
X symbol_offset = ebuf.f_symptr;
X symbol_size = ebuf.f_nsyms * sizeof (NLIST);
X strings_offset = symbol_offset + symbol_size;
X if (fseek(fsym, symbol_offset, SEEK_SET))
X goto done1;
X
X if (!(fstr = fopen(name, "r")))
X goto done1;
X
X /*
X * clean out any left-over information for all valid entries.
X * Type and value defined to be 0 if not found; historical
X * versions cleared other and desc as well. Also figure out
X * the largest string length so don't read any more of the
X * string table than we have to.
X */
X for (p = list, entries = maxlen = 0; ISVALID(p); ++p, ++entries)
X {
X p->n_value = 0;
X p->n_type = 0;
X p->n_scnum = 0;
X p->n_sclass = 0;
X p->n_numaux = 0;
X if ((len = strlen(p->n_nptr)) > maxlen)
X maxlen = len;
X }
X if (maxlen >= sizeof(sbuf))
X {
X (void)fprintf(stderr, "nlist: symbol too large.\n");
X entries = -1;
X goto done2;
X }
X
X for (s = &nbuf; symbol_size > 0; symbol_size -= sizeof(NLIST))
X {
X if (fread((char *)s, sizeof(NLIST), 1, fsym) != 1)
X goto done2;
X if (s->n_zeroes == 0)
X {
X if (!s->n_offset)
X continue;
X if (fseek(fstr, strings_offset + s->n_offset, SEEK_SET))
X goto done2;
X (void)fread(sbuf, sizeof(sbuf[0]), maxlen, fstr);
X np = sbuf;
X }
X else
X np = s->n_name;
X
X for (p = list; ISVALID(p); p++)
X if (!strcmp(p->n_nptr, np))
X {
X p->n_value = s->n_value;
X p->n_type = s->n_type;
X p->n_scnum = s->n_scnum;
X p->n_sclass = s->n_sclass;
X p->n_numaux = s->n_numaux;
X if (!--entries)
X goto done2;
X }
X }
done2: (void)fclose(fstr);
done1: (void)fclose(fsym);
X return(entries);
}
X
/*--------------------------------------------------------------
X * End of replacement nlist(3c)
X *--------------------------------------------------------------
X */


X
extern void *calloc();
extern void *malloc();
X

#define N_FILE 0
#define N_TCB 1
#define N_V 2
#define N_LAST 3
X
struct nlist nl [N_LAST+1];


X
static kvm_t *kd;
X
static struct file *xfile;
X

static int nfile;


X
static struct inpcb tcb;
X
X
int k_open()
{

X path_unix = "/unix";
X path_kmem = "/dev/kmem";


X
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X

X /* Kludge - have to do it here or A/UX 3 will barf */
X
X nl[N_FILE].n_nptr = "file_pageh";
X nl[N_TCB].n_nptr = "tcb";
X nl[N_V].n_nptr = "v";
X nl[N_LAST].n_nptr = "";


X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X

X if (nlist(path_unix,nl) != 0)
X ERROR("main: nlist");


X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)
X long addr;
X char *buf;
X int len;
X char *what;
{
X

X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;

X struct socket *sockp;
X int i;
X struct ucred ucb;

X int nf;
X struct file *xf;
X struct var my_var;
X int FILESPPG = (PAGESIZE / sizeof (struct file)); /* Files per Page */
X int file_page_size = FILESPPG * sizeof (struct file);


X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
X

X if (!getbuf(nl[N_V].n_value, &my_var, sizeof(my_var), "v"))
X return -1;
X
X /*-----------------------------------------------------
X * Round UP number of files to integral number of pages
X * The number of pages ACTUALLY allocated may be fewer,
X * if not in use.
X *-----------------------------------------------------
X */
X
X if (my_var.v_file <= 3)
X ERROR("k_getuid: System name list out of date");
X
X if (my_var.v_file % FILESPPG)
X nf = (my_var.v_file / FILESPPG + 1) * FILESPPG;
X else
X nf = my_var.v_file;


X
X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
X

X xfile = (struct file *) calloc (nf, sizeof(struct file));
X if (!xfile)
X ERROR2("k_getuid: calloc(%d,%d)", nf, sizeof(struct file));
X
X xf = xfile;
X nfile = 0;
X
X while ((addr != 0) && (nfile < nf))
X {
X /*----------------------------------------------------
X * Read in linked list of pages of file table entries.
X *----------------------------------------------------
X */
X
X if (!getbuf(addr, xf, file_page_size, "file[]"))
X return -1;
X
X nfile += FILESPPG;
X xf += FILESPPG;
X
X if (!getbuf(addr + PAGESIZE - sizeof (addr), &addr, sizeof(addr), "&file"))


X return -1;
X }
X

X
SHAR_EOF
$shar_touch -am 1009083995 'pidentd-2.7/src/kernel/aux301.c' &&
chmod 0644 'pidentd-2.7/src/kernel/aux301.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/aux301.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/aux301.c:' 'MD5 check failed'
1a3647bd87ffd111be5b9192f9688b98 pidentd-2.7/src/kernel/aux301.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/aux301.c'`"
test 9954 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/aux301.c:' 'original size' '9954,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/bsdi.c ==============
if test -f 'pidentd-2.7/src/kernel/bsdi.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/bsdi.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/bsdi.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/bsdi.c' &&
/*
** kernel/bsdi.c Low level kernel access functions for BSDI


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 7 April 1994


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X

#include <paths.h>


#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include <kvm.h>
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>
X

#include <sys/uio.h>
X
#define KERNEL
X
#include <sys/file.h>
X
#undef KERNEL
X
#if !defined(BSD4_4) || (defined(_BSDI_VERSION) && (_BSDI_VERSION <= 199312))
# include <sys/kinfo.h>
#else
# include <sys/sysctl.h>
# define KINFO_PROC_ALL KERN_PROC_ALL


#endif
X
#include <fcntl.h>
X

#include <sys/user.h>
X
#include <sys/wait.h>
X
#include <sys/filedesc.h>
#include <sys/proc.h>
X
#if !defined(BSD4_4) || (defined(_BSDI_VERSION) && (_BSDI_VERSION <= 199312))
# include <sys/kinfo_proc.h>


#endif
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X

#include <netinet/in_systm.h>
#include <netinet/ip.h>


X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X

#include <pwd.h>


X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X

X { "_filehead" },
X { "_nfiles" },
X { "_tcb" },
X { "" }
};
X


X
static struct file *xfile;

static int nfile;


X
static struct inpcb tcb;

static kvm_t *kd = NULL;


X
int k_open()
{
X /*
X ** Open the kernel memory device
X */

X if ((kd = (kvm_t *)kvm_openfiles(path_unix, path_kmem, NULL, O_RDONLY, NULL)) == NULL)


X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */

X if (kvm_nlist(kd, nl) < 0)

static struct socket *
X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X struct inpcb *head;
X
X if (!pcbp)
X return NULL;
X
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
{
X return pcbp->inp_socket;
}
X } while (pcbp->inp_next != head &&

X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X

/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;

X struct socket *sockp;
X int i;

X struct kinfo_proc *kp;
X int nentries;
X
X if ((kp = kvm_getprocs(kd, KINFO_PROC_ALL, 0, &nentries)) == NULL)
X {
X ERROR("k_getuid: kvm_getprocs");


X return -1;
X }
X

X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X /*
X ** Locate the file descriptor that has the socket in question
X ** open so that we can get the 'ucred' information
X */

X for (i = 0; i < nentries; i++)
X {
X if(kp[i].kp_proc.p_fd != NULL)
X {
X int j;
X struct filedesc pfd;
X struct file **ofiles;
X struct file ofile;
X
X if(!getbuf(kp[i].kp_proc.p_fd, &pfd, sizeof(pfd), "pfd"))
X return(-1);
X
X ofiles = (struct file **) malloc(pfd.fd_nfiles * sizeof(struct file *));
X
X if(!getbuf(pfd.fd_ofiles, ofiles,
X pfd.fd_nfiles * sizeof(struct file *), "ofiles"))
X {
X free(ofiles);
X return(-1);
X }
X
X for(j = 0; j < pfd.fd_nfiles; j ++)
X {
X if(!getbuf(ofiles[j], &ofile, sizeof(struct file), "ofile"))
X {
X free(ofiles);
X return(-1);
X }
X
X if(ofile.f_count == 0)
X continue;
X
X if(ofile.f_type == DTYPE_SOCKET &&
X (struct socket *) ofile.f_data == sockp)
X {
X struct pcred pc;
X
X if(!getbuf(kp[i].kp_proc.p_cred, &pc, sizeof(pc), "pcred"))
X return(-1);
X
X *uid = pc.p_ruid;
X free(ofiles);


X return 0;
X }
X }
X

X free(ofiles);


X }
X }
X
X return -1;
}
X
SHAR_EOF

$shar_touch -am 0811215796 'pidentd-2.7/src/kernel/bsdi.c' &&
chmod 0644 'pidentd-2.7/src/kernel/bsdi.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/bsdi.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/bsdi.c:' 'MD5 check failed'
37bc045dc31b3cf4792643c6e982e929 pidentd-2.7/src/kernel/bsdi.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/bsdi.c'`"
test 5056 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/bsdi.c:' 'original size' '5056,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/freebsd.c ==============
if test -f 'pidentd-2.7/src/kernel/freebsd.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/freebsd.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/freebsd.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/freebsd.c' &&
/*
** kernel/freebsd.c Low level kernel access functions for FreeBSD 2.x


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 11 Aug 1996


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X

#include <paths.h>


#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include <kvm.h>
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>

#include <sys/sysctl.h>
#include <sys/socket.h>
X
#include <sys/queue.h>
#include <sys/uio.h>


X
#include <sys/socketvar.h>
X
#define KERNEL

X
#include <sys/file.h>
X
#undef KERNEL
X
#include <fcntl.h>
X
#include <sys/time.h>


#include <sys/user.h>
#include <sys/wait.h>
X

#include <sys/filedesc.h>
#include <sys/proc.h>


X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_systm.h>

#include <netinet/ip.h>


X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X

#include <pwd.h>


X
#include "identd.h"
#include "error.h"
X

#ifdef INPLOOKUP_SETLOCAL
#define _HAVE_OLD_INPCB
#endif


X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{

#define N_TCB 0
X
X { "_tcb" },


X { "" }
};
X
static kvm_t *kd;
X

static int nfile;
X
#ifdef _HAVE_OLD_INPCB
static struct inpcb tcb;
#else
static struct inpcbhead tcb;
#endif


X
int k_open()
{
X /*
X ** Open the kernel memory device
X */

X if ((kd = (kvm_t *)kvm_openfiles(path_unix, path_kmem, NULL, O_RDONLY, NULL)) == NULL)


X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */

X if (kvm_nlist(kd, nl) < 0)

/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static struct socket *

#ifdef _HAVE_OLD_INPCB


X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;

#else
X getlist(pcbhead, faddr, fport, laddr, lport)
X struct inpcbhead *pcbhead;
#endif


X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{

#ifdef _HAVE_OLD_INPCB
X struct inpcb *head;
#else
X struct inpcb *head, pcbp;
#endif
X
#ifdef _HAVE_OLD_INPCB


X if (!pcbp)
X return NULL;

#else
X head = pcbhead->lh_first;
X if (!head)
X return NULL;
#endif
X
X
#ifdef _HAVE_OLD_INPCB


X head = pcbp->inp_prev;

#endif
X do
X {
#ifdef _HAVE_OLD_INPCB


X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X return pcbp->inp_socket;
X } while (pcbp->inp_next != head &&

X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));

#else
X if (!getbuf((long) head, &pcbp, sizeof(struct inpcb), "tcblist"))
X break;
X if (pcbp.inp_faddr.s_addr == faddr->s_addr &&
X pcbp.inp_fport == fport &&
X pcbp.inp_lport == lport )
X return(pcbp.inp_socket);
X head = pcbp.inp_list.le_next;
X } while (head != NULL);
#endif


X
X return NULL;
}
X

/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;

X struct socket *sockp;
X int i;

X struct kinfo_proc *kp;
X int nentries;
X
X if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL)
X {
X ERROR("k_getuid: kvm_getprocs");


X return -1;
X }
X

X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X

#ifdef _HAVE_OLD_INPCB


X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;

#endif


X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X /*
X ** Locate the file descriptor that has the socket in question
X ** open so that we can get the 'ucred' information
X */

X for (i = 0; i < nentries; i++)
X {
X if(kp[i].kp_proc.p_fd != NULL)
X {
X int j;
X struct filedesc pfd;
X struct file **ofiles;
X struct file ofile;
X
X if(!getbuf(kp[i].kp_proc.p_fd, &pfd, sizeof(pfd), "pfd"))
X return(-1);
X
X ofiles = (struct file **) malloc(pfd.fd_nfiles * sizeof(struct file *));
X
X if(!getbuf(pfd.fd_ofiles, ofiles,
X pfd.fd_nfiles * sizeof(struct file *), "ofiles"))
X {
X free(ofiles);
X return(-1);
X }
X
X for(j = 0; j < pfd.fd_nfiles; j ++)
X {
X if(!getbuf(ofiles[j], &ofile, sizeof(struct file), "ofile"))
X {
X free(ofiles);
X return(-1);
X }
X
X if(ofile.f_count == 0)
X continue;
X
X if(ofile.f_type == DTYPE_SOCKET &&
X (struct socket *) ofile.f_data == sockp)
X {
X struct pcred pc;
X
X if(!getbuf(kp[i].kp_proc.p_cred, &pc, sizeof(pc), "pcred"))
X return(-1);
X
X *uid = pc.p_ruid;
X free(ofiles);


X return 0;
X }
X }
X

X free(ofiles);


X }
X }
X
X return -1;
}
SHAR_EOF

$shar_touch -am 0811202696 'pidentd-2.7/src/kernel/freebsd.c' &&
chmod 0644 'pidentd-2.7/src/kernel/freebsd.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/freebsd.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/freebsd.c:' 'MD5 check failed'
db383a962ede77d6713c66dece39f021 pidentd-2.7/src/kernel/freebsd.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/freebsd.c'`"
test 5444 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/freebsd.c:' 'original size' '5444,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/hpux.c ==============
if test -f 'pidentd-2.7/src/kernel/hpux.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/hpux.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/hpux.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/hpux.c' &&
/*
** kernel/hpux.c Low level kernel access functions for HP-UX 7 & 8


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X

#include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>

#include <sys/file.h>
X
#include <fcntl.h>
X
#include <sys/user.h>
#include <sys/wait.h>
X

#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X

#ifndef HPUX7
# include <arpa/inet.h>


#endif
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{

#if ((defined(hp9000s800) || defined(__hp9000s800)) && !defined(HPUX7))
X
X /* HP9000 Series 800, HP-UX 8.0 */


X
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X
X { "file" },
X { "nfile" },
X { "tcb" },
X
#else

#if ((defined(hp9000s800) || defined(__hp9000s800)) && defined(HPUX7))
X
X /* HP9000 Series 800, HP-UX 7.0 */


X
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X
X { "file" },
X { "nfile" },

X { "tcp_cb" },
#else
#ifdef HPUX7 /* HP-UX 7.0 */


X
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X

X { "_file" },
X { "_nfile" },

X { "_tcp_cb" },
X
#else /* SUN or old BSD or other systems */

X
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X

X { "_file" },
X { "_nfile" },
X { "_tcb" },
X
#endif
#endif
#endif
X { "" }
};
X
static kvm_t *kd;
X
static struct file *xfile;

static int nfile;

static struct socket *
X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X struct inpcb *head;
X
X if (!pcbp)
X return NULL;
X
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X return pcbp->inp_socket;
X } while (pcbp->inp_next != head &&

$shar_touch -am 0516233693 'pidentd-2.7/src/kernel/hpux.c' &&
chmod 0644 'pidentd-2.7/src/kernel/hpux.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/hpux.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/hpux.c:' 'MD5 check failed'
94bbef10a8375d60e5f641a53c393ad5 pidentd-2.7/src/kernel/hpux.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/hpux.c'`"
test 4769 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/hpux.c:' 'original size' '4769,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/irix4.c ==============
if test -f 'pidentd-2.7/src/kernel/irix4.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/irix4.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/irix4.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/irix4.c' &&
/*
** kernel/irix4.c Kernel access functions to retrieve user number


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
**

** Last update: 28 June 1993
**
** Modified by Christopher Kranz, Princeton University to work with suid
** root programs. The method for which one descends through the kernel
** process structures was borrowed from lsof 2.10 written by Victor A. Abell,
** Purdue Research Foundation.


*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include "kvm.h"
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>
X

#include <sys/proc.h>
#include <sys/syssgi.h>


X
#define _KERNEL
X
#include <sys/file.h>

X
#include <sys/inode.h>
X
#include <fcntl.h>
X
#include <sys/user.h>
#include <sys/wait.h>
X

#undef _KERNEL


X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_FILE 0

#define N_V 1
#define N_TCB 2

#define N_PROC 3
X
X { "file" },


X { "v" },
X { "tcb" },

X { "proc" },


X { "" }
};
X
static kvm_t *kd;
X

static struct file *xfile;
static int nfile;


X
static struct var v;
X
static struct inpcb tcb;
X
X

X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X

X } while (pcbp->inp_next != head &&
X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;

X struct socket *sockp;
X int i;

X struct inode inode;
X long paddr;
X struct proc *pp;
X struct proc ps;
X long pa;
X int px;
X int nofiles;
X struct user *up;
X char *uu;
X size_t uul;
X struct file **fp;


X struct file f;
X

X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */

X if (!getbuf(nl[N_V].n_value, &v, sizeof(v), "v"))
X return -1;
X
X nfile = v.v_file;
X addr = nl[N_FILE].n_value;

X
X xfile = (struct file *) calloc(nfile, sizeof(struct file));
X if (!xfile)
X ERROR2("k_getuid: calloc(%d,%d)", nfile, sizeof(struct file));
X
X if (!getbuf(addr, xfile, sizeof(struct file)*nfile, "file[]"))
X return -1;
X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X

X /* -------------------- SCAN PROCESS TABLE ------------------- */
X if ( (paddr = nl[N_PROC].n_value) == NULL ) {
X if (debug_flag && syslog_flag)
X syslog(LOG_DEBUG, "k_getuid: paddr == NULL");


X return -1;
X }
X

X paddr &= 0x7fffffff;
X
X uul = (size_t) (sizeof(struct user)
X + (v.v_nofiles * sizeof(struct file *)));
X
X if ( (uu=(char *)malloc(uul)) == (char *)NULL )
X return -1;
X
X fp = (struct file **)(uu + sizeof(struct user));
X up = (struct user *)uu;
X
X for (pp=&ps, px=0 ; px < v.v_proc ; px++) {
X pa = paddr + (long)(px * sizeof(struct proc));
X
X if ( !getbuf(pa, (char *)&ps, sizeof(ps), "proc") )
X continue;
X
X if ( pp->p_stat == 0 || pp->p_stat == SZOMB )
X continue;
X
X /* ------------------- GET U_AREA FOR PROCESS ----------------- */
X if ((i=syssgi(SGI_RDUBLK, pp->p_pid, uu, uul)) < sizeof(struct user))
X continue;
X
X /* ------------------- SCAN FILE TABLE ------------------------ */
X if (i <= sizeof(struct user)
X || ((long)up->u_ofile - UADDR) != sizeof(struct user))
X nofiles = 0;
X else
X nofiles = (i - sizeof(struct user)) / sizeof(struct file *);
X
X for (i = 0 ; i < nofiles ; i++) {
X if (fp[i] == NULL)
X break;
X
X if (!getbuf(fp[i], &f, sizeof(f), "file"))
X return -1;
X
X if ( f.f_count == 0 )
X continue;
X
X if (!getbuf(f.f_inode, &inode, sizeof(inode), "inode"))
X return -1;
X
X if ((inode.i_ftype & IFMT) == IFCHR && soc_fsptr(&inode) == sockp) {
X *uid = up->u_ruid;
X return 0;
X }
X } /* scan file table */
X } /* scan process table */
X return -1;
}
SHAR_EOF
$shar_touch -am 0810030293 'pidentd-2.7/src/kernel/irix4.c' &&
chmod 0644 'pidentd-2.7/src/kernel/irix4.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/irix4.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/irix4.c:' 'MD5 check failed'
499c044dfc5d9c21ebceec64da645c87 pidentd-2.7/src/kernel/irix4.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/irix4.c'`"
test 5810 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/irix4.c:' 'original size' '5810,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/kvm.h ==============
if test -f 'pidentd-2.7/src/kernel/kvm.h' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/kvm.h' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/kvm.h' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/kvm.h' &&
/*
** kvm.h Header file for the kernel virtual memory access
** routines
**
** This code is in the public domain and may be used freely by anyone


** who wants to.
**

** Last update: 19 Oct 1992
**
** Author: Peter Eriksson <p...@lysator.liu.se>
*/
X
#ifndef __KVM_H__
#define __KVM_H__
X
typedef struct
{
X int fd;
X char *namelist;
#ifdef BSD43
X int swap_fd;
X int mem_fd;
X
X int procidx;
X int nproc;
X struct pte *Usrptma;
X struct pte *usrpt;
X struct proc *proctab;
#endif
} kvm_t;
X
X
extern kvm_t *kvm_open();
extern int kvm_close();
extern int kvm_nlist();
extern int kvm_read();
X
#ifdef BSD43
extern struct user *kvm_getu();
extern struct proc *kvm_getproc();
extern struct proc *kvm_nextproc();
extern int kvm_setproc();
#endif
X
#endif
SHAR_EOF
$shar_touch -am 1020003092 'pidentd-2.7/src/kernel/kvm.h' &&
chmod 0644 'pidentd-2.7/src/kernel/kvm.h' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/kvm.h' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/kvm.h:' 'MD5 check failed'
79949caa51a68722f554b1fbeb8abda2 pidentd-2.7/src/kernel/kvm.h
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/kvm.h'`"
test 786 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/kvm.h:' 'original size' '786,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/linux.c ==============
if test -f 'pidentd-2.7/src/kernel/linux.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/linux.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/linux.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/linux.c' &&
/*
** kernel/linux.c Linux 0.99.13q or later access functions


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 17 Nov 1993


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>

#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
X
int k_open()
{


X return 0;
}
X
X

int k_getuid(struct in_addr *faddr, int fport,
X struct in_addr *laddr, int lport,
X int *uid)
{
X FILE *fp;
X long dummy;
X char buf[512];
X struct in_addr myladdr, myraddr;
X int mylport, myrport;
X
X fport = ntohs(fport);
X lport = ntohs(lport);


X
X /*
X ** Open the kernel memory device
X */

X if ((fp = fopen("/proc/net/tcp", "r"))==NULL)


X {
X return -1;
X }
X

X /* eat header */
X fgets(buf,sizeof(buf)-1,fp);
X while (fgets(buf, sizeof(buf)-1, fp))
X {
X if (sscanf(buf,"%d: %lX:%x %lX:%x %x %lX:%lX %x:%lX %lx %d",
X &dummy, &myladdr, &mylport, &myraddr, &myrport,
X &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
X uid) == 12)
X {
X if (myladdr.s_addr==laddr->s_addr && mylport==lport &&
X myraddr.s_addr==faddr->s_addr && myrport==fport)
X {
X fclose(fp);


X return 0;
X }
X }
X }
X

X fclose(fp);
X return -1;
}
SHAR_EOF
$shar_touch -am 1117213593 'pidentd-2.7/src/kernel/linux.c' &&
chmod 0644 'pidentd-2.7/src/kernel/linux.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/linux.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/linux.c:' 'MD5 check failed'
bc6e4f7410078ae5b2803058b9f834bf pidentd-2.7/src/kernel/linux.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/linux.c'`"
test 1350 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/linux.c:' 'original size' '1350,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/next_mach.c ==============
if test -f 'pidentd-2.7/src/kernel/next_mach.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/next_mach.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/next_mach.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/next_mach.c' &&
/*
** kernel/next_mach.c Low level kernel access functions for 4.3BSD


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**
** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>

#include <sys/types.h>
#include <sys/param.h>
#include <netdb.h>


#include <nlist.h>
#include <pwd.h>
#include <signal.h>

X
#include "kvm.h"
#include "paths.h"
X
#include <sys/socket.h>
#include <sys/socketvar.h>
X
#include <sys/ioctl.h>
X
#ifndef NeXT31
# define KERNEL
# define KERNEL_FEATURES
#else
# define KERNEL_FILE


#endif
X
#include <sys/file.h>
X

#ifndef NeXT31
# undef KERNEL
# undef KERNEL_FEATURES
#else
# undef KERNEL_FILE
#endif
X
#include <sys/user.h>


X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>

#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>


#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X

#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>


X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X

X { {"_file_list"} },
X { {"_max_file"} },
X { {"_tcb"} },
X { {""} }
};


X
static kvm_t *kd;
X
X
int k_open()

***
*** Traverse the inpcb list until a match is found
*** Returns NULL if no match.
***
**/
X
static
struct socket *getlist(struct inpcb *pcbp,
X struct in_addr *faddr,
X int fport,
X struct in_addr *laddr,
X int lport)


{
X struct inpcb *head;
X
X if (!pcbp)

X return NULL; /* Someone gave us a duff one here */


X
X head = pcbp->inp_prev;
X do {

X if (pcbp->inp_faddr.s_addr == faddr->s_addr &&


X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X return pcbp->inp_socket;
X

X } while (pcbp->inp_next != head &&
X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X

X return NULL; /* Not found */


}
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{

X static struct ucred ucb;
X struct socket *sockp;
X int nfile;
X struct inpcb tcb; /* */
X struct file file_entry;
X void * addr;


X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X

X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */

X /* So now we hit the fun Mach kernel structures */
X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file_table"))
X return -1;
X
X /* We only use nfile as a failsafe in case something goes wrong! */


X if (!getbuf(nl[N_NFILE].n_value, &nfile, sizeof(nfile), "nfile"))
X return -1;
X

X file_entry.links.next = addr;
X /* ------------------- SCAN FILE TABLE ------------------------ */
X do {
X if (!getbuf((unsigned long) file_entry.links.next, &file_entry,
X sizeof(file_entry), "struct file"))
X return -1;
X
X if (file_entry.f_count &&
X file_entry.f_type == DTYPE_SOCKET) {
X if ((void *) file_entry.f_data == (void *) sockp) {
X if (!getbuf((unsigned long) file_entry.f_cred,
X &ucb, sizeof(ucb), "ucb"))


X return -1;
X
X *uid = ucb.cr_ruid;
X return 0;
X }
X }

X } while ((file_entry.links.next != addr) && (--nfile));
X return -1;
}
SHAR_EOF
$shar_touch -am 0127032195 'pidentd-2.7/src/kernel/next_mach.c' &&
chmod 0644 'pidentd-2.7/src/kernel/next_mach.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/next_mach.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/next_mach.c:' 'MD5 check failed'
f409e9f5511cf561573d29472a485162 pidentd-2.7/src/kernel/next_mach.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/next_mach.c'`"
test 4462 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/next_mach.c:' 'original size' '4462,' 'current size' "$shar_count!"
fi
fi
: || $echo 'restore of' 'pidentd-2.7/src/kernel/other.c' 'failed'
$echo 'End of part' '6,' 'continue with part' '7'
exit 0

Peter Eriksson

unread,
Sep 8, 1996, 3:00:00 AM9/8/96
to

Submitted-By: pe...@ifm.liu.se (Peter Eriksson)
Posting-Number: Volume 29, Issue 131
Archive-Name: pidentd-2.7/part08

#!/bin/sh
# This is part 08 of a multipart archive.

# ============= pidentd-2.7/src/kernel/svr4.c ==============


if test ! -d 'pidentd-2.7'; then
$echo 'x -' 'creating directory' 'pidentd-2.7'
mkdir 'pidentd-2.7'
fi

if test ! -d 'pidentd-2.7/src'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/src'
mkdir 'pidentd-2.7/src'
fi
if test ! -d 'pidentd-2.7/src/kernel'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/src/kernel'
mkdir 'pidentd-2.7/src/kernel'
fi

if test -f 'pidentd-2.7/src/kernel/svr4.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/svr4.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/svr4.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/svr4.c' &&
/*
** kernel/svr4.c SVR4 specific kernel access functions


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 17 March 1993
**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X

#define STRNET


X
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X

# include "kvm.h"


X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
X
#include <sys/socketvar.h>
X

#define KERNEL
X
#include <sys/file.h>
X
#include <fcntl.h>
X

#include <unistd.h>
#include <sys/fcntl.h>
#include <sys/stream.h>
#include <sys/stat.h>
#include <sys/cred.h>
#include <sys/vnode.h>

#include <sys/mkdev.h>
#define ucred cred
X


#include <sys/wait.h>
X
#undef KERNEL
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X

#ifndef ATTSVR4
#include <netinet/in_pcb.h>
#endif


X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{

#ifndef ATTSVR4


X
#define N_FILE 0
#define N_TCB 1

X
X { "file" },
X { "tcb" },
X

#else /* AT&T's hacked version below */
X
#define N_FILE 0
#define N_TCPD 1
#define N_TCPD_CNT 2
X
X { "file" },
X { "tcpd" },
X { "tcpd_cnt" },
#endif /* ATTSVR4 */
X

X { "" }
};
X
static kvm_t *kd;
X

#ifndef ATTSVR4
static struct inpcb tcb;
#endif
X
#ifdef ATTSVR4
static struct tcpd tcpd; /* we will read this one at a time */
static int tcpd_cnt; /* # of tcpd's we have */
#endif

static short


X getlist(pcbp, faddr, fport, laddr, lport)

#ifdef ATTSVR4
X struct tcpd *pcbp;
#else
X struct inpcb *pcbp;


#endif
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{

#ifdef ATTSVR4
X struct tcpcb *head;
X struct tcpcb tcpcb;
X int i;
X int address_of_tcpcb;


#else
X struct inpcb *head;

#endif
X
X if (!pcbp)
X return -1;
X
#ifdef ATTSVR4
X i = 0; /* because we have already read 1 we inc later of the struct */
X do
X {
X /* don't ask be why (HACK) but the forth element that td_tcpcb
X ** points to contains the address of the tcpcb
X ** the struct is struct msgb which is a bunch of pointers
X ** to arrays (in <sys/stream.h> and the fouth element of the
X ** struct seems to always have the address...there is no comments
X ** in the .h files to indict why this is, and since I don't have
X ** source I don't know why....I found this info using crash looking
X ** around the structure tcpd, using the command 'od -x address count'
X **
X ** I assume that this would change....but it seems to work on AT&T SVR4.0
X ** Rel. 2.1
X **
X ** Bradley E. Smith <br...@bradley.bradley.edu>
X */
X if (!getbuf( (long) pcbp->td_tcpcb + (3 * sizeof(int)),
X &address_of_tcpcb, sizeof(int), "&address_of_tcpcb") )


X {
X return -1;
X }
X

X if (!getbuf( address_of_tcpcb, &tcpcb, sizeof(tcpcb) , "&tcpcb"))


X {
X return -1;
X }
X

X i++; /* for the read */
X if (!tcpcb.t_laddr || !tcpcb.t_faddr) /* skip unused entrys */
X continue;
X
X /* have to convert these babies */
X if ( tcpcb.t_faddr == htonl(faddr->s_addr) &&
X tcpcb.t_laddr == htonl(laddr->s_addr) &&
X tcpcb.t_fport == htons(fport) &&
X tcpcb.t_lport == htons(lport) )
X
X return pcbp->td_dev;
X
X /* if we get here we need to read the tcpd followed by tcpcb, but
X ** first we check if we are at the end of the tcpd struct
X */
X } while ( (i != tcpd_cnt) &&
X getbuf((long) (nl[N_TCPD].n_value + ( i * sizeof(struct tcpd)) ),
X pcbp, sizeof(struct tcpd), "tcpdlist") );
X
#else


X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )

X return pcbp->inp_minor;


X } while (pcbp->inp_next != head &&
X getbuf((long) pcbp->inp_next,
X pcbp,
X sizeof(struct inpcb),
X "tcblist"));

#endif /* not ATTSVR4 */


X
X return -1;
}
X
X
X
/*

** Return the user number for the connection owner in the int pointed
** at in the uid argument.

*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;

X struct stat s;
X short tcpmajor; /* Major number of the tcp device */
X short sockp; /* Really a device minor number */
X struct file *filehead, file;

X struct ucred ucb;
X
X

X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */

X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
X

X /* we just need to determine the major number of the tcp module, which
X is the minor number of the tcp clone device /dev/tcp */
X if (stat("/dev/tcp", &s))
X ERROR("stat(\"/dev/tcp\")");
X
X tcpmajor = minor(s.st_rdev);

X
X /* -------------------- TCP PCB LIST -------------------- */

#ifdef ATTSVR4
X /* get the number of tcpd structs together */
X if (!getbuf(nl[N_TCPD_CNT].n_value, &tcpd_cnt,
X sizeof(tcpd_cnt), "&tcpd_cnt"))
X return -1;
X
X if (!getbuf(nl[N_TCPD].n_value, &tcpd, sizeof(tcpd), "&tcpd"))
X return -1;
X
X sockp = getlist(&tcpd, faddr, fport, laddr, lport);
#else


X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);

#endif
X
X if (sockp < 0)


X return -1;
X
X
X /*

X * Get the pointer to the head of the file list

X */
X if (!getbuf(nl[N_FILE].n_value, &filehead, sizeof(struct file *)))
X return -1;
X
X file.f_next = filehead;
X do
X {
X struct vnode vnode;
X
X /*


X ** Grab a file record
X */

X if (!getbuf((long)file.f_next, &file, sizeof(struct file), "file"))
X return -1;
X


X /*
X ** Grab the vnode information to check whether this file is the

X ** correct major & minor char device
X */
X if (!getbuf((off_t)file.f_vnode, &vnode, sizeof(struct vnode), "vnode"))
X return -1;
X

X if ((vnode.v_type == VCHR) && (major(vnode.v_rdev) == tcpmajor) &&
X (minor(vnode.v_rdev) == sockp))

X {
X /*


X ** We've found it!
X */

X if (!getbuf((off_t)file.f_cred, &ucb, sizeof(struct cred), "cred"))


X return -1;
X
X *uid = ucb.cr_ruid;
X return 0;
X }
X

X } while (file.f_next != filehead);


X
X return -1;
}
SHAR_EOF

$shar_touch -am 0317023593 'pidentd-2.7/src/kernel/svr4.c' &&
chmod 0644 'pidentd-2.7/src/kernel/svr4.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/svr4.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/svr4.c:' 'MD5 check failed'
624a40c47341f1b315d661b58ac42308 pidentd-2.7/src/kernel/svr4.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/svr4.c'`"
test 7316 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/svr4.c:' 'original size' '7316,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/unicos6.c ==============
if test -f 'pidentd-2.7/src/kernel/unicos6.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/unicos6.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/unicos6.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/unicos6.c' &&
/*
** kernel/unicos6.c Low level kernel access functions for Cray UNICOS 6

#define IP_SECURITY


X
#include <sys/socketvar.h>
X
#define KERNEL
X
#include <sys/file.h>
X
#include <fcntl.h>
X

#include <sys/param.h>
#include <sys/sysmacros.h>
X


#include <sys/wait.h>
X
#undef KERNEL
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X

X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{

#define N_TCB 0
X


X { "tcb" },
X { "" }
};
X
static kvm_t *kd;
X
static struct file *xfile;
static int nfile;
X
static struct inpcb tcb;
X

X } while (wtob((long) pcbp->inp_next) != (long) head &&
X getbuf(wtob((long) pcbp->inp_next), /* inp_next is a word ptr */


X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X
X return NULL;
}
X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;
X struct socket *sockp;
X int i;

X struct socket sockbuf;


X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X /*

X Creator of socket's uid is stored in the socket structure!!!
X No need to walk the file table...
X */
X if(!getbuf(wtob(sockp), &sockbuf, sizeof(sockbuf), "socket"))
X return -1;
X *uid = sockbuf.so_uid;
X return 0;
}
SHAR_EOF
$shar_touch -am 0318001993 'pidentd-2.7/src/kernel/unicos6.c' &&
chmod 0644 'pidentd-2.7/src/kernel/unicos6.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/unicos6.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/unicos6.c:' 'MD5 check failed'
a748342543ac9a2b136af780d03ee09f pidentd-2.7/src/kernel/unicos6.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/unicos6.c'`"
test 3462 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/unicos6.c:' 'original size' '3462,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/freebsd.c.old ==============
if test -f 'pidentd-2.7/src/kernel/freebsd.c.old' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/freebsd.c.old' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/freebsd.c.old' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/freebsd.c.old' &&
/*
** kernel/other.c Low level kernel access functions for FreeBSD 2.x


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 11 April 1995 - tors...@FreeBSD.ORG
*/
X
#include <stdio.h>
#include <nlist.h>


#include <syslog.h>
X
#include <kvm.h>
X

#include <sys/param.h>


#include <sys/socket.h>
X
#include <sys/socketvar.h>
X

#define KERNEL
X
#include <sys/file.h>
X
#include <fcntl.h>
X

#undef KERNEL
X
#include <sys/resource.h>
#include <sys/proc.h>


#include <sys/user.h>
#include <sys/wait.h>
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X

#include <netinet/in_systm.h>
#include <netinet/ip.h>
X
#include <netinet/in_pcb.h>
X
#include <netinet/tcp.h>
#include <netinet/ip_var.h>

X
#include <netinet/tcpip.h>
X

#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
X
#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X

#ifdef INPLOOKUP_SETLOCAL
#define _HAVE_OLD_INPCB
#endif
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{

#define N_FILE 0
#define N_NFILE 1
#define N_TCB 2
X
X { "_filehead" },
X { "_nfiles" },
X { "_tcb" },
X { "" }
};
X

static kvm_t *kd;
X
static struct file *xfile;
X
static int nfile;
X

#ifdef _HAVE_OLD_INPCB
static struct inpcb tcb;
#else
static struct inpcbhead tcb;
#endif
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */

X syslog(LOG_DEBUG,"getbuf: kvm_read(%08x, %d) - %s : %m",


X addr, len, what);
X
X return 0;
X }
X
X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static struct socket *

X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{
X long addr;
X struct socket *sockp;
X int i;
X struct ucred ucb;
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
X

X char *filebuf;
X filebuf=kvm_getfiles(kd,KERN_FILE,0,&nfile);
X if(filebuf==0)
X ERROR("k_getuid: out of memory (file table)");
X xfile = (struct file *)(filebuf + sizeof (struct file *));


X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
#ifdef _HAVE_OLD_INPCB
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
#endif
X sockp = getlist(&tcb, faddr, fport, laddr, lport);
X
X if (!sockp)
X return -1;
X
X /*
X ** Locate the file descriptor that has the socket in question
X ** open so that we can get the 'ucred' information
X */

X for (i = 0; i < nfile; i++)
X {
X if (xfile[i].f_count == 0)
X continue;
X
X if (xfile[i].f_type == DTYPE_SOCKET &&
X (struct socket *) xfile[i].f_data == sockp)
X {
X if (!getbuf(xfile[i].f_cred, &ucb, sizeof(ucb), "ucb"))
X return -1;
X

X *uid = ucb.cr_uid;


X
X return 0;
X }
X }
X

X return -1;
}
X
SHAR_EOF

$shar_touch -am 0605152795 'pidentd-2.7/src/kernel/freebsd.c.old' &&
chmod 0644 'pidentd-2.7/src/kernel/freebsd.c.old' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/freebsd.c.old' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/freebsd.c.old:' 'MD5 check failed'
9ff7b5140891f534cf690a14cad9a3bb pidentd-2.7/src/kernel/freebsd.c.old
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/freebsd.c.old'`"
test 4615 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/freebsd.c.old:' 'original size' '4615,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/machten.c ==============
if test -f 'pidentd-2.7/src/kernel/machten.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/machten.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/machten.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/machten.c' &&
/*
** kernel/machten.c Low level kernel access functions for
** Tenon's MachTen 4.0.x for Power Macintosh.
**
** Modified from kernel/other.c by Trevor Strohman, Tenon Intersystems
** <tr...@tenon.com>.


**
** This program is in the public domain and may be used freely by anyone

** who wants to use it.
**
** Last update: 16 July 1996


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/

#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <nlist.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
X
#include <kvm.h>
X
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>

#include <sys/socketvar.h>
X
#define KERNEL
X

#define nfile SOME_OTHER_VARIABLE_NAME


#define _KERNEL
X
#include <sys/file.h>
X

#undef nfile
#undef _KERNEL
X
#include <fcntl.h>
X
#undef KERNEL
X


#include <sys/user.h>
#include <sys/wait.h>
X
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
X

#include <netinet/in_systm.h>
#include <netinet/ip.h>


#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
X

#include <netinet/tcp.h>


#include <netinet/tcpip.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>

#include <arpa/inet.h>
X
#include "identd.h"
#include "error.h"
X
X
extern void *calloc();
extern void *malloc();
X
X
struct nlist nl[] =
{
#define N_FILE 0

#define N_NFILE 1
#define N_TCB 2
X
X { "file" },

X { "fileNFILE" },


X { "tcb" },
X { "" }
};
X
static kvm_t *kd;
X
static struct file *xfile;
static int nfile;
X

caddr_t nfile_dummy;


X
static struct inpcb tcb;
X
X
int k_open()
{
X /*
X ** Open the kernel memory device
X */

X int i;
X


X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X
X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");
X
X return 0;
}
X
X
/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int getbuf(addr, buf, len, what)

X caddr_t addr;


X char *buf;
X int len;
X char *what;
{
X
X if (kvm_read(kd, addr, buf, len) < 0)
X {
X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);
X
X return 0;
X }

X return 1;
}
X
X
X
/*
** Traverse the inpcb list until a match is found.
** Returns NULL if no match.
*/
static struct socket *
X getlist(pcbp, faddr, fport, laddr, lport)
X struct inpcb *pcbp;
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
{
X struct inpcb *head;

X if (!pcbp)
X return NULL;
X
X head = pcbp->inp_prev;
X do
X {
X if ( pcbp->inp_faddr.s_addr == faddr->s_addr &&
X pcbp->inp_laddr.s_addr == laddr->s_addr &&
X pcbp->inp_fport == fport &&
X pcbp->inp_lport == lport )
X return pcbp->inp_socket;

X } while (pcbp->inp_next != head &&

X getbuf((caddr_t) pcbp->inp_next,


X pcbp,
X sizeof(struct inpcb),
X "tcblist"));
X return NULL;
}

X
X
X
/*
** Return the user number for the connection owner
*/
int k_getuid(faddr, fport, laddr, lport, uid)
X struct in_addr *faddr;
X int fport;
X struct in_addr *laddr;
X int lport;
X int *uid;
{

X caddr_t addr;


X struct socket *sockp;
X int i;
X struct ucred ucb;
X
X /* -------------------- FILE DESCRIPTOR TABLE -------------------- */
X

X if (!getbuf(nl[N_NFILE].n_value, &nfile_dummy, sizeof(nfile_dummy), "nfile"))
X return -1;


X if (!getbuf(nl[N_FILE].n_value, &addr, sizeof(addr), "&file"))
X return -1;
X

X /* Convert pointer nfile_dummy to an integer number of files */
X nfile = (int) ((nfile_dummy - addr) / sizeof(struct file));


X
X xfile = (struct file *) calloc(nfile, sizeof(struct file));
X if (!xfile)
X ERROR2("k_getuid: calloc(%d,%d)", nfile, sizeof(struct file));
X
X if (!getbuf(addr, xfile, sizeof(struct file)*nfile, "file[]"))
X return -1;
X
X /* -------------------- TCP PCB LIST -------------------- */
X if (!getbuf(nl[N_TCB].n_value, &tcb, sizeof(tcb), "tcb"))
X return -1;
X
X tcb.inp_prev = (struct inpcb *) nl[N_TCB].n_value;
X sockp = getlist(&tcb, faddr, fport, laddr, lport);

X if (!sockp)
X return -1;

X /*
X ** Locate the file descriptor that has the socket in question
X ** open so that we can get the 'ucred' information
X */
X for (i = 0; i < nfile; i++)
X {
X if (xfile[i].f_count == 0)
X continue;
X
X if (xfile[i].f_type == DTYPE_SOCKET &&
X (struct socket *) xfile[i].f_data == sockp)
X {
X if (!getbuf(xfile[i].f_cred, &ucb, sizeof(ucb), "ucb"))
X return -1;
X
X *uid = ucb.cr_ruid;
X
X return 0;
X }
X }
X
X return -1;
}

SHAR_EOF
$shar_touch -am 0811204096 'pidentd-2.7/src/kernel/machten.c' &&
chmod 0644 'pidentd-2.7/src/kernel/machten.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/machten.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/machten.c:' 'MD5 check failed'
0e72945c50750d3e04d9684b5e7cbae2 pidentd-2.7/src/kernel/machten.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/machten.c'`"
test 4575 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/machten.c:' 'original size' '4575,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kernel/uw2.c ==============
if test -f 'pidentd-2.7/src/kernel/uw2.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kernel/uw2.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kernel/uw2.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kernel/uw2.c' &&
/*
** kernel/uw2.c UnixWare v2.x specific kernel access functions
**
**
** Last update: 28 Nov 1995
**
** Please send mods/bug fixes/bug reports to: Paul F. Wells <pa...@wellserv.com>
**
*/
X
#define _KMEMUSER
#include <sys/types.h>
#include <sys/ksynch.h>
#include <sys/flock.h>
#include <sys/pid.h>
#include <sys/var.h>
#include <sys/proc.h>
#include <sys/cred.h>
#include <sys/session.h>
#include <sys/socket.h>
#include <sys/strsubr.h>
#include <net/route.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp_kern.h>
#include <sys/fs/snode.h>
#include <sys/stat.h>
#include <sys/mkdev.h>
#undef _KMEMUSER
X
#include <sys/ksym.h>
#include <sys/sysmacros.h>
X
#include <arpa/inet.h>
X
#include <fcntl.h>
X
#include "paths.h"
#include "kvm.h"


#include "identd.h"
#include "error.h"
X

#include <stdio.h> /* this kinda reeks */
X
#ifndef TRUE
enum { FALSE, TRUE };
#endif


X
static kvm_t *kd;
X

int k_open()
{
X /*
X ** Open the kernel memory device
X */
X if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
X ERROR("main: kvm_open");
X

#ifndef UW2 /* don't really need this */


X /*
X ** Extract offsets to the needed variables in the kernel
X */
X if (kvm_nlist(kd, nl) != 0)
X ERROR("main: kvm_nlist");

#endif


X
X return 0;
}
X

/*
** Get a piece of kernel memory with error handling.
** Returns 1 if call succeeded, else 0 (zero).
*/
static int

getbuf(long addr,void *buf,int len,char *what)
{


X if (kvm_read(kd, addr, buf, len) < 0) {

X if (syslog_flag)
X syslog(LOG_ERR, "getbuf: kvm_read(%08x, %d) - %s : %m",
X addr, len, what);

X return 0;


X }
X return 1;
}
X

int
k_getuid(struct in_addr *faddr,int fport,struct in_addr *laddr,int lport,int *uid)
{
X int gotit;
X ulong_t info;
X struct stat tcpstat;
X dev_t tcp_clone;
X minor_t tcp_minor;
X snode_t **snode_base, *snodep, spec_node;
X int snode_hash;
X vnode_t *vnodep;
X struct inpcb pcb, *tcb_first;
X proc_t *proc_head, *procp, uproc;
X int maxfd;
X int ifdt, fdtable_len;
X fd_entry_t *fdp;
X file_t *filep, file_entry;
X cred_t creds;
X
X /* initialize & find pcb for specified connection */
X
X if (stat("/dev/tcp", &tcpstat) != 0)
X return -1;
X tcp_minor = minor(tcpstat.st_rdev);
X
X info = 0;
X tcb_first = NULL;
X if (getksym("tcb", (ulong_t *) &tcb_first, &info) < 0)
X return -1;
X
X for (gotit = FALSE, pcb.inp_prev = tcb_first; ; ) {
X /* why do we have to go backward? */
X if (!getbuf((long) pcb.inp_prev, &pcb, sizeof(pcb), "inp_prev"))
X return -1;
X if (
X pcb.inp_faddr.s_addr == faddr->s_addr &&
X pcb.inp_laddr.s_addr == laddr->s_addr &&
X pcb.inp_fport == fport &&
X pcb.inp_lport == lport
X ) {
X /* I screwed up: 2.01 allowed makedev() */
X tcp_clone = makedevice(tcp_minor, pcb.inp_minor);
X gotit = TRUE;
X break;
X }
X if (pcb.inp_prev == NULL || pcb.inp_prev == tcb_first) break;
X }
X if (!gotit) return -1;
X
X /* now crawl through snodes to find vnode of clone device */
X
X info = 0;
X snode_base = NULL;
X if (getksym("spectable", (ulong_t *) &snode_base, &info) < 0)
X return -1;
X snode_hash = SPECTBHASH(tcp_clone);
X if (!getbuf((long) (snode_base + snode_hash), &snodep, sizeof(snodep), "snode_hash"))
X return -1;
X
X for (gotit = FALSE; snodep != NULL ; snodep = spec_node.s_next) {
X if (!getbuf((long) snodep, &spec_node, sizeof(spec_node), "snodep"))
X return -1;
X if (spec_node.s_dev == tcp_clone) {
X vnodep = (vnode_t *) ((char *) snodep + offsetof(struct snode, s_vnode));
X gotit = TRUE;
X break;
X }
X }
X if (!gotit || (spec_node.s_flag & SINVALID)) return -1;
X
X /* find process with this vnode */
X
X info = 0;
X procp = NULL;
X if (getksym("practive", (ulong_t *) &procp, &info) < 0)
X return -1;
X if (!getbuf((long) procp, &proc_head, sizeof(proc_head), "practive"))
X return -1;
X
X for (gotit = FALSE, procp = proc_head; procp != NULL; procp = uproc.p_next) {
X if (!getbuf((long) procp, &uproc, sizeof(uproc), "procp"))
X return -1;
X if((maxfd = uproc.p_fdtab.fdt_sizeused) == 0) continue;
X fdtable_len = maxfd * sizeof(fd_entry_t);
X if ((fdp = (fd_entry_t *) malloc(fdtable_len)) == NULL)
X return -1;
X if (!getbuf((long) uproc.p_fdtab.fdt_entrytab, fdp, fdtable_len, "fdt_entrytab")) {
X free(fdp);
X return -1;
X }
X for (ifdt = 0; ifdt < maxfd; ifdt++) {
X if (fdp[ifdt].fd_status != FD_INUSE) continue;
X filep = fdp[ifdt].fd_file;
X if (!getbuf((long) filep, &file_entry, sizeof(file_entry), "filep")) {
X free(fdp);
X return -1;
X }
X if (vnodep == file_entry.f_vnode) {
X if (file_entry.f_cred != NULL) {
X if (!getbuf((long) file_entry.f_cred, &creds, sizeof(creds), "f_cred")) {
X free(fdp);
X return -1;
X }
X free(fdp);
X gotit = TRUE;
X goto got_proc;
X }
X }
X }
X free(fdp);
X }
got_proc: ; /* maybe */
X if (!gotit) return -1;
X
X /* wow! */


X *uid = creds.cr_ruid;
X

X return 0;
}
SHAR_EOF
$shar_touch -am 0811221296 'pidentd-2.7/src/kernel/uw2.c' &&
chmod 0644 'pidentd-2.7/src/kernel/uw2.c' ||
$echo 'restore of' 'pidentd-2.7/src/kernel/uw2.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kernel/uw2.c:' 'MD5 check failed'
e78e40e2ecda093a515b2cdc8742c342 pidentd-2.7/src/kernel/uw2.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kernel/uw2.c'`"
test 4742 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kernel/uw2.c:' 'original size' '4742,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/kvm.c ==============
if test -f 'pidentd-2.7/src/kvm.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/kvm.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/kvm.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/kvm.c' &&
/*
** kvm.c A set of functions emulating KVM for machines without them.


**
** This code is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 12 Dec 1992


**
** Author: Peter Eriksson <p...@lysator.liu.se>
*/
X

#ifndef NO_KVM
#ifndef HAVE_KVM
X
#ifdef NeXT31
# include <libc.h>
#endif


X
#include <stdio.h>
#include <errno.h>

#include <nlist.h>
X
#ifdef IRIX
# ifdef IRIX62
# if _MIPS_SZPTR == 64
# define _K64U64 1
# else
# define _K32U32 1
# endif
# endif
# include <sys/sbd.h>
# ifndef K0_TO_PHYS
# define K0_TO_PHYS(x) (x)
# endif
# if defined(IRIX6) || (defined(IRIX62) && _MIPS_SZPTR == 64)
# define nlist nlist64
# endif
#endif
X
#ifdef BSD43
# include <sys/types.h>
# include <sys/dir.h>
# include <sys/param.h>
# include <sys/vmmac.h>
#if 0
# include <sys/time.h>
#else
# include <sys/user.h>
#endif
# ifdef DIRBLKSIZ
# undef DIRBLKSIZ
# endif
#if 0
# include <sys/user.h>
#endif
# include <sys/proc.h>
# include <machine/pte.h>
# include "paths.h"
#endif
X
X
#include "kernel/kvm.h"
#include "paths.h"
X
#if defined(BSD43) || defined(MIPS)


extern int errno;
#endif
X

extern void *malloc();
X
X

kvm_t *kvm_open(namelist, corefile, swapfile, flag, errstr)
X char *namelist;
X char *corefile;
X char *swapfile;
X int flag;
X char *errstr;
{
X kvm_t *kd;
X
X if (!namelist)
X namelist = _PATH_UNIX;
X if (!corefile)
X corefile = _PATH_KMEM;
X
#ifdef BSD43
X if (!swapfile)
X swapfile = _PATH_SWAP;
#endif
X
X kd = (kvm_t *) malloc(sizeof(kvm_t));
X if (!kd)
X {
X if (errstr)
X perror(errstr);


X return NULL;
X }
X

X kd->namelist = (char *) malloc(strlen(namelist)+1);
X if (!kd->namelist)
X {
X if (errstr)
X perror(errstr);


X return NULL;
X }
X

X if ((kd->fd = open(corefile, flag)) < 0)
X {
X if (errstr)
X perror(errstr);
X free(kd->namelist);
X free(kd);


X return NULL;
X }
X

#ifdef BSD43
X if ((kd->swap_fd = open(swapfile, flag)) < 0)
X {
X if (errstr)
X perror(errstr);
X close(kd->fd);
X free(kd->namelist);
X free(kd);


X return NULL;
X }
X

X if ((kd->mem_fd = open(_PATH_MEM, flag)) < 0)
X {
X if (errstr)
X perror(errstr);
X close(kd->swap_fd);
X close(kd->fd);
X free(kd->namelist);
X free(kd);
X return NULL;
X }
#endif
X
X strcpy(kd->namelist, namelist);
X return kd;
}
X
X
int kvm_close(kd)
X kvm_t *kd;
{
X int code;
X
X code = close(kd->fd);
#ifdef BSD43
X close(kd->swap_fd);
X close(kd->mem_fd);
X if (kd->proctab)
X free(kd->proctab);
#endif
X free(kd->namelist);
X free(kd);
X
X return code;
}
X
X
/*
** Extract offsets to the symbols in the 'nl' list. Returns 0 if all found,
** or else the number of variables that was not found.
*/
int kvm_nlist(kd, nl)
X kvm_t *kd;
X struct nlist *nl;
{
X int code;
X int i;
X
X code = nlist(kd->namelist, nl);
X
X if (code != 0)
X return code;
X
X /*
X ** Verify that we got all the needed variables. Needed because some
X ** implementations of nlist() returns 0 although it didn't find all
X ** variables.
X */
X if (code == 0)
X {
#if defined(__convex__) || defined(NeXT)
X for (i = 0; nl[i].n_un.n_name && nl[i].n_un.n_name[0]; i++)
#else
X for (i = 0; nl[i].n_name && nl[i].n_name[0]; i++)
#endif
#if defined(_AUX_SOURCE) || defined(_CRAY) || defined(sco) || defined(_SEQUENT_)
X /* A/UX sets n_type to 0 if not compiled with -g. n_value will still
X ** contain the (correct?) value (unless symbol unknown).
X */
X if( nl[i].n_value == 0)
X code++;
#else
X if (nl[i].n_type == 0)
X code++;
#endif
X }
X
X return code;
}
X
X
/*
** Get a piece of the kernel memory
*/
static int readbuf(fd, addr, buf, len)
X int fd;


X long addr;
X char *buf;
X int len;

{
#ifdef IRIX
X addr = K0_TO_PHYS(addr);
#endif
X errno = 0;
#if defined(__alpha)
X /*
X * Let us be paranoid about return values.
X * It should be like this on all implementations,
X * but some may have broken lseek or read returns.
X */
X if (lseek(fd, addr, 0) != addr || errno != 0) return -1;
X if (read(fd, buf, len) != len || errno != 0) return -1;
X return len;
#else
X if (lseek(fd, addr, 0) == -1 && errno != 0) return -1;
X return read(fd, buf, len);
#endif
}
X
int kvm_read(kd, addr, buf, len)
X kvm_t *kd;


X long addr;
X char *buf;
X int len;
{

X return readbuf(kd->fd, addr, buf, len);
}
X
X
#ifdef BSD43
X
struct user *kvm_getu(kd, procp)
X kvm_t *kd;
X struct proc *procp;
{
X static union
X {
X struct user user;
X char upages[UPAGES][NBPG];
X } userb;
X
X int ncl;
X struct pte *pteaddr, apte;
X struct pte arguutl[UPAGES+CLSIZE];
X
X
X if ((procp->p_flag & SLOAD) == 0)
X {
X if(readbuf(kd->swap_fd,
X dtob(procp->p_swaddr),
X &userb.user, sizeof(struct user)) < 0)
X return NULL;
X }
X else
X {
X /*
X ** Sigh. I just *love* hard coded variable names in macros...
X */
X {
X struct pte *usrpt = kd->usrpt;
X
X pteaddr = &kd->Usrptma[btokmx(procp->p_p0br) + procp->p_szpt - 1];
X if (readbuf(kd->fd, pteaddr, &apte, sizeof(apte)) < 0)


X return NULL;
X }
X

X if (readbuf(kd->mem_fd,
X ctob(apte.pg_pfnum+1)-(UPAGES+CLSIZE)*sizeof(struct pte),
X arguutl, sizeof(arguutl)) < 0)
X return NULL;
X
X ncl = (sizeof(struct user) + NBPG*CLSIZE - 1) / (NBPG*CLSIZE);
X while (--ncl >= 0)
X {


X int i;
X
X

X i = ncl * CLSIZE;
X if(readbuf(kd->mem_fd,
X ctob(arguutl[CLSIZE+i].pg_pfnum),
X userb.upages[i], CLSIZE*NBPG) < 0)


X return NULL;
X }
X }
X

X return &userb.user;
}
X
X
X
struct proc *kvm_nextproc(kd)
X kvm_t *kd;
{
X if (kd->proctab == NULL)
X if (kvm_setproc(kd) < 0)
X return NULL;
X
X if (kd->procidx < kd->nproc)
X return &kd->proctab[kd->procidx++];
X
X return (struct proc *) NULL;
}
X
int kvm_setproc(kd)
X kvm_t *kd;
{
X long procaddr;
X
X static struct nlist nl[] =
X {
#define N_PROC 0
#define N_USRPTMA 1
#define N_NPROC 2
#define N_USRPT 3
X
X { "_proc" },
X { "_Usrptmap" },
X { "_nproc" },
X { "_usrpt" },
X { "" }
X };
X


X if (kvm_nlist(kd, nl) != 0)

X return -1;
X
X kd->Usrptma = (struct pte *) nl[N_USRPTMA].n_value;
X kd->usrpt = (struct pte *) nl[N_USRPT].n_value;
X
X if (readbuf(kd->fd, nl[N_NPROC].n_value, &kd->nproc, sizeof(kd->nproc)) < 0)
X return -1;
X
X if (readbuf(kd->fd, nl[N_PROC].n_value, &procaddr, sizeof(procaddr)) < 0)
X return -1;
X
X if (kd->proctab)
X free(kd->proctab);
X
X kd->proctab = (struct proc *) calloc(kd->nproc, sizeof(struct proc));
X if (!kd->proctab)
X return -1;
X
X if (readbuf(kd->fd,
X procaddr,
X kd->proctab,
X kd->nproc*sizeof(struct proc)) < 0)
X return -1;
X
X kd->procidx = 0;


X
X return 0;
}
X
X

struct proc *kvm_getproc(kd, pid)
X kvm_t *kd;
X int pid;
{
X struct proc *procp;
X
X
X if (kvm_setproc(kd) < 0)
X return NULL;
X
X while ((procp = kvm_nextproc(kd)) && procp->p_pid != pid)
X ;
X
X return procp;
}
X
#endif
X
#else
/* Just to make some compilers shut up! */
int kvm_dummy()
{
X return 1;
}
#endif
#endif
SHAR_EOF
$shar_touch -am 0811201896 'pidentd-2.7/src/kvm.c' &&
chmod 0644 'pidentd-2.7/src/kvm.c' ||
$echo 'restore of' 'pidentd-2.7/src/kvm.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/kvm.c:' 'MD5 check failed'
e5f8e791b14f8b26080ffcc452652f68 pidentd-2.7/src/kvm.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/kvm.c'`"
test 6918 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/kvm.c:' 'original size' '6918,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/paths.h ==============
if test -f 'pidentd-2.7/src/paths.h' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/paths.h' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/paths.h' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/paths.h' &&
/*
** paths.h Common path definitions for the in.identd daemon
**
** Last update: 11 Dec 1992


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X

#ifdef sequent
# define _PATH_UNIX "/dynix"
#endif
X
#if defined(MIPS) || defined(IRIX) || defined(sco) || defined(_SEQUENT_)
# define _PATH_UNIX "/unix"
#endif
X
#if defined(hpux) || defined(__hpux)
#ifdef HPUX_10
# define _PATH_UNIX "/stand/vmunix"
#else
# define _PATH_UNIX "/hp-ux"
#endif
#endif
X
#ifdef SOLARIS
# define _PATH_UNIX "/dev/ksyms"
#else
# if defined(SVR4) && !defined(_SEQUENT_)
# define _PATH_UNIX "/stand/unix"
# endif
#endif
X
#ifdef BSD43
# define _PATH_SWAP "/dev/drum"
# define _PATH_MEM "/dev/mem"
#endif
X
#ifdef _AUX_SOURCE
# define _PATH_UNIX "/unix"
#endif
X
#ifdef _CRAY
# define _PATH_UNIX "/unicos"
# define _PATH_MEM "/dev/mem"
#endif
X
#ifdef NeXT
# define _PATH_UNIX "/mach"
#endif
X
#ifdef __bsdi__
# define _PATH_UNIX "/bsd"
#endif /* __bsdi__ */
X
X
/*
X * Some defaults...
X */
#ifndef _PATH_KMEM
# define _PATH_KMEM "/dev/kmem"
#endif
X
#ifndef _PATH_UNIX
# define _PATH_UNIX "/vmunix"
#endif
X
X
#ifndef PATH_CONFIG
# define PATH_CONFIG "/etc/identd.conf"
#endif
X
#ifndef PATH_DESKEY
# define PATH_DESKEY "/etc/identd.key"
#endif
SHAR_EOF
$shar_touch -am 1004193895 'pidentd-2.7/src/paths.h' &&
chmod 0644 'pidentd-2.7/src/paths.h' ||
$echo 'restore of' 'pidentd-2.7/src/paths.h' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/paths.h:' 'MD5 check failed'
7ce70ab26eb657ca777b1670caccd1ec pidentd-2.7/src/paths.h
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/paths.h'`"
test 1259 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/paths.h:' 'original size' '1259,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/proxy.c ==============
if test -f 'pidentd-2.7/src/proxy.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/proxy.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/proxy.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/proxy.c' &&
/*
** proxy.c This file implements the proxy() call.


**
** This program is in the public domain and may be used freely by anyone
** who wants to.
**

** Last update: 12 Dec 1992


**
** Please send bug fixes/bug reports to: Peter Eriksson <p...@lysator.liu.se>
*/
X
#include <stdio.h>
#include <errno.h>

X
#include "identd.h"
X
X
#ifdef INCLUDE_PROXY
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
X
#include <ident.h>
#endif
X
X
/*
** This function should establish a connection to a remote IDENT
** server and query it for the information associated with the
** specified connection and the return that to the caller.
**
** Should there be three different timeouts (Connection Establishment,
** Query Transmit and Query Receive)?
*/
int proxy(laddr, faddr, lport, fport, timeout)
#ifdef INCLUDE_PROXY
X struct in_addr *laddr;
X struct in_addr *faddr;
#else
X void *laddr, *faddr;
#endif
X int lport;
X int fport;
#ifdef INCLUDE_PROXY
X struct timeval *timeout;
#else
X void *timeout;
#endif
{
#ifndef INCLUDE_PROXY
X /* Just here to make the compiler shut up! */
X laddr = faddr = NULL;
X timeout = NULL;
X
X printf("%d , %d : ERROR : %s\r\n",
X lport, fport,
X unknown_flag ? "UNKNOWN-ERROR" : "X-NOT-YET-IMPLEMENTED");
X
X return -1;
#else
X id_t *idp;
X char *answer;
X char *opsys;
X char *charset;
X
X idp = id_open(laddr, faddr, timeout);
X if (!idp)
X {
X printf("%d , %d : ERROR : %s\r\n",
X lport, fport,
X unknown_flag ? "UNKNOWN-ERROR" : "X-CONNECTION-REFUSED");


X return -1;
X }
X

X if (id_query(idp, lport, fport, timeout) < 0)
X {
X printf("%d , %d : ERROR : %s\r\n",
X lport, fport,
X unknown_flag ? "UNKNOWN-ERROR" : "X-TRANSMIT-QUERY-ERROR");
X id_close(idp);


X return -1;
X }
X

X switch (id_parse(idp, timeout, &lport, &fport, &answer, &opsys, &charset))
X {
X case 1:
X printf("%d , %d : USERID : %s %s%s : %s\r\n",
X lport, fport,
X opsys,
X charset ? "," : "",
X charset ? charset : "",
X answer);
X break;
X
X case 2:
X printf("%d , %d : ERROR : %s\r\n",
X lport, fport, answer);
X break;
X
X case 0: /* More to parse - fix this later! */
X case -1: /* Internal error */
X default:
X printf("%d , %d : ERROR : %s\r\n",
X lport, fport,
X unknown_flag ? "UNKNOWN-ERROR" : "X-PARSE-REPLY-ERROR");
X }
X
X id_close(idp);
#endif
}
SHAR_EOF
$shar_touch -am 0127035195 'pidentd-2.7/src/proxy.c' &&
chmod 0644 'pidentd-2.7/src/proxy.c' ||
$echo 'restore of' 'pidentd-2.7/src/proxy.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/proxy.c:' 'MD5 check failed'
f66dbb5d687acf6946d8fa0711ece226 pidentd-2.7/src/proxy.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/proxy.c'`"
test 2408 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/proxy.c:' 'original size' '2408,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/src/version.c ==============
if test -f 'pidentd-2.7/src/version.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/src/version.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/src/version.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/src/version.c' &&
char version[] = "2.7b1p";
SHAR_EOF
$shar_touch -am 0514004496 'pidentd-2.7/src/version.c' &&
chmod 0644 'pidentd-2.7/src/version.c' ||
$echo 'restore of' 'pidentd-2.7/src/version.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/src/version.c:' 'MD5 check failed'
e6c90a2cd31259126ca49cd6daf5681f pidentd-2.7/src/version.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/src/version.c'`"
test 27 -eq "$shar_count" ||
$echo 'pidentd-2.7/src/version.c:' 'original size' '27,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/testdir/Makefile ==============
if test ! -d 'pidentd-2.7/testdir'; then
$echo 'x -' 'creating directory' 'pidentd-2.7/testdir'
mkdir 'pidentd-2.7/testdir'
fi
if test -f 'pidentd-2.7/testdir/Makefile' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/testdir/Makefile' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/testdir/Makefile' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/testdir/Makefile' &&
all: test1
X @echo "Running tests.."
X @echo ""
X @echo ""
X @echo "Test #1..."
X @echo ""
X @echo "You should see your Unix username below:"
X ./test1
X @echo ""
X @echo ""
X @echo "End of tests."
X
X
test1: test1.c
X $(CC) -o test1 test1.c
X
clean:
X rm -f test1 *~ core *.o \#*
SHAR_EOF
$shar_touch -am 0223232094 'pidentd-2.7/testdir/Makefile' &&
chmod 0644 'pidentd-2.7/testdir/Makefile' ||
$echo 'restore of' 'pidentd-2.7/testdir/Makefile' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/testdir/Makefile:' 'MD5 check failed'
19663acae60da3898452b9a23074fad6 pidentd-2.7/testdir/Makefile
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/testdir/Makefile'`"
test 266 -eq "$shar_count" ||
$echo 'pidentd-2.7/testdir/Makefile:' 'original size' '266,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/testdir/test1.c ==============
if test -f 'pidentd-2.7/testdir/test1.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/testdir/test1.c' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/testdir/test1.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/testdir/test1.c' &&
/*
** A small test program. If run without any arguments, it should
** return *your* user name if the machine it is run on has a correctly
** installed and running Ident server.
**
** Last modified: 11 August 1993 by Michael Kuch


**
** Author: Peter Eriksson <p...@lysator.liu.se>
*/
X

#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>


#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <ctype.h>
X
X
int Toupper(c)
X int c;
{
X if (islower(c))
X return toupper(c);
X else
X return c;
}
X
X
/*
** Compare two strings, case insensitive
*/
int Stricmp(s1, s2)
X char *s1, *s2;
{
X int diff;
X
X
X while (!(diff = Toupper(*s1) - Toupper(*s2)) && *s1)
X s1++, s2++;
X
X return diff;
}
X
X
Perror(str)
X char *str;
{
X perror(str);
X exit(1);
}
X
X
main(argc,argv)
X int argc;
X char *argv[];
{
X int fd;
X struct sockaddr_in addr;
X int addrlen;
X int port;
X FILE *fp_in, *fp_out;
X int lport, fport;
X char buffer[8192];
X char *cp;
X char reply_type[81];
X char opsys_or_error[81];
X char identifier[1024];
X
X
X if (argc > 3)
X {
X printf("usage: %s [{host-ip-number} [{port number}]]", argv[0]);
X exit(1);
X }
X
X fd = socket(AF_INET, SOCK_STREAM, 0);
X if (fd == -1)
X Perror("socket");
X
X addr.sin_family = AF_INET;
X if(argc > 1)
X addr.sin_addr.s_addr = inet_addr(argv[1]);
X else
X addr.sin_addr.s_addr = inet_addr("127.0.0.1");
X
X if (argc > 2)
X port = atoi(argv[2]);
X else
X port = 113;
X
X addr.sin_port = htons(port);
X addrlen = sizeof(addr);
X
X if (connect(fd, &addr, addrlen) == -1)
X Perror("connect");
X
X addrlen = sizeof(addr);
X if (getsockname(fd, &addr, &addrlen) == -1)
X Perror("getsockname");
X
X fp_in = fdopen(fd, "r");
X fp_out = fdopen(fd, "w");
X if (!fp_in || !fp_out)
X Perror("fdopen");
X
X fprintf(fp_out, "%d , %d\n", ntohs(addr.sin_port), port);
X fflush(fp_out);
X
X if (fgets(buffer, sizeof(buffer)-1, fp_in) == NULL)
X Perror("fgets");
X
X shutdown(fd, 1);
X
X cp = buffer;
X while (*cp != 0 && (*cp < ' ' || isspace(*cp)))
X ++cp;
X
X argc = sscanf(cp, "%d , %d : %[^ \t\n\r:] : %[^\t\n\r:] : %[^\n\r]",
X &lport, &fport, reply_type, opsys_or_error, identifier);
X if (argc < 3)
X {
X fprintf(stderr, "sscanf: too few arguments (%d)\n", argc);
X exit(1);
X }
X if (Stricmp(reply_type, "ERROR") == 0)
X {
X printf("Ident error: error code: %s\n", opsys_or_error);
X exit(1);
X }
X else if (Stricmp(reply_type, "USERID") != 0)
X {
X printf("Ident error: illegal reply type: %s\n", reply_type);
X exit(1);
X }
X else
X printf("Ident returned:\n");
X printf("\tOpsys and Charset (if -c specified for identd) = %s\n",
X opsys_or_error);
X printf("\tIdentifier: %s\n", identifier);
X
X fclose(fp_out);
X fclose(fp_in);
X
X exit(0);
}
SHAR_EOF
$shar_touch -am 0605153495 'pidentd-2.7/testdir/test1.c' &&
chmod 0644 'pidentd-2.7/testdir/test1.c' ||
$echo 'restore of' 'pidentd-2.7/testdir/test1.c' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/testdir/test1.c:' 'MD5 check failed'
7348b5ce9e6e3647bbdf0a0e496bb175 pidentd-2.7/testdir/test1.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/testdir/test1.c'`"
test 2750 -eq "$shar_count" ||
$echo 'pidentd-2.7/testdir/test1.c:' 'original size' '2750,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/.cvsignore ==============
if test -f 'pidentd-2.7/.cvsignore' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/.cvsignore' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/.cvsignore' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/.cvsignore' &&
idecrypt
identconn
identd.8
in.identd
itest
SHAR_EOF
$shar_touch -am 0811214296 'pidentd-2.7/.cvsignore' &&
chmod 0644 'pidentd-2.7/.cvsignore' ||
$echo 'restore of' 'pidentd-2.7/.cvsignore' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/.cvsignore:' 'MD5 check failed'
42aa7090f58b0b9351fade8ff181519e pidentd-2.7/.cvsignore
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/.cvsignore'`"
test 44 -eq "$shar_count" ||
$echo 'pidentd-2.7/.cvsignore:' 'original size' '44,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/identconn.sh ==============
if test -f 'pidentd-2.7/identconn.sh' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/identconn.sh' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/identconn.sh' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/identconn.sh' &&
#! /bin/sh
:
PATH=/usr/bin:/usr/ucb:xDESTROOTx/bin ; export PATH
X
netstat -f inet -n | grep ESTAB | itest
X
SHAR_EOF
$shar_touch -am 0811215296 'pidentd-2.7/identconn.sh' &&
chmod 0755 'pidentd-2.7/identconn.sh' ||
$echo 'restore of' 'pidentd-2.7/identconn.sh' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/identconn.sh:' 'MD5 check failed'
967892bcd9c9967a121bc82aa883a200 pidentd-2.7/identconn.sh
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/identconn.sh'`"
test 107 -eq "$shar_count" ||
$echo 'pidentd-2.7/identconn.sh:' 'original size' '107,' 'current size' "$shar_count!"
fi
fi
# ============= pidentd-2.7/install-sh ==============
if test -f 'pidentd-2.7/install-sh' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'pidentd-2.7/install-sh' '(file already exists)'
else
$echo 'x -' extracting 'pidentd-2.7/install-sh' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'pidentd-2.7/install-sh' &&
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
X
X
# set DOITPROG to echo to test this script
X
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
X
X
# put in absolute paths if you don't have them in your path; or use env. vars.
X
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
X
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
X
while [ x"$1" != x ]; do
X case $1 in
X -c) instcmd="$cpprog"
X shift
X continue;;
X
X -d) dir_arg=true
X shift
X continue;;
X
X -m) chmodcmd="$chmodprog $2"
X shift
X shift
X continue;;
X
X -o) chowncmd="$chownprog $2"
X shift
X shift
X continue;;
X
X -g) chgrpcmd="$chgrpprog $2"
X shift
X shift
X continue;;
X
X -s) stripcmd="$stripprog"
X shift
X continue;;
X
X -t=*) transformarg=`echo $1 | sed 's/-t=//'`
X shift
X continue;;
X
X -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
X shift
X continue;;
X
X *) if [ x"$src" = x ]
X then
X src=$1
X else
X # this colon is to work around a 386BSD /bin/sh bug
X :
X dst=$1
X fi
X shift
X continue;;
X esac
done
X
if [ x"$src" = x ]
then
X echo "install: no input file specified"
X exit 1
else
X true
fi
X
if [ x"$dir_arg" != x ]; then
X dst=$src
X src=""
X
X if [ -d $dst ]; then
X instcmd=:
X else
X instcmd=mkdir
X fi
else
X
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
X
X if [ -f $src -o -d $src ]
X then
X true
X else
X echo "install: $src does not exist"
X exit 1
X fi
X
X if [ x"$dst" = x ]
X then
X echo "install: no destination specified"
X exit 1
X else
X true
X fi
X
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
X
X if [ -d $dst ]
X then
X dst="$dst"/`basename $src`
X else
X true
X fi
fi
X
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
X
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
X
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
X
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
X
pathcomp=''
X
while [ $# -ne 0 ] ; do
X pathcomp="${pathcomp}${1}"
X shift
X
X if [ ! -d "${pathcomp}" ] ;
X then
X $mkdirprog "${pathcomp}"
X else
X true
X fi
X
X pathcomp="${pathcomp}/"
done
fi
X
if [ x"$dir_arg" != x ]
then
X $doit $instcmd $dst &&
X
X if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
X if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
X if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
X if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
X
# If we're going to rename the final executable, determine the name now.
X
X if [ x"$transformarg" = x ]
X then
X dstfile=`basename $dst`
X else
X dstfile=`basename $dst $transformbasename |
X sed $transformarg`$transformbasename
X fi
X
# don't allow the sed command to completely eliminate the filename
X
X if [ x"$dstfile" = x ]
X then
X dstfile=`basename $dst`
X else
X true
X fi
X
# Make a temp file name in the proper directory.
X
X dsttmp=$dstdir/#inst.$$#
X
# Move or copy the file name to the temp name
X
X $doit $instcmd $src $dsttmp &&
X
X trap "rm -f ${dsttmp}" 0 &&
X
# and set any options; do chmod last to preserve setuid bits
X
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
X
X if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
X if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
X if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
X if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
X
# Now rename the file to the real destination.
X
X $doit $rmcmd -f $dstdir/$dstfile &&
X $doit $mvcmd $dsttmp $dstdir/$dstfile
X
fi &&
X
X
Xexit 0
SHAR_EOF
$shar_touch -am 0811230496 'pidentd-2.7/install-sh' &&
chmod 0755 'pidentd-2.7/install-sh' ||
$echo 'restore of' 'pidentd-2.7/install-sh' 'failed'


if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \

|| $echo 'pidentd-2.7/install-sh:' 'MD5 check failed'
e2f7509e56ca4245d80878e106226786 pidentd-2.7/install-sh
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pidentd-2.7/install-sh'`"
test 4773 -eq "$shar_count" ||
$echo 'pidentd-2.7/install-sh:' 'original size' '4773,' 'current size' "$shar_count!"
fi
fi
: || $echo 'restore of' 'pidentd-2.7/identd.8' 'failed'
$echo 'End of part' '8,' 'continue with part' '9'
exit 0

0 new messages