// Copyright (C) 2015-2017 Luke Shumaker // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sd_login import ( "net" "golang.org/x/sys/unix" ) const ( // from magic_TMPFS = 0x01021994 magic_CGROUP_SUPER = 0x0027e0eb magic_CGROUP2_SUPER = 0x63677270 // "cgrp" ) const ( // POSIX says at least 255, but Linux isn't POSIX. host_name_max = 64 ) // I borrowed this from libnslcd.git/nslcd_systemd (of which I am the // author) -- lukeshu func getpeercred(conn *net.UnixConn) (cred unix.Ucred, err error) { file, err := conn.File() if err != nil { return } defer file.Close() _cred, err := unix.GetsockoptUcred(int(file.Fd()), unix.SOL_SOCKET, unix.SO_PEERCRED) cred = *_cred return } func statfs(fspath string) (fs unix.Statfs_t, err error) { err = unix.Statfs(fspath, &fs) return }