Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

genkeys, yggdrasilctl: Use pledge(2) on OpenBSD #1193

Merged
merged 4 commits into from
Dec 12, 2024
Merged
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 cmd/genkeys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"runtime"
"time"

"suah.dev/protect"

"github.com/yggdrasil-network/yggdrasil-go/src/address"
)

Expand All @@ -27,6 +29,10 @@ type keySet struct {
}

func main() {
if err := protect.Pledge("stdio"); err != nil {
panic(err)
}

threads := runtime.GOMAXPROCS(0)
fmt.Println("Threads:", threads)
start := time.Now()
Expand Down
12 changes: 12 additions & 0 deletions cmd/yggdrasilctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strings"
"time"

"suah.dev/protect"

"github.com/olekukonko/tablewriter"
"github.com/yggdrasil-network/yggdrasil-go/src/admin"
"github.com/yggdrasil-network/yggdrasil-go/src/core"
Expand All @@ -22,6 +24,11 @@ import (
)

func main() {
// read config, speak DNS/TCP and/or over a UNIX socket
if err := protect.Pledge("stdio rpath inet unix dns"); err != nil {
panic(err)
}

// makes sure we can use defer and still return an error code to the OS
os.Exit(run())
}
Expand Down Expand Up @@ -78,6 +85,11 @@ func run() int {
panic(err)
}

// config and socket are done, work without unprivileges
if err := protect.Pledge("stdio"); err != nil {
panic(err)
}

logger.Println("Connected")
defer conn.Close()

Expand Down
Loading