diff --git a/central_auth.go b/central_auth.go index 76571c0..9588406 100644 --- a/central_auth.go +++ b/central_auth.go @@ -22,7 +22,7 @@ type centralAuth struct { // newCentralAuth will return a new and prepared *centralAuth func newCentralAuth(configuration *Configuration, errorKernel *errorKernel) *centralAuth { c := centralAuth{ - accessLists: newAccessLists(), + accessLists: newAccessLists(errorKernel), pki: newPKI(configuration, errorKernel), } diff --git a/central_auth_acl_handling.go b/central_auth_acl_handling.go index cae8efc..6df0806 100644 --- a/central_auth_acl_handling.go +++ b/central_auth_acl_handling.go @@ -36,13 +36,15 @@ type accessLists struct { // Holds the generated based on the editable structures for ACL handling. schemaGenerated *schemaGenerated validator *validator.Validate + errorKernel *errorKernel } -func newAccessLists() *accessLists { +func newAccessLists(errorKernel *errorKernel) *accessLists { a := accessLists{ schemaMain: newSchemaMain(), schemaGenerated: newSchemaGenerated(), validator: validator.New(), + errorKernel: errorKernel, } return &a diff --git a/central_auth_test.go b/central_auth_test.go index b4f2602..81e00dc 100644 --- a/central_auth_test.go +++ b/central_auth_test.go @@ -16,7 +16,7 @@ func TestACLSingleNode(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) a.aclAddCommand("ship101", "admin", "HORSE") a.aclAddCommand("ship101", "admin", "PIG") @@ -42,7 +42,7 @@ func TestACLWithGroups(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -101,7 +101,7 @@ func TestACLNodesGroupDeleteNode(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -158,7 +158,7 @@ func TestGroupNodesDeleteGroup(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -215,7 +215,7 @@ func TestGroupCommandDeleteGroup(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) const ( grp_nodes_operators = "grp_nodes_operators" @@ -272,7 +272,7 @@ func TestACLGenerated(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) a.aclAddCommand("ship101", "admin", "HORSE") @@ -321,7 +321,7 @@ func TestACLSchemaMainACLMap(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) //a.aclNodeFromnodeCommandAdd("ship101", "admin", "PIG") // fmt.Printf("---------------ADDING COMMAND-------------\n") @@ -400,7 +400,7 @@ func TestACLHash(t *testing.T) { log.SetOutput(io.Discard) } - a := newAccessLists() + a := newAccessLists(&errorKernel{}) a.aclAddCommand("ship101", "admin", "HORSE") @@ -417,7 +417,7 @@ func TestACLHash(t *testing.T) { } func TestACLConcurrent(t *testing.T) { - a := newAccessLists() + a := newAccessLists(&errorKernel{}) // -----------General testing and creation of some data---------------- @@ -466,7 +466,7 @@ func TestExportACLs(t *testing.T) { grp_commands_commandset1 = "grp_commands_commandset1" ) - a := newAccessLists() + a := newAccessLists(&errorKernel{}) a.groupNodesAddNode(grp_nodes_operators, "operator1") a.groupNodesAddNode(grp_nodes_operators, "operator2") @@ -501,7 +501,7 @@ func TestImportACLs(t *testing.T) { want := `map[grp_nodes_ships:map[admin:map[useradd -m kongen:{}] grp_nodes_operators:map[grp_commands_commandset1:{}]] ship101:map[admin:map[HORSE:{}]]]` - a := newAccessLists() + a := newAccessLists(&errorKernel{}) err := a.importACLs(js) if err != nil { diff --git a/requests-acl.go b/requests-acl.go index e519f95..f13a28b 100644 --- a/requests-acl.go +++ b/requests-acl.go @@ -45,15 +45,6 @@ func (m methodREQAclAddCommand) handler(proc process, message Message, node stri proc.centralAuth.accessLists.aclAddCommand(Node(host), Node(source), command(cmd)) - // Just print out for testing. - proc.centralAuth.accessLists.schemaMain.mu.Lock() - fmt.Printf("\n ########### content of main acl map: %v###########\n", proc.centralAuth.accessLists.schemaMain.ACLMap) - proc.centralAuth.accessLists.schemaMain.mu.Unlock() - - proc.centralAuth.accessLists.schemaGenerated.mu.Lock() - fmt.Printf("\n ########### content of generated acl map: %v###########\n", proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap) - proc.centralAuth.accessLists.schemaGenerated.mu.Unlock() - outString := fmt.Sprintf("acl added: host=%v, source=%v, command=%v\n", host, source, cmd) out := []byte(outString) @@ -125,15 +116,6 @@ func (m methodREQAclDeleteCommand) handler(proc process, message Message, node s proc.centralAuth.accessLists.aclDeleteCommand(Node(host), Node(source), command(cmd)) - // Just print out for testing. - proc.centralAuth.accessLists.schemaMain.mu.Lock() - fmt.Printf("\n ########### content of main acl map: %v###########\n", proc.centralAuth.accessLists.schemaMain.ACLMap) - proc.centralAuth.accessLists.schemaMain.mu.Unlock() - - proc.centralAuth.accessLists.schemaGenerated.mu.Lock() - fmt.Printf("\n ########### content of generated acl map: %v###########\n", proc.centralAuth.accessLists.schemaGenerated.GeneratedACLsMap) - proc.centralAuth.accessLists.schemaGenerated.mu.Unlock() - outString := fmt.Sprintf("acl deleted: host=%v, source=%v, command=%v\n", host, source, cmd) out := []byte(outString)