home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / tcp_wrappers / patch03 < prev    next >
Internet Message Format  |  1994-03-30  |  49KB

  1. From: wietse@wzv.win.tue.nl (Wietse Venema)
  2. Newsgroups: comp.sources.misc
  3. Subject: v42i037:  tcp_wrappers - TCP/IP daemon wrappers v6.0, Patch03
  4. Date: 30 Mar 1994 15:27:32 -0600
  5. Organization: Eindhoven University of Technology, The Netherlands
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2ncqs4$f9o@sparky.sterling.com>
  9. X-Md4-Signature: 4552bee8eebd294be84d5e5c6d761f03
  10.  
  11. Submitted-by: wietse@wzv.win.tue.nl (Wietse Venema)
  12. Posting-number: Volume 42, Issue 37
  13. Archive-name: tcp_wrappers/patch03
  14. Environment: UNIX, INET
  15. Patch-To: tcp_wrappers: Volume 39, Issue 110-113
  16.  
  17. diff -c ../6.2/BLURB ./BLURB
  18. *** ../6.2/BLURB    Wed Mar 23 18:14:55 1994
  19. --- ./BLURB    Wed Mar 23 18:15:40 1994
  20. ***************
  21. *** 1,6 ****
  22. ! @(#) BLURB 1.17 94/02/05 15:22:01
  23.   
  24. ! This is the 6.2 version of the TCP/IP daemon wrapper package.
  25.   
  26.   With these programs you can monitor and control who connects to your
  27.   TFTP, EXEC, FTP, RSH, TELNET, RLOGIN, FINGER, and SYSTAT network
  28. --- 1,8 ----
  29. ! @(#) BLURB 1.18 94/03/23 16:50:25
  30.   
  31. ! This is the 6.3 version of the TCP/IP daemon wrapper package. Release
  32. ! 6.2 was cancelled because of a significant source code contribution
  33. ! from Sequent.
  34.   
  35.   With these programs you can monitor and control who connects to your
  36.   TFTP, EXEC, FTP, RSH, TELNET, RLOGIN, FINGER, and SYSTAT network
  37. ***************
  38. *** 11,28 ****
  39.   and do some sanity checks on the origin of the request. No information
  40.   is exchanged with the remote client process.
  41.   
  42. ! Changes with this release:
  43.   
  44. !     - Portability: new Makefile rule sets for SCO and Pyramid OSx 5.1.
  45.   
  46. !     - Portability: improved TLI support for Dynix/PTX.
  47.   
  48. !     - Feature: a compile-time option (APPEND_DOT) to keep the hostname
  49. !       lookup routines from trying to append your own domain name to
  50. !       already fully-qualified hostnames. This may reduce the load on
  51. !       your name servers somewhat.
  52.   
  53. ! Other than that, the code should be binary compatible with release 6.1.
  54.   
  55.       Wietse Venema (wietse@wzv.win.tue.nl),
  56.       Department of Mathematics and Computing Science,
  57. --- 13,32 ----
  58.   and do some sanity checks on the origin of the request. No information
  59.   is exchanged with the remote client process.
  60.   
  61. ! Changes since release 6.1;
  62.   
  63. !     - Portability: new Makefile rule sets for SCO and Pyramid OSx 5.1;
  64. !       improved TLI support for Dynix/PTX; fix for Ultrix core dumps.
  65.   
  66. !     - Features: compile-time option (APPEND_DOT) for faster DNS lookup
  67. !       of already fully-qualified hostnames; a run-time option to enable
  68. !       keepalives (useful when users reset or turn off the PC while
  69. !       still connected), and an option to change the process nice value.
  70.   
  71. ! Good news: Sun patch 100804-03 for SunOS 4.1.x fixes the problem with
  72. ! the anti source-routing attack feature.
  73.   
  74. ! The libwrap.a code should be binary compatible with release 6.1.
  75.   
  76.       Wietse Venema (wietse@wzv.win.tue.nl),
  77.       Department of Mathematics and Computing Science,
  78. diff -c ../6.2/CHANGES ./CHANGES
  79. *** ../6.2/CHANGES    Wed Mar 23 18:15:04 1994
  80. --- ./CHANGES    Wed Mar 23 18:15:49 1994
  81. ***************
  82. *** 1,15 ****
  83.   Changes per release 6.2 (Feb 1994)
  84.   ==================================
  85.   
  86.   - Resurrected my year-old code to reduce DNS load by appending a dot to
  87.   the gethostbyname() argument. This feature is still experimental and it
  88. ! may go away if it causes more problems than it solves.
  89.   
  90.   - Auxiliary code for the Pyramid, BSD universe. Karl Vogel figured out
  91. ! what was missing: yp_get_default_domain() and vfprintf().
  92.   
  93.   - Improved support for Dynix/PTX. The wrapper should now be able to
  94. ! deal with all TLI over IP services.
  95.   
  96.   - The try command now uses the hostname that gethostbyaddr() would
  97.   return, instead of the hostname returned by gethostbyname(). This can
  98. --- 1,37 ----
  99. + Changes per release 6.3 (Mar 1994)
  100. + ==================================
  101. + - Keepalives option, to get rid of stuck daemons when people turn off
  102. + their PC while still connected. Files: options.c, hosts_options.5.
  103. + - Nice option, to calm down network daemons that take away too much CPU
  104. + time. Files: options.c, hosts_options.5.
  105. + - Ultrix perversion: the environ global pointer may be null. The
  106. + environment replacement routines now check for this. File: environ.c.
  107. + - Fixed a few places that still assumed the socket is on standard
  108. + input. Fixed some error messages that did not provide access control
  109. + file name and line number.  File: options.c.
  110. + - Just when I was going to release 6.2 I received code for Dynix/PTX.
  111. + That code is specific to PTX 2.x, so I'll keep around my generic
  112. + PTX code just in case. The difference is in the handling of UDP
  113. + services.  Files:  tli_sequent.[hc].
  114.   Changes per release 6.2 (Feb 1994)
  115.   ==================================
  116.   
  117.   - Resurrected my year-old code to reduce DNS load by appending a dot to
  118.   the gethostbyname() argument. This feature is still experimental and it
  119. ! may go away if it causes more problems than it solves. File: socket.c.
  120.   
  121.   - Auxiliary code for the Pyramid, BSD universe. Karl Vogel figured out
  122. ! what was missing: yp_get_default_domain() and vfprintf(). Files:
  123. ! workarounds.c, vfprintf.c.
  124.   
  125.   - Improved support for Dynix/PTX. The wrapper should now be able to
  126. ! deal with all TLI over IP services. File: ptx.c.
  127.   
  128.   - The try command now uses the hostname that gethostbyaddr() would
  129.   return, instead of the hostname returned by gethostbyname(). This can
  130. ***************
  131. *** 16,22 ****
  132.   be significant on systems with NIS that have short host names in the
  133.   hosts map. For example, gethostbyname("wzv.win.tue.nl") returns
  134.   "wzv.win.tue.nl"; gethostbyaddr(131.155.210.17) returns "wzv", and
  135. ! so does gethostbyname("wzv").
  136.   
  137.   Changes per release 6.1 (Dec 1993)
  138.   ==================================
  139. --- 38,44 ----
  140.   be significant on systems with NIS that have short host names in the
  141.   hosts map. For example, gethostbyname("wzv.win.tue.nl") returns
  142.   "wzv.win.tue.nl"; gethostbyaddr(131.155.210.17) returns "wzv", and
  143. ! that is what we should test with. File: try.c.
  144.   
  145.   Changes per release 6.1 (Dec 1993)
  146.   ==================================
  147. diff -c ../6.2/Makefile ./Makefile
  148. *** ../6.2/Makefile    Wed Mar 23 18:14:54 1994
  149. --- ./Makefile    Wed Mar 23 18:15:38 1994
  150. ***************
  151. *** 1,4 ****
  152. ! # @(#) Makefile 1.11 94/02/01 22:11:56
  153.   
  154.   what:
  155.       @echo
  156. --- 1,4 ----
  157. ! # @(#) Makefile 1.12 94/03/23 16:51:32
  158.   
  159.   what:
  160.       @echo
  161. ***************
  162. *** 17,26 ****
  163.       @echo "This Makefile knows about the following sys-types:"
  164.       @echo
  165.       @echo "    generic (most bsd-ish systems with sys5 compatibility)"
  166. !     @echo "    386bsd aix alpha apollo convex-ultranet dgux dynix"
  167. !     @echo "    dynix-ptx epix esix freebsd hpux irix isc(untested)"
  168. !     @echo "    linux mips(untested) netbsd next osf pyramid sco sco-nis"
  169. !     @echo "    sco-od2 sunos4 sunos40 sunos5 sysv4 ultrix unicos(untested)"
  170.       @echo
  171.       @echo "If none of these match your environment, edit the system"
  172.       @echo "dependencies sections in the Makefile and do a 'make other'."
  173. --- 17,27 ----
  174.       @echo "This Makefile knows about the following sys-types:"
  175.       @echo
  176.       @echo "    generic (most bsd-ish systems with sys5 compatibility)"
  177. !     @echo "    386bsd aix alpha apollo convex-ultranet dell-gcc dgux dynix"
  178. !     @echo "    epix esix freebsd hpux irix4 isc(untested) linux"
  179. !     @echo "    mips(untested) netbsd next osf ptx-2.x ptx-generic pyramid"
  180. !     @echo "    sco sco-nis sco-od2 sunos4 sunos40 sunos5 sysv4 ultrix"
  181. !     @echo "    unicos(untested) uxp"
  182.       @echo
  183.       @echo "If none of these match your environment, edit the system"
  184.       @echo "dependencies sections in the Makefile and do a 'make other'."
  185. ***************
  186. *** 38,44 ****
  187.   # 
  188.   # Uncomment the appropriate line if you are going to edit inetd.conf.
  189.   #
  190. ! # Ultrix 4.x SunOS 4.x ConvexOS 10.x
  191.   #REAL_DAEMON_DIR=/usr/etc
  192.   #
  193.   # SysV.4 Solaris 2.x OSF AIX
  194. --- 39,45 ----
  195.   # 
  196.   # Uncomment the appropriate line if you are going to edit inetd.conf.
  197.   #
  198. ! # Ultrix 4.x SunOS 4.x ConvexOS 10.x Dynix/ptx
  199.   #REAL_DAEMON_DIR=/usr/etc
  200.   #
  201.   # SysV.4 Solaris 2.x OSF AIX
  202. ***************
  203. *** 58,64 ****
  204.   # 
  205.   # Uncomment the appropriate line if you are going to move your daemons.
  206.   #
  207. ! # Ultrix 4.x SunOS 4.x ConvexOS 10.x
  208.   #REAL_DAEMON_DIR=/usr/etc/...
  209.   #
  210.   # SysV.4 Solaris 2.x OSF AIX
  211. --- 59,65 ----
  212.   # 
  213.   # Uncomment the appropriate line if you are going to move your daemons.
  214.   #
  215. ! # Ultrix 4.x SunOS 4.x ConvexOS 10.x Dynix/ptx
  216.   #REAL_DAEMON_DIR=/usr/etc/...
  217.   #
  218.   # SysV.4 Solaris 2.x OSF AIX
  219. ***************
  220. *** 138,152 ****
  221.       LIBS=-lulsock RANLIB=ranlib ARFLAGS=rv AUX_OBJ=environ.o \
  222.       NETGROUP=-DNETGROUP TLI= all
  223.   
  224. ! # Dynix/PTX has TLI, but the support is not as complete as with SYSV4.
  225. ! dynix-ptx:
  226.       @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
  227.       LIBS="-lsocket -linet -lnsl" RANLIB=echo ARFLAGS=rv \
  228.       AUX_OBJ="environ.o strcasecmp.o ptx.o" NETGROUP= TLI=-DPTX all
  229.   
  230.   # IRIX 4.0.x has a special ar(1) flag.
  231. ! irix:
  232.       @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
  233.       LIBS=-lsun RANLIB=echo ARFLAGS=rvs AUX_OBJ=environ.o \
  234.       NETGROUP=-DNETGROUP TLI= all
  235. --- 139,159 ----
  236.       LIBS=-lulsock RANLIB=ranlib ARFLAGS=rv AUX_OBJ=environ.o \
  237.       NETGROUP=-DNETGROUP TLI= all
  238.   
  239. ! # Generic support for the Dynix/PTX version of TLI.
  240. ! ptx-generic:
  241.       @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
  242.       LIBS="-lsocket -linet -lnsl" RANLIB=echo ARFLAGS=rv \
  243.       AUX_OBJ="environ.o strcasecmp.o ptx.o" NETGROUP= TLI=-DPTX all
  244.   
  245. + # With UDP support optimized for PTX 2.x (timw@sequent.com).
  246. + ptx-2.x:
  247. +     @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
  248. +     LIBS="-lsocket -linet -lnsl" RANLIB=echo ARFLAGS=rv \
  249. +     AUX_OBJ="environ.o strcasecmp.o tli-sequent.o" NETGROUP= \
  250. +     TLI=-DTLI_SEQUENT all
  251.   # IRIX 4.0.x has a special ar(1) flag.
  252. ! irix4:
  253.       @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
  254.       LIBS=-lsun RANLIB=echo ARFLAGS=rvs AUX_OBJ=environ.o \
  255.       NETGROUP=-DNETGROUP TLI= all
  256. ***************
  257. *** 164,169 ****
  258. --- 171,187 ----
  259.       NETGROUP=-DNETGROUP AUX_OBJ=environ.o TLI=-DTLI \
  260.       BUGS="$(BUGS) -DINET_ADDR_BUG" all
  261.   
  262. + # UXP/DS System V.4 clone (vic@uida0.uida.es).
  263. + uxp:
  264. +     @make LIBS="-L/usr/ucblib -lsocket -lnsl -lucb" \
  265. +     RANLIB=echo ARFLAGS=rv NETGROUP=-DNETGROUP \
  266. +     AUX_OBJ=environ.o TLI="-DTLI -DDRS_XTI" all
  267. + # DELL System V.4 Issue 2.2 using gcc (kim@grendel.lut.fi, jurban@norden1.com)
  268. + dell-gcc:
  269. +     @make LIBS="-lsocket -lnsl" RANLIB=ranlib ARFLAGS=rv CC=gcc \
  270. +     AUX_OBJ="environ.o strcasecmp.o" TLI=-DTLI all
  271.   # SCO 3.2v4.1 no frills (jedwards@sol1.solinet.net).
  272.   sco:
  273.       @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \
  274. ***************
  275. *** 463,471 ****
  276.   #
  277.   # This feature cannot be used with SunOS 4.x because of a kernel bug in
  278.   # the implementation of the getsockopt() system call. Kernel panics have
  279. ! # been reported for SunOS 4.1.1 and SunOS 4.1.2. Symptoms are "BAD TRAP"
  280. ! # and "Data fault" while executing the tcp_ctloutput() kernel function.
  281.   #
  282.   # Uncomment the following macro definition if your getsockopt() is OK.
  283.   #
  284.   # KILL_OPT= -DKILL_IP_OPTIONS
  285. --- 481,491 ----
  286.   #
  287.   # This feature cannot be used with SunOS 4.x because of a kernel bug in
  288.   # the implementation of the getsockopt() system call. Kernel panics have
  289. ! # been observed for SunOS 4.1.[1-3]. Symptoms are "BAD TRAP" and "Data
  290. ! # fault" while executing the tcp_ctloutput() kernel function.
  291.   #
  292. + # Reportedly, Sun patch 100804-03 fixes the problem for SunOS 4.1.x.
  293. + #
  294.   # Uncomment the following macro definition if your getsockopt() is OK.
  295.   #
  296.   # KILL_OPT= -DKILL_IP_OPTIONS
  297. ***************
  298. *** 496,502 ****
  299.       percent_x.c options.c clean_exit.c environ.c patchlevel.h strtok.c \
  300.       fix_options.c workarounds.c socket.c tli.c DISCLAIMER \
  301.       fakelog.c safe_finger.c hosts_options.5 options.h CHANGES \
  302. !     try-from.c init_client.c 6compat.c ptx.c vfprintf.c
  303.   
  304.   LIB    = libwrap.a
  305.   
  306. --- 516,523 ----
  307.       percent_x.c options.c clean_exit.c environ.c patchlevel.h strtok.c \
  308.       fix_options.c workarounds.c socket.c tli.c DISCLAIMER \
  309.       fakelog.c safe_finger.c hosts_options.5 options.h CHANGES \
  310. !     try-from.c init_client.c 6compat.c ptx.c vfprintf.c tli-sequent.c \
  311. !     tli-sequent.h
  312.   
  313.   LIB    = libwrap.a
  314.   
  315. ***************
  316. *** 597,602 ****
  317. --- 618,624 ----
  318.   socket.o: log_tcp.h Makefile
  319.   tcpd.o: patchlevel.h log_tcp.h Makefile
  320.   tli.o: log_tcp.h Makefile
  321. + tli-sequent.o: tli-sequent.h log_tcp.h Makefile
  322.   try-from: log_tcp.h Makefile
  323.   try.o: log_tcp.h Makefile
  324.   workarounds.o: log_tcp.h Makefile
  325. diff -c ../6.2/README ./README
  326. *** ../6.2/README    Wed Mar 23 18:14:48 1994
  327. --- ./README    Wed Mar 23 18:15:33 1994
  328. ***************
  329. *** 1,6 ****
  330. ! @(#) README 1.20 94/02/05 15:21:57
  331.   
  332. ! This is the 6.2 version of the TCP/IP daemon wrapper package.
  333.   
  334.   Table of contents
  335.   -----------------
  336. --- 1,6 ----
  337. ! @(#) README 1.21 94/03/23 17:47:16
  338.   
  339. ! This is the 6.3 version of the TCP/IP daemon wrapper package.
  340.   
  341.   Table of contents
  342.   -----------------
  343. ***************
  344. *** 287,296 ****
  345.   will be disabled for all TCP connections that are handled by the
  346.   wrapper programs.
  347.   
  348. ! All this cannot be used with SunOS 4.x because of a kernel bug in the
  349. ! implementation of the getsockopt() system call. Kernel panics have been
  350. ! observed for SunOS 4.1.1 up to SunOS 4.1.3. The symptoms are "BAD TRAP"
  351. ! and "Data fault" while executing the tcp_ctloutput() kernel function.
  352.   
  353.   The feature is disabled by default. It can be turned on by editing the
  354.   Makefile.  The configuration and installation section below describes
  355. --- 287,296 ----
  356.   will be disabled for all TCP connections that are handled by the
  357.   wrapper programs.
  358.   
  359. ! If you are going to use this feature on SunOS 4.1.x you should apply
  360. ! patch 100804-03 or later. Otherwise you may experience "BAD TRAP" and
  361. ! "Data fault" panics when the getsockopt() system call is executed after
  362. ! a TCP RESET has been received.
  363.   
  364.   The feature is disabled by default. It can be turned on by editing the
  365.   Makefile.  The configuration and installation section below describes
  366. ***************
  367. *** 372,377 ****
  368. --- 372,384 ----
  369.   
  370.       research.att.com:/dist/internet_security/berferd.ps
  371.   
  372. + Discussions on internet firewalls are archived on ftp.greatcircle.com.
  373. + Subscribe to the mailing list by sending a message to 
  374. +     majordomo@greatcircle.com
  375. + With in the body (not subject): subscribe firewalls.
  376.   5.2 - Related software
  377.   ----------------------
  378.   
  379. ***************
  380. *** 389,404 ****
  381.   firewall host, to the outer world. Socks consists of a daemon that is
  382.   run on the firewall host, and of a library with routines that redirect
  383.   application socket calls through the firewall daemon.  Socks is
  384. ! available from s1.gov in /pub/socks.tar.Z.
  385.   
  386.   Tcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
  387.   and telnet commands across a firewall. Unlike socks it can be used with
  388. ! unmodified client software. Available from ftp.alantec.com, pub/tcpr.
  389.   
  390.   Versions of rshd and rlogind, modified to report the remote user name
  391.   in addition to the remote host name, are available for anonymous ftp
  392. ! (ftp.win.tue.nl:/pub/security/logdaemon-3.tar.Z).  These programs are
  393. ! drop-in replacements for SunOS 4.x, Ultrix 4.x, and SunOS 5.x.
  394.   
  395.   The securelib shared library by William LeFebvre can be used to control
  396.   access to network daemons that are not run under control of the inetd
  397. --- 396,416 ----
  398.   firewall host, to the outer world. Socks consists of a daemon that is
  399.   run on the firewall host, and of a library with routines that redirect
  400.   application socket calls through the firewall daemon.  Socks is
  401. ! available from s1.gov in /pub/firewalls/socks.tar.Z.
  402.   
  403. + For a modified Socks version by Ying-Da Lee (ylee@syl.dl.nec.com) try
  404. + ftp.nec.com, directory /pub/security/socks.cstc.
  405.   Tcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
  406.   and telnet commands across a firewall. Unlike socks it can be used with
  407. ! unmodified client software. Available from ftp.alantec.com, /pub/tcpr.
  408.   
  409.   Versions of rshd and rlogind, modified to report the remote user name
  410.   in addition to the remote host name, are available for anonymous ftp
  411. ! (ftp.win.tue.nl:/pub/security/logdaemon-XX.tar.Z).  These programs are
  412. ! drop-in replacements for SunOS 4.x, Ultrix 4.x, and SunOS 5.x. This
  413. ! archive also contains ftpd/rexecd/login versions that support S/Key
  414. ! one-time passwords (tested with SunOS [45] and 44BSD).
  415.   
  416.   The securelib shared library by William LeFebvre can be used to control
  417.   access to network daemons that are not run under control of the inetd
  418. ***************
  419. *** 413,419 ****
  420.   
  421.   netlog from Texas A&M relies on the SunOS 4.x /dev/nit interface to
  422.   passively watch all TCP and UDP network traffic on a network.  The
  423. ! current version is net.tamu.edu:/pub/security/TAMU/netlog-1.03.tar.gz.
  424.   
  425.   Where shared libraries or router-based packet filtering are not an
  426.   option, an alternative portmap daemon can help to improve RPC security,
  427. --- 425,431 ----
  428.   
  429.   netlog from Texas A&M relies on the SunOS 4.x /dev/nit interface to
  430.   passively watch all TCP and UDP network traffic on a network.  The
  431. ! current version is net.tamu.edu:/pub/security/TAMU/netlog-1.2.tar.gz.
  432.   
  433.   Where shared libraries or router-based packet filtering are not an
  434.   option, an alternative portmap daemon can help to improve RPC security,
  435. ***************
  436. *** 422,429 ****
  437.   ... 4.1.3, Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and AIX. The protection
  438.   is less effective than that of the securelib library because portmap is
  439.   mostly a dictionary service.  SunOS 4.x users should install the latest
  440. ! revision of the portmap and NIS daemons instead, or adopt NIS+ which
  441. ! has access control built in.
  442.   
  443.   Source for a portable RFC 931 (TAP, IDENT)-compatible daemon by Peter
  444.   Eriksson is available from ftp.lysator.liu.se:/pub/ident/servers.
  445. --- 434,441 ----
  446.   ... 4.1.3, Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and AIX. The protection
  447.   is less effective than that of the securelib library because portmap is
  448.   mostly a dictionary service.  SunOS 4.x users should install the latest
  449. ! revision of the portmap and NIS daemons instead (patch 100482) or adopt
  450. ! NIS+ which has access control built in.
  451.   
  452.   Source for a portable RFC 931 (TAP, IDENT)-compatible daemon by Peter
  453.   Eriksson is available from ftp.lysator.liu.se:/pub/ident/servers.
  454. diff -c ../6.2/environ.c ./environ.c
  455. *** ../6.2/environ.c    Wed Mar 23 18:14:59 1994
  456. --- ./environ.c    Wed Mar 23 18:15:44 1994
  457. ***************
  458. *** 7,13 ****
  459.    */
  460.   
  461.   #ifndef lint
  462. ! static char sccsid[] = "@(#) environ.c 1.3 93/10/30 15:38:58";
  463.   #endif
  464.   
  465.   /* System libraries. */
  466. --- 7,13 ----
  467.    */
  468.   
  469.   #ifndef lint
  470. ! static char sccsid[] = "@(#) environ.c 1.2 94/03/23 16:09:46";
  471.   #endif
  472.   
  473.   /* System libraries. */
  474. ***************
  475. *** 54,60 ****
  476.   {
  477.       char  **envp;
  478.   
  479. !     for (envp = environ; *envp; envp++)
  480.       if (strncmp(name, *envp, len) == 0 && (*envp)[len] == '=')
  481.           return (envp);
  482.       return (0);
  483. --- 54,60 ----
  484.   {
  485.       char  **envp;
  486.   
  487. !     for (envp = environ; envp && *envp; envp++)
  488.       if (strncmp(name, *envp, len) == 0 && (*envp)[len] == '=')
  489.           return (envp);
  490.       return (0);
  491. ***************
  492. *** 154,160 ****
  493.       int     l_used;            /* bytes used excl. terminator */
  494.       int     l_need;            /* bytes needed incl. terminator */
  495.   
  496. !     for (envp = environ; *envp; envp++)
  497.        /* void */ ;
  498.       n_used = envp - environ;
  499.       l_used = n_used * sizeof(*envp);
  500. --- 154,160 ----
  501.       int     l_used;            /* bytes used excl. terminator */
  502.       int     l_need;            /* bytes needed incl. terminator */
  503.   
  504. !     for (envp = environ; envp && *envp; envp++)
  505.        /* void */ ;
  506.       n_used = envp - environ;
  507.       l_used = n_used * sizeof(*envp);
  508. ***************
  509. *** 186,192 ****
  510.   {
  511.       char  **envp;
  512.   
  513. !     for (envp = environ; *envp; envp++)
  514.       printf("%s\n", *envp);
  515.   }
  516.   
  517. --- 186,192 ----
  518.   {
  519.       char  **envp;
  520.   
  521. !     for (envp = environ; envp && *envp; envp++)
  522.       printf("%s\n", *envp);
  523.   }
  524.   
  525. diff -c ../6.2/fromhost.c ./fromhost.c
  526. *** ../6.2/fromhost.c    Wed Mar 23 18:14:50 1994
  527. --- ./fromhost.c    Wed Mar 23 18:15:35 1994
  528. ***************
  529. *** 23,29 ****
  530.     */
  531.   
  532.   #ifndef lint
  533. ! static char sccsid[] = "@(#) fromhost.c 1.15 94/02/01 22:12:03";
  534.   #endif
  535.   
  536.   /* System libraries. */
  537. --- 23,29 ----
  538.     */
  539.   
  540.   #ifndef lint
  541. ! static char sccsid[] = "@(#) fromhost.c 1.16 94/03/23 16:23:45";
  542.   #endif
  543.   
  544.   /* System libraries. */
  545. ***************
  546. *** 32,38 ****
  547.   #include <stdio.h>
  548.   #include <syslog.h>
  549.   
  550. ! #if defined(TLI) || defined(PTX)
  551.   #include <sys/tiuser.h>
  552.   #include <stropts.h>
  553.   #endif
  554. --- 32,38 ----
  555.   #include <stdio.h>
  556.   #include <syslog.h>
  557.   
  558. ! #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
  559.   #include <sys/tiuser.h>
  560.   #include <stropts.h>
  561.   #endif
  562. ***************
  563. *** 41,47 ****
  564.   
  565.   #include "log_tcp.h"
  566.   
  567. ! #if !defined(TLI) && !defined(PTX)
  568.   
  569.   /* fromhost - compatibility wrapper for socket-only systems */
  570.   
  571. --- 41,47 ----
  572.   
  573.   #include "log_tcp.h"
  574.   
  575. ! #if !defined(TLI) && !defined(PTX) && !defined(TLI_SEQUENT)
  576.   
  577.   /* fromhost - compatibility wrapper for socket-only systems */
  578.   
  579. ***************
  580. *** 53,61 ****
  581.       return (sock_host(client, client_fd));
  582.   }
  583.   
  584. ! #endif /* !defined(TLI) && !defined(PTX) */
  585.   
  586. ! #if defined(TLI) || defined(PTX)
  587.   
  588.   /* fromhost - find out what network API we should use */
  589.   
  590. --- 53,61 ----
  591.       return (sock_host(client, client_fd));
  592.   }
  593.   
  594. ! #endif /* !TLI && !PTX && !TLI_SEQUENT */
  595.   
  596. ! #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
  597.   
  598.   /* fromhost - find out what network API we should use */
  599.   
  600. ***************
  601. *** 80,83 ****
  602.       }
  603.   }
  604.   
  605. ! #endif /* TLI || PTX */
  606. --- 80,83 ----
  607.       }
  608.   }
  609.   
  610. ! #endif /* TLI || PTX || TLI_SEQUENT */
  611. diff -c ../6.2/hosts_options.5 ./hosts_options.5
  612. *** ../6.2/hosts_options.5    Wed Mar 23 18:15:03 1994
  613. --- ./hosts_options.5    Wed Mar 23 18:15:48 1994
  614. ***************
  615. *** 22,29 ****
  616.   .IP "severity = mail.info"
  617.   Change the severity level at which the event will be logged. Facility
  618.   names (such as mail) are optional, and are not supported on systems
  619. ! with older syslog implementations. This option is useful to emphasize
  620. ! or to completely ignore specific events.
  621.   .IP "allow (deny)"
  622.   Grant (deny) service, even when the matched rule was found in the
  623.   \fIhosts.deny (hosts.allow)\fR file. These options must appear at the
  624. --- 22,29 ----
  625.   .IP "severity = mail.info"
  626.   Change the severity level at which the event will be logged. Facility
  627.   names (such as mail) are optional, and are not supported on systems
  628. ! with older syslog implementations. The severity option can be used
  629. ! to emphasize or to completely ignore specific events.
  630.   .IP "allow (deny)"
  631.   Grant (deny) service, even when the matched rule was found in the
  632.   \fIhosts.deny (hosts.allow)\fR file. These options must appear at the
  633. ***************
  634. *** 54,62 ****
  635.   hosts_access(5) manual page.  Stdin, stdout and stderr are connected to
  636.   the remote client process. This option must appear at the end of a rule.
  637.   .sp
  638.   .nf
  639.   .ti +3
  640. ! in.ftpd : clients : twist = /bin/echo 421 Some bounce message
  641.   .fi
  642.   .sp
  643.   sends a customized bounce message to the remote client instead of
  644. --- 54,64 ----
  645.   hosts_access(5) manual page.  Stdin, stdout and stderr are connected to
  646.   the remote client process. This option must appear at the end of a rule.
  647.   .sp
  648. + Examples:
  649. + .sp
  650.   .nf
  651.   .ti +3
  652. ! in.ftpd : ... : twist = /bin/echo 421 Some bounce message
  653.   .fi
  654.   .sp
  655.   sends a customized bounce message to the remote client instead of
  656. ***************
  657. *** 64,70 ****
  658.   .sp
  659.   .nf
  660.   .ti +3
  661. ! in.telnetd : clients : twist = PATH=/some/other; exec in.telnetd
  662.   .fi
  663.   .sp
  664.   would run /some/other/in.telnetd without polluting its command-line
  665. --- 66,72 ----
  666.   .sp
  667.   .nf
  668.   .ti +3
  669. ! in.telnetd : ... : twist = PATH=/some/other; exec in.telnetd
  670.   .fi
  671.   .sp
  672.   would run /some/other/in.telnetd without polluting its command-line
  673. ***************
  674. *** 98,106 ****
  675.   Like the umask command that is built into the shell. An umask of 022
  676.   prevents the creation of files with group and world write permission.
  677.   The umask argument should be an octal number.
  678.   .IP "linger = number_of_seconds"
  679.   Specifies how long the kernel will try to deliver not-yet delivered
  680. ! data after the server process terminates. 
  681.   .IP "user = nobody"
  682.   Assume the privileges of the "nobody" account. This is useful with
  683.   inetd implementations that run all services with root privilege. It is
  684. --- 100,118 ----
  685.   Like the umask command that is built into the shell. An umask of 022
  686.   prevents the creation of files with group and world write permission.
  687.   The umask argument should be an octal number.
  688. + .IP "keepalive"
  689. + Causes the server to periodically send a message to the client.  The
  690. + connection is considered broken when the client does not respond. The
  691. + keepalive option can be useful when users turn off their machine while
  692. + it is still connected to a server.  The keepalive option is not useful
  693. + for datagram (UDP) services.
  694.   .IP "linger = number_of_seconds"
  695.   Specifies how long the kernel will try to deliver not-yet delivered
  696. ! data after the server process closes a connection. 
  697. ! .IP "nice = niceval"
  698. ! .IP "nice (no argument)"
  699. ! Change the nice value of the process (default 10).  Specify a positive
  700. ! value to spend more CPU resources on other processes. 
  701.   .IP "user = nobody"
  702.   Assume the privileges of the "nobody" account. This is useful with
  703.   inetd implementations that run all services with root privilege. It is
  704. ***************
  705. *** 117,132 ****
  706.   .sp
  707.   Warning: many network daemons reset their environment before spawning a
  708.   login or shell process.
  709. ! .IP "rfc931 [= timeout]"
  710. ! Look up the remote user name with the RFC 931 protocol.  This option is
  711. ! silently ignored in case of services based on transports other than
  712. ! TCP.  Requires that the remote system runs an RFC 931-compliant daemon,
  713. ! and may cause noticeable delays with connections from non-UNIX hosts.
  714. ! The timeout period (in seconds) is optional. If no timeout is specified
  715. ! a default value is taken.
  716.   .SH DIAGNOSTICS
  717. ! An error is reported when a syntax error is found in a host access
  718. ! control rule; further options will be ignored, and service is denied.
  719.   .SH SEE ALSO
  720.   hosts_access(5), the default access control language
  721.   .SH AUTHOR
  722. --- 129,146 ----
  723.   .sp
  724.   Warning: many network daemons reset their environment before spawning a
  725.   login or shell process.
  726. ! .IP "rfc931 = timeout_in_seconds"
  727. ! .IP "rfc931 (no argument)"
  728. ! Look up the remote user name with the RFC 931 (IDENT, etc.) protocol.
  729. ! This option is silently ignored in case of services based on transports
  730. ! other than TCP.  It requires that the client system runs an RFC 931
  731. ! (IDENT, etc.) -compliant daemon, and may cause noticeable delays with
  732. ! connections from non-UNIX hosts.  The timeout period is optional. If no
  733. ! timeout is specified a default value is taken.
  734.   .SH DIAGNOSTICS
  735. ! When a syntax error is found in an access control rule, the error
  736. ! is reported to the syslog daemon; further options will be ignored,
  737. ! and service is denied.
  738.   .SH SEE ALSO
  739.   hosts_access(5), the default access control language
  740.   .SH AUTHOR
  741. ***************
  742. *** 136,139 ****
  743.   Department of Mathematics and Computing Science
  744.   Eindhoven University of Technology
  745.   Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  746. ! \" @(#) hosts_options.5 1.8 93/12/13 22:23:09
  747. --- 150,153 ----
  748.   Department of Mathematics and Computing Science
  749.   Eindhoven University of Technology
  750.   Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  751. ! \" @(#) hosts_options.5 1.9 94/03/23 16:52:32
  752. diff -c ../6.2/options.c ./options.c
  753. *** ../6.2/options.c    Wed Mar 23 18:14:58 1994
  754. --- ./options.c    Wed Mar 23 18:15:43 1994
  755. ***************
  756. *** 25,30 ****
  757. --- 25,34 ----
  758.     * course of action.
  759.     */
  760.   
  761. + #ifndef lint
  762. + static char sccsid[] = "@(#) options.c 1.13 94/03/23 16:15:59";
  763. + #endif
  764.   /* System libraries. */
  765.   
  766.   #include <sys/types.h>
  767. ***************
  768. *** 57,66 ****
  769. --- 61,72 ----
  770.   static void group_option();        /* execute "group=name" option */
  771.   static void umask_option();        /* execute "umask=mask" option */
  772.   static void linger_option();        /* execute "linger=time" option */
  773. + static void keepalive_option();        /* execute "keepalive" option */
  774.   static void spawn_option();        /* execute "spawn=command" option */
  775.   static void twist_option();        /* execute "twist=command" option */
  776.   static void rfc931_option();        /* execute "rfc931" option */
  777.   static void setenv_option();        /* execute "setenv=name value" */
  778. + static void nice_option();        /* execute "nice" option */
  779.   static void severity_option();        /* execute "severity=value" */
  780.   static void allow_option();        /* execute "allow" option */
  781.   static void deny_option();        /* execute "deny" option */
  782. ***************
  783. *** 91,100 ****
  784. --- 97,108 ----
  785.       "group", group_option, NEED_ARG,    /* switch group id */
  786.       "umask", umask_option, NEED_ARG,    /* change umask */
  787.       "linger", linger_option, NEED_ARG,    /* change socket linger time */
  788. +     "keepalive", keepalive_option, 0,    /* set socket keepalive option */
  789.       "spawn", spawn_option, NEED_ARG,    /* spawn shell command */
  790.       "twist", twist_option, NEED_ARG | USE_LAST,    /* replace current process */
  791.       "rfc931", rfc931_option, OPT_ARG,    /* do RFC 931 lookup */
  792.       "setenv", setenv_option, NEED_ARG,    /* update environment */
  793. +     "nice", nice_option, OPT_ARG,    /* change nice value */
  794.       "severity", severity_option, NEED_ARG,    /* adjust logging level */
  795.       "allow", allow_option, USE_LAST,    /* grant access */
  796.       "deny", deny_option, USE_LAST,    /* deny access */
  797. ***************
  798. *** 330,337 ****
  799.       return;
  800.       }
  801.       linger.l_onoff = (linger.l_linger != 0);
  802. !     if (setsockopt(0, SOL_SOCKET, SO_LINGER, (char *) &linger, sizeof(linger))
  803. !     < 0) {
  804.       syslog(LOG_ERR, "error: %s, line %d: setsockopt SO_LINGER %d: %m",
  805.              hosts_access_file, hosts_access_line, linger.l_linger);
  806.       longjmp(options_buf, OPT_DENY);
  807. --- 338,345 ----
  808.       return;
  809.       }
  810.       linger.l_onoff = (linger.l_linger != 0);
  811. !     if (setsockopt(client->fd, SOL_SOCKET, SO_LINGER, (char *) &linger, 
  812. !     sizeof(linger)) < 0) {
  813.       syslog(LOG_ERR, "error: %s, line %d: setsockopt SO_LINGER %d: %m",
  814.              hosts_access_file, hosts_access_line, linger.l_linger);
  815.       longjmp(options_buf, OPT_DENY);
  816. ***************
  817. *** 343,348 ****
  818. --- 351,423 ----
  819.   #endif
  820.   }
  821.   
  822. + /* keepalive_option - set the socket keepalive option */
  823. + /* ARGSUSED */
  824. + static void keepalive_option(value, daemon, client)
  825. + char   *value;
  826. + char   *daemon;
  827. + struct client_info *client;
  828. + {
  829. + #if defined(SO_KEEPALIVE) && !defined(BROKEN_SO_KEEPALIVE)
  830. +     int     on = 1;
  831. +     if (dry_run) {
  832. +     syslog(LOG_DEBUG, "option:   keepalive");
  833. +     return;
  834. +     }
  835. +     if (setsockopt(client->fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &on,
  836. +            sizeof(on)) < 0)
  837. +     syslog(LOG_WARNING, "warning: %s, line %d: setsockopt SO_KEEPALIVE: %m",
  838. +            hosts_access_file, hosts_access_line);
  839. + #else
  840. +     syslog(LOG_WARNING, "warning: %s, line %d: SO_KEEPALIVE not supported",
  841. +        hosts_access_file, hosts_access_line);
  842. + #endif
  843. + }
  844. + /* nice_option - set nice value */
  845. + /* ARGSUSED */
  846. + static void nice_option(value, daemon, client)
  847. + char   *value;
  848. + char   *daemon;
  849. + struct client_info *client;
  850. + {
  851. +     int     niceval = 10;
  852. +     char    junk;
  853. +     if (value != 0 && sscanf(value, "%d%c", &niceval, &junk) != 1) {
  854. +     syslog(LOG_ERR, "error: %s, line %d: bad nice value: \"%s\"",
  855. +            hosts_access_file, hosts_access_line, value);
  856. +     longjmp(options_buf, OPT_DENY);
  857. +     }
  858. +     if (dry_run) {
  859. +     syslog(LOG_DEBUG, "option:   nice = %d", niceval);
  860. +     return;
  861. +     }
  862. +     if (nice(niceval) < 0) {
  863. +     syslog(LOG_WARNING, "warning: %s, line %d: nice(%d): %m",
  864. +            hosts_access_file, hosts_access_line, niceval);
  865. +     }
  866. + }
  867. + /* maybe_dup2 - conditional dup2 */
  868. + static int maybe_dup2(fd1, fd2)
  869. + int fd1;
  870. + int fd2;
  871. + {
  872. +     if (fd1 == fd2) {                /* already OK */
  873. +     return (fd2);
  874. +     } else {                    /* dup new to old */
  875. +     close(fd2);
  876. +     return (dup(fd1));
  877. +     }
  878. + }
  879.   /* twist_option - replace process by shell command */
  880.   
  881.   static void twist_option(value, daemon, client)
  882. ***************
  883. *** 364,379 ****
  884.       syslog(deny_severity, "twist %s to %s", hosts_info(client), buf);
  885.       closelog();
  886.   
  887. !     /*
  888. !      * Before switching to the shell, set up stdout and stderr in case the
  889. !      * Ultrix inetd didn't.
  890. !      */
  891.   
  892. !     (void) close(1);
  893. !     (void) close(2);
  894. !     if (dup(0) != 1 || dup(0) != 2) {
  895.       error = "twist_option: dup: %m";
  896.       } else {
  897.       (void) execl("/bin/sh", "sh", "-c", buf, (char *) 0);
  898.       error = "twist_option: /bin/sh: %m";
  899.       }
  900. --- 439,453 ----
  901.       syslog(deny_severity, "twist %s to %s", hosts_info(client), buf);
  902.       closelog();
  903.   
  904. !     /* Before switching to the shell, set up stdin, stdout and stderr. */
  905.   
  906. !     if (maybe_dup2(client->fd, 0) != 0 ||
  907. !     maybe_dup2(client->fd, 1) != 1 ||
  908. !     maybe_dup2(client->fd, 2) != 2) {
  909.       error = "twist_option: dup: %m";
  910.       } else {
  911. +     if (client->fd > 2)
  912. +         close(client->fd);
  913.       (void) execl("/bin/sh", "sh", "-c", buf, (char *) 0);
  914.       error = "twist_option: /bin/sh: %m";
  915.       }
  916. ***************
  917. *** 406,412 ****
  918.   
  919.       if (value) {
  920.       if (sscanf(value, "%d%c", &timeout, &junk) != 1 || timeout <= 0) {
  921. !         syslog(LOG_ERR, "error: rfc931_option: bad timeout: \"%s\"", value);
  922.           longjmp(options_buf, OPT_DENY);
  923.       }
  924.       rfc931_timeout = timeout;
  925. --- 480,487 ----
  926.   
  927.       if (value) {
  928.       if (sscanf(value, "%d%c", &timeout, &junk) != 1 || timeout <= 0) {
  929. !         syslog(LOG_ERR, "error: %s, line %d: bad rfc931 timeout: \"%s\"",
  930. !            hosts_access_file, hosts_access_line, value);
  931.           longjmp(options_buf, OPT_DENY);
  932.       }
  933.       rfc931_timeout = timeout;
  934. ***************
  935. *** 453,459 ****
  936.       return;
  937.       }
  938.       if (setenv(var_name, var_value, 1)) {
  939. !     syslog(LOG_ERR, "setenv_option: memory allocation failure");
  940.       longjmp(options_buf, OPT_DENY);
  941.       }
  942.   }
  943. --- 528,535 ----
  944.       return;
  945.       }
  946.       if (setenv(var_name, var_value, 1)) {
  947. !     syslog(LOG_ERR, "error: %s, line %d: memory allocation failure",
  948. !            hosts_access_file, hosts_access_line);
  949.       longjmp(options_buf, OPT_DENY);
  950.       }
  951.   }
  952. diff -c ../6.2/patchlevel.h ./patchlevel.h
  953. *** ../6.2/patchlevel.h    Wed Mar 23 18:14:59 1994
  954. --- ./patchlevel.h    Wed Mar 23 18:15:44 1994
  955. ***************
  956. *** 1,3 ****
  957.   #ifndef lint
  958. ! static char patchlevel[] = "@(#) patchlevel 6.2";
  959.   #endif
  960. --- 1,3 ----
  961.   #ifndef lint
  962. ! static char patchlevel[] = "@(#) patchlevel 6.3 94/03/23 17:59:52";
  963.   #endif
  964. diff -c ../6.2/ptx.c ./ptx.c
  965. *** ../6.2/ptx.c    Wed Mar 23 18:15:06 1994
  966. --- ./ptx.c    Wed Mar 23 18:15:50 1994
  967. ***************
  968. *** 20,26 ****
  969.     */
  970.   
  971.   #ifndef lint
  972. ! static char sccsid[] = "@(#) ptx.c 1.1 94/02/01 22:12:15";
  973.   #endif
  974.   
  975.   #ifdef PTX
  976. --- 20,26 ----
  977.     */
  978.   
  979.   #ifndef lint
  980. ! static char sccsid[] = "@(#) ptx.c 1.2 94/03/23 16:51:56";
  981.   #endif
  982.   
  983.   #ifdef PTX
  984. ***************
  985. *** 83,89 ****
  986.        * Another suggestion was to temporarily switch to the socket interface,
  987.        * identify the client name/address with socket calls, then to switch
  988.        * back to TLI. This seems to works OK with UDP services, but utterly
  989. !      * messes up rlogind and telnetd.
  990.        */
  991.   
  992.   #define SWAP_MODULE(f, old, new) (ioctl(f, I_POP, old), ioctl(f, I_PUSH, new))
  993. --- 83,90 ----
  994.        * Another suggestion was to temporarily switch to the socket interface,
  995.        * identify the client name/address with socket calls, then to switch
  996.        * back to TLI. This seems to works OK with UDP services, but utterly
  997. !      * messes up rlogind and telnetd. No problem, rlogind and telnetd are
  998. !      * taken care of by the code above.
  999.        */
  1000.   
  1001.   #define SWAP_MODULE(f, old, new) (ioctl(f, I_POP, old), ioctl(f, I_PUSH, new))
  1002. *** /dev/null    Wed Mar 23 17:59:02 1994
  1003. --- ./tli-sequent.c    Wed Mar 23 18:15:51 1994
  1004. ***************
  1005. *** 0 ****
  1006. --- 1,222 ----
  1007. +  /*
  1008. +   * tli_host() determines the type of transport (connected, connectionless),
  1009. +   * the name and address of the host at the other end of a network link. In
  1010. +   * case of an IP service, tli_host() also determines the local address and
  1011. +   * port, and the remote username if username lookups are done irrespective
  1012. +   * of client. All results are in static memory.
  1013. +   * 
  1014. +   * The return status is (-1) if the remote host pretends to have someone elses
  1015. +   * name, or if the remote host name is available but could not be verified;
  1016. +   * in either case the hostname will be ignored. The return status is zero in
  1017. +   * all other cases (the hostname is unavailable, or the host name double
  1018. +   * check succeeds).
  1019. +   * 
  1020. +   * Diagnostics are reported through syslog(3).
  1021. +   * 
  1022. +   * Warning - this relies heavily on the TLI implementation in PTX 2.X
  1023. +   * and will probably not work under PTX 4.
  1024. +   *
  1025. +   * Author: Tim Wright, Sequent Computer Systems Ltd., UK.
  1026. +   */
  1027. + #ifndef lint
  1028. + static char sccsid[] = "@(#) tli-sequent.c 1.0 94/02/11 10:20:30";
  1029. + #endif
  1030. + #ifdef TLI_SEQUENT
  1031. + /* System libraries. */
  1032. + #include <sys/types.h>
  1033. + #include <sys/param.h>
  1034. + #include <sys/stat.h>
  1035. + #include <sys/tiuser.h>
  1036. + #include <sys/stream.h>
  1037. + #include <sys/stropts.h>
  1038. + #include <sys/tihdr.h>
  1039. + #include <sys/timod.h>
  1040. + #include <sys/socket.h>
  1041. + #include <netinet/in.h>
  1042. + #include <stdio.h>
  1043. + #include <syslog.h>
  1044. + #include <errno.h>
  1045. + extern char *strncpy();
  1046. +  /* Some systems versions advertise a too small MAXHOSTNAMELEN value. */
  1047. + #if (MAXHOSTNAMELEN < 64)
  1048. + #undef MAXHOSTNAMELEN
  1049. + #endif
  1050. +  /* In case not defined in <sys/param.h>. */
  1051. + #ifndef MAXHOSTNAMELEN
  1052. + #define MAXHOSTNAMELEN    256        /* storage for host name */
  1053. + #endif
  1054. + extern int errno;
  1055. + extern char *sys_errlist[];
  1056. + extern int sys_nerr;
  1057. + extern int t_errno;
  1058. + extern char *t_errlist[];
  1059. + extern int t_nerr;
  1060. + /* Local stuff. */
  1061. + #include "log_tcp.h"
  1062. + #include "tli-sequent.h"
  1063. + /* Forward declarations. */
  1064. + static char *tli_error();
  1065. + static void tli_sink();
  1066. + /* tli_host - determine endpoint info */
  1067. + int     tli_host(client, fd)
  1068. + struct client_info *client;
  1069. + int     fd;
  1070. + {
  1071. +     static struct sockaddr_in rmt_sin;
  1072. +     static struct sockaddr_in our_sin;
  1073. +     struct _ti_user *tli_state_ptr;
  1074. +     union  T_primitives *TSI_prim_ptr;
  1075. +     struct strpeek peek;
  1076. +     int     len;
  1077. +     /*
  1078. +      * Initialize the result with suitable defaults.
  1079. +      */
  1080. +     init_client(client);
  1081. +     client->fd = fd;
  1082. +     /*
  1083. +      * Find out the client address using getpeerinaddr(). This call is the
  1084. +      * TLI equivalent to getpeername() under Dynix/ptx.
  1085. +      */
  1086. +     len = sizeof(rmt_sin);
  1087. +     t_sync(client->fd);
  1088. +     if (getpeerinaddr(client->fd, &rmt_sin, len) < 0) {
  1089. +     syslog(LOG_ERR, "error: can't get client address: %s", tli_error());
  1090. +     return (0);                /* address and name unknown */
  1091. +     }
  1092. +     client->rmt_sin = &rmt_sin;
  1093. +     /* Call TLI utility routine to get information on endpoint */
  1094. +     if ((tli_state_ptr = _t_checkfd(fd)) == NULL)
  1095. +     return(0);
  1096. +     if (tli_state_ptr->ti_servtype == T_CLTS) {
  1097. +     /* UDP - may need to get address the hard way */
  1098. +     if (rmt_sin.sin_addr.s_addr == 0) {
  1099. +         /* The UDP endpoint is not connected so we didn't get the */
  1100. +         /* remote address - get it the hard way ! */
  1101. +         /* Look at the control part of the top message on the stream */
  1102. +         /* we don't want to remove it from the stream so we use I_PEEK */
  1103. +         peek.ctlbuf.maxlen = tli_state_ptr->ti_ctlsize;
  1104. +         peek.ctlbuf.len = 0;
  1105. +         peek.ctlbuf.buf = tli_state_ptr->ti_ctlbuf;
  1106. +         /* Don't even look at the data */
  1107. +         peek.databuf.maxlen = -1;
  1108. +         peek.databuf.len = 0;
  1109. +         peek.databuf.buf = 0;
  1110. +         peek.flags = 0;
  1111. +         switch (ioctl(client->fd, I_PEEK, &peek)) {
  1112. +         case -1:
  1113. +         syslog(LOG_ERR, "error: can't peek at endpoint: %s", tli_error());
  1114. +         return(0);
  1115. +         case 0:
  1116. +         /* No control part - we're hosed */
  1117. +         syslog(LOG_ERR, "error: can't get UDP info: %s", tli_error());
  1118. +         return(0);
  1119. +         default:
  1120. +         /* FALL THROUGH */
  1121. +         ;
  1122. +         }
  1123. +         /* Can we even check the PRIM_type ? */
  1124. +         if (peek.ctlbuf.len < sizeof(long)) {
  1125. +         syslog(LOG_ERR, "error: UDP control info garbage");
  1126. +         return(0);
  1127. +         }
  1128. +         TSI_prim_ptr = (union T_primitives *) peek.ctlbuf.buf;
  1129. +         if (TSI_prim_ptr->type != T_UNITDATA_IND) {
  1130. +         syslog(LOG_ERR, "error: wrong type for UDP control info");
  1131. +         return(0);
  1132. +         }
  1133. +         /* Validate returned unitdata indication packet */
  1134. +         if ((peek.ctlbuf.len < sizeof(struct T_unitdata_ind)) ||
  1135. +         ((TSI_prim_ptr->unitdata_ind.OPT_length != 0) &&
  1136. +          (peek.ctlbuf.len <
  1137. +             TSI_prim_ptr->unitdata_ind.OPT_length +
  1138. +             TSI_prim_ptr->unitdata_ind.OPT_offset))) {
  1139. +         syslog(LOG_ERR, "error: UDP control info garbaged");
  1140. +         return(0);
  1141. +         }
  1142. +         /* Extract the address */
  1143. +         memcpy(&rmt_sin,
  1144. +         peek.ctlbuf.buf + TSI_prim_ptr->unitdata_ind.SRC_offset,
  1145. +         TSI_prim_ptr->unitdata_ind.SRC_length);
  1146. +     }
  1147. +     client->sink = tli_sink;
  1148. +     }
  1149. +     if (getmyinaddr(client->fd, &our_sin, len) < 0)
  1150. +     syslog(LOG_ERR, "error: can't get local address: %s", tli_error());
  1151. +     else
  1152. +     client->our_sin = &our_sin;
  1153. +     return (sock_names(client));
  1154. + }
  1155. + /* tli_error - convert tli error number to text */
  1156. + static char *tli_error()
  1157. + {
  1158. +     static char buf[40];
  1159. +     if (t_errno != TSYSERR) {
  1160. +     if (t_errno < 0 || t_errno >= t_nerr) {
  1161. +         sprintf(buf, "Unknown TLI error %d", t_errno);
  1162. +         return (buf);
  1163. +     } else {
  1164. +         return (t_errlist[t_errno]);
  1165. +     }
  1166. +     } else {
  1167. +     if (errno < 0 || errno >= sys_nerr) {
  1168. +         sprintf(buf, "Unknown UNIX error %d", errno);
  1169. +         return (buf);
  1170. +     } else {
  1171. +         return (sys_errlist[errno]);
  1172. +     }
  1173. +     }
  1174. + }
  1175. + /* tli_sink - absorb unreceived datagram */
  1176. + static void tli_sink(fd)
  1177. + int     fd;
  1178. + {
  1179. +     struct t_unitdata *unit;
  1180. +     int     flags;
  1181. +     /*
  1182. +      * Something went wrong. Absorb the datagram to keep inetd from looping.
  1183. +      * Allocate storage for address, control and data. If that fails, sleep
  1184. +      * for a couple of seconds in an attempt to keep inetd from looping too
  1185. +      * fast.
  1186. +      */
  1187. +     if ((unit = (struct t_unitdata *) t_alloc(fd, T_UNITDATA, T_ALL)) == 0) {
  1188. +     syslog(LOG_ERR, "error: t_alloc: %s", tli_error());
  1189. +     sleep(5);
  1190. +     } else {
  1191. +     (void) t_rcvudata(fd, unit, &flags);
  1192. +     t_free((void *) unit, T_UNITDATA);
  1193. +     }
  1194. + }
  1195. + #endif /* TLI_SEQUENT */
  1196. *** /dev/null    Wed Mar 23 17:59:02 1994
  1197. --- ./tli-sequent.h    Wed Mar 23 18:15:51 1994
  1198. ***************
  1199. *** 0 ****
  1200. --- 1,13 ----
  1201. + #ifdef __STDC__
  1202. + #define __P(X) X
  1203. + #else
  1204. + #define __P(X) ()
  1205. + #endif
  1206. + extern int t_sync __P((int));
  1207. + extern char *t_alloc __P((int, int, int));
  1208. + extern int t_free __P((char *, int));
  1209. + extern int t_rcvudata __P((int, struct t_unitdata *, int *));
  1210. + extern int getpeerinaddr __P((int, struct sockaddr_in *, int));
  1211. + extern int getmyinaddr __P((int, struct sockaddr_in *, int));
  1212. + extern struct _ti_user *_t_checkfd __P((int));
  1213. diff -c ../6.2/tli.c ./tli.c
  1214. *** ../6.2/tli.c    Wed Mar 23 18:15:02 1994
  1215. --- ./tli.c    Wed Mar 23 18:15:46 1994
  1216. ***************
  1217. *** 17,23 ****
  1218.     */
  1219.   
  1220.   #ifndef lint
  1221. ! static char sccsid[] = "@(#) tli.c 1.8 93/12/13 22:23:27";
  1222.   #endif
  1223.   
  1224.   #ifdef TLI
  1225. --- 17,23 ----
  1226.     */
  1227.   
  1228.   #ifndef lint
  1229. ! static char sccsid[] = "@(#) tli.c 1.9 94/03/23 16:24:47";
  1230.   #endif
  1231.   
  1232.   #ifdef TLI
  1233. ***************
  1234. *** 26,31 ****
  1235. --- 26,32 ----
  1236.   
  1237.   #include <sys/types.h>
  1238.   #include <sys/param.h>
  1239. + #include <sys/stream.h>
  1240.   #include <sys/stat.h>
  1241.   #include <sys/mkdev.h>
  1242.   #include <sys/tiuser.h>
  1243. ***************
  1244. *** 52,57 ****
  1245. --- 53,59 ----
  1246.   #define MAXHOSTNAMELEN    256        /* storage for host name */
  1247.   #endif
  1248.   
  1249. + extern char *nc_sperror();
  1250.   extern int errno;
  1251.   extern char *sys_errlist[];
  1252.   extern int sys_nerr;
  1253. diff -c ../6.2/try.c ./try.c
  1254. *** ../6.2/try.c    Wed Mar 23 18:14:52 1994
  1255. --- ./try.c    Wed Mar 23 18:15:37 1994
  1256. ***************
  1257. *** 17,23 ****
  1258.     */
  1259.   
  1260.   #ifndef lint
  1261. ! static char sccsid[] = "@(#) try.c 1.10 94/02/01 22:12:19";
  1262.   #endif
  1263.   
  1264.   #include <sys/types.h>
  1265. --- 17,23 ----
  1266.     */
  1267.   
  1268.   #ifndef lint
  1269. ! static char sccsid[] = "@(#) try.c 1.11 94/03/23 17:03:14";
  1270.   #endif
  1271.   
  1272.   #include <sys/types.h>
  1273. ***************
  1274. *** 31,36 ****
  1275. --- 31,37 ----
  1276.   
  1277.   extern void exit();
  1278.   extern char *strchr();
  1279. + extern char *strcpy();
  1280.   
  1281.   #ifndef HOSTS_ACCESS
  1282.   
  1283. ***************
  1284. *** 117,122 ****
  1285. --- 118,125 ----
  1286.       char   *at;
  1287.       char   *user;
  1288.       char   *host;
  1289. +     char    reverse_name[BUFSIZ];
  1290. +     struct in_addr addr;
  1291.   
  1292.       /*
  1293.        * Parse the JCL.
  1294. ***************
  1295. *** 170,200 ****
  1296.       /*
  1297.        * Otherwise, assume that a host name is specified, and insist that the
  1298.        * address is known. The reason is that in real life, the host address is
  1299. !      * always available.
  1300.        */
  1301.       if ((hp = gethostbyname(host)) == 0) {
  1302.       fprintf(stderr, "host %s: address lookup failed\n", host);
  1303.       return (1);
  1304.       }
  1305.   
  1306.       /*
  1307.        * Use the hostname that gethostbyaddr() would give us. On systems with
  1308. !      * NIS this may be an unqualified name. We should use that even though a
  1309. !      * FQDN was given on the command line.
  1310.        */
  1311. !     if ((hp = gethostbyaddr((char *) hp->h_addr_list[0],
  1312. !                 sizeof(struct in_addr), AF_INET)) == 0) {
  1313.       fprintf(stderr, "host %s: address->name lookup failed\n", host);
  1314.       return (1);
  1315.       }
  1316.   
  1317.       /*
  1318.        * Iterate over all known addresses for this host. This way we find out
  1319.        * if different addresses for the same host have different permissions,
  1320. !      * something that we probably do not want.
  1321.        */
  1322.       while (hp->h_addr_list[0]) {
  1323. !     try(server, hp->h_name,
  1324.           inet_ntoa(*(struct in_addr *) * hp->h_addr_list++), user);
  1325.       if (hp->h_addr_list[0])
  1326.           putchar('\n');
  1327. --- 173,212 ----
  1328.       /*
  1329.        * Otherwise, assume that a host name is specified, and insist that the
  1330.        * address is known. The reason is that in real life, the host address is
  1331. !      * always available (at least with IP).
  1332.        */
  1333.       if ((hp = gethostbyname(host)) == 0) {
  1334.       fprintf(stderr, "host %s: address lookup failed\n", host);
  1335.       return (1);
  1336.       }
  1337. +     if (hp->h_addrtype != 0 && hp->h_addrtype != AF_INET) {
  1338. +     fprintf(stderr,
  1339. +         "Sorry, this test program cannot handle address family %d\n",
  1340. +         hp->h_addrtype);
  1341. +     return (1);
  1342. +     }
  1343. +     memcpy((char *) &addr, hp->h_addr_list[0], sizeof(addr));
  1344.   
  1345.       /*
  1346.        * Use the hostname that gethostbyaddr() would give us. On systems with
  1347. !      * NIS this may be an unqualified name, even when an FQDN was given on
  1348. !      * the command line.
  1349.        */
  1350. !     if ((hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) == 0) {
  1351.       fprintf(stderr, "host %s: address->name lookup failed\n", host);
  1352.       return (1);
  1353.       }
  1354. +     strcpy(reverse_name, hp->h_name);
  1355. +     while ((hp = gethostbyname(reverse_name)) == 0)    /* XXX */
  1356. +     /* void */ ;
  1357.   
  1358.       /*
  1359.        * Iterate over all known addresses for this host. This way we find out
  1360.        * if different addresses for the same host have different permissions,
  1361. !      * something that we may not want.
  1362.        */
  1363.       while (hp->h_addr_list[0]) {
  1364. !     try(server, reverse_name,
  1365.           inet_ntoa(*(struct in_addr *) * hp->h_addr_list++), user);
  1366.       if (hp->h_addr_list[0])
  1367.           putchar('\n');
  1368. diff -c ../6.2/vfprintf.c ./vfprintf.c
  1369. *** ../6.2/vfprintf.c    Wed Mar 23 18:15:06 1994
  1370. --- ./vfprintf.c    Wed Mar 23 18:15:51 1994
  1371. ***************
  1372. *** 1,13 ****
  1373.    /*
  1374.     * vfprintf() and vprintf() clones. They will produce unexpected results
  1375. !   * when excessive dynamic ("*") field widths are specified. This code was
  1376. !   * adapted from my EXP programming language runtime system.
  1377.     * 
  1378.     * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1379.     */
  1380.   
  1381.   #ifndef lint
  1382. ! static char sccsid[] = "@(#) vfprintf.c 1.1 94/02/01 22:12:21";
  1383.   #endif
  1384.   
  1385.   #include <stdio.h>
  1386. --- 1,13 ----
  1387.    /*
  1388.     * vfprintf() and vprintf() clones. They will produce unexpected results
  1389. !   * when excessive dynamic ("*") field widths are specified. To be used for
  1390. !   * testing purposes only.
  1391.     * 
  1392.     * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  1393.     */
  1394.   
  1395.   #ifndef lint
  1396. ! static char sccsid[] = "@(#) vfprintf.c 1.2 94/03/23 17:44:46";
  1397.   #endif
  1398.   
  1399.   #include <stdio.h>
  1400. ***************
  1401. *** 48,54 ****
  1402.            * strings, since we are ging to let fprintf() do the hard work.
  1403.            * In regular expression notation, we recognize:
  1404.            * 
  1405. !          * %-?0?([0-9]*|\*)\.?([0-9]*|\*)l?[a-z]
  1406.            * 
  1407.            * which includes some combinations that do not make sense.
  1408.            */
  1409. --- 48,54 ----
  1410.            * strings, since we are ging to let fprintf() do the hard work.
  1411.            * In regular expression notation, we recognize:
  1412.            * 
  1413. !          * %-?0?([0-9]+|\*)?\.?([0-9]+|\*)?l?[a-z]
  1414.            * 
  1415.            * which includes some combinations that do not make sense.
  1416.            */
  1417.  
  1418. exit 0 # Just in case...
  1419.