mirror of
https://github.com/containers/podman.git
synced 2026-02-05 06:45:31 +01:00
Merge pull request #27974 from containers/renovate/github.com-coreos-go-systemd-v22-22.x
fix(deps): update module github.com/coreos/go-systemd/v22 to v22.7.0
This commit is contained in:
2
go.mod
2
go.mod
@@ -18,7 +18,7 @@ require (
|
||||
github.com/containers/ocicrypt v1.2.1
|
||||
github.com/containers/psgo v1.10.0
|
||||
github.com/containers/winquit v1.1.0
|
||||
github.com/coreos/go-systemd/v22 v22.6.0
|
||||
github.com/coreos/go-systemd/v22 v22.7.0
|
||||
github.com/crc-org/vfkit v0.6.3
|
||||
github.com/cyphar/filepath-securejoin v0.6.1
|
||||
github.com/digitalocean/go-qemu v0.0.0-20250212194115-ee9b0668d242
|
||||
|
||||
4
go.sum
4
go.sum
@@ -81,8 +81,8 @@ github.com/coreos/go-oidc/v3 v3.16.0 h1:qRQUCFstKpXwmEjDQTIbyY/5jF00+asXzSkmkoa/
|
||||
github.com/coreos/go-oidc/v3 v3.16.0/go.mod h1:wqPbKFrVnE90vty060SB40FCJ8fTHTxSwyXJqZH+sI8=
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c=
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo=
|
||||
github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA=
|
||||
github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/crc-org/vfkit v0.6.3 h1:X6pHxDWx0jQRV6TpzCmI4tfPyW/2R03HEEiS5vNnsBU=
|
||||
github.com/crc-org/vfkit v0.6.3/go.mod h1:jp0CkOQW5BAvSdJSV7OHUuTGRUo7+/fwaFHd+92pqR8=
|
||||
|
||||
29
vendor/github.com/coreos/go-systemd/v22/activation/files.go
generated
vendored
Normal file
29
vendor/github.com/coreos/go-systemd/v22/activation/files.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2026 RedHat, Inc.
|
||||
//
|
||||
// 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 activation
|
||||
|
||||
import "os"
|
||||
|
||||
// FilesWithNames maps fd names to a set of os.File pointers.
|
||||
func FilesWithNames() map[string][]*os.File {
|
||||
files := Files(true)
|
||||
filesWithNames := map[string][]*os.File{}
|
||||
|
||||
for _, f := range files {
|
||||
filesWithNames[f.Name()] = append(filesWithNames[f.Name()], f)
|
||||
}
|
||||
|
||||
return filesWithNames
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !unix
|
||||
|
||||
package activation
|
||||
|
||||
import "os"
|
||||
4
vendor/github.com/coreos/go-systemd/v22/activation/files_unix.go
generated
vendored
4
vendor/github.com/coreos/go-systemd/v22/activation/files_unix.go
generated
vendored
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !windows
|
||||
//go:build unix
|
||||
|
||||
// Package activation implements primitives for systemd socket activation.
|
||||
package activation
|
||||
@@ -51,7 +51,7 @@ func Files(unsetEnv bool) []*os.File {
|
||||
}
|
||||
|
||||
nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS"))
|
||||
if err != nil || nfds == 0 {
|
||||
if err != nil || nfds <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
7
vendor/github.com/coreos/go-systemd/v22/activation/listeners.go
generated
vendored
7
vendor/github.com/coreos/go-systemd/v22/activation/listeners.go
generated
vendored
@@ -45,12 +45,7 @@ func ListenersWithNames() (map[string][]net.Listener, error) {
|
||||
|
||||
for _, f := range files {
|
||||
if pc, err := net.FileListener(f); err == nil {
|
||||
current, ok := listeners[f.Name()]
|
||||
if !ok {
|
||||
listeners[f.Name()] = []net.Listener{pc}
|
||||
} else {
|
||||
listeners[f.Name()] = append(current, pc)
|
||||
}
|
||||
listeners[f.Name()] = append(listeners[f.Name()], pc)
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
22
vendor/github.com/coreos/go-systemd/v22/daemon/sdnotify_other.go
generated
vendored
Normal file
22
vendor/github.com/coreos/go-systemd/v22/daemon/sdnotify_other.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2025
|
||||
//
|
||||
// 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.
|
||||
|
||||
//go:build !unix
|
||||
|
||||
package daemon
|
||||
|
||||
// SdNotifyMonotonicUsec returns the empty string on unsupported platforms.
|
||||
func SdNotifyMonotonicUsec() string {
|
||||
return ""
|
||||
}
|
||||
36
vendor/github.com/coreos/go-systemd/v22/daemon/sdnotify_unix.go
generated
vendored
Normal file
36
vendor/github.com/coreos/go-systemd/v22/daemon/sdnotify_unix.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2025
|
||||
//
|
||||
// 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.
|
||||
|
||||
//go:build unix
|
||||
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// SdNotifyMonotonicUsec returns a MONOTONIC_USEC=... assignment for the current time
|
||||
// with a trailing newline included. This is typically used with [SdNotifyReloading].
|
||||
//
|
||||
// If the monotonic clock is not available on the system, the empty string is returned.
|
||||
func SdNotifyMonotonicUsec() string {
|
||||
var ts unix.Timespec
|
||||
if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &ts); err != nil {
|
||||
// Monotonic clock is not available on this system.
|
||||
return ""
|
||||
}
|
||||
return "MONOTONIC_USEC=" + strconv.FormatInt(ts.Nano()/1000, 10) + "\n"
|
||||
}
|
||||
7
vendor/github.com/coreos/go-systemd/v22/daemon/watchdog.go
generated
vendored
7
vendor/github.com/coreos/go-systemd/v22/daemon/watchdog.go
generated
vendored
@@ -15,6 +15,7 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -51,10 +52,10 @@ func SdWatchdogEnabled(unsetEnvironment bool) (time.Duration, error) {
|
||||
}
|
||||
s, err := strconv.Atoi(wusec)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("error converting WATCHDOG_USEC: %s", err)
|
||||
return 0, fmt.Errorf("error converting WATCHDOG_USEC: %w", err)
|
||||
}
|
||||
if s <= 0 {
|
||||
return 0, fmt.Errorf("error WATCHDOG_USEC must be a positive number")
|
||||
return 0, errors.New("error WATCHDOG_USEC must be a positive number")
|
||||
}
|
||||
interval := time.Duration(s) * time.Microsecond
|
||||
|
||||
@@ -63,7 +64,7 @@ func SdWatchdogEnabled(unsetEnvironment bool) (time.Duration, error) {
|
||||
}
|
||||
p, err := strconv.Atoi(wpid)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("error converting WATCHDOG_PID: %s", err)
|
||||
return 0, fmt.Errorf("error converting WATCHDOG_PID: %w", err)
|
||||
}
|
||||
if os.Getpid() != p {
|
||||
return 0, nil
|
||||
|
||||
4
vendor/github.com/coreos/go-systemd/v22/dbus/dbus.go
generated
vendored
4
vendor/github.com/coreos/go-systemd/v22/dbus/dbus.go
generated
vendored
@@ -95,7 +95,7 @@ type Conn struct {
|
||||
sigobj dbus.BusObject
|
||||
|
||||
jobListener struct {
|
||||
jobs map[dbus.ObjectPath]chan<- string
|
||||
jobs map[dbus.ObjectPath][]chan<- string
|
||||
sync.Mutex
|
||||
}
|
||||
subStateSubscriber struct {
|
||||
@@ -207,7 +207,7 @@ func NewConnection(dialBus func() (*dbus.Conn, error)) (*Conn, error) {
|
||||
}
|
||||
|
||||
c.subStateSubscriber.ignore = make(map[dbus.ObjectPath]int64)
|
||||
c.jobListener.jobs = make(map[dbus.ObjectPath]chan<- string)
|
||||
c.jobListener.jobs = make(map[dbus.ObjectPath][]chan<- string)
|
||||
|
||||
// Setup the listeners on jobs so that we can get completions
|
||||
c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0,
|
||||
|
||||
239
vendor/github.com/coreos/go-systemd/v22/dbus/methods.go
generated
vendored
239
vendor/github.com/coreos/go-systemd/v22/dbus/methods.go
generated
vendored
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/godbus/dbus/v5"
|
||||
)
|
||||
|
||||
// Who specifies which process to send a signal to via the [KillUnitWithTarget].
|
||||
// Who specifies which process to send a signal to via the [Conn.KillUnitWithTarget].
|
||||
type Who string
|
||||
|
||||
const (
|
||||
@@ -44,11 +44,10 @@ func (c *Conn) jobComplete(signal *dbus.Signal) {
|
||||
|
||||
_ = dbus.Store(signal.Body, &id, &job, &unit, &result)
|
||||
c.jobListener.Lock()
|
||||
out, ok := c.jobListener.jobs[job]
|
||||
if ok {
|
||||
for _, out := range c.jobListener.jobs[job] {
|
||||
out <- result
|
||||
delete(c.jobListener.jobs, job)
|
||||
}
|
||||
delete(c.jobListener.jobs, job)
|
||||
c.jobListener.Unlock()
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ func (c *Conn) startJob(ctx context.Context, ch chan<- string, job string, args
|
||||
}
|
||||
|
||||
if ch != nil {
|
||||
c.jobListener.jobs[p] = ch
|
||||
c.jobListener.jobs[p] = append(c.jobListener.jobs[p], ch)
|
||||
}
|
||||
|
||||
// ignore error since 0 is fine if conversion fails
|
||||
@@ -194,10 +193,16 @@ func (c *Conn) StartTransientUnit(name string, mode string, properties []Propert
|
||||
// unique. mode is the same as in StartUnitContext, properties contains properties
|
||||
// of the unit.
|
||||
func (c *Conn) StartTransientUnitContext(ctx context.Context, name string, mode string, properties []Property, ch chan<- string) (int, error) {
|
||||
return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, make([]PropertyCollection, 0))
|
||||
return c.StartTransientUnitAux(ctx, name, mode, properties, make([]PropertyCollection, 0), ch)
|
||||
}
|
||||
|
||||
// Deprecated: use [KillUnitWithTarget] instead.
|
||||
// StartTransientUnitAux is the same as StartTransientUnitContext but allows passing
|
||||
// auxiliary units in the aux parameter.
|
||||
func (c *Conn) StartTransientUnitAux(ctx context.Context, name string, mode string, properties []Property, aux []PropertyCollection, ch chan<- string) (int, error) {
|
||||
return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, aux)
|
||||
}
|
||||
|
||||
// Deprecated: use [Conn.KillUnitWithTarget] instead.
|
||||
func (c *Conn) KillUnit(name string, signal int32) {
|
||||
c.KillUnitContext(context.Background(), name, signal)
|
||||
}
|
||||
@@ -205,7 +210,7 @@ func (c *Conn) KillUnit(name string, signal int32) {
|
||||
// KillUnitContext takes the unit name and a UNIX signal number to send.
|
||||
// All of the unit's processes are killed.
|
||||
//
|
||||
// Deprecated: use [KillUnitWithTarget] instead, with target argument set to [All].
|
||||
// Deprecated: use [Conn.KillUnitWithTarget] instead, with target argument set to [All].
|
||||
func (c *Conn) KillUnitContext(ctx context.Context, name string, signal int32) {
|
||||
_ = c.KillUnitWithTarget(ctx, name, All, signal)
|
||||
}
|
||||
@@ -398,30 +403,33 @@ type UnitStatus struct {
|
||||
|
||||
type storeFunc func(retvalues ...any) error
|
||||
|
||||
func (c *Conn) listUnitsInternal(f storeFunc) ([]UnitStatus, error) {
|
||||
result := make([][]any, 0)
|
||||
// convertSlice converts a []any result into a slice of the target type T
|
||||
// using dbus.Store to handle the type conversion.
|
||||
func convertSlice[T any](result []any) ([]T, error) {
|
||||
converted := make([]T, len(result))
|
||||
convertedInterface := make([]any, len(converted))
|
||||
for i := range converted {
|
||||
convertedInterface[i] = &converted[i]
|
||||
}
|
||||
|
||||
err := dbus.Store(result, convertedInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return converted, nil
|
||||
}
|
||||
|
||||
// storeSlice fetches D-Bus array results via the provided storeFunc
|
||||
// and converts them into a slice of the target type T.
|
||||
func storeSlice[T any](f storeFunc) ([]T, error) {
|
||||
var result []any
|
||||
err := f(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
status := make([]UnitStatus, len(result))
|
||||
statusInterface := make([]any, len(status))
|
||||
for i := range status {
|
||||
statusInterface[i] = &status[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, statusInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return status, nil
|
||||
return convertSlice[T](result)
|
||||
}
|
||||
|
||||
// GetUnitByPID returns the unit object path of the unit a process ID
|
||||
@@ -458,7 +466,7 @@ func (c *Conn) ListUnits() ([]UnitStatus, error) {
|
||||
// Also note that a unit is only loaded if it is active and/or enabled.
|
||||
// Units that are both disabled and inactive will thus not be returned.
|
||||
func (c *Conn) ListUnitsContext(ctx context.Context) ([]UnitStatus, error) {
|
||||
return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnits", 0).Store)
|
||||
return storeSlice[UnitStatus](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnits", 0).Store)
|
||||
}
|
||||
|
||||
// Deprecated: use ListUnitsFilteredContext instead.
|
||||
@@ -469,7 +477,7 @@ func (c *Conn) ListUnitsFiltered(states []string) ([]UnitStatus, error) {
|
||||
// ListUnitsFilteredContext returns an array with units filtered by state.
|
||||
// It takes a list of units' statuses to filter.
|
||||
func (c *Conn) ListUnitsFilteredContext(ctx context.Context, states []string) ([]UnitStatus, error) {
|
||||
return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsFiltered", 0, states).Store)
|
||||
return storeSlice[UnitStatus](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsFiltered", 0, states).Store)
|
||||
}
|
||||
|
||||
// Deprecated: use ListUnitsByPatternsContext instead.
|
||||
@@ -482,7 +490,7 @@ func (c *Conn) ListUnitsByPatterns(states []string, patterns []string) ([]UnitSt
|
||||
// Note that units may be known by multiple names at the same time,
|
||||
// and hence there might be more unit names loaded than actual units behind them.
|
||||
func (c *Conn) ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]UnitStatus, error) {
|
||||
return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsByPatterns", 0, states, patterns).Store)
|
||||
return storeSlice[UnitStatus](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsByPatterns", 0, states, patterns).Store)
|
||||
}
|
||||
|
||||
// Deprecated: use ListUnitsByNamesContext instead.
|
||||
@@ -497,7 +505,7 @@ func (c *Conn) ListUnitsByNames(units []string) ([]UnitStatus, error) {
|
||||
//
|
||||
// Requires systemd v230 or higher.
|
||||
func (c *Conn) ListUnitsByNamesContext(ctx context.Context, units []string) ([]UnitStatus, error) {
|
||||
return c.listUnitsInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsByNames", 0, units).Store)
|
||||
return storeSlice[UnitStatus](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitsByNames", 0, units).Store)
|
||||
}
|
||||
|
||||
type UnitFile struct {
|
||||
@@ -505,32 +513,6 @@ type UnitFile struct {
|
||||
Type string
|
||||
}
|
||||
|
||||
func (c *Conn) listUnitFilesInternal(f storeFunc) ([]UnitFile, error) {
|
||||
result := make([][]any, 0)
|
||||
err := f(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
files := make([]UnitFile, len(result))
|
||||
fileInterface := make([]any, len(files))
|
||||
for i := range files {
|
||||
fileInterface[i] = &files[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, fileInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return files, nil
|
||||
}
|
||||
|
||||
// Deprecated: use ListUnitFilesContext instead.
|
||||
func (c *Conn) ListUnitFiles() ([]UnitFile, error) {
|
||||
return c.ListUnitFilesContext(context.Background())
|
||||
@@ -538,7 +520,7 @@ func (c *Conn) ListUnitFiles() ([]UnitFile, error) {
|
||||
|
||||
// ListUnitFilesContext returns an array of all available units on disk.
|
||||
func (c *Conn) ListUnitFilesContext(ctx context.Context) ([]UnitFile, error) {
|
||||
return c.listUnitFilesInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store)
|
||||
return storeSlice[UnitFile](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store)
|
||||
}
|
||||
|
||||
// Deprecated: use ListUnitFilesByPatternsContext instead.
|
||||
@@ -548,7 +530,7 @@ func (c *Conn) ListUnitFilesByPatterns(states []string, patterns []string) ([]Un
|
||||
|
||||
// ListUnitFilesByPatternsContext returns an array of all available units on disk matched the patterns.
|
||||
func (c *Conn) ListUnitFilesByPatternsContext(ctx context.Context, states []string, patterns []string) ([]UnitFile, error) {
|
||||
return c.listUnitFilesInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFilesByPatterns", 0, states, patterns).Store)
|
||||
return storeSlice[UnitFile](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFilesByPatterns", 0, states, patterns).Store)
|
||||
}
|
||||
|
||||
type LinkUnitFileChange EnableUnitFileChange
|
||||
@@ -576,29 +558,7 @@ func (c *Conn) LinkUnitFiles(files []string, runtime bool, force bool) ([]LinkUn
|
||||
// or unlink), the file name of the symlink and the destination of the
|
||||
// symlink.
|
||||
func (c *Conn) LinkUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) ([]LinkUnitFileChange, error) {
|
||||
result := make([][]any, 0)
|
||||
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.LinkUnitFiles", 0, files, runtime, force).Store(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
changes := make([]LinkUnitFileChange, len(result))
|
||||
changesInterface := make([]any, len(changes))
|
||||
for i := range changes {
|
||||
changesInterface[i] = &changes[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, changesInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return changes, nil
|
||||
return storeSlice[LinkUnitFileChange](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.LinkUnitFiles", 0, files, runtime, force).Store)
|
||||
}
|
||||
|
||||
// Deprecated: use EnableUnitFilesContext instead.
|
||||
@@ -624,25 +584,14 @@ func (c *Conn) EnableUnitFiles(files []string, runtime bool, force bool) (bool,
|
||||
// symlink.
|
||||
func (c *Conn) EnableUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) {
|
||||
var carries_install_info bool
|
||||
var result []any
|
||||
|
||||
result := make([][]any, 0)
|
||||
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.EnableUnitFiles", 0, files, runtime, force).Store(&carries_install_info, &result)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
changes := make([]EnableUnitFileChange, len(result))
|
||||
changesInterface := make([]any, len(changes))
|
||||
for i := range changes {
|
||||
changesInterface[i] = &changes[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, changesInterface...)
|
||||
changes, err := convertSlice[EnableUnitFileChange](result)
|
||||
if err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
@@ -674,29 +623,7 @@ func (c *Conn) DisableUnitFiles(files []string, runtime bool) ([]DisableUnitFile
|
||||
// symlink or unlink), the file name of the symlink and the destination of the
|
||||
// symlink.
|
||||
func (c *Conn) DisableUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]DisableUnitFileChange, error) {
|
||||
result := make([][]any, 0)
|
||||
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.DisableUnitFiles", 0, files, runtime).Store(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
changes := make([]DisableUnitFileChange, len(result))
|
||||
changesInterface := make([]any, len(changes))
|
||||
for i := range changes {
|
||||
changesInterface[i] = &changes[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, changesInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return changes, nil
|
||||
return storeSlice[DisableUnitFileChange](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.DisableUnitFiles", 0, files, runtime).Store)
|
||||
}
|
||||
|
||||
type DisableUnitFileChange struct {
|
||||
@@ -720,29 +647,7 @@ func (c *Conn) MaskUnitFiles(files []string, runtime bool, force bool) ([]MaskUn
|
||||
// runtime only (true, /run/systemd/..), or persistently (false,
|
||||
// /etc/systemd/..).
|
||||
func (c *Conn) MaskUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) ([]MaskUnitFileChange, error) {
|
||||
result := make([][]any, 0)
|
||||
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.MaskUnitFiles", 0, files, runtime, force).Store(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
changes := make([]MaskUnitFileChange, len(result))
|
||||
changesInterface := make([]any, len(changes))
|
||||
for i := range changes {
|
||||
changesInterface[i] = &changes[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, changesInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return changes, nil
|
||||
return storeSlice[MaskUnitFileChange](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.MaskUnitFiles", 0, files, runtime, force).Store)
|
||||
}
|
||||
|
||||
type MaskUnitFileChange struct {
|
||||
@@ -764,29 +669,7 @@ func (c *Conn) UnmaskUnitFiles(files []string, runtime bool) ([]UnmaskUnitFileCh
|
||||
// for runtime only (true, /run/systemd/..), or persistently (false,
|
||||
// /etc/systemd/..).
|
||||
func (c *Conn) UnmaskUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]UnmaskUnitFileChange, error) {
|
||||
result := make([][]any, 0)
|
||||
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.UnmaskUnitFiles", 0, files, runtime).Store(&result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
changes := make([]UnmaskUnitFileChange, len(result))
|
||||
changesInterface := make([]any, len(changes))
|
||||
for i := range changes {
|
||||
changesInterface[i] = &changes[i]
|
||||
}
|
||||
|
||||
err = dbus.Store(resultInterface, changesInterface...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return changes, nil
|
||||
return storeSlice[UnmaskUnitFileChange](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.UnmaskUnitFiles", 0, files, runtime).Store)
|
||||
}
|
||||
|
||||
type UnmaskUnitFileChange struct {
|
||||
@@ -832,35 +715,11 @@ func (c *Conn) ListJobs() ([]JobStatus, error) {
|
||||
|
||||
// ListJobsContext returns an array with all currently queued jobs.
|
||||
func (c *Conn) ListJobsContext(ctx context.Context) ([]JobStatus, error) {
|
||||
return c.listJobsInternal(ctx)
|
||||
}
|
||||
|
||||
func (c *Conn) listJobsInternal(ctx context.Context) ([]JobStatus, error) {
|
||||
result := make([][]any, 0)
|
||||
if err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListJobs", 0).Store(&result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resultInterface := make([]any, len(result))
|
||||
for i := range result {
|
||||
resultInterface[i] = result[i]
|
||||
}
|
||||
|
||||
status := make([]JobStatus, len(result))
|
||||
statusInterface := make([]any, len(status))
|
||||
for i := range status {
|
||||
statusInterface[i] = &status[i]
|
||||
}
|
||||
|
||||
if err := dbus.Store(resultInterface, statusInterface...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return status, nil
|
||||
return storeSlice[JobStatus](c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListJobs", 0).Store)
|
||||
}
|
||||
|
||||
// FreezeUnit freezes the cgroup associated with the unit.
|
||||
// Note that FreezeUnit and [ThawUnit] are only supported on systems running with cgroup v2.
|
||||
// Note that FreezeUnit and [Conn.ThawUnit] are only supported on systems running with cgroup v2.
|
||||
func (c *Conn) FreezeUnit(ctx context.Context, unit string) error {
|
||||
return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.FreezeUnit", 0, unit).Store()
|
||||
}
|
||||
|
||||
17
vendor/github.com/coreos/go-systemd/v22/dbus/set.go
generated
vendored
17
vendor/github.com/coreos/go-systemd/v22/dbus/set.go
generated
vendored
@@ -14,28 +14,43 @@
|
||||
|
||||
package dbus
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type set struct {
|
||||
data map[string]bool
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *set) Add(value string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.data[value] = true
|
||||
}
|
||||
|
||||
func (s *set) Remove(value string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
delete(s.data, value)
|
||||
}
|
||||
|
||||
func (s *set) Contains(value string) (exists bool) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
_, exists = s.data[value]
|
||||
return
|
||||
}
|
||||
|
||||
func (s *set) Length() int {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return len(s.data)
|
||||
}
|
||||
|
||||
func (s *set) Values() (values []string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
for val := range s.data {
|
||||
values = append(values, val)
|
||||
}
|
||||
@@ -43,5 +58,5 @@ func (s *set) Values() (values []string) {
|
||||
}
|
||||
|
||||
func newSet() *set {
|
||||
return &set{make(map[string]bool)}
|
||||
return &set{data: make(map[string]bool)}
|
||||
}
|
||||
|
||||
32
vendor/github.com/coreos/go-systemd/v22/dbus/subscription.go
generated
vendored
32
vendor/github.com/coreos/go-systemd/v22/dbus/subscription.go
generated
vendored
@@ -15,6 +15,7 @@
|
||||
package dbus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"time"
|
||||
@@ -94,16 +95,26 @@ func (c *Conn) dispatch() {
|
||||
}()
|
||||
}
|
||||
|
||||
// SubscribeUnits returns two unbuffered channels which will receive all changed units every
|
||||
// interval. Deleted units are sent as nil.
|
||||
// Deprecated: use SubscribeUnitsContext instead.
|
||||
func (c *Conn) SubscribeUnits(interval time.Duration) (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
return c.SubscribeUnitsCustom(interval, 0, func(u1, u2 *UnitStatus) bool { return *u1 != *u2 }, nil)
|
||||
return c.SubscribeUnitsContext(context.Background(), interval)
|
||||
}
|
||||
|
||||
// SubscribeUnitsCustom is like SubscribeUnits but lets you specify the buffer
|
||||
// SubscribeUnitsContext returns two unbuffered channels which will receive all changed units every
|
||||
// interval. Deleted units are sent as nil.
|
||||
func (c *Conn) SubscribeUnitsContext(ctx context.Context, interval time.Duration) (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
return c.SubscribeUnitsCustomContext(ctx, interval, 0, func(u1, u2 *UnitStatus) bool { return *u1 != *u2 }, nil)
|
||||
}
|
||||
|
||||
// Deprecated: use SubscribeUnitsCustomContext instead.
|
||||
func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
return c.SubscribeUnitsCustomContext(context.Background(), interval, buffer, isChanged, filterUnit)
|
||||
}
|
||||
|
||||
// SubscribeUnitsCustomContext is like [Conn.SubscribeUnitsContext] but lets you specify the buffer
|
||||
// size of the channels, the comparison function for detecting changes and a filter
|
||||
// function for cutting down on the noise that your channel receives.
|
||||
func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
func (c *Conn) SubscribeUnitsCustomContext(ctx context.Context, interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
old := make(map[string]*UnitStatus)
|
||||
statusChan := make(chan map[string]*UnitStatus, buffer)
|
||||
errChan := make(chan error, buffer)
|
||||
@@ -112,7 +123,7 @@ func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChange
|
||||
for {
|
||||
timerChan := time.After(interval)
|
||||
|
||||
units, err := c.ListUnits()
|
||||
units, err := c.ListUnitsContext(ctx)
|
||||
if err == nil {
|
||||
cur := make(map[string]*UnitStatus)
|
||||
for i := range units {
|
||||
@@ -145,7 +156,14 @@ func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChange
|
||||
errChan <- err
|
||||
}
|
||||
|
||||
<-timerChan
|
||||
select {
|
||||
case <-timerChan:
|
||||
continue
|
||||
case <-ctx.Done():
|
||||
close(statusChan)
|
||||
close(errChan)
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
12
vendor/github.com/coreos/go-systemd/v22/dbus/subscription_set.go
generated
vendored
12
vendor/github.com/coreos/go-systemd/v22/dbus/subscription_set.go
generated
vendored
@@ -15,6 +15,7 @@
|
||||
package dbus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -29,16 +30,21 @@ func (s *SubscriptionSet) filter(unit string) bool {
|
||||
return !s.Contains(unit)
|
||||
}
|
||||
|
||||
// Subscribe starts listening for dbus events for all of the units in the set.
|
||||
// SubscribeContext starts listening for dbus events for all of the units in the set.
|
||||
// Returns channels identical to conn.SubscribeUnits.
|
||||
func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
func (s *SubscriptionSet) SubscribeContext(ctx context.Context) (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
// TODO: Make fully evented by using systemd 209 with properties changed values
|
||||
return s.conn.SubscribeUnitsCustom(time.Second, 0,
|
||||
return s.conn.SubscribeUnitsCustomContext(ctx, time.Second, 0,
|
||||
mismatchUnitStatus,
|
||||
func(unit string) bool { return s.filter(unit) },
|
||||
)
|
||||
}
|
||||
|
||||
// Deprecated: use SubscribeContext instead.
|
||||
func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) {
|
||||
return s.SubscribeContext(context.Background())
|
||||
}
|
||||
|
||||
// NewSubscriptionSet returns a new subscription set.
|
||||
func (c *Conn) NewSubscriptionSet() *SubscriptionSet {
|
||||
return &SubscriptionSet{newSet(), c}
|
||||
|
||||
4
vendor/github.com/coreos/go-systemd/v22/internal/dlopen/dlopen.go
generated
vendored
4
vendor/github.com/coreos/go-systemd/v22/internal/dlopen/dlopen.go
generated
vendored
@@ -69,7 +69,7 @@ func (l *LibHandle) GetSymbolPointer(symbol string) (unsafe.Pointer, error) {
|
||||
p := C.dlsym(l.Handle, sym)
|
||||
e := C.dlerror()
|
||||
if e != nil {
|
||||
return nil, fmt.Errorf("error resolving symbol %q: %v", symbol, errors.New(C.GoString(e)))
|
||||
return nil, fmt.Errorf("error resolving symbol %q: %s", symbol, C.GoString(e))
|
||||
}
|
||||
|
||||
return p, nil
|
||||
@@ -85,7 +85,7 @@ func (l *LibHandle) Close() error {
|
||||
C.dlclose(l.Handle)
|
||||
e := C.dlerror()
|
||||
if e != nil {
|
||||
return fmt.Errorf("error closing %v: %v", l.Libname, errors.New(C.GoString(e)))
|
||||
return fmt.Errorf("error closing %v: %s", l.Libname, C.GoString(e))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
5
vendor/github.com/coreos/go-systemd/v22/internal/dlopen/dlopen_example.go
generated
vendored
5
vendor/github.com/coreos/go-systemd/v22/internal/dlopen/dlopen_example.go
generated
vendored
@@ -30,14 +30,13 @@ package dlopen
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func strlen(libs []string, s string) (int, error) {
|
||||
h, err := GetHandle(libs)
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf(`couldn't get a handle to the library: %v`, err)
|
||||
return -1, err
|
||||
}
|
||||
defer h.Close()
|
||||
|
||||
@@ -47,7 +46,7 @@ func strlen(libs []string, s string) (int, error) {
|
||||
|
||||
strlen, err := h.GetSymbolPointer(f)
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf(`couldn't get symbol %q: %v`, f, err)
|
||||
return -1, err
|
||||
}
|
||||
|
||||
len := C.my_strlen(strlen, cs)
|
||||
|
||||
2
vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go
generated
vendored
2
vendor/github.com/coreos/go-systemd/v22/journal/journal_unix.go
generated
vendored
@@ -106,7 +106,7 @@ func fdIsJournalStream(fd int) (bool, error) {
|
||||
var expectedStat syscall.Stat_t
|
||||
_, err := fmt.Sscanf(journalStream, "%d:%d", &expectedStat.Dev, &expectedStat.Ino)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to parse JOURNAL_STREAM=%q: %v", journalStream, err)
|
||||
return false, fmt.Errorf("failed to parse JOURNAL_STREAM=%q: %w", journalStream, err)
|
||||
}
|
||||
|
||||
var stat syscall.Stat_t
|
||||
|
||||
2
vendor/github.com/coreos/go-systemd/v22/sdjournal/functions.go
generated
vendored
2
vendor/github.com/coreos/go-systemd/v22/sdjournal/functions.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015 RedHat, Inc.
|
||||
// Copyright 2015 Red Hat, Inc.
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
70
vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go
generated
vendored
70
vendor/github.com/coreos/go-systemd/v22/sdjournal/journal.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015 RedHat, Inc.
|
||||
// Copyright 2015 Red Hat, Inc.
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,11 +17,11 @@
|
||||
// systemd journal wrapped around the sd-journal C API.
|
||||
//
|
||||
// All public read methods map closely to the sd-journal API functions. See the
|
||||
// sd-journal.h documentation[1] for information about each function.
|
||||
// [sd-journal.h documentation] for information about each function.
|
||||
//
|
||||
// To write to the journal, see the pure-Go "journal" package
|
||||
// To write to the journal, see the pure-Go "journal" package.
|
||||
//
|
||||
// [1] http://www.freedesktop.org/software/systemd/man/sd-journal.html
|
||||
// [sd-journal.h documentation]: http://www.freedesktop.org/software/systemd/man/sd-journal.html
|
||||
package sdjournal
|
||||
|
||||
// #include <systemd/sd-journal.h>
|
||||
@@ -431,7 +431,7 @@ func NewJournal() (j *Journal, err error) {
|
||||
r := C.my_sd_journal_open(sd_journal_open, &j.cjournal, C.SD_JOURNAL_LOCAL_ONLY)
|
||||
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to open journal: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to open journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return j, nil
|
||||
@@ -452,7 +452,7 @@ func NewJournalFromDir(path string) (j *Journal, err error) {
|
||||
|
||||
r := C.my_sd_journal_open_directory(sd_journal_open_directory, &j.cjournal, p, 0)
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to open journal in directory %q: %s", path, syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to open journal in directory %q: %w", path, syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return j, nil
|
||||
@@ -478,7 +478,7 @@ func NewJournalFromFiles(paths ...string) (j *Journal, err error) {
|
||||
|
||||
r := C.my_sd_journal_open_files(sd_journal_open_files, &j.cjournal, &cPaths[0], 0)
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to open journals in paths %q: %s", paths, syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to open journals in paths %q: %w", paths, syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return j, nil
|
||||
@@ -513,7 +513,7 @@ func (j *Journal) AddMatch(match string) error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to add match: %s", syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to add match: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -531,7 +531,7 @@ func (j *Journal) AddDisjunction() error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to add a disjunction in the match list: %s", syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to add a disjunction in the match list: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -549,7 +549,7 @@ func (j *Journal) AddConjunction() error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to add a conjunction in the match list: %s", syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to add a conjunction in the match list: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -579,7 +579,7 @@ func (j *Journal) Next() (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to iterate journal: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to iterate journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(r), nil
|
||||
@@ -598,7 +598,7 @@ func (j *Journal) NextSkip(skip uint64) (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to iterate journal: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to iterate journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(r), nil
|
||||
@@ -616,7 +616,7 @@ func (j *Journal) Previous() (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to iterate journal: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to iterate journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(r), nil
|
||||
@@ -635,7 +635,7 @@ func (j *Journal) PreviousSkip(skip uint64) (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to iterate journal: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to iterate journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(r), nil
|
||||
@@ -658,7 +658,7 @@ func (j *Journal) getData(field string) (unsafe.Pointer, C.int, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return nil, 0, fmt.Errorf("failed to read message: %s", syscall.Errno(-r).Error())
|
||||
return nil, 0, fmt.Errorf("failed to read message: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return d, C.int(l), nil
|
||||
@@ -753,7 +753,7 @@ func (j *Journal) GetEntry() (*JournalEntry, error) {
|
||||
var realtimeUsec C.uint64_t
|
||||
r = C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &realtimeUsec)
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to get realtime timestamp: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to get realtime timestamp: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
entry.RealtimeTimestamp = uint64(realtimeUsec)
|
||||
@@ -763,7 +763,7 @@ func (j *Journal) GetEntry() (*JournalEntry, error) {
|
||||
|
||||
r = C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &monotonicUsec, &boot_id)
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to get monotonic timestamp: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to get monotonic timestamp: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
entry.MonotonicTimestamp = uint64(monotonicUsec)
|
||||
@@ -774,7 +774,7 @@ func (j *Journal) GetEntry() (*JournalEntry, error) {
|
||||
r = C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &c)
|
||||
defer C.free(unsafe.Pointer(c))
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to get cursor: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to get cursor: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
entry.Cursor = C.GoString(c)
|
||||
@@ -790,13 +790,13 @@ func (j *Journal) GetEntry() (*JournalEntry, error) {
|
||||
}
|
||||
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to read message field: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to read message field: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
msg := C.GoStringN((*C.char)(d), C.int(l))
|
||||
kv := strings.SplitN(msg, "=", 2)
|
||||
if len(kv) < 2 {
|
||||
return nil, fmt.Errorf("failed to parse field")
|
||||
return nil, errors.New("failed to parse field")
|
||||
}
|
||||
|
||||
entry.Fields[kv[0]] = kv[1]
|
||||
@@ -820,7 +820,7 @@ func (j *Journal) SetDataThreshold(threshold uint64) error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to set data threshold: %s", syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to set data threshold: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -843,7 +843,7 @@ func (j *Journal) GetRealtimeUsec() (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to get realtime timestamp: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to get realtime timestamp: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(usec), nil
|
||||
@@ -867,7 +867,7 @@ func (j *Journal) GetMonotonicUsec() (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to get monotonic timestamp: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to get monotonic timestamp: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(usec), nil
|
||||
@@ -892,7 +892,7 @@ func (j *Journal) GetCursor() (string, error) {
|
||||
defer C.free(unsafe.Pointer(d))
|
||||
|
||||
if r < 0 {
|
||||
return "", fmt.Errorf("failed to get cursor: %s", syscall.Errno(-r).Error())
|
||||
return "", fmt.Errorf("failed to get cursor: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
cursor := C.GoString(d)
|
||||
@@ -916,7 +916,7 @@ func (j *Journal) TestCursor(cursor string) error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to test to cursor %q: %s", cursor, syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to test to cursor %q: %w", cursor, syscall.Errno(-r))
|
||||
} else if r == 0 {
|
||||
return ErrNoTestCursor
|
||||
}
|
||||
@@ -938,7 +938,7 @@ func (j *Journal) SeekHead() error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to seek to head of journal: %s", syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to seek to head of journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -958,7 +958,7 @@ func (j *Journal) SeekTail() error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to seek to tail of journal: %s", syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to seek to tail of journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -978,7 +978,7 @@ func (j *Journal) SeekRealtimeUsec(usec uint64) error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to seek to %d: %s", usec, syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to seek to %d: %w", usec, syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1001,7 +1001,7 @@ func (j *Journal) SeekCursor(cursor string) error {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return fmt.Errorf("failed to seek to cursor %q: %s", cursor, syscall.Errno(-r).Error())
|
||||
return fmt.Errorf("failed to seek to cursor %q: %w", cursor, syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1048,7 +1048,7 @@ func (j *Journal) GetUsage() (uint64, error) {
|
||||
j.mu.Unlock()
|
||||
|
||||
if r < 0 {
|
||||
return 0, fmt.Errorf("failed to get journal disk space usage: %s", syscall.Errno(-r).Error())
|
||||
return 0, fmt.Errorf("failed to get journal disk space usage: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
return uint64(out), nil
|
||||
@@ -1082,7 +1082,7 @@ func (j *Journal) GetUniqueValues(field string) ([]string, error) {
|
||||
r := C.my_sd_journal_query_unique(sd_journal_query_unique, j.cjournal, f)
|
||||
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to query journal: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to query journal: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
// Implements the SD_JOURNAL_FOREACH_UNIQUE macro from sd-journal.h
|
||||
@@ -1096,13 +1096,13 @@ func (j *Journal) GetUniqueValues(field string) ([]string, error) {
|
||||
}
|
||||
|
||||
if r < 0 {
|
||||
return nil, fmt.Errorf("failed to read message field: %s", syscall.Errno(-r).Error())
|
||||
return nil, fmt.Errorf("failed to read message field: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
msg := C.GoStringN((*C.char)(d), C.int(l))
|
||||
kv := strings.SplitN(msg, "=", 2)
|
||||
if len(kv) < 2 {
|
||||
return nil, fmt.Errorf("failed to parse field")
|
||||
return nil, errors.New("failed to parse field")
|
||||
}
|
||||
|
||||
result = append(result, kv[1])
|
||||
@@ -1128,7 +1128,7 @@ func (j *Journal) GetCatalog() (string, error) {
|
||||
defer C.free(unsafe.Pointer(c))
|
||||
|
||||
if r < 0 {
|
||||
return "", fmt.Errorf("failed to retrieve catalog entry for current journal entry: %s", syscall.Errno(-r).Error())
|
||||
return "", fmt.Errorf("failed to retrieve catalog entry for current journal entry: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
catalog := C.GoString(c)
|
||||
@@ -1146,7 +1146,7 @@ func (j *Journal) GetBootID() (string, error) {
|
||||
var boot_id C.sd_id128_t
|
||||
r := C.my_sd_id128_get_boot(sd_id128_get_boot, &boot_id)
|
||||
if r < 0 {
|
||||
return "", fmt.Errorf("failed to get boot id: %s", syscall.Errno(-r).Error())
|
||||
return "", fmt.Errorf("failed to get boot id: %w", syscall.Errno(-r))
|
||||
}
|
||||
|
||||
sd_id128_to_string, err := getFunction("sd_id128_to_string")
|
||||
|
||||
4
vendor/github.com/coreos/go-systemd/v22/sdjournal/read.go
generated
vendored
4
vendor/github.com/coreos/go-systemd/v22/sdjournal/read.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015 RedHat, Inc.
|
||||
// Copyright 2015 Red Hat, Inc.
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -258,7 +258,7 @@ process:
|
||||
func simpleMessageFormatter(entry *JournalEntry) (string, error) {
|
||||
msg, ok := entry.Fields["MESSAGE"]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("no MESSAGE field present in journal entry")
|
||||
return "", errors.New("no MESSAGE field present in journal entry")
|
||||
}
|
||||
|
||||
usec := entry.RealtimeTimestamp
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -181,7 +181,7 @@ github.com/coreos/go-oidc/v3/oidc
|
||||
# github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
|
||||
## explicit
|
||||
github.com/coreos/go-systemd/activation
|
||||
# github.com/coreos/go-systemd/v22 v22.6.0
|
||||
# github.com/coreos/go-systemd/v22 v22.7.0
|
||||
## explicit; go 1.23
|
||||
github.com/coreos/go-systemd/v22/activation
|
||||
github.com/coreos/go-systemd/v22/daemon
|
||||
|
||||
Reference in New Issue
Block a user