diff --git a/chkplat.sh b/chkplat.sh new file mode 100755 index 0000000..66d8201 --- /dev/null +++ b/chkplat.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# go tool dist list for all valid GOOS/GOARCH targets. + +for tgt in $(go tool dist list); +do + o="$(echo ${tgt} | cut -f1 -d '/')" + a="$(echo ${tgt} | cut -f2 -d '/')" + out="$(env GOOS=${o} GOARCH=${a} go build ./... 2>&1)" + ret=${?} + if [ $ret -ne 0 ]; + then + echo "OS: ${o}" + echo "ARCH: ${a}" + echo "${out}" + echo + echo + fi +done diff --git a/funcs_nix.go b/funcs_nix.go index 73d34fd..aca5f50 100644 --- a/funcs_nix.go +++ b/funcs_nix.go @@ -19,9 +19,9 @@ func GetIDState() (ids IDState) { var err error - ids.RUID, ids.EUID, ids.SUID = unix.Getresuid() + ids.RUID, ids.EUID, ids.SUID = getresuid() ids.uidsChecked = true - ids.RGID, ids.EGID, ids.SGID = unix.Getresgid() + ids.RGID, ids.EGID, ids.SGID = getresgid() ids.gidsChecked = true ids.SudoEnvCmd = envs.HasEnv(envSudoCmd) @@ -59,7 +59,7 @@ func GetIDState() (ids IDState) { func GetIDStateProc(pid uint32) (ids IDState, err error) { var i32 int32 - var ints []int32 + var ints []uint32 var sudoUid bool var sudoUname bool var proc *process.Process diff --git a/funcs_nix_noresuid.go b/funcs_nix_noresuid.go new file mode 100644 index 0000000..ad40774 --- /dev/null +++ b/funcs_nix_noresuid.go @@ -0,0 +1,31 @@ +//go:build !(windows || plan9 || wasip1 || js || ios) && (aix || darwin || dragonfly || freebsd || illumos || netbsd || solaris) + +package sysutils + +import ( + `golang.org/x/sys/unix` +) + +// getresgid spoofs unix.Getresgid, as this file targets platforms that do not support it. +func getresgid() (rgid, egid, sgid int) { + + // rgid, egid, sgid = unix.Getresgid() + + rgid = unix.Getgid() + egid = unix.Getegid() + sgid = -1 + + return +} + +// getresuid spoofs unix.Getresuid, as this file targets platforms that do not support it. +func getresuid() (ruid, euid, suid int) { + + // ruid, euid, suid = unix.Getresuid() + + ruid = unix.Getuid() + euid = unix.Geteuid() + suid = -1 + + return +} diff --git a/funcs_nix_resuid.go b/funcs_nix_resuid.go new file mode 100644 index 0000000..2294f54 --- /dev/null +++ b/funcs_nix_resuid.go @@ -0,0 +1,23 @@ +//go:build !(windows || plan9 || wasip1 || js || ios) && !(aix || darwin || dragonfly || freebsd || illumos || netbsd || solaris) + +package sysutils + +import ( + `golang.org/x/sys/unix` +) + +// getresgid wraps unix.Getresgid, as this file targets platforms that fully support it. +func getresgid() (rgid, egid, sgid int) { + + rgid, egid, sgid = unix.Getresgid() + + return +} + +// getresuid wraps unix.Getresuid, as this file targets platforms that fully support it. +func getresuid() (ruid, euid, suid int) { + + ruid, euid, suid = unix.Getresuid() + + return +} diff --git a/go.mod b/go.mod index 569a984..985d27f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( golang.org/x/sync v0.19.0 golang.org/x/sys v0.40.0 honnef.co/go/augeas v0.0.0-20161110001225-ca62e35ed6b8 - r00t2.io/goutils v1.16.3 + r00t2.io/goutils v1.16.4 ) require ( diff --git a/go.sum b/go.sum index 466cf5a..7822b9b 100644 --- a/go.sum +++ b/go.sum @@ -39,5 +39,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/augeas v0.0.0-20161110001225-ca62e35ed6b8 h1:FW42yWB1sGClqswyHIB68wo0+oPrav1IuQ+Tdy8Qp8E= honnef.co/go/augeas v0.0.0-20161110001225-ca62e35ed6b8/go.mod h1:44w9OfBSQ9l3o59rc2w3AnABtE44bmtNnRMNC7z+oKE= -r00t2.io/goutils v1.16.2 h1:aJtAD+t1pCaM9cpO1o1S7UDDh7fxBPT7CTYuGHJsVVo= -r00t2.io/goutils v1.16.2/go.mod h1:h+XtmWIvgm5S/liSJYFw3N09r5J7cjZ+Z5+aoYGw67k= +r00t2.io/goutils v1.16.4 h1:pzF2JcejcbIBeCpvE2yVwXfIlUs0yL2TKMB8sBl1xJc= +r00t2.io/goutils v1.16.4/go.mod h1:57B9wDCUgR5+sE02Nwk9DHG76Sgrt9EinCY10SSw6ac= diff --git a/types_nix.go b/types_nix.go index b26f6a5..da22af9 100644 --- a/types_nix.go +++ b/types_nix.go @@ -11,7 +11,16 @@ IDState collects information about the current running process. It should only be used as returned from GetIDState(). Its methods WILL return false information if any of these values are altered. -FSUID/FSGID are not supported. +FSUID/FSGID are not currently supported. + +Currently, macOS (and FreeBSD, and a couple others) will not populate: + + * SUID + * SGID + +due to Apple in their "infinite wisdom" allowing you to *set* these +but exposing no direct syscall whatsoever to *retrieve* them. +Enjoy your crippled OS, fanboys. */ type IDState struct { // RUID: Real UID