Ravenports generated: 04 Feb 2024 05:27
[ravenports.git] / bucket_A3 / socat
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               socat
4 VERSION=                1.8.0.0
5 KEYWORDS=               net
6 VARIANTS=               standard
7 SDESC[standard]=        Multipurpose relay
8 HOMEPAGE=               none
9 CONTACT=                nobody
10
11 DOWNLOAD_GROUPS=        main
12 SITES[main]=            http://www.dest-unreach.org/socat/download/
13 DISTFILE[1]=            socat-1.8.0.0.tar.gz:main
14 DF_INDEX=               1
15 SPKGS[standard]=        complete
16                         primary
17                         docs
18
19 OPTIONS_AVAILABLE=      none
20 OPTIONS_STANDARD=       none
21
22 USES=                   cpe ssl:openssl11
23
24 LICENSE=                GPLv2:primary
25 LICENSE_TERMS=          primary:{{WRKDIR}}/TERMS
26 LICENSE_FILE=           GPLv2:{{WRKSRC}}/COPYING
27 LICENSE_AWK=            TERMS:"^\#include"
28 LICENSE_SOURCE=         TERMS:{{WRKSRC}}/socat.c
29 LICENSE_SCHEME=         solo
30
31 CPE_VENDOR=             dest-unreach
32 FPC_EQUIVALENT=         net/socat
33
34 MUST_CONFIGURE=         gnu
35
36 RC_SUBR=                socat:primary
37
38 CFLAGS=                 -Wno-unused-variable
39
40 do-install:
41 .for f in filan procan socat
42         ${INSTALL_PROGRAM} ${WRKSRC}/${f} ${STAGEDIR}${PREFIX}/bin
43 .endfor
44         ${INSTALL_MAN} ${WRKSRC}/doc/socat.1 ${STAGEDIR}${MAN1PREFIX}/man/man1
45         ${MKDIR} ${STAGEDIR}${STD_DOCDIR}
46         cd ${WRKSRC} && ${INSTALL_DATA} EXAMPLES README SECURITY FAQ \
47                 ${STAGEDIR}${STD_DOCDIR}
48         ${INSTALL_DATA} ${FILESDIR}/socat-instances.conf.sample \
49                 ${STAGEDIR}${PREFIX}/etc
50
51 [FILE:667:descriptions/desc.primary]
52 socat is a relay for bidirectional data transfer between two independent
53 data channels. Each of these data channels may be a file, pipe, device
54 (terminal or modem etc.), socket (UNIX, IP4, IP6 - raw, UDP, TCP), a file
55 descriptor (stdin etc.), a program, or an arbitrary combination of two of
56 these.
57
58 socat can be used, e.g., as TCP relay (one-shot or daemon), as an external
59 socksifier, for attacking weak firewalls, as a shell interface to UNIX
60 sockets, IP6 relay, for redirecting TCP oriented programs like brutus to a
61 serial line, or to establish a relatively secure environment (su and chroot)
62 for running client or server shell scripts with network connections.
63
64
65 [FILE:99:distinfo]
66 6010f4f311e5ebe0e63c77f78613d264253680006ac8979f52b0711a9a231e82       712469 socat-1.8.0.0.tar.gz
67
68
69 [FILE:93:manifests/plist.primary]
70 @sample etc/socat-instances.conf.sample
71 bin/
72  filan
73  procan
74  socat
75 share/man/man1/socat.1.gz
76
77
78 [FILE:50:manifests/plist.docs]
79 share/doc/socat/
80  EXAMPLES
81  FAQ
82  README
83  SECURITY
84
85
86 [FILE:875:patches/patch-fdname.c]
87 Use correct prototype for getprotobynumber_r() on SunOS
88
89 --- fdname.c.orig       2023-11-13 19:31:08 UTC
90 +++ fdname.c
91 @@ -250,7 +250,7 @@ int sockname(int fd, FILE *outfile, char
92     /*Linux struct ifreq ifc = {{{ 0 }}};*/
93     struct ifreq ifc = {{ 0 }};
94  #endif
95 -   int rc;
96 +   int rc = 0;
97  
98  #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
99     optlen = sizeof(proto);
100 @@ -280,7 +280,12 @@ int sockname(int fd, FILE *outfile, char
101  
102  #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
103  #if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */
104 +# if defined(__sun)
105 +   protoentp = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname));
106 +   rc = errno;
107 +# else
108     rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp);
109 +# endif
110     if (protoentp == NULL) {
111        Warn2("sockname(): getprotobynumber_r(proto=%d, ...): %s",
112             proto, strerror(rc));
113
114
115 [FILE:429:patches/patch-filan.c]
116 --- filan.c.orig        2023-11-13 19:31:08 UTC
117 +++ filan.c
118 @@ -939,6 +939,7 @@ int tcpan(int fd, FILE *outfile) {
119  #if WITH_TCP && defined(TCP_INFO)
120  
121  int tcpan2(int fd, FILE *outfile) {
122 +# ifdef TCP_INFO
123     struct tcp_info tcpinfo;
124     socklen_t tcpinfolen = sizeof(tcpinfo);
125     int result;
126 @@ -966,6 +967,9 @@ int tcpan2(int fd, FILE *outfile) {
127  #endif
128  
129     return 0;
130 +# else
131 +   return -1;
132 +# endif
133  }
134  
135  #endif /* WITH_TCP */
136
137
138 [FILE:1445:files/socat-instances.conf.sample]
139 # socat-instances.conf.sample
140 # This config file is evaluated by the rc script from the FreeBSD
141 # port of net/socat.
142 # It is not related to socat(1) itself!
143 # This file is shell syntax.
144
145 # Each instance to be daemonized must be defined with a line starting
146 # with [instancename].  instancename can be any alnum and is case insensitive
147 # (will internally be converted to upper case).
148
149 #[ntp4]
150 # Default socat_daemonuser=nobody won't be able to open sockets with port numbers
151 # below 1024.
152 #daemonuser=root
153 #flags="UDP4-RECVFROM:123,fork,bind=192.0.2.20 UDP4-SENDTO:169.254.0.53:123"
154
155 #[ntp6]
156 #daemonuser=root
157 #flags="UDP6-RECVFROM:123,fork,bind=[2001:DB8::1:2:3] UDP4-SENDTO:169.254.0.53:123"
158
159 #
160 # Variable definitions:
161 #
162 #   daemonuser (optional):
163 #      Overrides socat_daemonuser= from rc.conf if defined or the
164 #      rc scripts builtin default (nobody).
165 #      daemon(8) will run socat as this user.
166 #
167 #   pidfile (optional):
168 #     If not defined, /var/run/socat_INSTANCENAME.pid will be used
169 #     (will be derived from rc script's default, which is /var/run/socat.pid).
170 #
171 #   flags (mandatory):
172 #     See socat(1).
173 #
174 # service(8)/rc(8) "start" commands will skip instances without flags defined,
175 # while "stop" commands will try to stop any present instance section.
176 #
177 # To control a single instance, you can append one instance name to the
178 # rc(8) command.
179 # Otherwise all uncommented instance definitions in this file will be processed.
180
181
182 [FILE:5297:files/socat.in]
183 #!/bin/sh
184 #
185 # PROVIDE: socat
186 # REQUIRE: LOGIN
187 # KEYWORD: shutdown
188 #
189 # Add the following lines to /etc/rc.conf to enable socat:
190 # socat_enable="YES"
191 # socat_daemonuser="root" for priviledged ports e.g.
192 # socat_flags="<set as needed>" or create %%PREFIX%%/etc/socat-instances.conf
193
194 . /etc/rc.subr
195
196 name="socat"
197 rcvar=socat_enable
198
199 load_rc_config $name
200
201 : ${socat_enable="NO"}
202 : ${socat_daemonuser:=nobody}
203 : ${socat_config:=%%PREFIX%%/etc/socat-instances.conf}
204
205 start_precmd="socat_prestart"
206 pidfile=/var/run/socat.pid
207 procname="%%PREFIX%%/bin/socat"
208 command=/usr/sbin/daemon
209 command_args=' -f -p ${pidfile} -u ${socat_daemonuser} ${procname} ${socat_flags}'
210
211 [ -n "${2}" ] && socat_instance_arg=`echo "${2}" | tr '[:lower:]' '[:upper:]'`
212
213 socat_prestart()
214 {
215         # socat_flags gets applied too early if we don't do this.
216         # I didn't want to force people to update their rc.conf files
217         # and change the socat_flags to something else.
218         rc_flags=""
219 }
220
221 socat_parse_instances()
222 {
223   local _line _section_search
224
225   socat_instances=`grep -Eo "^[[:blank:]]*\[[[:alnum:]_]+\]" ${socat_config} |
226     tr '[:lower:]' '[:upper:]'`
227                                 
228   if [ -n "${socat_instance_arg}" ] && ! echo "${socat_instances}" |
229       grep -q -E '(^|[[:blank:]])\['${socat_instance_arg}'\]([[:blank:]]|$)'
230   then
231     echo -n "$name: Can't find instance definition " >&2
232     echo "\"[${1}]\" in config file ${socat_config}." >&2
233     return 1
234   fi
235
236   [ -n "${socat_instance_arg}" ] && socat_instances="[${socat_instance_arg}]"
237
238   for i in ${socat_instances}; do
239     _section_search=1
240     _instance=${i#[}
241     _instance=${_instance%]}
242
243     # Process each line of the optional config file, which
244     # matches the regex, defined at the end of the loop.
245     # There we filter to only process definitions and section separators.
246     while read -r _line; do
247
248       # Look for ${i} section until found
249       if [ ${_section_search} ]; then
250         if echo "${_line}" | grep -qi "^[[:blank:]]*\[${_instance}\]"; then
251           unset _section_search
252           continue # Nothing to do with section identifiers
253         else
254           # Continue with next line s_instance we haven't reached our section yet
255           continue
256         fi
257       fi
258
259       # Stop processing if the current line is another section identifier.
260       echo "${_line}" | grep -q "^[[:blank:]]*\[[^]]*\]" && break
261
262       # Only proceed with lines which contain variable declaration.
263       echo "${_line}" | grep -q -E \
264                         -e "^[[:blank:]]*[[:alpha:]_][[:alnum:]_]{0,30}=" ||
265                             continue
266       # Filter malformed lines (which could cause command execution)
267       #   (shell exits with test result, wich is false as soon as
268       #   there's a 2nd argument (1st is considered as 0))
269       eval sh -c \'[ \$# -eq 0 ]\' "${_line}" \|\| continue
270
271       eval socat_${_instance}_${_line%%=*}=${_line#*=}
272
273     done << EOCFF
274 $(cat "${socat_config}")
275 EOCFF
276   done
277 }
278
279 # Check if daemon(8) handles title and syslog parameters
280 # (as in FreeBSD 11).
281 if [ "${1%start}" != "${1}" ]; then
282         daemon_extended_args=" -l daemon"
283         ${command} -t "test" ${daemon_extended_args} -f -u nobody true \
284                 > /dev/null 2>&1 || unset daemon_extended_args
285 fi
286
287
288 # If we can read the config file, handle multiple instances,
289 # else just process a single instance.
290 if [ -r ${socat_config} ]; then
291
292         # T O D O :   Check rc(8) how restarts are handled and make
293         #               all-instaces restart working.
294         #       For now refuse restart commands without instance argument.
295         #
296         if [ "${1%restart}" != "${1}" ] && [ -z "${socat_instance_arg}" ]; then
297                 echo -n "$name: Restart command requires a instance argument,"
298                 echo "since config file is in use."
299                 exit 1
300         fi
301
302         if [ -n "${socat_flags}" ]; then
303                 echo -n "${name}: WARNING:"
304                 echo -n " Ignoring \"socat_flags\" in rc.conf because"
305                 echo " \"${socat_config}\" is present."
306         fi
307
308         socat_parse_instances "${2}" || exit 1
309
310         default_pidfile="${pidfile}"
311         default_socat_daemonuser="${socat_daemonuser}"
312         eval default_command_args=\'${command_args}\'
313
314         for i in ${socat_instances}; do
315                 _instance=${i#[}
316                 _instance=${_instance%]}
317
318                 eval socat_flags=\"\$\{socat_${_instance}_flags\}\"
319
320                 # We need to have socat_flags to start, else skip start commands
321                 if [ "${1%start}" != "${1}" ] && [ -z "${socat_flags}" ]; then
322                         echo -n "$name: Missing \"flags\" definition for"
323                         echo " instance ${i}, skipping \"${1}\" command."
324                         continue
325                 fi
326
327                 eval pidfile=\"\$\{socat_${_instance}_pidfile\}\"
328                 [ -n "${pidfile}" ] ||
329                         pidfile="${default_pidfile%.pid}_${_instance}.pid"
330
331                 eval socat_daemonuser=\"\$\{socat_${_instance}_daemonuser\}\"
332                 [ -n "${socat_daemonuser}" ] ||
333                         socat_daemonuser="${default_socat_daemonuser}"
334
335                 eval command_args=\"${default_command_args}\"
336                 if [ -n "${daemon_extended_args}" ]; then
337                         # A bit confusing, but to keep 80 chars line break:
338                         command_args="(${_instance})\" ${command_args}"
339                         command_args="-t \"${procname} ${command_args}"
340                         command_args="${daemon_extended_args} ${command_args}"
341                 fi
342
343                 run_rc_command "$1"
344         done
345
346 else
347
348         if [ -n "${socat_instance_arg}" ]; then
349                 echo -n "$name: Missing config file (${socat_config}), " >&2
350                 echo "can't handle instance \"${2}\"." >&2
351                 exit 1
352         fi
353
354         eval command_args=\"${daemon_extended_args} ${command_args}\"
355         run_rc_command "$1"
356
357 fi
358
359