LoadConfigCheckDuplicate is the same as the above function but also checks for duplicate attributes TODO (HCL_DUP_KEYS_DEPRECATION): keep only LoadConfig once deprecation is complete
(path string)
| 540 | // LoadConfigCheckDuplicate is the same as the above function but also checks for duplicate attributes |
| 541 | // TODO (HCL_DUP_KEYS_DEPRECATION): keep only LoadConfig once deprecation is complete |
| 542 | func LoadConfigCheckDuplicate(path string) (cfg *Config, duplicate bool, err error) { |
| 543 | fi, err := os.Stat(path) |
| 544 | if err != nil { |
| 545 | return nil, false, err |
| 546 | } |
| 547 | |
| 548 | if fi.IsDir() { |
| 549 | // check permissions on the config directory |
| 550 | var enableFilePermissionsCheck bool |
| 551 | if enableFilePermissionsCheckEnv := os.Getenv(consts.VaultEnableFilePermissionsCheckEnv); enableFilePermissionsCheckEnv != "" { |
| 552 | var err error |
| 553 | enableFilePermissionsCheck, err = strconv.ParseBool(enableFilePermissionsCheckEnv) |
| 554 | if err != nil { |
| 555 | return nil, false, errors.New("Error parsing the environment variable VAULT_ENABLE_FILE_PERMISSIONS_CHECK") |
| 556 | } |
| 557 | } |
| 558 | f, err := os.Open(path) |
| 559 | if err != nil { |
| 560 | return nil, false, err |
| 561 | } |
| 562 | defer f.Close() |
| 563 | |
| 564 | if enableFilePermissionsCheck { |
| 565 | err = osutil.OwnerPermissionsMatchFile(f, 0, 0) |
| 566 | if err != nil { |
| 567 | return nil, false, err |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | cfg, duplicate, err = LoadConfigDirCheckDuplicate(path) |
| 572 | if err != nil { |
| 573 | return nil, duplicate, err |
| 574 | } |
| 575 | } else { |
| 576 | cfg, duplicate, err = LoadConfigFileCheckDuplicate(path) |
| 577 | if err != nil { |
| 578 | return nil, duplicate, err |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | cfg, err = CheckConfig(cfg) |
| 583 | return cfg, duplicate, err |
| 584 | } |
| 585 | |
| 586 | func CheckConfig(c *Config) (*Config, error) { |
| 587 | if err := c.checkSealConfig(); err != nil { |
no test coverage detected
searching dependent graphs…