Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pledge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build !openbsd

package s3

func Unveil(string, string) error { return nil }
func Pledge(string) error { return nil }
13 changes: 13 additions & 0 deletions pledge_openbsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build openbsd

package s3

import "golang.org/x/sys/unix"

func Unveil(path, perm string) error {
return unix.Unveil(path, perm)
}

func Pledge(promises string) error {
return unix.PledgePromises(promises)
}
22 changes: 22 additions & 0 deletions plugin/storage/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
package main

import (
"log"
"os"
"runtime"

sdk "github.com/PlakarKorp/go-kloset-sdk"
s3 "github.com/PlakarKorp/integration-s3"
"github.com/PlakarKorp/integration-s3/storage"
)

func main() {
// golang stdlib tries to open cert files at "well known"
// locations. On OpenBSD, we only really have
// /etc/ssl/cert.pem, so that's a safe guess, but attempt to
// respect SSL_CERT_FILE if set.
if runtime.GOOS == "openbsd" {
cert, ok := os.LookupEnv("SSL_CERT_FILE")
if !ok {
cert = "/etc/ssl/cert.pem"
os.Setenv("SSL_CERT_FILE", cert)
}

if err := s3.Unveil(cert, "r"); err != nil {
log.Fatalln("unveil /etc/ssl/cert.pem:", err)
}
if err := s3.Pledge("stdio rpath inet dns"); err != nil {
log.Fatalln("pledge:", err)
}
}

sdk.EntrypointStorage(os.Args, storage.NewStore)
}