Follow the localapi fold on the info API's side

The control socket's fold made Group a value and gave the two 0600
constants one name; the info API's config reader and its tests catch up.

- defaultInfoMode goes for ownerOnlyMode; a group is present when its ID is
- the config test compares the whole Access with ownerOnly()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Matt RichardsonandClaude Opus 5.5 committed 2026-10-21 12:27:12 -04:00
1 parent f2a8883563
commit 2f1931dc36
3 files changed
+7 -12

No files matched your search

+1 -3
View File
@@ -159,7 +159,6 @@ func TestInfoAccessFromConfig(t *testing.T) {
cfg, err := load(section(" group: " + name + "\n"))
require.NoError(t, err)
assert.Equal(t, os.FileMode(0660), cfg.Access.Mode)
require.NotNil(t, cfg.Access.Group)
assert.Equal(t, gid, cfg.Access.Group.ID)
cfg, err = load(section(" group: " + name + "\n socket_mode: \"0664\"\n"))
@@ -172,8 +171,7 @@ func TestInfoAccessFromConfig(t *testing.T) {
cfg, err = load(section(""))
require.NoError(t, err)
assert.Equal(t, os.FileMode(0600), cfg.Access.Mode)
assert.Nil(t, cfg.Access.Group)
assert.Equal(t, ownerOnly(), cfg.Access)
}
// TestRemovingTheGroupHandsTheSocketBack: a reload that drops the group key leaves the
+5 -8
View File
@@ -36,11 +36,6 @@ const (
)
const (
// defaultInfoMode is the socket's mode when the config names neither a mode nor a
// group: the daemon's user alone, so that enabling the API does not open it to
// anyone until the operator says who. Naming a group makes it groupSocketMode.
defaultInfoMode os.FileMode = 0600
// infoMaxConns bounds the connections held open at once. Beyond it the kernel
// queues, which is what an HTTP client expects of a busy server; the control socket
// refuses instead because its clients are people at a prompt.
@@ -412,8 +407,10 @@ func infoConfigFrom(c *config.C) (infoConfig, error) {
if err != nil {
return cfg, err
}
def := defaultInfoMode
if group != nil {
// With neither a mode nor a group named, the daemon's user alone, so that enabling
// the API does not open it to anyone until the operator says who.
def := ownerOnlyMode
if group.ID != "" {
def = groupSocketMode
}
@@ -424,7 +421,7 @@ func infoConfigFrom(c *config.C) (infoConfig, error) {
// On unix the mode is what admits the group, so one that shuts it out is a config
// error; on windows the group is an entry in the pipe's security descriptor and the
// mode means nothing to a pipe, so it is not held against the group there.
if runtime.GOOS != "windows" && group != nil && mode&0070 == 0 {
if runtime.GOOS != "windows" && group.ID != "" && mode&0070 == 0 {
return cfg, fmt.Errorf("%s %s gives group %s no access to the socket; use \"%04o\" or leave the mode unset", InfoModeKey, modeString(mode), group.Name, mode|0060)
}
cfg.Access = Access{Mode: mode, Group: group}
+1 -1
View File
@@ -24,7 +24,7 @@ import (
func TestInfoIsServedOnAPipe(t *testing.T) {
users, err := windows.CreateWellKnownSid(windows.WinBuiltinUsersSid)
require.NoError(t, err)
group := &Group{Name: "Users", ID: users.String()}
group := Group{Name: "Users", ID: users.String()}
s := NewInfoServer(test.NewLogger(), commands.New())
path := pipePrefix + "nebula-info-test"