소켓 바인딩 권한 부여
This commit is contained in:
@ -153,7 +153,11 @@ func prepareProcessLaunch(storageRoot string, req *shared.StartProcessRequest) *
|
||||
|
||||
if err == nil && fi.IsDir() {
|
||||
exefile := "./" + path.Clean(strings.TrimPrefix(req.Args[0], "/"))
|
||||
os.Chmod(path.Join(verpath, exefile), 0777)
|
||||
err = set_permission(path.Join(verpath, exefile))
|
||||
if err != nil {
|
||||
logger.Println("set_permission failed :", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
exef, _ := os.Executable()
|
||||
cmd := exec.Command(path.Join(path.Dir(exef), verpath, exefile), req.Args[1:]...)
|
||||
|
||||
21
client/set_permission_linux.go
Normal file
21
client/set_permission_linux.go
Normal file
@ -0,0 +1,21 @@
|
||||
//go:build client && linux
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func init() {
|
||||
file, _ := os.OpenFile("setcap.sh", os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0777)
|
||||
file.Write([]byte("sudo setcap 'cap_net_bind_service=+ep' $1"))
|
||||
file.Sync()
|
||||
file.Close()
|
||||
}
|
||||
|
||||
func set_permission(path string) error {
|
||||
os.Chmod(path, 0777)
|
||||
cmd := exec.Command("/bin/bash", "./setcap.sh", path)
|
||||
return cmd.Run()
|
||||
}
|
||||
7
client/set_permission_windows.go
Normal file
7
client/set_permission_windows.go
Normal file
@ -0,0 +1,7 @@
|
||||
//go:build client && windows
|
||||
|
||||
package client
|
||||
|
||||
func set_permission(path string) error {
|
||||
return nil
|
||||
}
|
||||
2
go.mod
2
go.mod
@ -10,7 +10,7 @@ require (
|
||||
golang.org/x/text v0.10.0
|
||||
google.golang.org/grpc v1.56.0
|
||||
google.golang.org/protobuf v1.31.0
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231116105647-72a62b678f83
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231123004536-9688731b3e15
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
4
go.sum
4
go.sum
@ -120,5 +120,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
||||
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231116105647-72a62b678f83 h1:0X/ZTLb71JQ+ksZyPdLkxAHz9nDTT+/qRjV/zYBzlMc=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231116105647-72a62b678f83/go.mod h1:XvklTTSvQX5uviivGBcZo8eIL+mV94W2e4uBBXcT5JY=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231123004536-9688731b3e15 h1:si/g/ygGTY3Xxx62fXkei3f4BNLiYlbt+2854XinVvE=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20231123004536-9688731b3e15/go.mod h1:XvklTTSvQX5uviivGBcZo8eIL+mV94W2e4uBBXcT5JY=
|
||||
|
||||
@ -4,6 +4,10 @@ del houston.zip
|
||||
|
||||
$Env:GOOS="linux"
|
||||
$Env:GOARCH="amd64"
|
||||
|
||||
go get repositories.action2quare.com/ayo/gocommon
|
||||
go mod tidy
|
||||
|
||||
go build -ldflags="-s -w" -tags=client .
|
||||
|
||||
cp houston .\replacer\houston
|
||||
|
||||
Reference in New Issue
Block a user