home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume39 / tcp_wrappers / part01 next >
Encoding:
Text File  |  1993-09-29  |  58.4 KB  |  1,480 lines

  1. Newsgroups: comp.sources.misc
  2. From: wietse@wzv.win.tue.nl (Wietse Venema)
  3. Subject: v39i110:  tcp_wrappers - TCP/IP daemon wrappers, v6.0, Part01/04
  4. Message-ID: <csm-v39i110=tcp_wrappers.165601@sparky.Sterling.COM>
  5. X-Md4-Signature: f7f0bba0608f3341f993d4d163f6a3fc
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Eindhoven University of Technology, The Netherlands
  8. Date: Wed, 29 Sep 1993 21:56:53 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: wietse@wzv.win.tue.nl (Wietse Venema)
  12. Posting-number: Volume 39, Issue 110
  13. Archive-name: tcp_wrappers/part01
  14. Environment: UNIX, INET
  15. Supersedes: log_tcp: Volume 36, Issue 4-6
  16.  
  17. This is the 6.0 version of the TCP/IP daemon wrapper package.
  18.  
  19. With these programs you can monitor and control who connects to your
  20. TFTP, EXEC, FTP, RSH, TELNET, RLOGIN, FINGER, and many other network
  21. services.  The programs can be installed without changes to existing
  22. software or configuration files.
  23.  
  24. Significant differences with respect to the previous release:
  25.  
  26.     - Easier to install: ready-to-use build procedures for many common
  27.     UNIX implementations (sun, ultrix, hp-ux, irix, aix, ...).
  28.  
  29.     - Support for the System V.4 TLI network programming interface
  30.     (Solaris, DG/UX etc.).  In case of TLI applications on top of
  31.     TCP/IP, the wrappers provide the same functionality as with
  32.     socket-based applications.
  33.  
  34.     - A more secure finger tool for automatic reverse finger probes.
  35.  
  36.     - New extension language keywords:  "severity", to adjust the log
  37.     noise level; "allow" and "deny", to keep all access-control rules
  38.     within a single file.
  39.  
  40.     - More support for selective remote username lookups.
  41.  
  42.     - More workarounds for System V bugs: IRIX username lookups, and
  43.     SCO problems with UDP.
  44.  
  45. The default mode of operation (no TLI support) should be backwards
  46. compatible with earlier versions. The library interface has changed,
  47. though, and programs that depend on the libwrap.a library will have to
  48. be recompiled before they can be relinked.
  49.  
  50.     Wietse Venema (wietse@wzv.win.tue.nl),
  51.     Department of Mathematics and Computing Science,
  52.     Eindhoven University of Technology,
  53.     The Netherlands.
  54. ----
  55. #! /bin/sh
  56. # This is a shell archive.  Remove anything before this line, then unpack
  57. # it by saving it into a file and typing "sh file".  To overwrite existing
  58. # files, type "sh file -c".  You can also feed this as standard input via
  59. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  60. # will see the following message at the end:
  61. #        "End of archive 1 (of 4)."
  62. # Contents:  README BLURB CHANGES DISCLAIMER clean_exit.c fakelog.c
  63. #   fix_options.c fromhost.c hosts_ctl.c hosts_info.c
  64. # Wrapped by wietse@wzv on Wed Sep 29 18:45:46 1993
  65. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  66. if test -f README -a "${1}" != "-c" ; then 
  67.   echo shar: Will not over-write existing file \"README\"
  68. else
  69. echo shar: Extracting \"README\" \(37825 characters\)
  70. sed "s/^X//" >README <<'END_OF_README'
  71. X@(#) README 1.17 93/09/28 23:03:22
  72. X
  73. XThis is the 6.0 version of the TCP/IP daemon wrapper package.
  74. X
  75. XTable of contents
  76. X-----------------
  77. X
  78. X    1 - Introduction
  79. X    2 - Disclaimer
  80. X    3 - Tutorials
  81. X        3.1 - How it works
  82. X        3.2 - Where the logging information goes
  83. X    4 - Features
  84. X        4.1 - Access control
  85. X        4.2 - Host name spoofing
  86. X        4.3 - Host address spoofing
  87. X        4.4 - Remote username lookups
  88. X        4.5 - Language extensions
  89. X    5 - Other works
  90. X        5.1 - Related documents
  91. X        5.2 - Related software
  92. X    6 - Limitations
  93. X        6.1 - Known wrapper limitations
  94. X        6.2 - Known system software bugs
  95. X    7 - Configuration and installation
  96. X        7.1 - Easy configuration and installation
  97. X        7.2 - Advanced configuration and installation
  98. X        7.3 - Daemons with arbitrary path names
  99. X        7.4 - Building and testing the access control rules
  100. X        7.5 - Other applications
  101. X    8 - Acknowledgements
  102. X
  103. X1 - Introduction
  104. X----------------
  105. X
  106. XWith this package you can monitor and filter incoming requests for the
  107. XSYSTAT, FINGER, FTP, TELNET, RLOGIN, RSH, EXEC, TFTP, TALK, and other
  108. Xnetwork services.
  109. X
  110. XIt supports both 4.3BSD-style sockets and System V.4-style TLI. Praise
  111. Xyourself lucky if you don't know what that means.
  112. X
  113. XThe package provides tiny daemon wrapper programs that can be installed
  114. Xwithout any changes to existing software or to existing configuration
  115. Xfiles.  The wrappers report the name of the remote host and of the
  116. Xrequested service; the wrappers do not exchange information with the
  117. Xremote client process, and impose no overhead on the actual
  118. Xcommunication between the client and server applications.
  119. X
  120. XOptional features are: access control to restrict what systems can
  121. Xconnect to your network daemons; remote user name lookups with the RFC
  122. X931 protocol; additional protection against hosts that pretend to have
  123. Xsomeone elses host name; additional protection against hosts that
  124. Xpretend to have someone elses host address.
  125. X
  126. XEarly versions of the programs were tested with Ultrix >= 2.2, with
  127. XSunOS >= 3.4 and ISC 2.2. Later versions have been installed on a wide
  128. Xvariety of platforms such as SunOS 4.x and 5.x, Ultrix 3.x and 4.x, DEC
  129. XOSF/1 T1.2-2, HP-UX 8.x, AIX 3.1.5 up to 3.2.4, Apollo SR10.3.5, Sony,
  130. XNeXT, SCO UNIX, DG/UX, Cray, and an unknown number of other ones.
  131. X
  132. XRequirements are that the network daemons are spawned by a super server
  133. Xsuch as the inetd; a 4.3BSD-style socket programming interface and/or
  134. XSystem V.4-style TLI programming interface; and the availability of a
  135. Xsyslog(3) library and of a syslogd(8) daemon.  The wrappers should run
  136. Xwithout modification on any system that satisfies these requirements.
  137. XWorkarounds have been implemented for several common bugs in systems
  138. Xsoftware.
  139. X
  140. XWhat to do if this is your first encounter with the wrapper programs:
  141. X1) read the tutorial sections for an introduction to the relevant
  142. Xconcepts and terminology; 2) glance over the security feature sections
  143. Xin this document; 3) follow the installation instructions (easy or
  144. Xadvanced). I recommend that you first use the default security feature
  145. Xsettings.  Run the wrappers for a few days to become familiar with
  146. Xtheir logs, before doing anything drastic such as cutting off access or
  147. Xinstalling booby traps.
  148. X
  149. X2 - Disclaimer
  150. X--------------
  151. X
  152. XThe wrapper programs rely on source address information obtained from
  153. Xnetwork packets. Such information is not 100 percent reliable, although
  154. Xthe wrappers do their best to expose forgeries.
  155. X
  156. XIn the absence of cryptographic protection of message contents, and of
  157. Xcryptographic authentication of message originators, all data from the
  158. Xnetwork should be treated with sound scepticism.
  159. X
  160. XTHIS RESTRICTION IS BY NO MEANS SPECIFIC TO THE TCP/IP PROTOCOLS.
  161. X
  162. X3 - Tutorials
  163. X-------------
  164. X
  165. XThe tutorial sections give a gentle introduction to the operation of
  166. Xthe wrapper programs, and introduce some of the terminology that is
  167. Xused in the remainder of the document: client, server, the inetd and
  168. Xsyslogd daemons, and their configuration files.
  169. X
  170. X3.1 - How it works
  171. X------------------
  172. X
  173. XAlmost every application of the TCP/IP protocols is based on a client-
  174. Xserver model. For example, when a user invokes the telnet command to
  175. Xconnect to one of your systems, a telnet server process is executed on
  176. Xthe target host. The telnet server process connects the user to a login
  177. Xprocess. A few examples of client and server programs are shown in the
  178. Xtable below:
  179. X
  180. X              client   server    application
  181. X              --------------------------------
  182. X              telnet   telnetd   remote login
  183. X              ftp      ftpd      file transfer
  184. X              finger   fingerd   show users
  185. X
  186. XThe usual approach is to run one single daemon process that waits for
  187. Xall kinds of incoming network connections. Whenever a connection is
  188. Xestablished, this daemon (usually called inetd) runs the appropriate
  189. Xserver program and goes back to sleep, waiting for other connections.
  190. X
  191. XThe wrapper programs rely on a simple, but powerful mechanism.  Instead
  192. Xof directly running the desired server program, the inetd is tricked
  193. Xinto running a small wrapper program. The wrapper logs the remote host
  194. Xname or address and performs some additional checks.  When all is well,
  195. Xthe wrapper executes the desired server program and goes away.
  196. X
  197. XThe wrapper programs have no interaction with the remote user (or
  198. Xclient process).  This has two major advantages: 1) the wrappers are
  199. Xapplication-independent, so that the same program can protect many
  200. Xkinds of network services; 2) no interaction also means that the
  201. Xwrappers are invisible from outside (at least for authorized users).
  202. X
  203. XAnother important property is that the wrapper programs are active only
  204. Xwhen the initial contact between client and server is established. Once
  205. Xa wrapper has done its work there is no overhead on the client-server
  206. Xcommunication.
  207. X
  208. XThe simple mechanism has one major drawback: since the wrappers go away
  209. Xafter the initial contact between client and server processes, the
  210. Xwrappers are of little use with network daemons that service more than
  211. Xone client.  The wrappers would only see the first client attempt to
  212. Xcontact such a server. The NFS mount daemon is a typical example of a
  213. Xdaemon that services requests from multiple clients. See the section on
  214. Xrelated software for ways to deal with such programs.
  215. X
  216. XThere are two ways to use the wrapper programs:
  217. X
  218. X1) The easy way: move network daemons to some other directory and fill
  219. X   the resulting holes with copies of the wrapper programs.  This
  220. X   approach involves no changes to system configuration files, so there
  221. X   is very little risk of breaking things.
  222. X
  223. X2) The advanced way: leave the network daemons alone and modify the
  224. X   inetd configuration file.  For example, an entry such as:
  225. X
  226. X     tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
  227. X
  228. X   When a tftp request arrives, inetd will run the wrapper program
  229. X   (tcpd) with a process name `in.tftpd'.  This is the name that the
  230. X   wrapper will use when logging the request and when scanning the
  231. X   optional access control tables.  `in.tftpd' is also the name of the
  232. X   server program that the wrapper will attempt to run when all is
  233. X   well.  Any arguments (`-s /tftpboot' in this particular example) are
  234. X   transparently passed on to the server program.
  235. X
  236. XFor an account of the history of the wrapper programs, with real-life
  237. Xexamples, see the section below on related documents.
  238. X
  239. X3.2 - Where the logging information goes
  240. X----------------------------------------
  241. X
  242. XThe wrapper programs send their logging information to the syslog
  243. Xdaemon (syslogd). The disposition of the wrapper logs is determined by
  244. Xthe syslog configuration file (usually /etc/syslog.conf). Messages are
  245. Xwritten to files, to the console, or are forwarded to a @loghost.
  246. X
  247. XOlder syslog implementations (still found on Ultrix systems) only
  248. Xsupport priority levels ranging from 9 (debug-level messages) to 0
  249. X(alerts). All logging information of the same priority level (or more
  250. Xurgent) is written to the same destination.  In the syslog.conf file,
  251. Xpriority levels are specified in numerical form.  For example,
  252. X
  253. X    8/usr/spool/mqueue/syslog
  254. X
  255. Xcauses all messages with priority 8 (informational messages), and
  256. Xanything that is more urgent, to be appended to the file
  257. X/usr/spool/mqueue/syslog.
  258. X
  259. XNewer syslog implementations support message classes in addition to
  260. Xpriority levels.  Examples of message classes are: mail, daemon, auth
  261. Xand news. In the syslog.conf file, priority levels are specified with
  262. Xsymbolic names: debug, info, notice, ..., emerg. For example,
  263. X
  264. X    mail.debug            /var/log/syslog
  265. X
  266. Xcauses all messages of class mail with priority debug (or more urgent)
  267. Xto be appended to the /var/log/syslog file.
  268. X
  269. XBy default, the wrapper logs go to the same place as the transaction
  270. Xlogs of the sendmail daemon. The disposition can be changed by editing
  271. Xthe Makefile and/or the syslog.conf file. Send a `kill -HUP' to the
  272. Xsyslogd after changing its configuration file. Remember that syslogd,
  273. Xjust like sendmail, insists on one or more TABs between the left-hand
  274. Xside and the right-hand side expressions in its configuration file.
  275. X
  276. X4 - Features
  277. X------------
  278. X
  279. X4.1 - Access control
  280. X--------------------
  281. X
  282. XWhen compiled with -DHOSTS_ACCESS, the wrapper programs support a
  283. Xsimple form of access control.  Access can be controlled per host, per
  284. Xservice, or combinations thereof. The software provides hooks for the
  285. Xexecution of shell commands when an access control rule fires; this
  286. Xfeature may be used to install "booby traps".  For details, see the
  287. Xhosts_access.5 manual page, which is in `nroff -man' format. A later
  288. Xsection describes how you can test your access control rules. The
  289. Xhosts_options.5 manual page describes additional features that
  290. Xare turned off by default.
  291. X
  292. XAccess control is enabled by default. It can be turned off by editing
  293. Xthe Makefile, or by providing no access control tables. The install
  294. Xinstructions below describe the Makefile editing process.
  295. X
  296. XWhen TCP/IP or UDP/IP is used underneath TLI, the wrapper programs
  297. Xprovide the same functions as with socket-based applications. When some
  298. Xother protocol is used underneath TLI, the host address will be some
  299. Xuniversal magic cookie that may not be usable for access control
  300. Xpurposes.
  301. X
  302. X4.2 - Host name spoofing
  303. X------------------------
  304. X
  305. XWith some network applications, such as RSH or RLOGIN, the remote host
  306. Xname plays an important role in the authentication process. Host name
  307. Xinformation can be reliable when lookups are done from a _local_ hosts
  308. Xtable, provided that the client IP address can be trusted.
  309. X
  310. XWith _distributed_ name services, authentication schemes that rely on
  311. Xhost names become more problematic. The security of your system now may
  312. Xdepend on some far-away DNS (domain name server) outside your own
  313. Xcontrol. 
  314. X
  315. XThe wrapper programs verify the remote host name that is returned by
  316. Xthe address->name DNS server, by asking for a second opinion.  To this
  317. Xend, the programs look at the name and addresses that are returned by
  318. Xthe name->address DNS server. 
  319. X
  320. XIf any name or address discrepancies are found, or if the second DNS
  321. Xopinion is not available, the wrappers assume that one of the two name
  322. Xservers is lying, and assume that the client host pretends to have
  323. Xsomeone elses host name.
  324. X
  325. XWhen the sources are compiled with -DPARANOID, the wrappers will drop
  326. Xthe connection in case of a host name/address discrepancy. 
  327. X
  328. XWhen the sources are not compiled with -DPARANOID, the wrappers just
  329. Xpretend that an offending host name is unknown.
  330. X
  331. XParanoid mode is enabled by default. It can be turned off by editing
  332. Xthe Makefile. The configuration and installation below describes the
  333. XMakefile editing process.
  334. X
  335. X4.3 - Host address spoofing
  336. X---------------------------
  337. X
  338. XWhile host name spoofing can be found out by asking a second opinion,
  339. Xit is much harder to find out that a host claims to have someone elses
  340. Xnetwork address. And since host names are deduced from network
  341. Xaddresses, address spoofing is at least as effective as name spoofing.
  342. X
  343. XThe wrapper programs can give additional protection against hosts that
  344. Xclaim to have an address that lies outside their own network.  For
  345. Xexample, some far-away host that claims to be a trusted host within
  346. Xyour own network. Such things are possible even while the impersonated
  347. Xsystem is up and running.
  348. X
  349. XThis additional protection is not an invention of my own; it has been
  350. Xpresent for at least five years in the BSD rsh and rlogin daemons.
  351. XUnfortunately, that feature was added *after* 4.3 BSD came out, so that
  352. Xvery few, if any, UNIX vendors have adopted it.  Our site, and many
  353. Xother ones, has been running these enhanced daemons for several years,
  354. Xand without any ill effects.
  355. X
  356. XWhen the programs are compiled with -DKILL_IP_OPTIONS, source routing
  357. Xwill be disabled for all TCP connections that are handled by the
  358. Xwrapper programs.
  359. X
  360. XAll this cannot be used with SunOS 4.x because of a kernel bug in the
  361. Ximplementation of the getsockopt() system call. Kernel panics have been
  362. Xobserved for SunOS 4.1.1 up to SunOS 4.1.3. The symptoms are "BAD TRAP"
  363. Xand "Data fault" while executing the tcp_ctloutput() kernel function.
  364. X
  365. XThe feature is disabled by default. It can be turned on by editing the
  366. XMakefile.  The configuration and installation section below describes
  367. Xthe Makefile editing process.
  368. X
  369. XUDP services do not benefit from this additional protection. With UDP,
  370. Xall you can be certain of is the network packet's destination address.
  371. X
  372. X4.4 - Remote username lookups
  373. X-----------------------------
  374. X
  375. XThe protocol proposed in RFC 931 provides a means to get the remote
  376. Xuser name from the client host.  The requirement is that the client
  377. Xhost runs an RFC 931-compliant daemon. The information provided by such
  378. Xa daemon is not intended to be used for authentication purposes, but it
  379. Xcan provide additional information about the owner of a TCP connection.
  380. X
  381. XThere are some limitations: the number of hosts that run an RFC 931 (or
  382. Xcompatible) daemon is small (but growing); remote user name lookups do
  383. Xnot work for datagram (UDP) connections. More seriously, remote user
  384. Xname lookups can cause noticeable delays with connections from non-UNIX
  385. XPCs. The wrappers use a 10-second timeout for RFC931 lookups, to
  386. Xaccommodate slow networks and slow hosts.
  387. X
  388. XBy default, the wrappers will do username lookup only when the access
  389. Xcontrol rules require them to do so.  The wrappers can be configured to
  390. Xalways perform remote username lookups by editing the Makefile.  The
  391. Xremote username lookup timeout period (10 seconds default) can also be
  392. Xchanged by editing the Makefile. The installation sections below
  393. Xdescribe the Makefile editing process.
  394. X
  395. XThe RFC 931 protocol has diverged into different directions (IDENT and
  396. XTAP). To add to the confusion, both protocols use the same network
  397. Xport.  The daemon wrappers implement a common subset of the protocols.
  398. X
  399. XWith TLI-based network services, remote username lookups will be
  400. Xpossible only when TCP/IP is the underlying network protocol.
  401. X
  402. X4.5 - Language extensions
  403. X-------------------------
  404. X
  405. XThe wrappers sport only a limited number of features. This is for a
  406. Xgood reason: programs that run at high privilege levels must be easy to
  407. Xverify. And the smaller a program, the easier to verify. There is,
  408. Xhowever, a provision to add features.
  409. X
  410. XThe options.c module provides a framework for language extensions.
  411. XQuite a few extensions have already been implemented; they are
  412. Xdocumented in the hosts_options.5 document, which is in `nroff -man'
  413. Xformat. Examples: changing the severity level at which a request for
  414. Xservice is logged; "allow" and "deny" keywords; running a customized
  415. Xserver instead of the standard one; many others.
  416. X
  417. XThe language extensions are not enabled by default because they
  418. Xintroduce an incompatible change to the access control language
  419. Xsyntax.  Instructions to enable the extensions are given in the
  420. XMakefile.
  421. X
  422. X5 - Other works
  423. X---------------
  424. X
  425. X5.1 - Related documents
  426. X-----------------------
  427. X
  428. XThe war story behind the wrapper tools is described in:
  429. X
  430. X    W.Z. Venema, "TCP WRAPPER, network monitoring, access control and
  431. X    booby traps", UNIX Security Symposium III Proceedings (Baltimore),
  432. X    September 1992. 
  433. X
  434. X    ftp.win.tue.nl:/pub/security/tcp_wrapper.ps.Z (postscript)
  435. X    ftp.win.tue.nl:/pub/security/tcp_wrapper.txt.Z (flat text)
  436. X
  437. XThe same cracker is also described in:
  438. X
  439. X    W.R. Cheswick, "An Evening with Berferd, In Which a Cracker is
  440. X    Lured, Endured, and Studied", Proceedings of the Winter USENIX
  441. X    Conference (San Francisco), January 1992.
  442. X
  443. X    research.att.com:/dist/internet_security/berferd.ps
  444. X
  445. X5.2 - Related software
  446. X----------------------
  447. X
  448. XNetwork daemons etc. with enhanced logging capabilities can generate
  449. Xmassive amounts of information: our 100+ workstations generate several
  450. Xhundred kbytes each day. egrep-based filters can help to suppress some
  451. Xof the noise.  A more powerful tool is the Swatch monitoring system by
  452. XStephen E. Hansen and E. Todd Atkins. Swatch can process log files in
  453. Xreal time and can associate arbitrary actions with patterns; its
  454. Xapplications are by no means restricted to security.  Swatch is
  455. Xavailable from sierra.stanford.edu, directory /pub/sources.
  456. X
  457. XSocks, described in the UNIX Security III proceedings, can be used to
  458. Xcontrol network traffic from hosts on an internal network, through a
  459. Xfirewall host, to the outer world. Socks consists of a daemon that is
  460. Xrun on the firewall host, and of a library with routines that redirect
  461. Xapplication socket calls through the firewall daemon.  Socks is
  462. Xavailable from s1.gov in /pub/socks.tar.Z.
  463. X
  464. XTcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
  465. Xand telnet commands across a firewall. Unlike socks it can be used with
  466. Xunmodified client software. Available from ftp.alantec.com, pub/tcpr.
  467. X
  468. XVersions of rshd and rlogind, modified to report the remote user name
  469. Xin addition to the remote host name, are available for anonymous ftp
  470. X(ftp.win.tue.nl:/pub/security/logdaemon-3.tar.Z).  These programs are
  471. Xdrop-in replacements for SunOS 4.x, Ultrix 4.x, and SunOS 5.x.
  472. X
  473. XThe securelib shared library by William LeFebvre can be used to control
  474. Xaccess to network daemons that are not run under control of the inetd
  475. Xor that serve more than one client, such as the NFS mount daemon that
  476. Xruns until the machine goes down.  Available from eecs.nwu.edu, file
  477. X/pub/securelib.tar.
  478. X
  479. Xxinetd (posted to comp.sources.unix) is an inetd replacement program
  480. Xthat provides, among others, logging, username lookup and access
  481. Xcontrol. However, it does not support TLI services, and it is only six
  482. Xtimes as much source code as the daemon wrapper programs.
  483. X
  484. XWhere shared libraries or router-based packet filtering are not an
  485. Xoption, an alternative portmap daemon can help to improve RPC security,
  486. Xin particular that of NFS and of the NIS (YP) information service.
  487. Xftp.win.tue.nl:/pub/security/portmap.shar.Z was tested with SunOS 4.1.1
  488. X... 4.1.3, Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and AIX. The protection
  489. Xis less effective than that of the securelib library because portmap is
  490. Xmostly a dictionary service.  SunOS 4.x users should install the latest
  491. Xrevision of the portmap and NIS daemons instead, or adopt NIS+ which
  492. Xhas access control built in.
  493. X
  494. XSource for a portable RFC 931 (TAP, IDENT)-compatible daemon by Peter
  495. XEriksson is available from ftp.lysator.liu.se:/pub/ident/servers.
  496. X
  497. XSome TCP/IP implementations come without syslog library. Some come with
  498. Xthe library but have no syslog daemon. A replacement can be found in
  499. Xftp.win.tue.nl:/pub/security/surrogate-syslog.tar.Z.  The fakesyslog
  500. Xlibrary that comes with the nntp sources reportedly works well, too.
  501. X
  502. X6 - Limitations
  503. X---------------
  504. X
  505. X6.1 - Known wrapper limitations
  506. X-------------------------------
  507. X
  508. XSome UDP (and rpc/udp) daemons linger around for a while after they
  509. Xhave serviced a request, just in case another request comes in.  In the
  510. Xinetd configuration file these daemons are registered with the `wait'
  511. Xoption. Only the request that started such a daemon will be seen by the
  512. Xwrappers.  Such daemons are better protected with the securelib shared
  513. Xlibrary (see: Related software).
  514. X
  515. XThe wrappers do not work with RPC services over TCP. These services are
  516. Xregistered as rpc/tcp in the inetd configuration file. The only non-
  517. Xtrivial service that is affected by this limitation is rexd, which is
  518. Xused by the on(1) command. This is no great loss.  On most systems,
  519. Xrexd is less secure than a wildcard in /etc/hosts.equiv.
  520. X
  521. XSome RPC requests (for example: rwall, rup, rusers) appear to come from
  522. Xthe responding host. What happens is that the client sends its request
  523. Xto all portmap daemons on its network; each portmap daemon forwards the
  524. Xrequest to its own system. As far as the rwall etc.  daemons know, the
  525. Xrequest comes from the local host.
  526. X
  527. XPortmap and RPC (e.g. NIS and NFS) (in)security is a topic in itself.
  528. XSee the section in this document on related software.
  529. X
  530. X6.2 - Known system software bugs
  531. X--------------------------------
  532. X
  533. XWorkarounds have been implemented for several bugs in system software.
  534. XThey are described in the Makefile. Unfortunately, some system software
  535. Xbugs cannot be worked around. The result is loss of functionality.
  536. X
  537. XOlder ConvexOS versions come with a broken recvfrom(2) implementation.
  538. XThis makes it impossible for the daemon wrappers to look up the
  539. Xremote host address (and hence, the name) in case of UDP requests.
  540. XA patch is available for ConvexOS 10.1; later releases should be OK.
  541. X
  542. XOn some systems, the optional RFC 931 remote username lookups may
  543. Xtrigger a kernel bug.  When a client host connects to your system, and
  544. Xthe RFC 931 connection from your system to that client is rejected by a
  545. Xrouter, your kernel may drop all connections with that client.  This is
  546. Xnot a bug in the wrapper programs: complain to your vendor, and don't
  547. Xenable remote user name lookups until the bug has been fixed.
  548. X
  549. XReportedly, SunOS 4.1.1, Next 2.0a, ISC 3.0 with TCP 1.3, and AIX 3.2.2
  550. Xand later are OK.
  551. X
  552. XSony News/OS 4.51, HP-UX 8-something and Ultrix 4.3 still have the bug.
  553. XReportedly, a fix for Ultrix is available ((CXO-8919).
  554. X
  555. XThe following procedure can be used (from outside the tue.nl domain) to
  556. Xfind out if your kernel has the bug. From the system under test, do:
  557. X
  558. X    % ftp 131.155.70.100
  559. X
  560. XThis command attempts to make an ftp connection to our anonymous ftp
  561. Xserver (ftp.win.tue.nl).  When the connection has been established, run
  562. Xthe following command from the same system under test, while keeping
  563. Xthe ftp connection open:
  564. X
  565. X    % telnet 131.155.70.100 111
  566. X
  567. XDo not forget the `111' at the end of the command. This telnet command
  568. Xattempts to connect to our portmap process.  The telnet command should
  569. Xfail with:  "host not reachable", or something like that. If your ftp
  570. Xconnection gets messed up, you have the bug. If the telnet command does
  571. Xnot fail, please let me know a.s.a.p.!
  572. X
  573. XFor those who care, the bug is that the BSD kernel code was not careful
  574. Xenough with incoming ICMP UNREACHABLE control messages (it ignored the
  575. Xlocal and remote port numbers, and therefore zapped *all* connections
  576. Xwith the remote system). The bug is still present in the BSD NET/1
  577. Xsource release (1989) but apparently has been fixed in BSD NET/2 (1991). 
  578. X
  579. X7 - Configuration and installation
  580. X----------------------------------
  581. X
  582. X7.1 - Easy configuration and installation
  583. X-----------------------------------------
  584. X
  585. XThe "easy" recipe requires no changes to existing software or
  586. Xconfiguration files.  Basically, you move the daemons that you want to
  587. Xprotect to a different directory and plug the resulting holes with
  588. Xcopies of the wrapper programs.
  589. X
  590. XIf you don't run Ultrix, you won't need the miscd wrapper program.  The
  591. Xmiscd daemon implements among others the SYSTAT service, which produces
  592. Xthe same output as the the WHO command.
  593. X
  594. XType `make' and follow the instructions.  The Makefile comes with
  595. Xready-to-use templates for many common UNIX implementations (sun,
  596. Xultrix, hp-ux, irix, ...).
  597. X
  598. XWhen the `make' succeeds the result is four executables (five in
  599. Xcase of Ultrix).
  600. X
  601. XThe `try' program can be used to play with host access control tables
  602. Xand is described in a later section.
  603. X
  604. XThe `safe_finger' command should be used when you implement booby
  605. Xtraps:  it gives better protection against nasty stuff that hosts may
  606. Xsend in response to finger probes.
  607. X
  608. XThe `try-from' program tests the host and username lookup code.  Run it
  609. Xfrom a remote shell command (`rsh host /some/where/try-from') and it
  610. Xshould be able to figure out from what system it is being called.
  611. X
  612. XThe tcpd program can be used to monitor the telnet, finger, ftp, exec,
  613. Xrsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
  614. Xa one-to-one mapping onto executable files.
  615. X
  616. XThe tcpd program can also be used for services that are marked as
  617. Xrpc/udp in the inetd configuration file, but not for rpc/tcp services
  618. Xsuch as rexd.  You probably do not want to run rexd anyway. On most
  619. Xsystems it is even less secure than a wildcard in /etc/hosts.equiv.
  620. X
  621. XWith System V.4-style systems, the tcpd program can also handle TLI
  622. Xservices. When TCP/IP or UDP/IP is used underneath TLI, the wrappers
  623. Xprovide the same functions as with socket-based applications. When some
  624. Xother protocol is used underneath TLI, functionality will be limited
  625. X(no remote username lookups, weird network address formats).
  626. X
  627. XDecide which services you want to monitor. Move the corresponding
  628. Xvendor-provided daemon programs to the location specified by the
  629. XREAL_DAEMON_DIR constant in the Makefile, and fill the holes with
  630. Xcopies of the tcpd wrapper. That is, one copy of (or link to) the tcpd
  631. Xprogram for each service that you want to monitor. For example, to
  632. Xmonitor the use of your finger service:
  633. X
  634. X    # mkdir REAL_DAEMON_DIR
  635. X    # mv /usr/etc/in.fingerd REAL_DAEMON_DIR
  636. X    # cp tcpd /usr/etc/in.fingerd
  637. X
  638. XThe example applies to SunOS 4. With other UNIX implementations the
  639. Xnetwork daemons live in /usr/libexec, /usr/sbin or in /etc, or have no
  640. X"in." prefix to their names, but you get the idea.
  641. X
  642. XUltrix only:  If you want to monitor the SYSTAT service, move the
  643. Xvendor-provided miscd daemon to the location specified by the
  644. XREAL_DAEMON_DIR macro in the Makefile, and install the miscd wrapper
  645. Xat the original miscd location.
  646. X
  647. XIn the absence of any access-control tables, the daemon wrappers
  648. Xwill just maintain a record of network connections made to your system.
  649. X
  650. X7.2 - Advanced configuration and installation
  651. X---------------------------------------------
  652. X
  653. XThe advanced recipe leaves your daemon executables alone, but involves
  654. Xsimple modifications to the inetd configuration file.
  655. X
  656. XType `make' and follow the instructions.  The Makefile comes with
  657. Xready-to-use templates for many common UNIX implementations (sun,
  658. Xultrix, hp-ux, irix, ...).
  659. X
  660. XWhen the `make' succeeds the result is four executables (five in
  661. Xcase of Ultrix).
  662. X
  663. XThe `try' program can be used to play with host access control tables
  664. Xand is described in a later section.
  665. X
  666. XThe `try-from' program tests the host and username lookup code.  Run it
  667. Xfrom a remote shell command (`rsh host /some/where/try-from') and it
  668. Xshould be able to figure out from what system it is being called.
  669. X
  670. XThe `safe_finger' command should be used when you implement a booby
  671. Xtrap:  it gives better protection against nasty stuff that hosts may
  672. Xsend in response to finger probes.
  673. X
  674. XThe tcpd program can be used to monitor the telnet, finger, ftp, exec,
  675. Xrsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
  676. Xa one-to-one mapping onto executable files.
  677. X
  678. XWith System V.4-style systems, the tcpd program can also handle TLI
  679. Xservices. When TCP/IP or UDP/IP is used underneath TLI, the wrappers
  680. Xprovide the same functions as with socket-based applications. When some
  681. Xother protocol is used underneath TLI, functionality will be limited
  682. X(no remote username lookups, weird network address formats).
  683. X
  684. XThe tcpd program can also be used for services that are marked as
  685. Xrpc/udp in the inetd configuration file, but not for rpc/tcp services
  686. Xsuch as rexd.  You probably do not want to run rexd anyway. On most
  687. Xsystems it is even less secure than a wildcard in /etc/hosts.equiv.
  688. X
  689. XInstall the tcpd command in a suitable place. Apollo UNIX users will
  690. Xwant to install it under a different name because the name "tcpd" is
  691. Xalready taken; a suitable name for the wrapper program would be
  692. X"frontd".  Then perform the following edits on the inetd configuration
  693. Xfile (usually /etc/inetd.conf or /etc/inet/inetd.conf):
  694. X
  695. X    finger  stream  tcp     nowait  nobody  /usr/etc/in.fingerd     in.fingerd
  696. X                                            ^^^^^^^^^^^^^^^^^^^
  697. Xbecomes:
  698. X
  699. X    finger  stream  tcp     nowait  nobody  /usr/etc/tcpd in.fingerd
  700. X                        ^^^^^^^^^^^^^
  701. XSend a `kill -HUP' to the inetd process to make the change effective.
  702. XSome inetd implementations require that you first disable the finger
  703. Xservice (comment out the finger service and `kill -HUP' the inetd)
  704. Xbefore you can turn on the modified version.
  705. X
  706. XThe example applies to SunOS 4. With other UNIX implementations the
  707. Xnetwork daemons live in /usr/libexec, /usr/sbin, or /etc, the network
  708. Xdaemons have no "in." prefix to their names, or the username field in
  709. Xthe inetd configuration file may be missing.
  710. X
  711. XWhen the finger service works as expected you can perform similar
  712. Xchanges for other network services. Do not forget the `kill -HUP'.
  713. X
  714. XThe miscd daemon that comes with Ultrix implements several network
  715. Xservices. It decides what to do by looking at its process name. One of
  716. Xthe services is systat, which is a kind of limited finger service.  If
  717. Xyou want to monitor the systat service, install the miscd wrapper in a
  718. Xsuitable place and update the inetd configuration file:
  719. X
  720. X    systat  stream  tcp     nowait  /suitable/place/miscd      systatd
  721. X
  722. XUltrix 4.3 allows you to specify a user id under which the daemon will
  723. Xbe executed. This feature is not documented in the manual pages.  Thus,
  724. Xthe example would become:
  725. X
  726. X    systat  stream  tcp     nowait  nobody /suitable/place/miscd    systatd
  727. X
  728. XOlder Ultrix systems still run all their network daemons as root.
  729. X
  730. XIn the absence of any access-control tables, the daemon wrappers
  731. Xwill just maintain a record of network connections made to your system.
  732. X
  733. X7.3 - Daemons with arbitrary path names
  734. X---------------------------------------
  735. X
  736. XThe above tcpd examples work fine with network daemons that live in a
  737. Xcommon directory, but sometimes that is not practical. Having soft
  738. Xlinks all over your file system is not a clean solution, either.
  739. X
  740. XInstead you can specify, in the inetd configuration file, an absolute
  741. Xpath name for the daemon process name.  For example,
  742. X
  743. X    ntalk   dgram   udp     wait    root    /usr/etc/tcpd /usr/local/lib/ntalkd
  744. X
  745. XWhen the daemon process name is an absolute path name, tcpd ignores the
  746. Xvalue of the REAL_DAEMON_DIR constant, and uses the last path component
  747. Xof the daemon process name for logging and for access control.
  748. X
  749. X7.4 - Building and testing the access control rules
  750. X---------------------------------------------------
  751. X
  752. XIn order to support access control the wrappers must be compiled with
  753. Xthe -DHOSTS_ACCESS option. The access control policy is given in the
  754. Xform of two tables (default: /etc/hosts.allow and /etc/hosts.deny).
  755. XAccess control is disabled when there are no access control tables, or
  756. Xwhen the tables are empty.
  757. X
  758. XIf you haven't used the wrappers before I recommend that you first run
  759. Xthem a couple of days without any access control restrictions. The
  760. Xlogfile records should give you an idea of the process names and of the
  761. Xhost names that you will have to build into your access control rules.
  762. X
  763. XThe syntax of the access control rules is documented in the file
  764. Xhosts_access.5, which is in `nroff -man' format. This is a lengthy
  765. Xdocument, and no-one expects you to read it right away from beginning
  766. Xto end.  Instead, after reading the introductory section, skip to the
  767. Xexamples at the end so that you get a general idea of the language.
  768. XThen you can appreciate the detailed reference sections near the
  769. Xbeginning of the document.
  770. X
  771. XThe examples in the hosts_access.5 document (`nroff -man' format) show
  772. Xtwo specific types of access control policy:  1) mostly closed (only
  773. Xpermitting access from a limited number of systems) and 2) mostly open
  774. X(permitting access from everyone except a limited number of trouble
  775. Xmakers). You will have to choose what model suits your situation best.
  776. XImplementing a mixed policy should not be overly difficult either.
  777. X
  778. XOptional extensions to the access control language are described in the
  779. Xhosts_options.5 document (`nroff -man' format).
  780. X
  781. XThe `try' command can be used to try out your local access control
  782. Xfiles.  The command syntax is:
  783. X
  784. X    ./try process_name hostname    (e.g.: ./try in.tftpd localhost)
  785. X
  786. X    ./try process_name address    (e.g.: ./try in.tftpd 127.0.0.1)
  787. X
  788. XThis way you can simulate what decisions will be made, and what actions
  789. Xwill be taken, when hosts connect to your own system.
  790. X
  791. XNote 1: `try -d' will look for hosts.{allow,deny} tables in the
  792. Xcurrent working directory. This is useful for testing new rules
  793. Xwithout bothering your users.
  794. X
  795. XNote 2: you cannot use the `try' command to simulate what happens when
  796. Xthe local system connects to other hosts.
  797. X
  798. XIn order to find out what process name to use, just use the service and
  799. Xwatch the process name that shows up in the logfile.  Alternatively,
  800. Xyou can look up the name from the inetd configuration file. Coming back
  801. Xto the tftp example in the tutorial section above:
  802. X
  803. X    tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
  804. X
  805. XThis entry causes the inetd to run the wrapper program (tcpd) with a
  806. Xprocess name `in.tftpd'.  This is the name that the wrapper will use
  807. Xwhen scanning the access control tables. Therefore, `in.tftpd' is the
  808. Xprocess name that should be given to the `try' command. On your system
  809. Xthe actual inetd.conf entry may differ (tftpd instead of in.tftpd, and
  810. Xno `root' field), but you get the idea.
  811. X
  812. XWhen you specify a host name, the `try' program will use both the host
  813. Xname and address. This way you can simulate the most common case where
  814. Xthe wrappers know both the host address and the host name.  The `try'
  815. Xprogram will iterate over all addresses that it can find for the given
  816. Xhost name.
  817. X
  818. XWhen you specify a host address instead of a host name, the `try'
  819. Xprogram will pretend that the host name is unknown, so that you can
  820. Xsimulate what happens when the wrapper is unable to look up the remote
  821. Xhost name.
  822. X
  823. XThe `try' command will report serious errors to the standard error
  824. Xstream (no need to tail the syslog file anymore).
  825. X
  826. X7.5 - Other applications
  827. X------------------------
  828. X
  829. XThe access control routines can easily be integrated with other
  830. Xprograms.  The hosts_access.3 manual page (`nroff -man' format)
  831. Xdescribes the external interface of the libwrap.a library.
  832. X
  833. XThe tcpd wrapper can even be used to control access to the smtp port.
  834. XIn that case, sendmail should not be run as a stand-alone daemon, but
  835. Xit should be registered in the inetd configuration file. For example:
  836. X
  837. X    smtp    stream  tcp     nowait  root    /usr/etc/tcpd /usr/lib/sendmail -bs
  838. X
  839. XYou will periodically want to run sendmail to process queued-up
  840. Xmessages. A crontab entry like:
  841. X
  842. X    0,15,30,45 * * * * /usr/lib/sendmail -q
  843. X
  844. Xshould take care of that. When you are going to "protect" your sendmail
  845. Xdaemon this way, you should realize that there are many "unprotected"
  846. Xsendmail daemons all over the network that can still be abused.
  847. X
  848. X8 - Acknowledgements
  849. X--------------------
  850. X
  851. XMany people contributed to the evolution of the programs, by asking
  852. Xinspiring questions, by suggesting features or bugfixes, or by
  853. Xsubmitting source code.  Nevertheless, all mistakes and bugs in the
  854. Xwrappers are my own.
  855. X
  856. XThanks to Brendan Kehoe (brendan@cs.widener.edu), Heimir Sverrisson
  857. X(heimir@hafro.is) and Dan Bernstein (brnstnd@kramden.acf.nyu.edu) for
  858. Xfeedback on an early release of this product.  The host name/address
  859. Xcheck was suggested by John Kimball (jkimball@src.honeywell.com).
  860. XApollo's UNIX environment has some peculiar quirks: Willem-Jan Withagen
  861. X(wjw@eb.ele.tue.nl), Pieter Schoenmakers (tiggr@es.ele.tue.nl) and
  862. XCharles S. Fuller (fuller@wccs.psc.edu) provided assistance.  Hal R.
  863. XBrand (BRAND@addvax.llnl.gov) told me how to get the remote IP address
  864. Xin case of datagram-oriented services, and suggested the optional shell
  865. Xcommand feature.  Shabbir Safdar (shabby@mentor.cc.purdue.edu) provided
  866. Xa first version of a much-needed manual page.  Granville Boman Goza, IV
  867. X(gbg@sei.cmu.edu) suggested to use the remote IP address even when the
  868. Xhost name is available.  Casper H.S. Dik (casper@fwi.uva.nl) provided
  869. Xadditional insight into DNS spoofing techniques.  The bogus daemon
  870. Xfeature was inspired by code from Andrew Macpherson (BNR Europe Ltd).
  871. XSteve Bellovin (smb@research.att.com) confirmed some of my suspicions
  872. Xabout the darker sides of TCP/IP insecurity. Risks of automated fingers
  873. Xwere pointed out by Borja Marcos (borjam@we.lc.ehu.es). Brad Plecs
  874. X(mbp@jhuspo.ca.jhu.edu) was kind enough to try my early TLI code and
  875. Xto work out how DG/UX differs from Solaris.
  876. X
  877. XJohn P.  Rouillard (rouilj@cs.umb.edu) deserves special mention for his
  878. Xpersistent, but constructive, nagging about wrong or missing things,
  879. Xand for trying out and discussing embryonic code or ideas.
  880. X
  881. XLat but not least, Howard Chu (hyc@hanauma.jpl.nasa.gov), Darren Reed
  882. X(avalon@coombs.anu.edu.au), Icarus Sparry (I.Sparry@gdr.bath.ac.uk),
  883. XScott Schwartz (schwartz@ cs.psu.edu), John A. Kunze
  884. X(jak@violet.berkeley.edu), Daniel Len Schales (dan@engr.latech.edu),
  885. XChris Turbeville <turbo@cse.uta.edu>, Paul Kranenburg
  886. X<pk@cs.few.eur.nl>, Marc Boucher <marc@cam.org>, Dave Mitchell
  887. X<D.Mitchell@dcs.shef.ac.uk>, and many, many others provided fixes, code
  888. Xfragments, or other improvements to the wrappers.
  889. X
  890. X    Wietse Venema (wietse@wzv.win.tue.nl)
  891. X    Department of Mathematics and Computing Science
  892. X    Eindhoven University of Technology
  893. X    P.O. Box 513
  894. X    5600 MB Eindhoven
  895. X    The Netherlands
  896. END_OF_README
  897. if test 37825 -ne `wc -c <README`; then
  898.     echo shar: \"README\" unpacked with wrong size!
  899. fi
  900. # end of overwriting check
  901. fi
  902. if test -f BLURB -a "${1}" != "-c" ; then 
  903.   echo shar: Will not over-write existing file \"BLURB\"
  904. else
  905. echo shar: Extracting \"BLURB\" \(1735 characters\)
  906. sed "s/^X//" >BLURB <<'END_OF_BLURB'
  907. X@(#) BLURB 1.14 93/09/28 23:03:27
  908. X
  909. XThis is the 6.0 version of the TCP/IP daemon wrapper package.
  910. X
  911. XWith these programs you can monitor and control who connects to your
  912. XTFTP, EXEC, FTP, RSH, TELNET, RLOGIN, FINGER, and SYSTAT network
  913. Xservices, and many others.
  914. X
  915. XThe programs can be installed without any changes to existing software
  916. Xor configuration files. By default, they just log the remote host name
  917. Xand do some sanity checks on the origin of the request. No information
  918. Xis exchanged with the remote client process.
  919. X
  920. XSignificant differences with respect to the previous release:
  921. X
  922. X    - Easier to install: ready-to-use build procedures for many common
  923. X    UNIX implementations (sun, ultrix, hp-ux, irix, aix, ...).
  924. X
  925. X    - Support for the System V.4 TLI network programming interface
  926. X    (Solaris, DG/UX etc.).  In case of TLI applications on top of
  927. X    TCP/IP, the wrappers provide the same functionality as with
  928. X    socket-based applications.
  929. X
  930. X    - A more secure finger tool for automatic reverse finger probes.
  931. X
  932. X    - New extension language keywords:  "severity", to adjust the log
  933. X    noise level; "allow" and "deny", to keep all access-control rules
  934. X    within a single file.
  935. X
  936. X    - More support for selective remote username lookups.
  937. X
  938. X    - More workarounds for System V bugs: IRIX username lookups, and
  939. X    SCO problems with UDP.
  940. X
  941. XThe default mode of operation (no TLI support) should be backwards
  942. Xcompatible with earlier versions. The library interface has changed,
  943. Xthough, and programs that depend on the libwrap.a library will have to
  944. Xbe recompiled before they can be relinked.
  945. X
  946. X    Wietse Venema (wietse@wzv.win.tue.nl),
  947. X    Department of Mathematics and Computing Science,
  948. X    Eindhoven University of Technology,
  949. X    The Netherlands.
  950. END_OF_BLURB
  951. if test 1735 -ne `wc -c <BLURB`; then
  952.     echo shar: \"BLURB\" unpacked with wrong size!
  953. fi
  954. # end of overwriting check
  955. fi
  956. if test -f CHANGES -a "${1}" != "-c" ; then 
  957.   echo shar: Will not over-write existing file \"CHANGES\"
  958. else
  959. echo shar: Extracting \"CHANGES\" \(2334 characters\)
  960. sed "s/^X//" >CHANGES <<'END_OF_CHANGES'
  961. XChanges per release 6.0.
  962. X========================
  963. X
  964. X- Easy build procedures for common platforms (sun, ultrix, aix, hpux
  965. Xand others).
  966. X
  967. X- TLI support, System V.4 style (Solaris, DG/UX).
  968. X
  969. X- Username lookup integrated with the access control language.
  970. XSelective username lookups are now the default (was: no username
  971. Xlookups).
  972. X
  973. X- A safer finger command for booby traps. This one solves a host of
  974. Xpossible problems with automatic reverse fingers. Thanks, Borja Marcos
  975. X(borjam@we.lc.ehu.es) for some inspiring discussions.
  976. X
  977. X- KNOWN pattern that matches hosts whose name and address are known.
  978. X
  979. X- Cleanup of diagnostics. Errors in access-control files are now shown
  980. Xwith file name and line number.
  981. X
  982. X- With AIX 3.2, hostnames longer than 32 would be truncated.  This
  983. Xcaused hostname verification failures, so that service would be refused
  984. Xwhen paranoid mode was enabled.  Found by:  Adrian van Bloois
  985. X(A.vanBloois@info.nic.surfnet.nl).
  986. X
  987. X- With some IRIX versions, remote username lookups failed because the
  988. Xfgets() library function does not handle partial read()s from sockets.
  989. XFound by:  Daniel O'Callaghan (danny@austin.unimelb.edu.au).
  990. X
  991. X- Added a DISCLAIMER document to help you satisfy legal departments.
  992. X
  993. XThe extension language module has undergone major revisions and
  994. Xextensions.  Thanks, John P. Rouillard (rouilj@ra.cs.umb.edu) for
  995. Xdiscussions, experiments, and for being a good guinea pig. The
  996. Xextensions are documented in hosts_options.5, and are enabled by
  997. Xediting the Makefile STYLE macro definition.
  998. X
  999. X- (Extension language) The ":" separator may now occur within options
  1000. Xas long as it is protected with a backslash. A warning is issued when
  1001. Xa rule ends on ":".
  1002. X
  1003. X- (Extension language) Better verification mode. When the `try' command
  1004. Xis run, each option function now explains what it would do.
  1005. X
  1006. X- (Extension language) New "allow" and "deny" keywords so you can now
  1007. Xhave all rules within a single file. See "nroff -man hosts_options.5"
  1008. Xfor examples.
  1009. X
  1010. X- (Extension language) "linger" keyword to set the socket linger time
  1011. X(SO_LINGER). From:  Marc Boucher <marc@cam.org>.
  1012. X
  1013. X- (Extension language) "severity" keyword to turn the logging noise up
  1014. Xor down. Many sites wanted a means to shut up the program; other sites
  1015. Xwanted to to emphasize specific events.  Adapted from code contributed
  1016. Xby Dave Mitchell <D.Mitchell@dcs.shef.ac.uk>.
  1017. END_OF_CHANGES
  1018. if test 2334 -ne `wc -c <CHANGES`; then
  1019.     echo shar: \"CHANGES\" unpacked with wrong size!
  1020. fi
  1021. # end of overwriting check
  1022. fi
  1023. if test -f DISCLAIMER -a "${1}" != "-c" ; then 
  1024.   echo shar: Will not over-write existing file \"DISCLAIMER\"
  1025. else
  1026. echo shar: Extracting \"DISCLAIMER\" \(973 characters\)
  1027. sed "s/^X//" >DISCLAIMER <<'END_OF_DISCLAIMER'
  1028. X/************************************************************************
  1029. X* Copyright 1993 by Wietse Venema.  All rights reserved.  Some individual
  1030. X* files may be covered by other copyrights.
  1031. X*
  1032. X* This material was originally written and compiled by Wietse Venema at
  1033. X* Eindhoven University of Technology, The Netherlands, in 1990, 1991,
  1034. X* 1992 and 1993.
  1035. X*
  1036. X* Redistribution and use in source and binary forms are permitted
  1037. X* provided that this entire copyright notice is duplicated in all such
  1038. X* copies.  No charge, other than an "at-cost" distribution fee, may be
  1039. X* charged for copies, derivations, or distributions of this material
  1040. X* without the express written consent of the copyright holder.
  1041. X*
  1042. X* This software is provided "as is" and without any expressed or implied
  1043. X* warranties, including, without limitation, the implied warranties of
  1044. X* merchantibility and fitness for any particular purpose.
  1045. X************************************************************************/
  1046. END_OF_DISCLAIMER
  1047. if test 973 -ne `wc -c <DISCLAIMER`; then
  1048.     echo shar: \"DISCLAIMER\" unpacked with wrong size!
  1049. fi
  1050. # end of overwriting check
  1051. fi
  1052. if test -f clean_exit.c -a "${1}" != "-c" ; then 
  1053.   echo shar: Will not over-write existing file \"clean_exit.c\"
  1054. else
  1055. echo shar: Extracting \"clean_exit.c\" \(1075 characters\)
  1056. sed "s/^X//" >clean_exit.c <<'END_OF_clean_exit.c'
  1057. X /*
  1058. X  * clean_exit() cleans up and terminates the program. It should be called
  1059. X  * instead of exit when for some reason the real network daemon will not or
  1060. X  * cannot be run. Reason: in the case of a datagram-oriented service we must
  1061. X  * discard the not-yet received data from the client. Otherwise, inetd will
  1062. X  * see the same datagram again and again, and go into a loop.
  1063. X  * 
  1064. X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1065. X  */
  1066. X
  1067. X#ifndef lint
  1068. Xstatic char sccsid[] = "@(#) clean_exit.c 1.3 93/09/11 20:45:43";
  1069. X#endif
  1070. X
  1071. X#include <stdio.h>
  1072. X
  1073. Xextern void exit();
  1074. X
  1075. X#include "log_tcp.h"
  1076. X
  1077. X/* clean_exit - clean up and exit */
  1078. X
  1079. Xvoid    clean_exit(client)
  1080. Xstruct client_info *client;
  1081. X{
  1082. X
  1083. X    /*
  1084. X     * In case of unconnected protocols we must eat up the not-yet received
  1085. X     * data or inetd will loop.
  1086. X     */
  1087. X
  1088. X    if (client->sink)
  1089. X    client->sink(client->fd);
  1090. X
  1091. X    /*
  1092. X     * Be kind to the inetd. We already reported the problem via the syslogd,
  1093. X     * and there is no need for additional garbage in the logfile.
  1094. X     */
  1095. X
  1096. X    sleep(1);
  1097. X    exit(0);
  1098. X}
  1099. END_OF_clean_exit.c
  1100. if test 1075 -ne `wc -c <clean_exit.c`; then
  1101.     echo shar: \"clean_exit.c\" unpacked with wrong size!
  1102. fi
  1103. # end of overwriting check
  1104. fi
  1105. if test -f fakelog.c -a "${1}" != "-c" ; then 
  1106.   echo shar: Will not over-write existing file \"fakelog.c\"
  1107. else
  1108. echo shar: Extracting \"fakelog.c\" \(2288 characters\)
  1109. sed "s/^X//" >fakelog.c <<'END_OF_fakelog.c'
  1110. X /*
  1111. X  * This module intercepts syslog() library calls and redirects their output
  1112. X  * to the standard error stream. For interactive testing. Not for critical
  1113. X  * applications, because it will happily write beyond the end of buffers.
  1114. X  * 
  1115. X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1116. X  */
  1117. X
  1118. X#ifndef lint
  1119. Xstatic char sccsid[] = "@(#) fakelog.c 1.2 93/09/25 12:56:20";
  1120. X#endif
  1121. X
  1122. X#include <stdio.h>
  1123. X
  1124. X /*
  1125. X  * What follows is an attempt to unify varargs.h and stdarg.h. I'd rather
  1126. X  * have this than #ifdefs all over the code.
  1127. X  */
  1128. X
  1129. X#ifdef __STDC__
  1130. X#include <stdarg.h>
  1131. X#define VARARGS(func,type,arg) func(type arg, ...)
  1132. X#define VASTART(ap,type,name)  va_start(ap,name)
  1133. X#define VAEND(ap)              va_end(ap)
  1134. X#else
  1135. X#include <varargs.h>
  1136. X#define VARARGS(func,type,arg) func(va_alist) va_dcl
  1137. X#define VASTART(ap,type,name)  {type name; va_start(ap); name = va_arg(ap, type)
  1138. X#define VAEND(ap)              va_end(ap);}
  1139. X#endif
  1140. X
  1141. Xextern int errno;
  1142. Xextern char *sys_errlist[];
  1143. Xextern int sys_nerr;
  1144. Xextern char *strcpy();
  1145. X
  1146. X/* percentm - replace %m by error message associated with value in err */
  1147. X
  1148. Xchar   *percentm(buf, str, err)
  1149. Xchar   *buf;
  1150. Xchar   *str;
  1151. Xint     err;
  1152. X{
  1153. X    char   *ip = str;
  1154. X    char   *op = buf;
  1155. X
  1156. X    while (*ip) {
  1157. X    switch (*ip) {
  1158. X    case '%':
  1159. X        switch (ip[1]) {
  1160. X        case '\0':                /* don't fall off end */
  1161. X        *op++ = *ip++;
  1162. X        break;
  1163. X        case 'm':                /* replace %m */
  1164. X        if (err < sys_nerr && err > 0)
  1165. X            strcpy(op, sys_errlist[err]);
  1166. X        else
  1167. X            sprintf(op, "Unknown error %d", err);
  1168. X        op += strlen(op);
  1169. X        ip += 2;
  1170. X        break;
  1171. X        default:                /* leave %<any> alone */
  1172. X        *op++ = *ip++, *op++ = *ip++;
  1173. X        break;
  1174. X        }
  1175. X    default:
  1176. X        *op++ = *ip++;
  1177. X    }
  1178. X    }
  1179. X    *op = 0;
  1180. X    return (buf);
  1181. X}
  1182. X
  1183. X/* openlog - dummy */
  1184. X
  1185. X/* ARGSUSED */
  1186. X
  1187. Xopenlog(name, logopt, facility)
  1188. Xchar   *name;
  1189. Xint     logopt;
  1190. Xint     facility;
  1191. X{
  1192. X    /* void */
  1193. X}
  1194. X
  1195. X/* syslog - append record to system log -- not */
  1196. X
  1197. X/* VARARGS */
  1198. X
  1199. XVARARGS(syslog, int, severity)
  1200. X{
  1201. X    va_list ap;
  1202. X    char   *fmt;
  1203. X    int     err = errno;
  1204. X    char    buf[BUFSIZ];
  1205. X
  1206. X    VASTART(ap, int, severity);
  1207. X    fmt = va_arg(ap, char *);
  1208. X    fprintf(stderr, " ");
  1209. X    vfprintf(stderr, percentm(buf, fmt, err), ap);
  1210. X    fprintf(stderr, "\n");
  1211. X    VAEND(ap);
  1212. X}
  1213. X
  1214. X/* closelog - dummy */
  1215. X
  1216. Xcloselog()
  1217. X{
  1218. X    /* void */
  1219. X}
  1220. END_OF_fakelog.c
  1221. if test 2288 -ne `wc -c <fakelog.c`; then
  1222.     echo shar: \"fakelog.c\" unpacked with wrong size!
  1223. fi
  1224. # end of overwriting check
  1225. fi
  1226. if test -f fix_options.c -a "${1}" != "-c" ; then 
  1227.   echo shar: Will not over-write existing file \"fix_options.c\"
  1228. else
  1229. echo shar: Extracting \"fix_options.c\" \(1348 characters\)
  1230. sed "s/^X//" >fix_options.c <<'END_OF_fix_options.c'
  1231. X /*
  1232. X  * Routine to disable IP-level socket options. This code was taken from 4.4BSD
  1233. X  * rlogind source, but all mistakes in it are my fault.
  1234. X  *
  1235. X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1236. X  */
  1237. X
  1238. X#ifndef lint
  1239. Xstatic char sccsid[] = "@(#) fix_options.c 1.2 93/09/11 20:45:45";
  1240. X#endif
  1241. X
  1242. X#include <sys/types.h>
  1243. X#include <sys/param.h>
  1244. X#include <netinet/in.h>
  1245. X#include <netdb.h>
  1246. X#include <stdio.h>
  1247. X#include <syslog.h>
  1248. X
  1249. X#include "log_tcp.h"
  1250. X
  1251. X/* fix_options - get rid of IP-level socket options */
  1252. X
  1253. Xfix_options(client)
  1254. Xstruct client_info *client;
  1255. X{
  1256. X#ifdef IP_OPTIONS
  1257. X    unsigned char optbuf[BUFSIZ / 3], *cp;
  1258. X    char    lbuf[BUFSIZ], *lp;
  1259. X    int     optsize = sizeof(optbuf), ipproto;
  1260. X    struct protoent *ip;
  1261. X    int     fd = client->fd;
  1262. X
  1263. X    if ((ip = getprotobyname("ip")) != 0)
  1264. X    ipproto = ip->p_proto;
  1265. X    else
  1266. X    ipproto = IPPROTO_IP;
  1267. X
  1268. X    if (getsockopt(fd, ipproto, IP_OPTIONS, (char *) optbuf, &optsize) == 0
  1269. X    && optsize != 0) {
  1270. X    lp = lbuf;
  1271. X    for (cp = optbuf; optsize > 0; cp++, optsize--, lp += 3)
  1272. X        sprintf(lp, " %2.2x", *cp);
  1273. X    syslog(LOG_NOTICE,
  1274. X           "connect from %s with IP options (ignored):%s",
  1275. X           hosts_info(client), lbuf);
  1276. X    if (setsockopt(fd, ipproto, IP_OPTIONS, (char *) 0, optsize) != 0) {
  1277. X        syslog(LOG_ERR, "setsockopt IP_OPTIONS NULL: %m");
  1278. X        clean_exit(client);
  1279. X    }
  1280. X    }
  1281. X#endif
  1282. X}
  1283. END_OF_fix_options.c
  1284. if test 1348 -ne `wc -c <fix_options.c`; then
  1285.     echo shar: \"fix_options.c\" unpacked with wrong size!
  1286. fi
  1287. # end of overwriting check
  1288. fi
  1289. if test -f fromhost.c -a "${1}" != "-c" ; then 
  1290.   echo shar: Will not over-write existing file \"fromhost.c\"
  1291. else
  1292. echo shar: Extracting \"fromhost.c\" \(2196 characters\)
  1293. sed "s/^X//" >fromhost.c <<'END_OF_fromhost.c'
  1294. X /*
  1295. X  * On socket-only systems, fromhost() is nothing but an alias for the
  1296. X  * socket-specific sock_host() function.
  1297. X  * 
  1298. X  * On systems with sockets and TLI, fromhost() determines the type of API
  1299. X  * (sockets, TLI), then invokes the appropriate API-specific routines.
  1300. X  * 
  1301. X  * The API-specific routines determine the nature of the service (datagram,
  1302. X  * stream), and the name and address of the host at the other end. In case
  1303. X  * of an IP service, these routines also determine the local address and
  1304. X  * port, and the remote username if username lookups are done irrespective
  1305. X  * of client. All results are in static memory.
  1306. X  * 
  1307. X  * The return value is (-1) if the remote host pretends to have someone elses
  1308. X  * name, or if the remote host name is available but could not be verified;
  1309. X  * in either case the hostname will be ignored. The return status is zero in
  1310. X  * all other cases (the hostname is unavailable, or the host name double
  1311. X  * check succeeds).
  1312. X  * 
  1313. X  * Diagnostics are reported through syslog(3).
  1314. X  * 
  1315. X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1316. X  */
  1317. X
  1318. X#ifndef lint
  1319. Xstatic char sccsid[] = "@(#) fromhost.c 1.13 93/09/24 19:16:08";
  1320. X#endif
  1321. X
  1322. X/* System libraries. */
  1323. X
  1324. X#include <sys/types.h>
  1325. X#include <stdio.h>
  1326. X#include <syslog.h>
  1327. X
  1328. X#ifdef TLI
  1329. X#include <sys/tiuser.h>
  1330. X#include <stropts.h>
  1331. X#endif
  1332. X
  1333. X/* Local stuff. */
  1334. X
  1335. X#include "log_tcp.h"
  1336. X
  1337. X#ifdef TLI
  1338. X
  1339. X/* fromhost - find out what network API we should use */
  1340. X
  1341. Xint     fromhost(client)
  1342. Xstruct client_info *client;
  1343. X{
  1344. X
  1345. X    /*
  1346. X     * On systems with streams support the IP network protocol family may
  1347. X     * have more than one programming interface (sockets and TLI).
  1348. X     * 
  1349. X     * Thus, we must first find out what programming interface to use: sockets
  1350. X     * or TLI. On some systems, sockets are not part of the streams system,
  1351. X     * so if stdin is not a stream we assume sockets.
  1352. X     */
  1353. X
  1354. X    if (!isastream(client->fd))
  1355. X    return (sock_host(client));
  1356. X    if (ioctl(0, I_FIND, "timod") > 0)
  1357. X    return (tli_host(client));
  1358. X    if (ioctl(0, I_FIND, "sockmod") > 0)
  1359. X    return (sock_host(client));
  1360. X    syslog(LOG_ERR, "wrapper: cannot establish type of transport interface");
  1361. X    return (0);
  1362. X}
  1363. X
  1364. X#endif /* TLI */
  1365. END_OF_fromhost.c
  1366. if test 2196 -ne `wc -c <fromhost.c`; then
  1367.     echo shar: \"fromhost.c\" unpacked with wrong size!
  1368. fi
  1369. # end of overwriting check
  1370. fi
  1371. if test -f hosts_ctl.c -a "${1}" != "-c" ; then 
  1372.   echo shar: Will not over-write existing file \"hosts_ctl.c\"
  1373. else
  1374. echo shar: Extracting \"hosts_ctl.c\" \(1065 characters\)
  1375. sed "s/^X//" >hosts_ctl.c <<'END_OF_hosts_ctl.c'
  1376. X /*
  1377. X  * hosts_ctl() combines the most common applications of the host access
  1378. X  * control library. routine. It bundles its arguments into a client_info
  1379. X  * structure, then calls the hosts_access() access control checker. The host
  1380. X  * name and user name arguments should be empty strings, "unknown" or real
  1381. X  * data. If a match is found, the optional shell command is executed.
  1382. X  * 
  1383. X  * Restriction: this interface does not pass enough information to support
  1384. X  * selective remote username lookups.
  1385. X  * 
  1386. X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1387. X  */
  1388. X
  1389. X#ifndef lint
  1390. Xstatic char sccsid[] = "@(#) hosts_ctl.c 1.3 93/09/24 19:48:26";
  1391. X#endif
  1392. X
  1393. X#include <stdio.h>
  1394. X
  1395. X#include "log_tcp.h"
  1396. X
  1397. X/* hosts_ctl - general interface for the hosts_access() routine */
  1398. X
  1399. Xint     hosts_ctl(daemon, name, addr, user)
  1400. Xchar   *daemon;
  1401. Xchar   *name;
  1402. Xchar   *addr;
  1403. Xchar   *user;
  1404. X{
  1405. X    struct client_info client;
  1406. X
  1407. X    init_client (&client);
  1408. X    client.name = name;
  1409. X    client.addr = addr;
  1410. X    client.user = user;
  1411. X
  1412. X    return (hosts_access(daemon, &client));
  1413. X}
  1414. END_OF_hosts_ctl.c
  1415. if test 1065 -ne `wc -c <hosts_ctl.c`; then
  1416.     echo shar: \"hosts_ctl.c\" unpacked with wrong size!
  1417. fi
  1418. # end of overwriting check
  1419. fi
  1420. if test -f hosts_info.c -a "${1}" != "-c" ; then 
  1421.   echo shar: Will not over-write existing file \"hosts_info.c\"
  1422. else
  1423. echo shar: Extracting \"hosts_info.c\" \(790 characters\)
  1424. sed "s/^X//" >hosts_info.c <<'END_OF_hosts_info.c'
  1425. X /*
  1426. X  * hosts_info() returns a string with as much information about the origin
  1427. X  * of a connection as we have: the user name, if known, and the host name,
  1428. X  * or the host address if the name is not available.
  1429. X  * 
  1430. X  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1431. X  */
  1432. X
  1433. X#ifndef lint
  1434. Xstatic char sccsid[] = "@(#) hosts_info.c 1.2 93/09/11 20:45:32";
  1435. X#endif
  1436. X
  1437. X#include <stdio.h>
  1438. X
  1439. X#include "log_tcp.h"
  1440. X
  1441. X/* hosts_info - return string with as much about the client as we know */
  1442. X
  1443. Xchar   *hosts_info(client)
  1444. Xstruct client_info *client;
  1445. X{
  1446. X    static char buf[BUFSIZ];        /* XXX */
  1447. X
  1448. X    if (client->user[0] && strcmp(client->user, FROM_UNKNOWN)) {
  1449. X    sprintf(buf, "%s@%s", client->user, FROM_HOST(client));
  1450. X    return (buf);
  1451. X    } else {
  1452. X    return (FROM_HOST(client));
  1453. X    }
  1454. X}
  1455. END_OF_hosts_info.c
  1456. if test 790 -ne `wc -c <hosts_info.c`; then
  1457.     echo shar: \"hosts_info.c\" unpacked with wrong size!
  1458. fi
  1459. # end of overwriting check
  1460. fi
  1461. echo shar: End of archive 1 \(of 4\).
  1462. cp /dev/null ark1isdone
  1463. MISSING=""
  1464. for I in 1 2 3 4 ; do
  1465.     if test ! -f ark${I}isdone ; then
  1466.     MISSING="${MISSING} ${I}"
  1467.     fi
  1468. done
  1469. if test "${MISSING}" = "" ; then
  1470.     echo You have unpacked all 4 archives.
  1471.     rm -f ark[1-9]isdone
  1472. else
  1473.     echo You still need to unpack the following archives:
  1474.     echo "        " ${MISSING}
  1475. fi
  1476. ##  End of shell archive.
  1477. exit 0
  1478.  
  1479. exit 0 # Just in case...
  1480.