Skip to content

Commit

Permalink
refactor: Stub out macOS command elevation on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
  • Loading branch information
pojntfx committed Nov 23, 2024
1 parent 89ee07c commit cb0aec0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/pojntfx/hydrapp/hydrapp/pkg/ui"
"github.com/pojntfx/hydrapp/hydrapp/pkg/utils"
"github.com/pojntfx/panrpc/go/pkg/rpc"
"golang.org/x/sys/unix"
"nhooyr.io/websocket"
)

Expand Down Expand Up @@ -434,7 +433,7 @@ restartTraceCommand:
}

stdoutPath := filepath.Join(fifoTmpDir, "stdout.fifo")
if err := unix.Mknod(stdoutPath, unix.S_IFIFO|0666, 0); err != nil {
if err := uutils.MknodStdout(stdoutPath); err != nil {
return errors.Join(ErrCouldNotCreateElevatedCommand, err)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/mknod_all.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package utils

import "errors"

var (
ErrMknodUnimplemented = errors.New("mknod is unimplemented on this platform")
)
9 changes: 9 additions & 0 deletions pkg/utils/mknod_common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !windows

package utils

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

func MknodStdout(path string) error {
return unix.Mknod(path, unix.S_IFIFO|0666, 0)
}
7 changes: 7 additions & 0 deletions pkg/utils/mknod_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build windows

package utils

func MknodStdout(path string) error {
return ErrMknodUnimplemented
}

0 comments on commit cb0aec0

Please sign in to comment.