Skip to content

Commit

Permalink
A few small changes for BSD support after standalone changes and keep…
Browse files Browse the repository at this point in the history
… up with Ubuntu in tests.
  • Loading branch information
hdholm committed Jan 27, 2023
1 parent 3d6efb1 commit d0fb068
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- debian:testing
- debian:latest
- ubuntu:rolling
- ubuntu:jammy
- ubuntu:focal
- ubuntu:bionic
stable: [true]
include:
Expand Down
5 changes: 5 additions & 0 deletions tests/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ random_port() {
}

check_if_port_listening() {
if [ -n "${TANG_BSD}" ]; then
sockstat -nl|grep "[\:\.]${1}" >/dev/null 2>&1
else

ss -anl|grep "[\:\.]${1}"|grep LISTEN >/dev/null 2>&1
fi
}

wait_for_port()
Expand Down
24 changes: 3 additions & 21 deletions units/tangd.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,26 @@
#

# Should probably in the future allow running as non-root
# and enable multiple interfaces in some cleaner way.
# and enable multiple interfaces in some way in the future.

# PROVIDE: tangd
# REQUIRE: NETWORKING DAEMON
# KEYWORD: nojail

. /etc/rc.subr

name="tangd"
desc="Network Presence Binding Daemon (tang)"
rcvar="tangd_enable"
command="/usr/local/bin/socat"

load_rc_config $name
: ${tangd_enable:=no}
: ${tangd_ip="127.0.0.1"}
: ${tangd_port="8888"}
: ${tangd_jwkdir="@jwkdir@"}
: ${tangd_logfile="/var/log/tang"}
: ${tangd_executable="@libexecdir@/tangd"}

pidfile="/var/run/${name}.pid"
required_files="@libexecdir@/${name}"
required_dirs="${tangd_jwkdir}"

start_postcmd="${name}_poststart"
_tangd_listen_args="TCP-LISTEN:${tangd_port},bind=${tangd_ip},fork"
command_args="${_tangd_listen_args} SYSTEM:\"${tangd_executable} ${tangd_jwkdir} 2>> ${tangd_logfile} \" &"

# Since we may not be the only socat running we can't use the built-in process
# management, so we'll need to use a pid file and find the pid from unique arguments.
tangd_poststart() {
ps_pid=`ps ax -o pid= -o command= | grep ${_tangd_listen_args} | grep -v grep | awk '{print $1}'`
if [ -z "$ps_pid" ]; then
err 1 "Cannot get pid for ${command} ${command_args}"
fi
echo $ps_pid > ${pidfile}
return $?
}
command="@libexecdir@/${name}"
command_args="-p ${tangd_port} -l ${tangd_jwkdir} 2>> ${tangd_logfile} &"

run_rc_command "$1"

0 comments on commit d0fb068

Please sign in to comment.