소켓 바인딩 권한 부여

This commit is contained in:
2023-11-23 12:36:57 +09:00
parent 882d35d604
commit 3208eba280
6 changed files with 40 additions and 4 deletions

View 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()
}