Skip to content

Commit

Permalink
validate instead that file data is not empty
Browse files Browse the repository at this point in the history
Signed-off-by: garfthoffman <[email protected]>
  • Loading branch information
garfthoffman committed Nov 22, 2024
1 parent c636acf commit eca5d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions go/vt/tableacl/tableacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ var currentTableACL tableACL
// }
// ]
// }
func Init(configFile string, aclCB func()) error {
return currentTableACL.init(configFile, aclCB)
func Init(configFile string, aclCB func(), enforceTableACLConfig string) error {
return currentTableACL.init(configFile, aclCB, enforceTableACLConfig string)
}

func (tacl *tableACL) init(configFile string, aclCB func()) error {
func (tacl *tableACL) init(configFile string, aclCB func(), enforceTableACLConfig string) error {
tacl.SetCallback(aclCB)
if configFile == "" {
return nil
Expand All @@ -110,6 +110,10 @@ func (tacl *tableACL) init(configFile string, aclCB func()) error {
log.Infof("unable to read tableACL config file: %v Error: %v", configFile, err)
return err
}
if len(data) == 0 {
return error.New("tableACL config file is empty")
}

config := &tableaclpb.Config{}
if err := config.UnmarshalVT(data); err != nil {
// try to parse tableacl as json file
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (tsv *TabletServer) initACL(tableACLConfigFile string, enforceTableACLConfi
},
)
// Log failure if either there was a problem loading the ACL, or if the ACL is empty
if err != nil || tableacl.GetCurrentConfig().String() == "" {
if err != nil {
log.Errorf("Fail to initialize Table ACL: %v", err)
if enforceTableACLConfig {
log.Exit("Need a valid initial Table ACL when enforce-tableacl-config is set, exiting.")
Expand Down

0 comments on commit eca5d61

Please sign in to comment.