summaryrefslogtreecommitdiff
path: root/sd_login/type_pid.go.gen
diff options
context:
space:
mode:
Diffstat (limited to 'sd_login/type_pid.go.gen')
-rwxr-xr-xsd_login/type_pid.go.gen17
1 files changed, 15 insertions, 2 deletions
diff --git a/sd_login/type_pid.go.gen b/sd_login/type_pid.go.gen
index ec1bfe0..8d5e5fb 100755
--- a/sd_login/type_pid.go.gen
+++ b/sd_login/type_pid.go.gen
@@ -21,13 +21,21 @@
cat <<EOF
package sd_login
-import "net"
+import (
+ "net"
-// PID represents a process.
+ "golang.org/x/sys/unix"
+)
+
+// A PID represents a process.
//
// As a special case, PID(0) refers to the current process.
type PID int
+func (pid PID) isValid() bool {
+ return pid >= 0
+}
+
func GetPeer(conn *net.UnixConn) (PID, error) {
ucred, err := getpeercred(conn)
if err != nil {
@@ -35,6 +43,7 @@ func GetPeer(conn *net.UnixConn) (PID, error) {
}
return PID(ucred.Pid), nil
}
+
EOF
data=(
@@ -52,6 +61,10 @@ EOF
cat <<EOF
func (pid PID) ${Func}() (v ${Type}, err error) {
+ if !pid.isValid() {
+ err = unix.EINVAL
+ return
+ }
cgroup, err := pid.getCgroup()
if err != nil {
return