Always store files in ~/.certspotter, even if running as root

This commit is contained in:
Andrew Ayer 2016-07-26 16:57:26 -07:00
parent c185657181
commit f75c47d9ca
1 changed files with 2 additions and 14 deletions

View File

@ -39,10 +39,6 @@ var stateDir string
var printMutex sync.Mutex var printMutex sync.Mutex
func isRoot () bool {
return os.Geteuid() == 0
}
func homedir () string { func homedir () string {
home := os.Getenv("HOME") home := os.Getenv("HOME")
if home != "" { if home != "" {
@ -56,19 +52,11 @@ func homedir () string {
} }
func DefaultStateDir (programName string) string { func DefaultStateDir (programName string) string {
if isRoot() { return filepath.Join(homedir(), "." + programName)
return filepath.Join("/var/lib", programName)
} else {
return filepath.Join(homedir(), "." + programName)
}
} }
func DefaultConfigDir (programName string) string { func DefaultConfigDir (programName string) string {
if isRoot() { return filepath.Join(homedir(), "." + programName)
return filepath.Join("/etc", programName)
} else {
return filepath.Join(homedir(), "." + programName)
}
} }
func LogEntry (info *certspotter.EntryInfo) { func LogEntry (info *certspotter.EntryInfo) {