os-tailscale: pre-auth key is not used when tailscaled.state is missing or holds a stale profile

Đang mở
#5,903 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
shell
Lĩnh vực
backend, devops

Hướng nghiên cứu

Start by reading the rc.conf.d/tailscaled logic described in the issue and compare its state-file check with the proposed tailscale status --json check after the daemon starts. Trace how service startup builds the tailscale up arguments for missing state and a logged-out profile. Done means a configured pre-auth key is used in both cases, while an already logged-in node does not reuse it.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Describe the bug

Since #5047, rc.conf.d/tailscaled passes --auth-key only when tailscaled.state exists and has no "_current-profile":

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

That fixed the key being reused at boot (#4661), but leaves two cases where a valid, unused pre-auth key is never passed to tailscale up:

  1. No state file yet. The rc script reads its config before tailscaled creates tailscaled.state, so the first start runs tailscale up without --auth-key. It prints a login URL and times out ("timeout waiting for Tailscale service to enter a Running state"). A second start then passes the key and joins.
  2. Stale profile. Removing the plugin leaves /var/db/tailscale in place. If the node was then deleted from the tailnet, the old profile is still in tailscaled.state. After reinstalling the plugin and setting a new pre-auth key, the key is never passed; tailscale status shows Logged out., and Services start/restart returns Error (1). Recovery needs a shell: stop tailscaled, move tailscaled.state and profile-data aside, then start twice (case 1).

To Reproduce

Case 2:

  1. Install os-tailscale, set a pre-auth key, enable, and let the node join.
  2. Delete the node from the tailnet in the admin console.
  3. Remove the os-tailscale plugin, then install it again.
  4. Generate a new, unused pre-auth key, set it under VPN › Tailscale › Authentication, enable and apply.
  5. tailscale status shows Logged out.; the node never joins.

Case 1:

  1. With tailscaled stopped, move /var/db/tailscale/tailscaled.state aside.
  2. Start the service: tailscale up runs without --auth-key and prints a login URL.
  3. Start it again: it joins with the configured key.

Expected behavior

When a pre-auth key is configured and tailscaled is not logged in, tailscale up uses the key. That includes a missing state file, and a profile that is logged out or whose node no longer exists. For example, decide on tailscale status --json (BackendState = NeedsLogin) after tailscaled starts, instead of grepping the state file before it starts.

Describe alternatives you considered

  • Keep the grep, but also pass the key when the state file does not exist (fixes case 1 only).
  • Remove /var/db/tailscale when the plugin is removed, or offer a "reset node state" action (helps case 2).

Environment

OPNsense 26.1.11_10 (amd64)
os-tailscale 1.4
tailscale 1.98.5_1

Ngôn ngữ chính
PHP
Star
1.2k
Fork
932
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opnsense/plugins

Tất cả issue của opnsense/plugins

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.