(Go version) Multi platform build (#319)

This commit is contained in:
Max Horstmann
2020-11-18 10:42:08 -05:00
committed by GitHub
parent 4807dc527c
commit b71378db82
7 changed files with 104 additions and 11 deletions

11
pkg/bbutil/umask_posix.go Normal file
View File

@@ -0,0 +1,11 @@
// +build !windows
package bbutil
import "syscall"
// Umask is a no-op on Windows, and calls syscall.Umask on all other
// systems. On Windows it returns 0, which is a decoy.
func Umask(mask int) int {
return syscall.Umask(mask)
}

View File

@@ -0,0 +1,9 @@
// +build windows
package bbutil
// Umask is a no-op on Windows, and calls syscall.Umask on all other
// systems. On Windows it returns 0, which is a decoy.
func Umask(mask int) int {
return 0o000
}

View File

@@ -7,7 +7,6 @@ import (
"os"
"os/exec"
"path/filepath"
"syscall"
"github.com/StackExchange/blackbox/v2/pkg/bblog"
"github.com/StackExchange/blackbox/v2/pkg/bbutil"
@@ -66,9 +65,9 @@ func (crypt CrypterHandle) Decrypt(filename string, umask int, overwrite bool) e
}
a = append(a, filename+".gpg")
oldumask := syscall.Umask(umask)
oldumask := bbutil.Umask(umask)
err := bbutil.RunBash(crypt.GPGCmd, a...)
syscall.Umask(oldumask)
bbutil.Umask(oldumask)
return err
}
@@ -118,10 +117,10 @@ func (crypt CrypterHandle) Encrypt(filename string, umask int, receivers []strin
a = append(a, filename)
//err = bbutil.RunBash("ls", "-la")
oldumask := syscall.Umask(umask)
oldumask := bbutil.Umask(umask)
crypt.logDebug.Printf("Args = %q", a)
err = bbutil.RunBash(crypt.GPGCmd, a...)
syscall.Umask(oldumask)
bbutil.Umask(oldumask)
return encrypted, err
}