security/tailscale: pre-auth key not used on first start of a fresh install (regression from 248ef719)

Abierto Apto para principiantes
#5,982 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
83/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, shell

Línea de trabajo

Lee la plantilla security/tailscale/src/opnsense/service/templates/OPNsense/Tailscale/rc.conf.d y compara la condición de la clave de autenticación con el comportamiento descrito cuando falta el archivo tailscaled.state. Reproduce los casos del primer inicio y del reinicio en una instalación nueva, si está disponible. Se considera terminado cuando la clave pre-auth se pasa en el primer inicio y se omite una vez que el estado contiene _current-profile.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Important notices
Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug
On a fresh install, os-tailscale does not log in with the configured pre-auth key on the first start. It only logs in after the service is restarted once.

The cause is the auth-key condition in security/tailscale/src/opnsense/service/templates/OPNsense/Tailscale/rc.conf.d:

if [ -f /var/db/tailscale/tailscaled.state ]; then
	if ! grep -q '"_current-profile"' /var/db/tailscale/tailscaled.state; then
		tailscaled_up_args_ext="--auth-key=..."
	fi
fi

--auth-key is only added when tailscaled.state already exists. On a fresh install that file does not exist yet (tailscaled creates it on its first start), so the first tailscale up runs without a key and the node never authenticates. On the next start the file exists without _current-profile, so the key is added and login works.

The original fix in #5047 (commit 351090da) handled this correctly: it added the key unless the file existed and contained a profile. The follow-up commit 248ef719 ("simplify previous a little") nested the checks, which dropped the "file does not exist" case.

To Reproduce

  1. Fresh OPNsense install, install os-tailscale.
  2. VPN > Tailscale > Authentication: set a pre-auth key. Settings: enable.
  3. Apply / start the service.
  4. tailscale status shows the node logged out (needs login). /var/db/tailscale/tailscaled.state now exists.
  5. Restart the service: it now logs in with the same key.

Expected behavior
The node authenticates with the pre-auth key on the first start.

Suggested fix

if [ ! -f /var/db/tailscale/tailscaled.state ] || ! grep -q '"_current-profile"' /var/db/tailscale/tailscaled.state; then
	tailscaled_up_args_ext="--auth-key={{ OPNsense.tailscale.authentication.preAuthKey }}"
fi

This keeps the intent of #5047 (no key once authenticated) and also covers the first start.

Additional context
Last version without the bug: the template as of commit 351090da (#5047), before 248ef719. The template on master is unchanged.

Environment
OPNsense 26.7.10 (amd64), os-tailscale 1.4, tailscale 1.104.7.

Lenguaje dominante
PHP
Estrellas
1.2k
Forks
932
Merge medio
1 d 11 h
PR fusionados (30 d)
22

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de opnsense/plugins

Todos los issues de opnsense/plugins

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.