diff options
author | Andinus <andinus@nand.sh> | 2020-04-24 19:52:18 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-04-24 19:52:18 +0530 |
commit | 53d4a70ed2d1db9e7ebb98ec734d414539a74fc8 (patch) | |
tree | 521d3f87c08cc695d4207b1925f0de17f416a3ff /main.go | |
parent | a01ce7b96892849d91911a2ef143a08b8e4e57c5 (diff) | |
download | cetus-53d4a70ed2d1db9e7ebb98ec734d414539a74fc8.tar.gz |
Move app func to main
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/main.go b/main.go new file mode 100644 index 0000000..dfe208c --- /dev/null +++ b/main.go @@ -0,0 +1,78 @@ +package main + +import ( + "log" + "os" + + "tildegit.org/andinus/cetus/cache" + "tildegit.org/andinus/lynx" +) + +var ( + version string = "v0.6.7" + dump bool + random bool + notify bool + print bool + + err error + body string + file string + reqInfo map[string]string + + apodDate string +) + +func main() { + initCetus() + + // Early Check: If command was not passed then print usage and + // exit. Later command & service both are checked, this check + // is for version command. If not checked then running cetus + // without any args will fail because os.Args[1] will panic + // the program & produce runtime error. + if len(os.Args) == 1 { + printUsage() + os.Exit(0) + } + + parseArgs() +} + +func initCetus() { + unveil() +} + +func unveil() { + paths := make(map[string]string) + + paths[cache.Dir()] = "rwc" + paths["/dev/null"] = "rw" // required by feh + paths["/etc/resolv.conf"] = "r" + + // ktrace output + paths["/usr/libexec/ld.so"] = "r" + paths["/var/run/ld.so.hints"] = "r" + paths["/usr/lib"] = "r" + paths["/dev/urandom"] = "r" + paths["/etc/hosts"] = "r" + paths["/etc/ssl"] = "r" + + err := lynx.UnveilPaths(paths) + if err != nil { + log.Fatal(err) + } + + commands := []string{"feh", "gsettings", "pcmanfm", "notify-send"} + + err = lynx.UnveilCommands(commands) + if err != nil { + log.Fatal(err) + } + + // Block further unveil calls + err = lynx.UnveilBlock() + if err != nil { + log.Fatal(err) + } +} |