aboutsummaryrefslogtreecommitdiff
path: root/file
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-07 18:16:38 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-07 18:16:38 +0200
commit0363451ca18213b1f9e4c412070cd871c84ce3a5 (patch)
tree7500678cc7a7114873662c2cf0e524b9c2b63745 /file
parent535de9831a3731167f61b14372664df0c417a307 (diff)
cleanup
Diffstat (limited to 'file')
-rw-r--r--file/names.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/file/names.go b/file/names.go
index 15e480e..6bf440b 100644
--- a/file/names.go
+++ b/file/names.go
@@ -3,7 +3,6 @@ package file
import (
"errors"
"os"
- "os/user"
"path"
"path/filepath"
"strings"
@@ -12,9 +11,10 @@ import (
var ErrNames = errors.New("please use naming scheme of keyname.pub and keyname.sec")
const (
- PubExt = ".pub"
- EncExt = ".sec"
- SigExt = ".sig"
+ PubExt = ".pub"
+ EncExt = ".sec"
+ SigExt = ".sig"
+ verifyWith = "verify with "
)
func splitNameExt(fname string) (string, string) {
@@ -41,8 +41,6 @@ func SigName(msgFile string) string {
return msgFile + SigExt
}
-const verifyWith = "verify with "
-
func PubFile(comment string) (string, bool) {
if strings.HasPrefix(comment, verifyWith) {
file := comment[len(verifyWith):]
@@ -59,17 +57,13 @@ func VerifyWith(encFile string) string {
var safePath = []string{
"/etc/signify",
- "~/.signify",
- ".", // redundant, but keep it here for clarity
+ "$HOME/.signify",
}
+// FindFile locates keys in safe path. Falls back to current dir.
func FindFile(fname string) string {
- usr, _ := user.Current()
for _, v := range safePath {
- p := path.Join(v, fname)
- if p[0] == '~' {
- p = path.Join(usr.HomeDir, p[1:])
- }
+ p := path.Join(os.Expand(v, os.Getenv), fname)
if _, err := os.Stat(p); err == nil {
return p
}