aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-12-09 22:34:55 +0200
committerArnold D. Robbins <arnold@skeeve.com>2010-12-09 22:34:55 +0200
commita7a9cbdc136cb0f5cb67b94fb76dc3b6a9ca6c62 (patch)
tree1bc89eedfa2dc4254c2cbe4131553e4aa350b785
parent759ab08ef5dc236428c427f1fbe5e7cc491e4485 (diff)
downloadegawk-a7a9cbdc136cb0f5cb67b94fb76dc3b6a9ca6c62.tar.gz
egawk-a7a9cbdc136cb0f5cb67b94fb76dc3b6a9ca6c62.tar.bz2
egawk-a7a9cbdc136cb0f5cb67b94fb76dc3b6a9ca6c62.zip
Restore IPv4/IPv6. Remove raw sockets.
-rw-r--r--ChangeLog7
-rw-r--r--NEWS4
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/awkcard.in13
-rw-r--r--doc/gawk.111
-rw-r--r--doc/gawk.info303
-rw-r--r--doc/gawk.texi14
-rw-r--r--doc/gawkinet.info233
-rw-r--r--doc/gawkinet.texi116
-rw-r--r--io.c116
10 files changed, 319 insertions, 503 deletions
diff --git a/ChangeLog b/ChangeLog
index 92fe3b47..4a7b8c96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Dec 9 22:12:48 2010 Arnold D. Robbins <arnold@skeeve.com>
+
+ * io.c: Restored changes of 1 July 2010 to allow /inet4 and /inet6;
+ they got lost amongst the merges. Fixed checking of do_sandbox.
+ Also, removed the option for raw IP sockets since it was never
+ implemented and wasn't going to be.
+
Tue Dec 7 11:59:00 2010 Arnold D. Robbins <arnold@skeeve.com>
* configure.ac: Remove test for return type of sprintf. Another
diff --git a/NEWS b/NEWS
index 047f676d..849099e2 100644
--- a/NEWS
+++ b/NEWS
@@ -71,7 +71,9 @@ Changes from 3.1.8 to 4.0.0
23. In POSIX mode, string comparisons use strcoll/wcscoll.
THIS CHANGES BEHAVIOR!!!!
-24. Many code cleanups. Removed code for many old, unsupported systems.
+24. The option for raw sockets was removed, since it was never implemented.
+
+25. Many code cleanups. Removed code for many old, unsupported systems.
Changes from 3.1.7 to 3.1.8
---------------------------
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 98414248..00d609ef 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 9 22:27:53 2010 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkcard.in, gawk.1, gawk.texi, gawkinet.texi: Remove discussion
+ of raw option in making sockets, since it was never implemented.
+
Wed Dec 1 21:39:15 2010 Arnold D. Robbins <arnold@skeeve.com>
* awkcard.in, gawk.1: Document arrays of arrays.
diff --git a/doc/awkcard.in b/doc/awkcard.in
index af4c5955..2389ca38 100644
--- a/doc/awkcard.in
+++ b/doc/awkcard.in
@@ -1241,18 +1241,7 @@ Usable only with the \*(FC|&\*(FR two-way I/O operator.
.ti -.2i
\*(FC/inet6/udp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
.br
-Similar, but use UDP/IP instead of TCP/IP.
-.ti -.2i
-\*(CR\*(FC/inet/raw/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
-.br
-.ti -.2i
-\*(FC/inet4/raw/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
-.br
-.ti -.2i
-\*(FC/inet6/raw/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
-.br
-.\" Similar, but use raw IP sockets.
-Reserved for future use.\*(CL
+Similar, but use UDP/IP instead of TCP/IP.\*(CL
.in -.2i
.EB "\s+2\f(HBSPECIAL FILENAMES\*(FR\s0"
diff --git a/doc/gawk.1 b/doc/gawk.1
index acd86f7a..38903b05 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -2366,17 +2366,6 @@ uses the system default (most likely IPv4).
.PD
.BI /inet6/udp/ lport / rhost / rport
Similar, but use UDP/IP instead of TCP/IP.
-.TP
-.PD 0
-.BI /inet/raw/ lport / rhost / rport
-.TP
-.PD 0
-.BI /inet4/raw/ lport / rhost / rport
-.TP
-.PD
-.BI /inet6/raw/ lport / rhost / rport
-.\" Similar, but use raw IP sockets.
-Reserved for future use.
.SS Numeric Functions
.PP
\*(AK has the following built-in arithmetic functions:
diff --git a/doc/gawk.info b/doc/gawk.info
index df7d4929..36510b6d 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -13482,11 +13482,9 @@ NET-TYPE
IPv4.
PROTOCOL
- The protocol to use over IP. This must be either `tcp', `udp', or
- `raw', for a TCP, UDP, or raw IP connection, respectively. The
- use of TCP is recommended for most applications.
-
- *Caution:* The use of raw sockets is not currently supported.
+ The protocol to use over IP. This must be either `tcp', or `udp',
+ for a TCP or UDP IP connection, respectively. The use of TCP is
+ recommended for most applications.
LOCAL-PORT
The local TCP or UDP port number to use. Use a port number of `0'
@@ -19542,7 +19540,8 @@ all be disabled with either the `--traditional' or `--posix' options
* The `/inet4' and `/inet6' special files for TCP/IP networking
using `|&' to specify which version of the IP protocol to use.
- (*note TCP/IP Networking::).
+ The option to use a raw IP socket was removed, since it was never
+ implemented (*note TCP/IP Networking::).
* The `--compat', `--copyleft' and `--usage' options were removed.
@@ -25838,7 +25837,7 @@ Index
* get_curfunc_arg_count internal function: Internals. (line 37)
* get_record input method: Internals. (line 162)
* get_scalar_argument internal macro: Internals. (line 126)
-* getaddrinfo() function (C library): TCP/IP Networking. (line 39)
+* getaddrinfo() function (C library): TCP/IP Networking. (line 37)
* getgrent() function (C library): Group Functions. (line 6)
* getgrent() user-defined function: Group Functions. (line 6)
* getgrgid() function (C library): Group Functions. (line 187)
@@ -26560,7 +26559,6 @@ Index
* Rankin, Pat <2>: Contributors. (line 35)
* Rankin, Pat <3>: Assignment Ops. (line 100)
* Rankin, Pat: Acknowledgments. (line 59)
-* raw sockets: TCP/IP Networking. (line 36)
* readable data files, checking: File Checking. (line 6)
* readable.awk program: File Checking. (line 11)
* recipe for a programming language: History. (line 6)
@@ -26758,7 +26756,6 @@ Index
* single-precision floating-point: Basic Data Typing. (line 33)
* Skywalker, Luke: Undocumented. (line 6)
* sleep utility: Alarm Program. (line 102)
-* sockets: TCP/IP Networking. (line 36)
* Solaris, POSIX compliant awk: Other Versions. (line 101)
* sort function, arrays, sorting: Array Sorting. (line 6)
* sort utility: Word Sorting. (line 56)
@@ -27355,149 +27352,149 @@ Node: Nondecimal Data547256
Node: Two-way I/O548817
Ref: Two-way I/O-Footnote-1554231
Node: TCP/IP Networking554308
-Node: Profiling557161
-Node: Library Functions564561
-Ref: Library Functions-Footnote-1567531
-Node: Library Names567702
-Ref: Library Names-Footnote-1571173
-Ref: Library Names-Footnote-2571393
-Node: General Functions571479
-Node: Nextfile Function572542
-Node: Strtonum Function576923
-Node: Assert Function579874
-Node: Round Function583200
-Node: Cliff Random Function584741
-Node: Ordinal Functions585757
-Ref: Ordinal Functions-Footnote-1588827
-Ref: Ordinal Functions-Footnote-2589079
-Node: Join Function589295
-Ref: Join Function-Footnote-1591066
-Node: Gettimeofday Function591266
-Node: Data File Management594981
-Node: Filetrans Function595613
-Node: Rewind Function599850
-Node: File Checking601303
-Node: Empty Files602397
-Node: Ignoring Assigns604627
-Node: Getopt Function606180
-Ref: Getopt Function-Footnote-1617505
-Node: Passwd Functions617708
-Ref: Passwd Functions-Footnote-1626696
-Node: Group Functions626784
-Node: Sample Programs634864
-Node: Running Examples635533
-Node: Clones636261
-Node: Cut Program637393
-Node: Egrep Program647160
-Ref: Egrep Program-Footnote-1654914
-Node: Id Program655024
-Node: Split Program658631
-Node: Tee Program662099
-Node: Uniq Program664842
-Node: Wc Program672219
-Ref: Wc Program-Footnote-1676465
-Node: Miscellaneous Programs676661
-Node: Dupword Program677781
-Node: Alarm Program679812
-Node: Translate Program684356
-Ref: Translate Program-Footnote-1688735
-Ref: Translate Program-Footnote-2688972
-Node: Labels Program689106
-Ref: Labels Program-Footnote-1692397
-Node: Word Sorting692481
-Node: History Sorting696828
-Node: Extract Program698666
-Node: Simple Sed706029
-Node: Igawk Program709086
-Ref: Igawk Program-Footnote-1723821
-Ref: Igawk Program-Footnote-2724022
-Node: Signature Program724160
-Node: Debugger725240
-Node: Debugging726116
-Node: Debugging Concepts726430
-Node: Debugging Terms728283
-Node: Awk Debugging730831
-Node: Sample dgawk session731723
-Node: dgawk invocation732215
-Node: Finding The Bug733399
-Node: List of Debugger Commands739914
-Node: Breakpoint Control741229
-Node: Dgawk Execution Control744439
-Node: Viewing And Changing Data747788
-Node: Dgawk Stack751084
-Node: Dgawk Info752545
-Node: Miscellaneous Dgawk Commands756483
-Node: Readline Support762199
-Node: Dgawk Limitations763015
-Node: Language History765187
-Node: V7/SVR3.1766564
-Node: SVR4768859
-Node: POSIX770304
-Node: BTL772016
-Node: POSIX/GNU773706
-Node: Contributors783370
-Node: Installation786979
-Node: Gawk Distribution787950
-Node: Getting788434
-Node: Extracting789260
-Node: Distribution contents790648
-Node: Unix Installation795721
-Node: Quick Installation796312
-Node: Additional Configuration Options798014
-Node: Configuration Philosophy799777
-Node: Non-Unix Installation802141
-Node: PC Installation802606
-Node: PC Binary Installation803912
-Node: PC Compiling805755
-Node: PC Dynamic810260
-Node: PC Using812623
-Node: Cygwin817171
-Node: MSYS818155
-Node: VMS Installation818661
-Node: VMS Compilation819265
-Node: VMS Installation Details820842
-Node: VMS Running822472
-Node: VMS POSIX824069
-Node: VMS Old Gawk825367
-Node: Unsupported825836
-Node: Atari Installation826298
-Node: Atari Compiling827585
-Node: Atari Using829474
-Node: BeOS Installation832321
-Node: Tandem Installation833466
-Node: Bugs835145
-Node: Other Versions838977
-Node: Notes844199
-Node: Compatibility Mode844891
-Node: Additions845674
-Node: Adding Code846424
-Node: New Ports852476
-Node: Dynamic Extensions856608
-Node: Internals857989
-Node: Plugin License868394
-Node: Sample Library869028
-Node: Internal File Description869692
-Node: Internal File Ops873387
-Ref: Internal File Ops-Footnote-1878263
-Node: Using Internal File Ops878411
-Node: Future Extensions880436
-Node: Basic Concepts884473
-Node: Basic High Level885230
-Ref: Basic High Level-Footnote-1889349
-Node: Basic Data Typing889543
-Node: Floating Point Issues893980
-Node: String Conversion Precision895063
-Ref: String Conversion Precision-Footnote-1896757
-Node: Unexpected Results896866
-Node: POSIX Floating Point Problems898692
-Ref: POSIX Floating Point Problems-Footnote-1902391
-Node: Glossary902429
-Node: Copying926212
-Node: GNU Free Documentation License963769
-Node: next-edition988913
-Node: unresolved989265
-Node: revision989765
-Node: consistency990188
-Node: Index993541
+Node: Profiling557080
+Node: Library Functions564480
+Ref: Library Functions-Footnote-1567450
+Node: Library Names567621
+Ref: Library Names-Footnote-1571092
+Ref: Library Names-Footnote-2571312
+Node: General Functions571398
+Node: Nextfile Function572461
+Node: Strtonum Function576842
+Node: Assert Function579793
+Node: Round Function583119
+Node: Cliff Random Function584660
+Node: Ordinal Functions585676
+Ref: Ordinal Functions-Footnote-1588746
+Ref: Ordinal Functions-Footnote-2588998
+Node: Join Function589214
+Ref: Join Function-Footnote-1590985
+Node: Gettimeofday Function591185
+Node: Data File Management594900
+Node: Filetrans Function595532
+Node: Rewind Function599769
+Node: File Checking601222
+Node: Empty Files602316
+Node: Ignoring Assigns604546
+Node: Getopt Function606099
+Ref: Getopt Function-Footnote-1617424
+Node: Passwd Functions617627
+Ref: Passwd Functions-Footnote-1626615
+Node: Group Functions626703
+Node: Sample Programs634783
+Node: Running Examples635452
+Node: Clones636180
+Node: Cut Program637312
+Node: Egrep Program647079
+Ref: Egrep Program-Footnote-1654833
+Node: Id Program654943
+Node: Split Program658550
+Node: Tee Program662018
+Node: Uniq Program664761
+Node: Wc Program672138
+Ref: Wc Program-Footnote-1676384
+Node: Miscellaneous Programs676580
+Node: Dupword Program677700
+Node: Alarm Program679731
+Node: Translate Program684275
+Ref: Translate Program-Footnote-1688654
+Ref: Translate Program-Footnote-2688891
+Node: Labels Program689025
+Ref: Labels Program-Footnote-1692316
+Node: Word Sorting692400
+Node: History Sorting696747
+Node: Extract Program698585
+Node: Simple Sed705948
+Node: Igawk Program709005
+Ref: Igawk Program-Footnote-1723740
+Ref: Igawk Program-Footnote-2723941
+Node: Signature Program724079
+Node: Debugger725159
+Node: Debugging726035
+Node: Debugging Concepts726349
+Node: Debugging Terms728202
+Node: Awk Debugging730750
+Node: Sample dgawk session731642
+Node: dgawk invocation732134
+Node: Finding The Bug733318
+Node: List of Debugger Commands739833
+Node: Breakpoint Control741148
+Node: Dgawk Execution Control744358
+Node: Viewing And Changing Data747707
+Node: Dgawk Stack751003
+Node: Dgawk Info752464
+Node: Miscellaneous Dgawk Commands756402
+Node: Readline Support762118
+Node: Dgawk Limitations762934
+Node: Language History765106
+Node: V7/SVR3.1766483
+Node: SVR4768778
+Node: POSIX770223
+Node: BTL771935
+Node: POSIX/GNU773625
+Node: Contributors783372
+Node: Installation786981
+Node: Gawk Distribution787952
+Node: Getting788436
+Node: Extracting789262
+Node: Distribution contents790650
+Node: Unix Installation795723
+Node: Quick Installation796314
+Node: Additional Configuration Options798016
+Node: Configuration Philosophy799779
+Node: Non-Unix Installation802143
+Node: PC Installation802608
+Node: PC Binary Installation803914
+Node: PC Compiling805757
+Node: PC Dynamic810262
+Node: PC Using812625
+Node: Cygwin817173
+Node: MSYS818157
+Node: VMS Installation818663
+Node: VMS Compilation819267
+Node: VMS Installation Details820844
+Node: VMS Running822474
+Node: VMS POSIX824071
+Node: VMS Old Gawk825369
+Node: Unsupported825838
+Node: Atari Installation826300
+Node: Atari Compiling827587
+Node: Atari Using829476
+Node: BeOS Installation832323
+Node: Tandem Installation833468
+Node: Bugs835147
+Node: Other Versions838979
+Node: Notes844201
+Node: Compatibility Mode844893
+Node: Additions845676
+Node: Adding Code846426
+Node: New Ports852478
+Node: Dynamic Extensions856610
+Node: Internals857991
+Node: Plugin License868396
+Node: Sample Library869030
+Node: Internal File Description869694
+Node: Internal File Ops873389
+Ref: Internal File Ops-Footnote-1878265
+Node: Using Internal File Ops878413
+Node: Future Extensions880438
+Node: Basic Concepts884475
+Node: Basic High Level885232
+Ref: Basic High Level-Footnote-1889351
+Node: Basic Data Typing889545
+Node: Floating Point Issues893982
+Node: String Conversion Precision895065
+Ref: String Conversion Precision-Footnote-1896759
+Node: Unexpected Results896868
+Node: POSIX Floating Point Problems898694
+Ref: POSIX Floating Point Problems-Footnote-1902393
+Node: Glossary902431
+Node: Copying926214
+Node: GNU Free Documentation License963771
+Node: next-edition988915
+Node: unresolved989267
+Node: revision989767
+Node: consistency990190
+Node: Index993543

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index e1100b5a..1e7e2cff 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -18242,14 +18242,10 @@ Plain @samp{/inet/} (which used to be the only option) uses
the system default, most likely IPv4.
@item protocol
-The protocol to use over IP. This must be either @samp{tcp},
-@samp{udp}, or @samp{raw}, for a TCP, UDP, or raw IP connection,
+The protocol to use over IP. This must be either @samp{tcp}, or
+@samp{udp}, for a TCP or UDP IP connection,
respectively. The use of TCP is recommended for most applications.
-@cindex raw sockets
-@cindex sockets
-@strong{Caution:} The use of raw sockets is not currently supported.
-
@item local-port
@cindex @code{getaddrinfo()} function (C library)
The local TCP or UDP port number to use. Use a port number of @samp{0}
@@ -18270,8 +18266,9 @@ service name.
@end table
@quotation NOTE
-Failure in opening a two-way socket will result in a non-fatal error being returned
-to the calling code. The value of @code{ERRNO} indicates the error (@pxref{Auto-set}).
+Failure in opening a two-way socket will result in a non-fatal error
+being returned to the calling code. The value of @code{ERRNO} indicates
+the error (@pxref{Auto-set}).
@end quotation
Consider the following very simple example:
@@ -26313,6 +26310,7 @@ The @code{patsplit()} function
@item
The @file{/inet4} and @samp{/inet6} special files for TCP/IP networking
using @samp{|&} to specify which version of the IP protocol to use.
+The option to use a raw IP socket was removed, since it was never implemented
(@pxref{TCP/IP Networking}).
@item
diff --git a/doc/gawkinet.info b/doc/gawkinet.info
index 325dc5a9..5bc6d773 100644
--- a/doc/gawkinet.info
+++ b/doc/gawkinet.info
@@ -105,7 +105,6 @@ texts being (a) (see below), and with the Back-Cover Texts being (b)
* Comparing Protocols:: Differences between the protocols.
* File /inet/tcp:: The TCP special file.
* File /inet/udp:: The UDP special file.
-* File /inet/raw:: The RAW special file.
* TCP Connecting:: Making a TCP connection.
* Troubleshooting:: Troubleshooting TCP/IP connections.
* Interacting:: Interacting with a service.
@@ -418,7 +417,6 @@ blocks.
TCP X X
UDP X
-RAW X
---------- Footnotes ----------
@@ -457,9 +455,8 @@ learn object-oriented ideology; underlying languages such as Tcl/Tk,
Perl, Python; or all of the libraries necessary to extend these
languages before they are ready for the Internet.
- This major node demonstrates how to use the TCP protocol. The other
-protocols are much less important for most users (UDP) or even
-untractable (RAW).
+ This major node demonstrates how to use the TCP protocol. The UDP
+protocol is much less important for most users.
* Menu:
@@ -511,10 +508,7 @@ fields, all of which are mandatory:
/NET-TYPE/PROTOCOL/LOCALPORT/HOSTNAME/REMOTEPORT
The NET-TYPE field lets you specify IPv4 versus IPv6, or lets you
-allow the system to choose. The LOCALPORT and REMOTEPORT fields do not
-have a meaning when used with `/inet/raw' because "ports" only apply to
-TCP and UDP. So, when using `/inet/raw', the port fields always have to
-be `0'.
+allow the system to choose.
* Menu:
@@ -540,14 +534,13 @@ NET-TYPE
PROTOCOL
Determines which member of the TCP/IP family of protocols is
- selected to transport the data across the network. There are three
- possible values (always written in lowercase): `tcp', `udp', and
- `raw'. The exact meaning of each is explained later in this node.
+ selected to transport the data across the network. There are two
+ possible values (always written in lowercase): `tcp' and `udp'.
+ The exact meaning of each is explained later in this node.
LOCALPORT
Determines which port on the local machine is used to communicate
- across the network. It has no meaning with `/inet/raw' and must
- therefore be `0'. Application-level clients usually use `0' to
+ across the network. Application-level clients usually use `0' to
indicate they do not care which local port is used--instead they
specify a remote port to connect to. It is vital for
application-level servers to use a number different from `0' here
@@ -568,8 +561,7 @@ HOSTNAME
REMOTEPORT
Determines which port on the remote machine is used to communicate
- across the network. It has no meaning with `/inet/raw' and must
- therefore be 0. For `/inet/tcp' and `/inet/udp',
+ across the network. For `/inet/tcp' and `/inet/udp',
application-level clients _must_ use a number other than `0' to
indicate to which port on the remote machine they want to connect.
Application-level servers must not fill this field with a `0'.
@@ -611,30 +603,20 @@ PROTOCOL LOCAL PORT HOST NAME REMOTE RESULTING CONNECTION-LEVEL
server on the
other side fails*
udp 0 x x Dedicated client
-raw 0 x 0 Dedicated client, works only
- as `root'
*tcp, udp* *x* *x* *x* *Client, switches to
dedicated server if
necessary*
*tcp, udp* *x* *0* *0* *Dedicated server*
-raw 0 0 0 Dedicated server, works only
- as `root'
-tcp, udp, x x 0 Invalid
-raw
-tcp, udp, 0 0 x Invalid
-raw
-tcp, udp, x 0 x Invalid
-raw
+tcp, udp x x 0 Invalid
+tcp, udp 0 0 x Invalid
+tcp, udp x 0 x Invalid
tcp, udp 0 0 0 Invalid
tcp, udp 0 x 0 Invalid
-raw x 0 0 Invalid
-raw 0 x x Invalid
-raw x x x Invalid
Table 2.1: /inet Special File Components
In general, TCP is the preferred mechanism to use. It is the
-simplest protocol to understand and to use. Use the others only if
+simplest protocol to understand and to use. Use UDP only if
circumstances demand low-overhead.

@@ -645,14 +627,13 @@ File: gawkinet.info, Node: Comparing Protocols, Prev: Special File Fields, Up
This node develops a pair of programs (sender and receiver) that do
nothing but send a timestamp from one machine to another. The sender
-and the receiver are implemented with each of the three protocols
+and the receiver are implemented with each of the two protocols
available and demonstrate the differences between them.
* Menu:
* File /inet/tcp:: The TCP special file.
* File /inet/udp:: The UDP special file.
-* File /inet/raw:: The RAW special file.

File: gawkinet.info, Node: File /inet/tcp, Next: File /inet/udp, Prev: Comparing Protocols, Up: Comparing Protocols
@@ -687,7 +668,7 @@ It does matter which side starts first. The sender/server has to be
started first, and it waits for the receiver to read a line.

-File: gawkinet.info, Node: File /inet/udp, Next: File /inet/raw, Prev: File /inet/tcp, Up: Comparing Protocols
+File: gawkinet.info, Node: File /inet/udp, Prev: File /inet/tcp, Up: Comparing Protocols
2.1.2.2 `/inet/udp'
...................
@@ -720,75 +701,6 @@ to accomplish this. This unreliable behavior is good enough for tasks
such as data acquisition, logging, and even stateless services like NFS.

-File: gawkinet.info, Node: File /inet/raw, Prev: File /inet/udp, Up: Comparing Protocols
-
-2.1.2.3 `/inet/raw'
-...................
-
-This is an IP-level protocol. Only `root' is allowed to access this
-special file. It is meant to be the basis for implementing and
-experimenting with transport-level protocols.(1) In the most general
-case, the sender has to supply the encapsulating header bytes in front
-of the packet and the receiver has to strip the additional bytes from
-the message.
-
- RAW receivers cannot receive packets sent with TCP or UDP because the
-operating system does not deliver the packets to a RAW receiver. The
-operating system knows about some of the protocols on top of IP and
-decides on its own which packet to deliver to which process. (d.c.)
-Therefore, the UDP receiver must be used for receiving UDP datagrams
-sent with the RAW sender. This is a dark corner, not only of `gawk',
-but also of TCP/IP.
-
- For extended experimentation with protocols, look into the approach
-implemented in a tool called SPAK. This tool reflects the hierarchical
-layering of protocols (encapsulation) in the way data streams are piped
-out of one program into the next one. It shows which protocol is based
-on which other (lower-level) protocol by looking at the command-line
-ordering of the program calls. Cleverly thought out, SPAK is much
-better than `gawk''s `/inet' for learning the meaning of each and every
-bit in the protocol headers.
-
- The next example uses the RAW protocol to emulate the behavior of
-UDP. The sender program is the same as above, but with some additional
-bytes that fill the places of the UDP fields:
-
- BEGIN {
- Message = "Hello world\n"
- SourcePort = 0
- DestinationPort = 8888
- MessageLength = length(Message)+8
- RawService = "/inet/raw/0/localhost/0"
- printf("%c%c%c%c%c%c%c%c%s",
- SourcePort/256, SourcePort%256,
- DestinationPort/256, DestinationPort%256,
- MessageLength/256, MessageLength%256,
- 0, 0, Message) |& RawService
- fflush(RawService)
- close(RawService)
- }
-
- Since this program tries to emulate the behavior of UDP, it checks if
-the RAW sender is understood by the UDP receiver but not if the RAW
-receiver can understand the UDP sender. In a real network, the RAW
-receiver is hardly of any use because it gets every IP packet that
-comes across the network. There are usually so many packets that `gawk'
-would be too slow for processing them. Only on a network with little
-traffic can the IP-level receiver program be tested. Programs for
-analyzing IP traffic on modem or ISDN channels should be possible.
-
- Port numbers do not have a meaning when using `/inet/raw'. Their
-fields have to be `0'. Only TCP and UDP use ports. Receiving data from
-`/inet/raw' is difficult, not only because of processing speed but also
-because data is usually binary and not restricted to ASCII. This
-implies that line separation with `RS' does not work as usual.
-
- ---------- Footnotes ----------
-
- (1) This special file is reserved, but not otherwise currently
-implemented.
-
-
File: gawkinet.info, Node: TCP Connecting, Next: Troubleshooting, Prev: Gawk Special Files, Up: Using Networking
2.2 Establishing a TCP Connection
@@ -4250,7 +4162,6 @@ Index
* Menu:
* /inet/ files (gawk): Gawk Special Files. (line 34)
-* /inet/raw special files (gawk): File /inet/raw. (line 6)
* /inet/tcp special files (gawk): File /inet/tcp. (line 6)
* /inet/udp special files (gawk): File /inet/udp. (line 6)
* advanced features, network connections: Troubleshooting. (line 6)
@@ -4274,7 +4185,6 @@ Index
* contest: Challenges. (line 6)
* cron utility: STOXPRED. (line 23)
* CSV format: STOXPRED. (line 128)
-* dark corner, RAW protocol: File /inet/raw. (line 13)
* Dow Jones Industrial Index: STOXPRED. (line 44)
* ELIZA program: Simple Server. (line 11)
* email: Email. (line 11)
@@ -4283,7 +4193,6 @@ Index
(line 6)
* filenames, for network access: Gawk Special Files. (line 29)
* files, /inet/ (gawk): Gawk Special Files. (line 34)
-* files, /inet/raw (gawk): File /inet/raw. (line 6)
* files, /inet/tcp (gawk): File /inet/tcp. (line 6)
* files, /inet/udp (gawk): File /inet/udp. (line 6)
* finger utility: Setting Up. (line 22)
@@ -4292,7 +4201,7 @@ Index
* FTP (File Transfer Protocol): Basic Protocols. (line 45)
* gawk, networking: Using Networking. (line 6)
* gawk, networking, connections <1>: TCP Connecting. (line 6)
-* gawk, networking, connections: Special File Fields. (line 55)
+* gawk, networking, connections: Special File Fields. (line 53)
* gawk, networking, filenames: Gawk Special Files. (line 29)
* gawk, networking, See Also email: Email. (line 6)
* gawk, networking, service, establishing: Setting Up. (line 6)
@@ -4311,7 +4220,7 @@ Index
* GNUPlot utility: Interacting Service. (line 189)
* Hoare, C.A.R. <1>: PROTBASE. (line 6)
* Hoare, C.A.R.: MOBAGWHO. (line 6)
-* hostname field: Special File Fields. (line 35)
+* hostname field: Special File Fields. (line 34)
* HTML (Hypertext Markup Language): Web page. (line 30)
* HTTP (Hypertext Transfer Protocol) <1>: Web page. (line 6)
* HTTP (Hypertext Transfer Protocol): Basic Protocols. (line 45)
@@ -4346,7 +4255,7 @@ Index
* network type field: Special File Fields. (line 11)
* networks, gawk and: Using Networking. (line 6)
* networks, gawk and, connections <1>: TCP Connecting. (line 6)
-* networks, gawk and, connections: Special File Fields. (line 55)
+* networks, gawk and, connections: Special File Fields. (line 53)
* networks, gawk and, filenames: Gawk Special Files. (line 29)
* networks, gawk and, See Also email: Email. (line 6)
* networks, gawk and, service, establishing: Setting Up. (line 6)
@@ -4373,7 +4282,6 @@ Index
* PS image format: STATIST. (line 6)
* Python: Using Networking. (line 14)
* Python, gawk networking and: Using Networking. (line 24)
-* RAW protocol: File /inet/raw. (line 6)
* record separators, HTTP and: Web page. (line 30)
* record separators, POP and: Email. (line 36)
* REMCONF program: REMCONF. (line 6)
@@ -4384,13 +4292,12 @@ Index
* RS variable, POP and: Email. (line 36)
* servers <1>: Setting Up. (line 22)
* servers: Making Connections. (line 14)
-* servers, as hosts: Special File Fields. (line 35)
+* servers, as hosts: Special File Fields. (line 34)
* servers, HTTP: Interacting Service. (line 6)
* servers, web: Simple Server. (line 6)
* Simple Mail Transfer Protocol (SMTP): Email. (line 6)
* SMTP (Simple Mail Transfer Protocol) <1>: Email. (line 6)
* SMTP (Simple Mail Transfer Protocol): Basic Protocols. (line 45)
-* SPAK utility: File /inet/raw. (line 21)
* STATIST program: STATIST. (line 6)
* STOXPRED program: STOXPRED. (line 6)
* synchronous communications: Making Connections. (line 35)
@@ -4435,58 +4342,56 @@ Index

Tag Table:
Node: Top2015
-Node: Preface5709
-Node: Introduction7084
-Node: Stream Communications8110
-Node: Datagram Communications9283
-Node: The TCP/IP Protocols10914
-Ref: The TCP/IP Protocols-Footnote-111598
-Node: Basic Protocols11755
-Ref: Basic Protocols-Footnote-113798
-Node: Ports13827
-Node: Making Connections15234
-Ref: Making Connections-Footnote-117815
-Ref: Making Connections-Footnote-217862
-Node: Using Networking18043
-Node: Gawk Special Files20397
-Node: Special File Fields22403
-Ref: table-inet-components26418
-Node: Comparing Protocols28330
-Node: File /inet/tcp28919
-Node: File /inet/udp29945
-Node: File /inet/raw31066
-Ref: File /inet/raw-Footnote-134099
-Node: TCP Connecting34179
-Node: Troubleshooting36517
-Ref: Troubleshooting-Footnote-139568
-Node: Interacting40137
-Node: Setting Up42867
-Node: Email46361
-Node: Web page48687
-Ref: Web page-Footnote-151492
-Node: Primitive Service51689
-Node: Interacting Service54423
-Ref: Interacting Service-Footnote-163552
-Node: CGI Lib63584
-Node: Simple Server70545
-Ref: Simple Server-Footnote-178268
-Node: Caveats78369
-Node: Challenges79512
-Node: Some Applications and Techniques88191
-Node: PANIC90648
-Node: GETURL92366
-Node: REMCONF94989
-Node: URLCHK100465
-Node: WEBGRAB104300
-Node: STATIST108750
-Ref: STATIST-Footnote-1120458
-Node: MAZE120903
-Node: MOBAGWHO127091
-Ref: MOBAGWHO-Footnote-1141035
-Node: STOXPRED141090
-Node: PROTBASE155345
-Node: Links168427
-Node: GNU Free Documentation License171861
-Node: Index197000
+Node: Preface5652
+Node: Introduction7027
+Node: Stream Communications8053
+Node: Datagram Communications9226
+Node: The TCP/IP Protocols10857
+Ref: The TCP/IP Protocols-Footnote-111541
+Node: Basic Protocols11698
+Ref: Basic Protocols-Footnote-113741
+Node: Ports13770
+Node: Making Connections15177
+Ref: Making Connections-Footnote-117738
+Ref: Making Connections-Footnote-217785
+Node: Using Networking17966
+Node: Gawk Special Files20284
+Node: Special File Fields22094
+Ref: table-inet-components25967
+Node: Comparing Protocols27287
+Node: File /inet/tcp27820
+Node: File /inet/udp28846
+Node: TCP Connecting29944
+Node: Troubleshooting32282
+Ref: Troubleshooting-Footnote-135333
+Node: Interacting35902
+Node: Setting Up38632
+Node: Email42126
+Node: Web page44452
+Ref: Web page-Footnote-147257
+Node: Primitive Service47454
+Node: Interacting Service50188
+Ref: Interacting Service-Footnote-159317
+Node: CGI Lib59349
+Node: Simple Server66310
+Ref: Simple Server-Footnote-174033
+Node: Caveats74134
+Node: Challenges75277
+Node: Some Applications and Techniques83956
+Node: PANIC86413
+Node: GETURL88131
+Node: REMCONF90754
+Node: URLCHK96230
+Node: WEBGRAB100065
+Node: STATIST104515
+Ref: STATIST-Footnote-1116223
+Node: MAZE116668
+Node: MOBAGWHO122856
+Ref: MOBAGWHO-Footnote-1136800
+Node: STOXPRED136855
+Node: PROTBASE151110
+Node: Links164192
+Node: GNU Free Documentation License167626
+Node: Index192765

End Tag Table
diff --git a/doc/gawkinet.texi b/doc/gawkinet.texi
index a7fe43b7..08748165 100644
--- a/doc/gawkinet.texi
+++ b/doc/gawkinet.texi
@@ -172,7 +172,6 @@ version 4.0 and later.
* Comparing Protocols:: Differences between the protocols.
* File /inet/tcp:: The TCP special file.
* File /inet/udp:: The UDP special file.
-* File /inet/raw:: The RAW special file.
* TCP Connecting:: Making a TCP connection.
* Troubleshooting:: Troubleshooting TCP/IP connections.
* Interacting:: Interacting with a service.
@@ -496,7 +495,6 @@ where an ``X'' indicates that the given action blocks.
@multitable {Protocol} {Reads} {Writes}
@item TCP @tab X @tab X
@item UDP @tab X @tab
-@item RAW @tab X @tab
@end multitable
@end ifnottex
@tex
@@ -512,7 +510,6 @@ Protocol&&\quad Reads\quad &Writes\cr
\noalign{\hrule height0pt}% without this the rule does not extend; why?
TCP&&X&X\cr
UDP&&X&\cr
-RAW&&X&\cr
}}}
@end tex
@@ -564,8 +561,7 @@ the libraries necessary to extend these languages before they are ready for the
@cindex Transmission Control Protocol, See TCP
@cindex TCP (Transmission Control Protocol)
This @value{CHAPTER} demonstrates how to use the TCP protocol. The
-other protocols are much less important for most users (UDP) or even
-untractable (RAW).
+UDP protocol is much less important for most users.
@menu
* Gawk Special Files:: How to do @command{gawk} networking.
@@ -633,10 +629,6 @@ of which are mandatory:
@cindex remoteport field
The @var{net-type} field lets you specify IPv4 versus IPv6, or lets
you allow the system to choose.
-The @var{localport} and @var{remoteport} fields do not have a meaning
-when used with @file{/inet/raw} because ``ports'' only apply to
-TCP and UDP. So, when using @file{/inet/raw}, the port fields always have
-to be @samp{0}.
@menu
* Special File Fields:: The fields in the special file name.
@@ -666,15 +658,14 @@ in our descriptions of how @command{gawk}'s networking works.
@item protocol
Determines which member of the TCP/IP
family of protocols is selected to transport the data across the
-network. There are three possible values (always written in lowercase):
-@samp{tcp}, @samp{udp}, and @samp{raw}. The exact meaning of each is
+network. There are two possible values (always written in lowercase):
+@samp{tcp} and @samp{udp}. The exact meaning of each is
explained later in this @value{SECTION}.
@item localport
@cindex networks, ports, specifying
Determines which port on the local
-machine is used to communicate across the network. It has no meaning
-with @file{/inet/raw} and must therefore be @samp{0}. Application-level clients
+machine is used to communicate across the network. Application-level clients
usually use @samp{0} to indicate they do not care which local port is
used---instead they specify a remote port to connect to. It is vital for
application-level servers to use a number different from @samp{0} here
@@ -696,8 +687,7 @@ The name can be either symbolic
@item remoteport
Determines which port on the remote
-machine is used to communicate across the network. It has no meaning
-with @file{/inet/raw} and must therefore be 0.
+machine is used to communicate across the network.
For @file{/inet/tcp} and @file{/inet/udp},
application-level clients @emph{must} use a number
other than @samp{0} to indicate to which port on the remote machine
@@ -750,25 +740,20 @@ patterns printed in bold letters.
@strong{Dedicated client, fails if immediately connecting to a
server on the other side fails}
@item udp @tab 0 @tab x @tab x @tab Dedicated client
-@item raw @tab 0 @tab x @tab 0 @tab Dedicated client, works only as @code{root}
@item @strong{tcp, udp} @tab @strong{x} @tab @strong{x} @tab @strong{x} @tab
@strong{Client, switches to dedicated server if necessary}
@item @strong{tcp, udp} @tab @strong{x} @tab @strong{0} @tab @strong{0} @tab
@strong{Dedicated server}
-@item raw @tab 0 @tab 0 @tab 0 @tab Dedicated server, works only as @code{root}
-@item tcp, udp, raw @tab x @tab x @tab 0 @tab Invalid
-@item tcp, udp, raw @tab 0 @tab 0 @tab x @tab Invalid
-@item tcp, udp, raw @tab x @tab 0 @tab x @tab Invalid
+@item tcp, udp @tab x @tab x @tab 0 @tab Invalid
+@item tcp, udp @tab 0 @tab 0 @tab x @tab Invalid
+@item tcp, udp @tab x @tab 0 @tab x @tab Invalid
@item tcp, udp @tab 0 @tab 0 @tab 0 @tab Invalid
@item tcp, udp @tab 0 @tab x @tab 0 @tab Invalid
-@item raw @tab x @tab 0 @tab 0 @tab Invalid
-@item raw @tab 0 @tab x @tab x @tab Invalid
-@item raw @tab x @tab x @tab x @tab Invalid
@end multitable
@end float
In general, TCP is the preferred mechanism to use. It is the simplest
-protocol to understand and to use. Use the others only if circumstances
+protocol to understand and to use. Use UDP only if circumstances
demand low-overhead.
@node Comparing Protocols, , Special File Fields, Gawk Special Files
@@ -776,13 +761,12 @@ demand low-overhead.
This @value{SECTION} develops a pair of programs (sender and receiver)
that do nothing but send a timestamp from one machine to another. The
-sender and the receiver are implemented with each of the three protocols
+sender and the receiver are implemented with each of the two protocols
available and demonstrate the differences between them.
@menu
* File /inet/tcp:: The TCP special file.
* File /inet/udp:: The UDP special file.
-* File /inet/raw:: The RAW special file.
@end menu
@node File /inet/tcp, File /inet/udp, Comparing Protocols, Comparing Protocols
@@ -823,7 +807,7 @@ a reliable service.
It does matter which side starts first. The sender/server has to be started
first, and it waits for the receiver to read a line.
-@node File /inet/udp, File /inet/raw, File /inet/tcp, Comparing Protocols
+@node File /inet/udp, , File /inet/tcp, Comparing Protocols
@subsubsection @file{/inet/udp}
@cindex @code{/inet/udp} special files (@command{gawk})
@cindex files, @code{/inet/udp} (@command{gawk})
@@ -859,82 +843,6 @@ lost, some doubled, and some out of order. But no overhead is necessary to
accomplish this. This unreliable behavior is good enough for tasks
such as data acquisition, logging, and even stateless services like NFS.
-@node File /inet/raw, , File /inet/udp, Comparing Protocols
-@subsubsection @file{/inet/raw}
-@cindex @code{/inet/raw} special files (@command{gawk})
-@cindex files, @code{/inet/raw} (@command{gawk})
-@cindex RAW protocol
-
-This is an IP-level protocol. Only @code{root} is allowed to access this
-special file. It is meant to be the basis for implementing
-and experimenting with transport-level protocols.@footnote{This special file
-is reserved, but not otherwise currently implemented.}
-In the most general case,
-the sender has to supply the encapsulating header bytes in front of the
-packet and the receiver has to strip the additional bytes from the message.
-
-@cindex dark corner, RAW protocol
-RAW receivers cannot receive packets sent with TCP or UDP because the
-operating system does not deliver the packets to a RAW receiver. The
-operating system knows about some of the protocols on top of IP
-and decides on its own which packet to deliver to which process.
-@value{DARKCORNER}
-Therefore, the UDP receiver must be used for receiving UDP
-datagrams sent with the RAW sender. This is a dark corner, not only of
-@command{gawk}, but also of TCP/IP.
-
-@cindex SPAK utility
-For extended experimentation with protocols, look into
-the approach implemented in a tool called SPAK.
-This tool reflects the hierarchical layering of protocols (encapsulation)
-in the way data streams are piped out of one program into the next one.
-It shows which protocol is based on which other (lower-level) protocol
-by looking at the command-line ordering of the program calls.
-Cleverly thought out, SPAK is much better than @command{gawk}'s
-@file{/inet} for learning the meaning of each and every bit in the
-protocol headers.
-
-The next example uses the RAW protocol to emulate
-the behavior of UDP. The sender program is the same as above, but with some
-additional bytes that fill the places of the UDP fields:
-
-@example
-@group
-BEGIN @{
- Message = "Hello world\n"
- SourcePort = 0
- DestinationPort = 8888
- MessageLength = length(Message)+8
- RawService = "/inet/raw/0/localhost/0"
- printf("%c%c%c%c%c%c%c%c%s",
- SourcePort/256, SourcePort%256,
- DestinationPort/256, DestinationPort%256,
- MessageLength/256, MessageLength%256,
- 0, 0, Message) |& RawService
- fflush(RawService)
- close(RawService)
-@}
-@end group
-@end example
-
-Since this program tries
-to emulate the behavior of UDP, it checks if
-the RAW sender is understood by the UDP receiver but not if the RAW receiver
-can understand the UDP sender. In a real network, the
-RAW receiver is hardly
-of any use because it gets every IP packet that
-comes across the network. There are usually so many packets that
-@command{gawk} would be too slow for processing them.
-Only on a network with little
-traffic can the IP-level receiver program be tested. Programs for analyzing
-IP traffic on modem or ISDN channels should be possible.
-
-Port numbers do not have a meaning when using @file{/inet/raw}. Their fields
-have to be @samp{0}. Only TCP and UDP use ports. Receiving data from
-@file{/inet/raw} is difficult, not only because of processing speed but also
-because data is usually binary and not restricted to ASCII. This
-implies that line separation with @code{RS} does not work as usual.
-
@node TCP Connecting, Troubleshooting, Gawk Special Files, Using Networking
@section Establishing a TCP Connection
@@ -4751,7 +4659,7 @@ They are presented in the order in which they appear.
@end table
@c The GNU Free Documentation License.
-@node GNU Free Documentation License
+@node GNU Free Documentation License, Index, Links, Top
@unnumbered GNU Free Documentation License
@cindex FDL (Free Documentation License)
@cindex Free Documentation License (FDL)
diff --git a/io.c b/io.c
index efad6af3..687c9eaf 100644
--- a/io.c
+++ b/io.c
@@ -190,6 +190,7 @@ static RECVALUE (*matchrec)(IOBUF *iop, struct recmatch *recm, SCANSTATE *state)
static int get_a_record(char **out, IOBUF *iop, int *errcode);
static void free_rp(struct redirect *rp);
+static int inetfile(const char *str, int *length, int *family);
#if defined(HAVE_POPEN_H)
#include "popen.h"
@@ -536,10 +537,14 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
int fd;
const char *what = NULL;
int new_rp = FALSE;
+ int len; /* used with /inet */
static struct redirect *save_rp = NULL; /* hold onto rp that should
* be freed for reuse
*/
+ if (do_sandbox)
+ fatal(_("redirection not allowed in sandbox mode"));
+
switch (redirtype) {
case redirect_append:
tflag = RED_APPEND;
@@ -587,10 +592,14 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
lintwarn(_("filename `%s' for `%s' redirection may be result of logical expression"),
str, what);
+ /*
+ * XXX: Use /inet4 and /inet6 with plain /inet being whatever
+ * we get back from the system.
+ */
#ifdef HAVE_SOCKETS
- if (STREQN(str, "/inet/", 6)) {
+ if (inetfile(str, & len, NULL)) {
tflag |= RED_SOCKET;
- if (STREQN(str + 6, "tcp/", 4))
+ if (STREQN(str + len, "tcp/", 4))
tflag |= RED_TCP; /* use shutdown when closing */
}
#endif /* HAVE_SOCKETS */
@@ -702,8 +711,9 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
direction = "to/from";
if (! two_way_open(str, rp)) {
#ifdef HAVE_SOCKETS
- if (STREQN(redir_exp->stptr, "/inet/", 6)) {
+ if (inetfile(str, NULL, NULL)) {
*errflg = errno;
+ free_rp(rp);
return NULL;
} else
#endif
@@ -1193,8 +1203,8 @@ str2mode(const char *mode)
/* socketopen --- open a socket and set it into connected state */
static int
-socketopen(int type, const char *localpname, const char *remotepname,
- const char *remotehostname)
+socketopen(int family, int type, const char *localpname,
+ const char *remotepname, const char *remotehostname)
{
struct addrinfo *lres, *lres0;
struct addrinfo lhints;
@@ -1210,6 +1220,7 @@ socketopen(int type, const char *localpname, const char *remotepname,
memset (&lhints, '\0', sizeof (lhints));
lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
lhints.ai_socktype = type;
+ lhints.ai_family = family;
lerror = getaddrinfo (NULL, localpname, &lhints, &lres);
if (lerror) {
@@ -1236,7 +1247,7 @@ socketopen(int type, const char *localpname, const char *remotepname,
rres0 = rres;
socket_fd = INVALID_HANDLE;
while (rres != NULL) {
- socket_fd = socket (rres->ai_family,
+ socket_fd = socket(rres->ai_family,
rres->ai_socktype, rres->ai_protocol);
if (socket_fd < 0 || socket_fd == INVALID_HANDLE)
goto nextrres;
@@ -1260,22 +1271,8 @@ socketopen(int type, const char *localpname, const char *remotepname,
goto nextrres;
if (! any_remote_host) { /* not ANY => create a client */
- if (type != SOCK_RAW) {
- if (connect(socket_fd, rres->ai_addr,
- rres->ai_addrlen) == 0)
- break;
- } else {
- /* /inet/raw client not ready yet */
- if (socket_fd != INVALID_HANDLE)
- close(socket_fd);
- freeaddrinfo(rres0);
- if (lres0 != NULL)
- freeaddrinfo(lres0);
- fatal(_("/inet/raw client not ready yet, sorry"));
- if (geteuid() != 0)
- /* FIXME: is this second fatal ever reached? */
- fatal(_("only root may use `/inet/raw'."));
- }
+ if (connect(socket_fd, rres->ai_addr, rres->ai_addrlen) == 0)
+ break;
} else { /* remote host is ANY => create a server */
if (type == SOCK_STREAM) {
int clientsocket_fd = INVALID_HANDLE;
@@ -1306,16 +1303,6 @@ socketopen(int type, const char *localpname, const char *remotepname,
readle) == 0)
break;
#endif
- } else {
- /* /inet/raw server not ready yet */
- if (socket_fd != INVALID_HANDLE)
- close(socket_fd);
- freeaddrinfo(rres0);
- if (lres0 != NULL)
- freeaddrinfo(lres0);
- fatal(_("/inet/raw server not ready yet, sorry"));
- if (geteuid() != 0)
- fatal(_("only root may use `/inet/raw'."));
}
}
@@ -1340,13 +1327,6 @@ nextrres:
/* devopen --- handle /dev/std{in,out,err}, /dev/fd/N, regular files */
/*
- * This separate version is still needed for output, since file and pipe
- * output is done with stdio. iop_open() handles input with IOBUFs of
- * more "special" files. Those files are not handled here since it makes
- * no sense to use them for output.
- */
-
-/*
* Strictly speaking, "name" is not a "const char *" because we temporarily
* change the string.
*/
@@ -1358,6 +1338,8 @@ devopen(const char *name, const char *mode)
char *cp;
char *ptr;
int flag = 0;
+ int len;
+ int family;
extern unsigned long strtoul(const char *, char **endptr, int base);
flag = str2mode(mode);
@@ -1385,15 +1367,18 @@ devopen(const char *name, const char *mode)
else if (STREQ(cp, "stderr") && (flag & O_ACCMODE) == O_WRONLY)
openfd = fileno(stderr);
else if (STREQN(cp, "fd/", 3)) {
+ struct stat sbuf;
+
cp += 3;
openfd = (int) strtoul(cp, &ptr, 10);
- if (openfd <= INVALID_HANDLE || ptr == cp)
+ if (openfd <= INVALID_HANDLE || ptr == cp
+ || fstat(openfd, &sbuf) < 0)
openfd = INVALID_HANDLE;
}
/* do not set close-on-exec for inherited fd's */
if (openfd != INVALID_HANDLE)
return openfd;
- } else if (STREQN(name, "/inet/", 6)) {
+ } else if (inetfile(name, & len, & family)) {
#ifdef HAVE_SOCKETS
/* /inet/protocol/localport/hostname/remoteport */
int protocol;
@@ -1402,14 +1387,12 @@ devopen(const char *name, const char *mode)
char *localpname;
char *localpnamelastcharp;
- cp = (char *) name + 6;
+ cp = (char *) name + len;
/* which protocol? */
if (STREQN(cp, "tcp/", 4))
protocol = SOCK_STREAM;
else if (STREQN(cp, "udp/", 4))
protocol = SOCK_DGRAM;
- else if (STREQN(cp, "raw/", 4))
- protocol = SOCK_RAW;
else {
protocol = SOCK_STREAM; /* shut up the compiler */
fatal(_("no (known) protocol supplied in special filename `%s'"),
@@ -1428,7 +1411,8 @@ devopen(const char *name, const char *mode)
if (*cp != '/' || cp == localpname)
fatal(_("special file name `%s' is incomplete"), name);
- /* We change the special file name temporarily because we
+ /*
+ * We change the special file name temporarily because we
* need a 0-terminated string here for conversion with atoi().
* By using atoi() the use of decimal numbers is enforced.
*/
@@ -1498,7 +1482,7 @@ devopen(const char *name, const char *mode)
retries = def_retries;
do {
- openfd = socketopen(protocol, localpname, cp, hostname);
+ openfd = socketopen(family, protocol, localpname, cp, hostname);
retries--;
} while (openfd == INVALID_HANDLE && retries > 0 && usleep(msleep) == 0);
}
@@ -1540,7 +1524,7 @@ two_way_open(const char *str, struct redirect *rp)
#ifdef HAVE_SOCKETS
/* case 1: socket */
- if (STREQN(str, "/inet/", 6)) {
+ if (inetfile(str, NULL, NULL)) {
int fd, newfd;
fd = devopen(str, "rw");
@@ -1869,6 +1853,7 @@ use_pipes:
save_errno = errno;
close(ptoc[1]);
close(ctop[0]);
+
errno = save_errno;
return FALSE;
}
@@ -2532,6 +2517,7 @@ iop_alloc(int fd, const char *name, IOBUF *iop, int do_openhooks)
else if (iop->fd == INVALID_HANDLE)
return iop;
+ /* test reached if tried to find open hook and could not */
if (iop->fd == INVALID_HANDLE) {
if (iop_malloced)
efree(iop);
@@ -3123,8 +3109,8 @@ set_RS()
save_rs = dupnode(RS_node->var_value);
RS_is_null = FALSE;
RS = force_string(RS_node->var_value);
-
- /* used to be if (RS_regexp != NULL) { refree(..); refree(..); ...; }.
+ /*
+ * used to be if (RS_regexp != NULL) { refree(..); refree(..); ...; }.
* Please do not remerge the if condition; hinders memory deallocation
* in case of fatal error in make_regexp.
*/
@@ -3175,7 +3161,7 @@ pty_vs_pipe(const char *command)
full_len = strlen(command)
+ SUBSEP_node->var_value->stlen
- + 3 /* strlen("pty") */
+ + 3 /* strlen("pty") */
+ 1; /* string terminator */
emalloc(full_index, char *, full_len, "pty_vs_pipe");
sprintf(full_index, "%s%.*spty", command,
@@ -3223,3 +3209,33 @@ free_rp(struct redirect *rp)
efree(rp->value);
efree(rp);
}
+
+/* inetfile --- return true for a /inet special file, set other values */
+
+static int
+inetfile(const char *str, int *length, int *family)
+{
+ int ret = FALSE;
+
+ if (STREQN(str, "/inet/", 6)) {
+ ret = TRUE;
+ if (length != NULL)
+ *length = 6;
+ if (family != NULL)
+ *family = AF_UNSPEC;
+ } else if (STREQN(str, "/inet4/", 7)) {
+ ret = TRUE;
+ if (length != NULL)
+ *length = 7;
+ if (family != NULL)
+ *family = AF_INET;
+ } else if (STREQN(str, "/inet6/", 7)) {
+ ret = TRUE;
+ if (length != NULL)
+ *length = 7;
+ if (family != NULL)
+ *family = AF_INET6;
+ }
+
+ return ret;
+}