Skip to content

Commit

Permalink
security/tailscale: Robustify rc.d script
Browse files Browse the repository at this point in the history
Check for orphaned network interface at the time of start, and if such
an interface exists then destroy it before starting tailscaled. When
tailscaled terminates unexpectedly it fails to cleanup, leaving the
orphaned interface behind. This results in it failing to start until
the interface is cleaned up, making it unsuitable for being monitored
by a service monitoring software (e.g. monit)

Reported by:	ler
  • Loading branch information
wahjava committed May 13, 2022
1 parent 1430dab commit 94f671f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions security/tailscale/Makefile
@@ -1,5 +1,6 @@
PORTNAME= tailscale
PORTVERSION= 1.24.2
PORTREVISION= 1
DISTVERSIONPREFIX= v
CATEGORIES= security

Expand Down
6 changes: 6 additions & 0 deletions security/tailscale/files/tailscaled.in
Expand Up @@ -65,6 +65,12 @@ stop_postcmd="${name}_poststop"

tailscaled_start()
{
# Check for orphaned tailscale network interface
# And if it exists, then destroy it
/sbin/ifconfig ${tailscale_tap_dev} >/dev/null 2>&1 && (
/sbin/ifconfig ${tailscale_tap_dev} | fgrep -qw PID ||
/sbin/ifconfig ${tailscale_tap_dev} destroy
)
env CACHE_DIRECTORY=/var/db/tailscale /usr/sbin/daemon -f ${tailscaled_syslog_output_flags} -p ${pidfile} ${procname} --port ${tailscaled_port}
}

Expand Down

0 comments on commit 94f671f

Please sign in to comment.