github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/providers/security/puppetsec/util.go (about) 1 // Copyright (c) 2020-2022, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package puppetsec 6 7 import ( 8 "fmt" 9 "os" 10 "path/filepath" 11 "runtime" 12 13 puppetwrapper "github.com/choria-io/go-choria/puppet" 14 ) 15 16 var puppet = puppetwrapper.New() 17 18 func userSSlDir() (string, error) { 19 if os.Geteuid() == 0 || runtime.GOOS == "windows" { 20 path, err := puppet.Setting("ssldir") 21 if err != nil { 22 return "", err 23 } 24 25 return path, nil 26 } 27 28 homedir := os.Getenv("HOME") 29 if homedir == "" { 30 return "", fmt.Errorf("cannot determine home directory, HOME is not set") 31 } 32 33 return filepath.FromSlash(filepath.Join(homedir, ".puppetlabs", "etc", "puppet", "ssl")), nil 34 }