MCPcopy
hub / github.com/hashicorp/vault / LoadConfigCheckDuplicate

Function LoadConfigCheckDuplicate

command/server/config.go:542–584  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
542func 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
586func CheckConfig(c *Config) (*Config, error) {
587 if err := c.checkSealConfig(); err != nil {

Callers 3

parseConfigMethod · 0.92
reloadConfigFilesMethod · 0.92
LoadConfigFunction · 0.70

Calls 6

CheckConfigFunction · 0.70
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…