vendor: update go-systemd
Godeps.json and vendor need to be updated according to the newest go-systemd, as SdNotify() in go-systemd has changed its API.
This commit is contained in:
12
cmd/Godeps/Godeps.json
generated
12
cmd/Godeps/Godeps.json
generated
@ -38,18 +38,18 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/coreos/go-systemd/daemon",
|
"ImportPath": "github.com/coreos/go-systemd/daemon",
|
||||||
"Comment": "v3-6-gcea488b",
|
"Comment": "v10-13-gd6c05a1d",
|
||||||
"Rev": "cea488b4e6855fee89b6c22a811e3c5baca861b6"
|
"Rev": "d6c05a1dcbb5ac02b7653da4d99e5db340c20778"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/coreos/go-systemd/journal",
|
"ImportPath": "github.com/coreos/go-systemd/journal",
|
||||||
"Comment": "v3-6-gcea488b",
|
"Comment": "v10-13-gd6c05a1d",
|
||||||
"Rev": "cea488b4e6855fee89b6c22a811e3c5baca861b6"
|
"Rev": "d6c05a1dcbb5ac02b7653da4d99e5db340c20778"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/coreos/go-systemd/util",
|
"ImportPath": "github.com/coreos/go-systemd/util",
|
||||||
"Comment": "v3-6-gcea488b",
|
"Comment": "v10-13-gd6c05a1d",
|
||||||
"Rev": "cea488b4e6855fee89b6c22a811e3c5baca861b6"
|
"Rev": "d6c05a1dcbb5ac02b7653da4d99e5db340c20778"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/coreos/pkg/capnslog",
|
"ImportPath": "github.com/coreos/pkg/capnslog",
|
||||||
|
21
cmd/vendor/github.com/coreos/go-systemd/daemon/sdnotify.go
generated
vendored
21
cmd/vendor/github.com/coreos/go-systemd/daemon/sdnotify.go
generated
vendored
@ -2,30 +2,37 @@
|
|||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SdNotifyNoSocket = errors.New("No socket")
|
|
||||||
|
|
||||||
// SdNotify sends a message to the init daemon. It is common to ignore the error.
|
// SdNotify sends a message to the init daemon. It is common to ignore the error.
|
||||||
func SdNotify(state string) error {
|
// It returns one of the following:
|
||||||
|
// (false, nil) - notification not supported (i.e. NOTIFY_SOCKET is unset)
|
||||||
|
// (false, err) - notification supported, but failure happened (e.g. error connecting to NOTIFY_SOCKET or while sending data)
|
||||||
|
// (true, nil) - notification supported, data has been sent
|
||||||
|
func SdNotify(state string) (sent bool, err error) {
|
||||||
socketAddr := &net.UnixAddr{
|
socketAddr := &net.UnixAddr{
|
||||||
Name: os.Getenv("NOTIFY_SOCKET"),
|
Name: os.Getenv("NOTIFY_SOCKET"),
|
||||||
Net: "unixgram",
|
Net: "unixgram",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTIFY_SOCKET not set
|
||||||
if socketAddr.Name == "" {
|
if socketAddr.Name == "" {
|
||||||
return SdNotifyNoSocket
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr)
|
conn, err := net.DialUnix(socketAddr.Net, nil, socketAddr)
|
||||||
|
// Error connecting to NOTIFY_SOCKET
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
_, err = conn.Write([]byte(state))
|
_, err = conn.Write([]byte(state))
|
||||||
return err
|
// Error sending the message
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,14 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
// Package journal provides write bindings to the systemd journal
|
// Package journal provides write bindings to the local systemd journal.
|
||||||
|
// It is implemented in pure Go and connects to the journal directly over its
|
||||||
|
// unix socket.
|
||||||
|
//
|
||||||
|
// To read from the journal, see the "sdjournal" package, which wraps the
|
||||||
|
// sd-journal a C API.
|
||||||
|
//
|
||||||
|
// http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html
|
||||||
package journal
|
package journal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -53,14 +60,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enabled returns true iff the systemd journal is available for logging
|
// Enabled returns true if the local systemd journal is available for logging
|
||||||
func Enabled() bool {
|
func Enabled() bool {
|
||||||
return conn != nil
|
return conn != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a message to the systemd journal. vars is a map of journald fields to
|
// Send a message to the local systemd journal. vars is a map of journald
|
||||||
// values. Fields must be composed of uppercase letters, numbers, and
|
// fields to values. Fields must be composed of uppercase letters, numbers,
|
||||||
// underscores, but must not start with an underscore. Within these
|
// and underscores, but must not start with an underscore. Within these
|
||||||
// restrictions, any arbitrary field name may be used. Some names have special
|
// restrictions, any arbitrary field name may be used. Some names have special
|
||||||
// significance: see the journalctl documentation
|
// significance: see the journalctl documentation
|
||||||
// (http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html)
|
// (http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html)
|
||||||
@ -83,6 +90,7 @@ func Send(message string, priority Priority, vars map[string]string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return journalError(err.Error())
|
return journalError(err.Error())
|
||||||
}
|
}
|
||||||
|
defer file.Close()
|
||||||
_, err = io.Copy(file, data)
|
_, err = io.Copy(file, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return journalError(err.Error())
|
return journalError(err.Error())
|
||||||
@ -102,6 +110,11 @@ func Send(message string, priority Priority, vars map[string]string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print prints a message to the local systemd journal using Send().
|
||||||
|
func Print(priority Priority, format string, a ...interface{}) error {
|
||||||
|
return Send(fmt.Sprintf(format, a...), priority, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func appendVariable(w io.Writer, name, value string) {
|
func appendVariable(w io.Writer, name, value string) {
|
||||||
if !validVarName(name) {
|
if !validVarName(name) {
|
||||||
journalError("variable name contains invalid character, ignoring")
|
journalError("variable name contains invalid character, ignoring")
|
67
cmd/vendor/github.com/coreos/go-systemd/util/util.go
generated
vendored
67
cmd/vendor/github.com/coreos/go-systemd/util/util.go
generated
vendored
@ -13,15 +13,66 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
// Package util contains utility functions related to systemd that applications
|
// Package util contains utility functions related to systemd that applications
|
||||||
// can use to check things like whether systemd is running.
|
// can use to check things like whether systemd is running. Note that some of
|
||||||
|
// these functions attempt to manually load systemd libraries at runtime rather
|
||||||
|
// than linking against them.
|
||||||
package util
|
package util
|
||||||
|
|
||||||
|
// #include <stdlib.h>
|
||||||
|
// #include <sys/types.h>
|
||||||
|
// #include <unistd.h>
|
||||||
|
//
|
||||||
|
// int
|
||||||
|
// my_sd_pid_get_owner_uid(void *f, pid_t pid, uid_t *uid)
|
||||||
|
// {
|
||||||
|
// int (*sd_pid_get_owner_uid)(pid_t, uid_t *);
|
||||||
|
//
|
||||||
|
// sd_pid_get_owner_uid = (int (*)(pid_t, uid_t *))f;
|
||||||
|
// return sd_pid_get_owner_uid(pid, uid);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int
|
||||||
|
// my_sd_pid_get_unit(void *f, pid_t pid, char **unit)
|
||||||
|
// {
|
||||||
|
// int (*sd_pid_get_unit)(pid_t, char **);
|
||||||
|
//
|
||||||
|
// sd_pid_get_unit = (int (*)(pid_t, char **))f;
|
||||||
|
// return sd_pid_get_unit(pid, unit);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int
|
||||||
|
// my_sd_pid_get_slice(void *f, pid_t pid, char **slice)
|
||||||
|
// {
|
||||||
|
// int (*sd_pid_get_slice)(pid_t, char **);
|
||||||
|
//
|
||||||
|
// sd_pid_get_slice = (int (*)(pid_t, char **))f;
|
||||||
|
// return sd_pid_get_slice(pid, slice);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int
|
||||||
|
// am_session_leader()
|
||||||
|
// {
|
||||||
|
// return (getsid(0) == getpid());
|
||||||
|
// }
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var libsystemdNames = []string{
|
||||||
|
// systemd < 209
|
||||||
|
"libsystemd-login.so.0",
|
||||||
|
"libsystemd-login.so",
|
||||||
|
|
||||||
|
// systemd >= 209 merged libsystemd-login into libsystemd proper
|
||||||
|
"libsystemd.so.0",
|
||||||
|
"libsystemd.so",
|
||||||
|
}
|
||||||
|
|
||||||
// IsRunningSystemd checks whether the host was booted with systemd as its init
|
// IsRunningSystemd checks whether the host was booted with systemd as its init
|
||||||
// system. This functions similar to systemd's `sd_booted(3)`: internally, it
|
// system. This functions similarly to systemd's `sd_booted(3)`: internally, it
|
||||||
// checks whether /run/systemd/system/ exists and is a directory.
|
// checks whether /run/systemd/system/ exists and is a directory.
|
||||||
// http://www.freedesktop.org/software/systemd/man/sd_booted.html
|
// http://www.freedesktop.org/software/systemd/man/sd_booted.html
|
||||||
func IsRunningSystemd() bool {
|
func IsRunningSystemd() bool {
|
||||||
@ -31,3 +82,15 @@ func IsRunningSystemd() bool {
|
|||||||
}
|
}
|
||||||
return fi.IsDir()
|
return fi.IsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMachineID returns a host's 128-bit machine ID as a string. This functions
|
||||||
|
// similarly to systemd's `sd_id128_get_machine`: internally, it simply reads
|
||||||
|
// the contents of /etc/machine-id
|
||||||
|
// http://www.freedesktop.org/software/systemd/man/sd_id128_get_machine.html
|
||||||
|
func GetMachineID() (string, error) {
|
||||||
|
machineID, err := ioutil.ReadFile("/etc/machine-id")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("failed to read /etc/machine-id: %v", err)
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(machineID)), nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user