From: Simon Ruderich Date: Sat, 17 Apr 2021 12:48:42 +0000 (+0200) Subject: Add basic support for OpenBSD X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=7c4e5d64e25acec7209a54a15836b4481c450416;p=safcm%2Fsafcm.git Add basic support for OpenBSD Installing packages and starting/enabling services is not yet supported. There are minor limitations when handling symlinks (see README.adoc). /var/tmp is a symlink on OpenBSD so just remove this test. --- diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml new file mode 100644 index 0000000..6ba273e --- /dev/null +++ b/.builds/openbsd.yml @@ -0,0 +1,17 @@ +image: openbsd/latest +packages: + - go + - gmake + - xz +tasks: + - all: | + # OpenBSD 6.8 only ships with Go 1.15 + curl -O https://ruderich.eu/go-1.16.3-openbsd-amd64.tar.xz + xz -d go-1.16.3-openbsd-amd64.tar.xz + tar xf go-1.16.3-openbsd-amd64.tar + mv go-1.16.3 go + # + doas ln -sf /usr/local/bin/gmake /usr/bin/make + cd safcm + # Go does not yet support -race on OpenBSD + ./ci/run GOFLAGS= diff --git a/README.adoc b/README.adoc index f120694..d65e2b0 100644 --- a/README.adoc +++ b/README.adoc @@ -135,6 +135,7 @@ future, others are due to the design of safcm. ** GNU/Linux with common commands (`uname`, `id`, `stat`, `sha512sum`, `cat`, `mktemp`, `rm`, `ln`, `chmod`) ** FreeBSD (same commands, but uses `sha512`) + ** OpenBSD (same commands, but uses `sha512`) * SSH server * to install packages: ** `apt-get` (Debian or derivative) diff --git a/ci/run b/ci/run index 30b22a1..92e81a6 100755 --- a/ci/run +++ b/ci/run @@ -7,15 +7,20 @@ set -x PATH=$HOME/go/bin:$PATH export PATH -make -make test +flags= +if test $# -ne 0; then + flags="$*" +fi + +make $flags +make test $flags # Strict umask umask 077 rm -rf * git checkout . -make -make test +make $flags +make test $flags # Additional static checks only run in CI go get honnef.co/go/tools/cmd/staticcheck diff --git a/cmd/safcm-remote/build.sh b/cmd/safcm-remote/build.sh index 7edd090..3ee7ccd 100755 --- a/cmd/safcm-remote/build.sh +++ b/cmd/safcm-remote/build.sh @@ -36,5 +36,6 @@ mkdir -p "$dest" build freebsd amd64 build linux amd64 +build openbsd amd64 build_arm linux arm 7 # TODO: support more operating systems and architectures diff --git a/cmd/safcm-remote/sync/files_test.go b/cmd/safcm-remote/sync/files_test.go index 91a85be..879fefd 100644 --- a/cmd/safcm-remote/sync/files_test.go +++ b/cmd/safcm-remote/sync/files_test.go @@ -288,13 +288,6 @@ func TestSyncFiles(t *testing.T) { Gid: 0, OrigGroup: "group", }, - "/var/tmp": { - Path: "/var/tmp", - Mode: fs.ModeDir | 0777 | fs.ModeSticky, - Uid: 0, - Gid: 0, - OrigGroup: "group", - }, }, }, nil, @@ -307,7 +300,6 @@ func TestSyncFiles(t *testing.T) { `4: sync remote: files: "/" (group): unchanged`, `4: sync remote: files: "/etc" (group): unchanged`, `4: sync remote: files: "/tmp" (group): unchanged`, - `4: sync remote: files: "/var/tmp" (group): unchanged`, }, nil, }, diff --git a/cmd/safcm/config/files_test.go b/cmd/safcm/config/files_test.go index 46da590..6124e8a 100644 --- a/cmd/safcm/config/files_test.go +++ b/cmd/safcm/config/files_test.go @@ -47,7 +47,8 @@ func TestLoadFiles(t *testing.T) { } // Regular users cannot create sticky files - skipInvalidSticky := runtime.GOOS == "freebsd" + skipInvalidSticky := runtime.GOOS == "freebsd" || + runtime.GOOS == "openbsd" chmod("files-invalid-perm-dir/files", 0500) defer chmod("files-invalid-perm-dir/files", 0700) diff --git a/rpc/dial.go b/rpc/dial.go index f300370..ef28019 100644 --- a/rpc/dial.go +++ b/rpc/dial.go @@ -113,7 +113,7 @@ compat_sha512sum() { sha512sum "$1" } ` - case "freebsd": + case "freebsd", "openbsd": compat = ` dir_stat='41777 0 0' file_stat="100700 $(id -u) $(id -g)" @@ -274,7 +274,7 @@ f } func connGetGoos(stdin io.Writer, stdout *bufio.Reader) (string, error) { - _, err := fmt.Fprintln(stdin, "uname -o") + _, err := fmt.Fprintln(stdin, "uname") if err != nil { return "", err } @@ -287,12 +287,14 @@ func connGetGoos(stdin io.Writer, stdout *bufio.Reader) (string, error) { // NOTE: Adapt helper uploading in dialSSH() when adding new systems var goos string switch x { - case "GNU/Linux": + case "Linux": goos = "linux" case "FreeBSD": goos = "freebsd" + case "OpenBSD": + goos = "openbsd" default: - return "", fmt.Errorf("unsupported OS %q (`uname -o`)", x) + return "", fmt.Errorf("unsupported OS %q (`uname`)", x) } return goos, nil }