blob: 5a102b445dad43873b0c077b76e5564eb8ee4b64 (
plain) (
blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package main
import (
"fmt"
"os"
"os/exec"
)
var (
version = "v0.1.0"
cmd Config
flags []string
)
func main() {
initPledge()
initUnveil()
if len(os.Args) == 1 {
fmt.Println("Usage: pavo <command> <flags>")
os.Exit(1)
}
if os.Args[1] == "version" {
fmt.Println("Pavo", version)
os.Exit(0)
}
// Parse the config file.
parseConfig()
// Block futher unveil calls.
blockUnveil()
// Get path of command.
cmdPath, err := exec.LookPath(cmd.Command)
if err != nil {
fmt.Printf("%s %s :: %s\n",
cmd.Command,
"not found in $PATH",
err.Error())
os.Exit(1)
}
// TODO: Make the output realtime.
out, err := exec.Command(cmdPath, flags...).Output()
if err != nil {
err = fmt.Errorf("%s :: %s",
"Failed to execute command",
err.Error())
os.Exit(1)
}
// Print the output.
fmt.Printf(string(out))
}
|