1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[standard]= Multipurpose relay
12 SITES[main]= http://www.dest-unreach.org/socat/download/
13 DISTFILE[1]= socat-1.8.0.0.tar.gz:main
15 SPKGS[standard]= complete
19 OPTIONS_AVAILABLE= none
20 OPTIONS_STANDARD= none
22 USES= cpe ssl:openssl11
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
31 CPE_VENDOR= dest-unreach
32 FPC_EQUIVALENT= net/socat
36 RC_SUBR= socat:primary
38 CFLAGS= -Wno-unused-variable
41 .for f in filan procan socat
42 ${INSTALL_PROGRAM} ${WRKSRC}/${f} ${STAGEDIR}${PREFIX}/bin
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
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
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.
66 6010f4f311e5ebe0e63c77f78613d264253680006ac8979f52b0711a9a231e82 712469 socat-1.8.0.0.tar.gz
69 [FILE:93:manifests/plist.primary]
70 @sample etc/socat-instances.conf.sample
75 share/man/man1/socat.1.gz
78 [FILE:50:manifests/plist.docs]
86 [FILE:875:patches/patch-fdname.c]
87 Use correct prototype for getprotobynumber_r() on SunOS
89 --- fdname.c.orig 2023-11-13 19:31:08 UTC
91 @@ -250,7 +250,7 @@ int sockname(int fd, FILE *outfile, char
92 /*Linux struct ifreq ifc = {{{ 0 }}};*/
93 struct ifreq ifc = {{ 0 }};
98 #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
99 optlen = sizeof(proto);
100 @@ -280,7 +280,12 @@ int sockname(int fd, FILE *outfile, char
102 #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
103 #if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */
105 + protoentp = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname));
108 rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp);
110 if (protoentp == NULL) {
111 Warn2("sockname(): getprotobynumber_r(proto=%d, ...): %s",
112 proto, strerror(rc));
115 [FILE:429:patches/patch-filan.c]
116 --- filan.c.orig 2023-11-13 19:31:08 UTC
118 @@ -939,6 +939,7 @@ int tcpan(int fd, FILE *outfile) {
119 #if WITH_TCP && defined(TCP_INFO)
121 int tcpan2(int fd, FILE *outfile) {
123 struct tcp_info tcpinfo;
124 socklen_t tcpinfolen = sizeof(tcpinfo);
126 @@ -966,6 +967,9 @@ int tcpan2(int fd, FILE *outfile) {
135 #endif /* WITH_TCP */
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
142 # It is not related to socat(1) itself!
143 # This file is shell syntax.
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).
150 # Default socat_daemonuser=nobody won't be able to open sockets with port numbers
153 #flags="UDP4-RECVFROM:123,fork,bind=192.0.2.20 UDP4-SENDTO:169.254.0.53:123"
157 #flags="UDP6-RECVFROM:123,fork,bind=[2001:DB8::1:2:3] UDP4-SENDTO:169.254.0.53:123"
160 # Variable definitions:
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.
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).
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.
177 # To control a single instance, you can append one instance name to the
179 # Otherwise all uncommented instance definitions in this file will be processed.
182 [FILE:5297:files/socat.in]
189 # Add the following lines to /etc/rc.conf to enable socat:
191 # socat_daemonuser="root" for priviledged ports e.g.
192 # socat_flags="<set as needed>" or create %%PREFIX%%/etc/socat-instances.conf
201 : ${socat_enable="NO"}
202 : ${socat_daemonuser:=nobody}
203 : ${socat_config:=%%PREFIX%%/etc/socat-instances.conf}
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}'
211 [ -n "${2}" ] && socat_instance_arg=`echo "${2}" | tr '[:lower:]' '[:upper:]'`
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.
221 socat_parse_instances()
223 local _line _section_search
225 socat_instances=`grep -Eo "^[[:blank:]]*\[[[:alnum:]_]+\]" ${socat_config} |
226 tr '[:lower:]' '[:upper:]'`
228 if [ -n "${socat_instance_arg}" ] && ! echo "${socat_instances}" |
229 grep -q -E '(^|[[:blank:]])\['${socat_instance_arg}'\]([[:blank:]]|$)'
231 echo -n "$name: Can't find instance definition " >&2
232 echo "\"[${1}]\" in config file ${socat_config}." >&2
236 [ -n "${socat_instance_arg}" ] && socat_instances="[${socat_instance_arg}]"
238 for i in ${socat_instances}; do
241 _instance=${_instance%]}
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
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
254 # Continue with next line s_instance we haven't reached our section yet
259 # Stop processing if the current line is another section identifier.
260 echo "${_line}" | grep -q "^[[:blank:]]*\[[^]]*\]" && break
262 # Only proceed with lines which contain variable declaration.
263 echo "${_line}" | grep -q -E \
264 -e "^[[:blank:]]*[[:alpha:]_][[:alnum:]_]{0,30}=" ||
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
271 eval socat_${_instance}_${_line%%=*}=${_line#*=}
274 $(cat "${socat_config}")
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
288 # If we can read the config file, handle multiple instances,
289 # else just process a single instance.
290 if [ -r ${socat_config} ]; then
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.
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."
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."
308 socat_parse_instances "${2}" || exit 1
310 default_pidfile="${pidfile}"
311 default_socat_daemonuser="${socat_daemonuser}"
312 eval default_command_args=\'${command_args}\'
314 for i in ${socat_instances}; do
316 _instance=${_instance%]}
318 eval socat_flags=\"\$\{socat_${_instance}_flags\}\"
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."
327 eval pidfile=\"\$\{socat_${_instance}_pidfile\}\"
328 [ -n "${pidfile}" ] ||
329 pidfile="${default_pidfile%.pid}_${_instance}.pid"
331 eval socat_daemonuser=\"\$\{socat_${_instance}_daemonuser\}\"
332 [ -n "${socat_daemonuser}" ] ||
333 socat_daemonuser="${default_socat_daemonuser}"
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}"
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
354 eval command_args=\"${daemon_extended_args} ${command_args}\"