func main() { goopt.Parse(func() []string { return []string{} }) syscall.Umask(0077) // Turn off read/write/execute priviledges for others if len(goopt.Args) < 1 { fmt.Println("You need to provide a go file argument.") os.Exit(1) } execname := goopt.Args[0] + ".secret" e := compile.Compile(execname, goopt.Args) if e != nil { fmt.Fprintln(os.Stderr, e) os.Exit(1) } if *outname == "FILENAME.go" { fmt.Fprintln(os.Stderr, "secretrun requires a -o argument!") os.Exit(1) } e = deps.Exec("./"+execname, *outname) os.Remove(execname) if e != nil { fmt.Fprintln(os.Stderr, e) os.Exit(1) } }
func main() { goopt.Parse(func() []string { return []string{} }) if len(goopt.Args) < 1 { fmt.Println("You need to provide a go file argument.") os.Exit(1) } if *outname == "FILENAME" { *outname = goopt.Args[0][0 : len(goopt.Args[0])-3] } fs := make([]string, len(goopt.Args)+1) for i, f := range goopt.Args { fs[i] = f } fs[len(goopt.Args)] = "testing.go" makeSource("testing.go") e := compile.Compile(*outname, fs) if e != nil { fmt.Println(e) os.Exit(1) } if e != nil { return } fi, err := os.Stat(*outname) if err != nil { return } enc0, err := os.Open(*outname+".encrypted", os.O_WRONLY+os.O_TRUNC+os.O_CREAT, 0644) if err != nil { return } enc, err := crypt.Encrypt(key, privatekey, enc0, fi.Size, sequence) if err != nil { return } plain, err := os.Open(*outname, os.O_RDONLY, 0644) if err != nil { return } _, err = io.Copyn(enc, plain, fi.Size) if err != nil { return } }