-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirsig.go
44 lines (40 loc) · 920 Bytes
/
dirsig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"path"
"github.com/go-yaml/yaml"
"github.com/hypoactiv/autoannex/dirsig"
)
// Starts a new group with a random UUID, and makes dir a member of the group
func dirsigCmdNew() {
dir := *sigNewPath
file := path.Join(dir, *appSigFilename)
fmt.Println("placing new signature in", file)
if !*sigNewForce {
if _, err := os.Stat(file); err == nil {
fmt.Println(file, "already exists, won't overwrite without --force")
return
}
}
err := dirsig.NewSignature(*appSigFilename).Write(dir)
if err != nil {
fmt.Println("unable to create signature:", err)
return
}
}
func dirsigCmdFind() {
groups := dirsig.Find(*appSigFilename, "", *appDepth)
g := make(map[string][]string)
for s := range groups {
if *sigFindUuid != "" && s != *sigFindUuid {
continue
}
g[s] = groups[s]
}
y, err := yaml.Marshal(g)
if err != nil {
panic(err)
}
fmt.Println(string(y))
}