Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sighup issue with empty acl #2296

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,10 @@ func (h *Headscale) Serve() error {
Str("signal", sig.String()).
Msg("Received SIGHUP, reloading ACL and Config")

if h.cfg.Policy.IsEmpty() {
continue
}

if err := h.loadPolicyManager(); err != nil {
log.Error().Err(err).Msg("failed to reload Policy")
}
Expand Down Expand Up @@ -1102,6 +1106,10 @@ func (h *Headscale) policyBytes() ([]byte, error) {
return nil, err
}

if p.Data == "" {
return nil, nil
}

return []byte(p.Data), err
}

Expand Down
4 changes: 4 additions & 0 deletions hscontrol/policy/pm.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ func (pm *PolicyManagerV1) SSHPolicy(node *types.Node) (*tailcfg.SSHPolicy, erro
}

func (pm *PolicyManagerV1) SetPolicy(polB []byte) (bool, error) {
if len(polB) == 0 {
return false, nil
}

pol, err := LoadACLPolicyFromBytes(polB)
if err != nil {
return false, fmt.Errorf("parsing policy: %w", err)
Expand Down
4 changes: 4 additions & 0 deletions hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ type PolicyConfig struct {
Mode PolicyMode
}

func (p *PolicyConfig) IsEmpty() bool {
return p.Mode == PolicyModeFile && p.Path == ""
}

type LogConfig struct {
Format string
Level zerolog.Level
Expand Down
Loading