mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 23:06:52 +01:00
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:
1 parent
f2a8883563
commit
2f1931dc36
3 files changed
+7
-12
No files matched your search
@@ -159,7 +159,6 @@ func TestInfoAccessFromConfig(t *testing.T) {
|
|||||||
cfg, err := load(section(" group: " + name + "\n"))
|
cfg, err := load(section(" group: " + name + "\n"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, os.FileMode(0660), cfg.Access.Mode)
|
assert.Equal(t, os.FileMode(0660), cfg.Access.Mode)
|
||||||
require.NotNil(t, cfg.Access.Group)
|
|
||||||
assert.Equal(t, gid, cfg.Access.Group.ID)
|
assert.Equal(t, gid, cfg.Access.Group.ID)
|
||||||
|
|
||||||
cfg, err = load(section(" group: " + name + "\n socket_mode: \"0664\"\n"))
|
cfg, err = load(section(" group: " + name + "\n socket_mode: \"0664\"\n"))
|
||||||
@@ -172,8 +171,7 @@ func TestInfoAccessFromConfig(t *testing.T) {
|
|||||||
|
|
||||||
cfg, err = load(section(""))
|
cfg, err = load(section(""))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, os.FileMode(0600), cfg.Access.Mode)
|
assert.Equal(t, ownerOnly(), cfg.Access)
|
||||||
assert.Nil(t, cfg.Access.Group)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestRemovingTheGroupHandsTheSocketBack: a reload that drops the group key leaves the
|
// TestRemovingTheGroupHandsTheSocketBack: a reload that drops the group key leaves the
|
||||||
|
|||||||
+5
-8
@@ -36,11 +36,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
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
|
// 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
|
// 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.
|
// refuses instead because its clients are people at a prompt.
|
||||||
@@ -412,8 +407,10 @@ func infoConfigFrom(c *config.C) (infoConfig, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, err
|
return cfg, err
|
||||||
}
|
}
|
||||||
def := defaultInfoMode
|
// With neither a mode nor a group named, the daemon's user alone, so that enabling
|
||||||
if group != nil {
|
// the API does not open it to anyone until the operator says who.
|
||||||
|
def := ownerOnlyMode
|
||||||
|
if group.ID != "" {
|
||||||
def = groupSocketMode
|
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
|
// 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
|
// 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.
|
// 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)
|
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}
|
cfg.Access = Access{Mode: mode, Group: group}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
func TestInfoIsServedOnAPipe(t *testing.T) {
|
func TestInfoIsServedOnAPipe(t *testing.T) {
|
||||||
users, err := windows.CreateWellKnownSid(windows.WinBuiltinUsersSid)
|
users, err := windows.CreateWellKnownSid(windows.WinBuiltinUsersSid)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
group := &Group{Name: "Users", ID: users.String()}
|
group := Group{Name: "Users", ID: users.String()}
|
||||||
|
|
||||||
s := NewInfoServer(test.NewLogger(), commands.New())
|
s := NewInfoServer(test.NewLogger(), commands.New())
|
||||||
path := pipePrefix + "nebula-info-test"
|
path := pipePrefix + "nebula-info-test"
|
||||||
|
|||||||
Reference in new issue
Block a user