mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-11 15:44:52 +08:00
putting acl check before server pull
This commit is contained in:
parent
8306c213a7
commit
fdfbde118e
2 changed files with 12 additions and 23 deletions
11
main.go
11
main.go
|
@ -66,6 +66,11 @@ func initialize() { // Client Mode Prereq Check
|
||||||
logger.Log(0, "no OAuth provider found or not configured, continuing without OAuth")
|
logger.Log(0, "no OAuth provider found or not configured, continuing without OAuth")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = serverctl.SetDefaultACLS()
|
||||||
|
if err != nil {
|
||||||
|
logger.FatalLog("error setting default acls: ", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
if servercfg.IsClientMode() != "off" {
|
if servercfg.IsClientMode() != "off" {
|
||||||
output, err := ncutils.RunCmd("id -u", true)
|
output, err := ncutils.RunCmd("id -u", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -85,12 +90,6 @@ func initialize() { // Client Mode Prereq Check
|
||||||
logger.FatalLog("could not inintialize comms network")
|
logger.FatalLog("could not inintialize comms network")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = serverctl.SetDefaultACLS()
|
|
||||||
if err != nil {
|
|
||||||
logger.FatalLog("error setting default acls: ", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize iptables to ensure gateways work correctly and mq is forwarded if containerized
|
// initialize iptables to ensure gateways work correctly and mq is forwarded if containerized
|
||||||
if servercfg.ManageIPTables() != "off" {
|
if servercfg.ManageIPTables() != "off" {
|
||||||
if err = serverctl.InitIPTables(); err != nil {
|
if err = serverctl.InitIPTables(); err != nil {
|
||||||
|
|
|
@ -150,27 +150,17 @@ func SyncServerNetwork(network string) error {
|
||||||
// SetDefaultACLS - runs through each network to see if ACL's are set. If not, goes through each node in network and adds the default ACL
|
// SetDefaultACLS - runs through each network to see if ACL's are set. If not, goes through each node in network and adds the default ACL
|
||||||
func SetDefaultACLS() error {
|
func SetDefaultACLS() error {
|
||||||
// upgraded systems will not have ACL's set, which is why we need this function
|
// upgraded systems will not have ACL's set, which is why we need this function
|
||||||
var err error
|
nodes, err := logic.GetAllNodes()
|
||||||
networks, err := logic.GetNetworks()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i, _ := range networks {
|
for i := range nodes {
|
||||||
_, err := nodeacls.FetchAllACLs(nodeacls.NetworkID(networks[i].NetID))
|
currentNodeACL, err := nodeacls.FetchNodeACL(nodeacls.NetworkID(nodes[i].Network), nodeacls.NodeID(nodes[i].ID))
|
||||||
if err != nil {
|
if (err != nil && (database.IsEmptyRecord(err) || strings.Contains(err.Error(), "no node ACL present"))) || currentNodeACL == nil {
|
||||||
if database.IsEmptyRecord(err) {
|
if _, err = nodeacls.CreateNodeACL(nodeacls.NetworkID(nodes[i].Network), nodeacls.NodeID(nodes[i].ID), acls.Allowed); err != nil {
|
||||||
nodes, err := logic.GetNetworkNodes(networks[i].NetID)
|
logger.Log(1, "could not create a default ACL for node", nodes[i].ID)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for j, _ := range nodes {
|
|
||||||
_, err = nodeacls.CreateNodeACL(nodeacls.NetworkID(networks[i].NetID), nodeacls.NodeID(nodes[j].ID), acls.Allowed)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue