From c9d99dc98a19a39a0c0414234e1382ffc7f37016 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 12:42:37 +0000 Subject: [PATCH] fix(deps): update module github.com/godbus/dbus/v5 to v5.2.0 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/godbus/dbus/v5/.cirrus.yml | 3 +- vendor/github.com/godbus/dbus/v5/auth.go | 2 +- .../godbus/dbus/v5/auth_default_other.go | 8 ++ .../godbus/dbus/v5/auth_default_windows.go | 5 ++ .../v5/{auth_sha1.go => auth_sha1_windows.go} | 20 +++++ vendor/github.com/godbus/dbus/v5/call.go | 6 +- vendor/github.com/godbus/dbus/v5/conn.go | 22 +++--- .../github.com/godbus/dbus/v5/conn_other.go | 9 +-- vendor/github.com/godbus/dbus/v5/conn_unix.go | 23 ++++++ vendor/github.com/godbus/dbus/v5/dbus.go | 12 +-- vendor/github.com/godbus/dbus/v5/decoder.go | 10 +-- .../godbus/dbus/v5/default_handler.go | 14 ++-- vendor/github.com/godbus/dbus/v5/encoder.go | 4 +- vendor/github.com/godbus/dbus/v5/export.go | 74 +++++++++++++------ vendor/github.com/godbus/dbus/v5/homedir.go | 25 ------- vendor/github.com/godbus/dbus/v5/message.go | 4 +- vendor/github.com/godbus/dbus/v5/object.go | 26 +++---- .../godbus/dbus/v5/server_interfaces.go | 10 +-- vendor/github.com/godbus/dbus/v5/sig.go | 2 +- .../godbus/dbus/v5/transport_nonce_tcp.go | 2 + .../godbus/dbus/v5/transport_unix.go | 8 ++ vendor/github.com/godbus/dbus/v5/variant.go | 31 ++++++-- .../godbus/dbus/v5/variant_lexer.go | 2 +- .../godbus/dbus/v5/variant_parser.go | 36 ++++----- vendor/modules.txt | 2 +- 27 files changed, 224 insertions(+), 142 deletions(-) create mode 100644 vendor/github.com/godbus/dbus/v5/auth_default_other.go create mode 100644 vendor/github.com/godbus/dbus/v5/auth_default_windows.go rename vendor/github.com/godbus/dbus/v5/{auth_sha1.go => auth_sha1_windows.go} (81%) delete mode 100644 vendor/github.com/godbus/dbus/v5/homedir.go diff --git a/go.mod b/go.mod index 7cc6da26aa6..de441effa3d 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/docker/go-connections v0.6.0 github.com/docker/go-plugins-helpers v0.0.0-20240701071450-45e2431495c8 github.com/docker/go-units v0.5.0 - github.com/godbus/dbus/v5 v5.1.1-0.20241109141217-c266b19b28e9 + github.com/godbus/dbus/v5 v5.2.0 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.6.0 github.com/gorilla/handlers v1.5.2 diff --git a/go.sum b/go.sum index 5cdeae29002..84598b32427 100644 --- a/go.sum +++ b/go.sum @@ -159,8 +159,8 @@ github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= -github.com/godbus/dbus/v5 v5.1.1-0.20241109141217-c266b19b28e9 h1:Kzr9J0S0V2PRxiX6B6xw1kWjzsIyjLO2Ibi4fNTaYBM= -github.com/godbus/dbus/v5 v5.1.1-0.20241109141217-c266b19b28e9/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= +github.com/godbus/dbus/v5 v5.2.0 h1:3WexO+U+yg9T70v9FdHr9kCxYlazaAXUhx2VMkbfax8= +github.com/godbus/dbus/v5 v5.2.0/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= diff --git a/vendor/github.com/godbus/dbus/v5/.cirrus.yml b/vendor/github.com/godbus/dbus/v5/.cirrus.yml index 75a0d798aea..0c9b365d7ef 100644 --- a/vendor/github.com/godbus/dbus/v5/.cirrus.yml +++ b/vendor/github.com/godbus/dbus/v5/.cirrus.yml @@ -1,5 +1,6 @@ +# See https://cirrus-ci.org/guide/FreeBSD/ freebsd_instance: - image_family: freebsd-14-0 + image_family: freebsd-14-2 task: name: Test on FreeBSD diff --git a/vendor/github.com/godbus/dbus/v5/auth.go b/vendor/github.com/godbus/dbus/v5/auth.go index 5fecbd3d419..5924690b855 100644 --- a/vendor/github.com/godbus/dbus/v5/auth.go +++ b/vendor/github.com/godbus/dbus/v5/auth.go @@ -54,7 +54,7 @@ type Auth interface { func (conn *Conn) Auth(methods []Auth) error { if methods == nil { uid := strconv.Itoa(os.Geteuid()) - methods = []Auth{AuthExternal(uid), AuthCookieSha1(uid, getHomeDir())} + methods = getDefaultAuthMethods(uid) } in := bufio.NewReader(conn.transport) err := conn.transport.SendNullByte() diff --git a/vendor/github.com/godbus/dbus/v5/auth_default_other.go b/vendor/github.com/godbus/dbus/v5/auth_default_other.go new file mode 100644 index 00000000000..64c911dd349 --- /dev/null +++ b/vendor/github.com/godbus/dbus/v5/auth_default_other.go @@ -0,0 +1,8 @@ +//go:build !windows +// +build !windows + +package dbus + +func getDefaultAuthMethods(user string) []Auth { + return []Auth{AuthExternal(user)} +} diff --git a/vendor/github.com/godbus/dbus/v5/auth_default_windows.go b/vendor/github.com/godbus/dbus/v5/auth_default_windows.go new file mode 100644 index 00000000000..2289850a8e7 --- /dev/null +++ b/vendor/github.com/godbus/dbus/v5/auth_default_windows.go @@ -0,0 +1,5 @@ +package dbus + +func getDefaultAuthMethods(user string) []Auth { + return []Auth{AuthCookieSha1(user, getHomeDir())} +} diff --git a/vendor/github.com/godbus/dbus/v5/auth_sha1.go b/vendor/github.com/godbus/dbus/v5/auth_sha1_windows.go similarity index 81% rename from vendor/github.com/godbus/dbus/v5/auth_sha1.go rename to vendor/github.com/godbus/dbus/v5/auth_sha1_windows.go index 80286700b6d..fecc18a1e93 100644 --- a/vendor/github.com/godbus/dbus/v5/auth_sha1.go +++ b/vendor/github.com/godbus/dbus/v5/auth_sha1_windows.go @@ -7,6 +7,7 @@ import ( "crypto/sha1" "encoding/hex" "os" + "os/user" ) // AuthCookieSha1 returns an Auth that authenticates as the given user with the @@ -100,3 +101,22 @@ func (a authCookieSha1) generateChallenge() []byte { hex.Encode(enc, b) return enc } + +// Get returns the home directory of the current user, which is usually the +// value of HOME environment variable. In case it is not set or empty, os/user +// package is used. +// +// If linking statically with cgo enabled against glibc, make sure the +// osusergo build tag is used. +// +// If needing to do nss lookups, do not disable cgo or set osusergo. +func getHomeDir() string { + homeDir := os.Getenv("HOME") + if homeDir != "" { + return homeDir + } + if u, err := user.Current(); err == nil { + return u.HomeDir + } + return "/" +} diff --git a/vendor/github.com/godbus/dbus/v5/call.go b/vendor/github.com/godbus/dbus/v5/call.go index ac01ec669fc..d16171ab91d 100644 --- a/vendor/github.com/godbus/dbus/v5/call.go +++ b/vendor/github.com/godbus/dbus/v5/call.go @@ -9,7 +9,7 @@ type Call struct { Destination string Path ObjectPath Method string - Args []interface{} + Args []any // Strobes when the call is complete. Done chan *Call @@ -19,7 +19,7 @@ type Call struct { Err error // Holds the response once the call is done. - Body []interface{} + Body []any // ResponseSequence stores the sequence number of the DBus message containing // the call response (or error). This can be compared to the sequence number @@ -52,7 +52,7 @@ func (c *Call) ContextCancel() { // Store stores the body of the reply into the provided pointers. It returns // an error if the signatures of the body and retvalues don't match, or if // the error status is not nil. -func (c *Call) Store(retvalues ...interface{}) error { +func (c *Call) Store(retvalues ...any) error { if c.Err != nil { return c.Err } diff --git a/vendor/github.com/godbus/dbus/v5/conn.go b/vendor/github.com/godbus/dbus/v5/conn.go index af6be85066b..4551be6305d 100644 --- a/vendor/github.com/godbus/dbus/v5/conn.go +++ b/vendor/github.com/godbus/dbus/v5/conn.go @@ -97,7 +97,7 @@ func SessionBusPrivate(opts ...ConnOption) (*Conn, error) { return Dial(address, opts...) } -// SessionBusPrivate returns a new private connection to the session bus. If +// SessionBusPrivateNoAutoStartup returns a new private connection to the session bus. If // the session bus is not already open, do not attempt to launch it. func SessionBusPrivateNoAutoStartup(opts ...ConnOption) (*Conn, error) { address, err := getSessionBusAddress(false) @@ -108,7 +108,7 @@ func SessionBusPrivateNoAutoStartup(opts ...ConnOption) (*Conn, error) { return Dial(address, opts...) } -// SessionBusPrivate returns a new private connection to the session bus. +// SessionBusPrivateHandler returns a new private connection to the session bus. // // Deprecated: use SessionBusPrivate with options instead. func SessionBusPrivateHandler(handler Handler, signalHandler SignalHandler) (*Conn, error) { @@ -625,7 +625,7 @@ func (conn *Conn) sendError(err error, dest string, serial uint32) { // sendReply creates a method reply message corresponding to the parameters and // sends it to conn.out. -func (conn *Conn) sendReply(dest string, serial uint32, values ...interface{}) { +func (conn *Conn) sendReply(dest string, serial uint32, values ...any) { msg := new(Message) msg.Type = TypeMethodReply msg.Headers = make(map[HeaderField]Variant) @@ -713,10 +713,10 @@ func (conn *Conn) SupportsUnixFDs() bool { // Error represents a D-Bus message of type Error. type Error struct { Name string - Body []interface{} + Body []any } -func NewError(name string, body []interface{}) *Error { +func NewError(name string, body []any) *Error { return &Error{name, body} } @@ -736,7 +736,7 @@ type Signal struct { Sender string Path ObjectPath Name string - Body []interface{} + Body []any Sequence Sequence } @@ -787,10 +787,10 @@ func getTransport(address string) (transport, error) { // getKey gets a key from a the list of keys. Returns "" on error / not found... func getKey(s, key string) string { - for _, keyEqualsValue := range strings.Split(s, ",") { - keyValue := strings.SplitN(keyEqualsValue, "=", 2) - if len(keyValue) == 2 && keyValue[0] == key { - val, err := UnescapeBusAddressValue(keyValue[1]) + keyEq := key + "=" + for _, kv := range strings.Split(s, ",") { + if v, ok := strings.CutPrefix(kv, keyEq); ok { + val, err := UnescapeBusAddressValue(v) if err != nil { // No way to return an error. return "" @@ -963,7 +963,7 @@ func (tracker *callTracker) handleSendError(msg *Message, err error) { } } -func (tracker *callTracker) finalizeWithBody(sn uint32, sequence Sequence, body []interface{}) { +func (tracker *callTracker) finalizeWithBody(sn uint32, sequence Sequence, body []any) { tracker.lck.Lock() c, ok := tracker.calls[sn] if ok { diff --git a/vendor/github.com/godbus/dbus/v5/conn_other.go b/vendor/github.com/godbus/dbus/v5/conn_other.go index 1e9959446aa..9c1284c2745 100644 --- a/vendor/github.com/godbus/dbus/v5/conn_other.go +++ b/vendor/github.com/godbus/dbus/v5/conn_other.go @@ -61,13 +61,8 @@ func tryDiscoverDbusSessionBusAddress() string { // DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E1c73yNqrG if f, err := os.ReadFile(runUserSessionDbusFile); err == nil { - fileContent := string(f) - - prefix := "DBUS_SESSION_BUS_ADDRESS=" - - if strings.HasPrefix(fileContent, prefix) { - address := strings.TrimRight(strings.TrimPrefix(fileContent, prefix), "\n\r") - return address + if addr, ok := strings.CutPrefix(string(f), "DBUS_SESSION_BUS_ADDRESS="); ok { + return strings.TrimRight(addr, "\n\r") } } } diff --git a/vendor/github.com/godbus/dbus/v5/conn_unix.go b/vendor/github.com/godbus/dbus/v5/conn_unix.go index 1a0daa6566c..84e1dc652dd 100644 --- a/vendor/github.com/godbus/dbus/v5/conn_unix.go +++ b/vendor/github.com/godbus/dbus/v5/conn_unix.go @@ -4,6 +4,7 @@ package dbus import ( + "net" "os" ) @@ -16,3 +17,25 @@ func getSystemBusPlatformAddress() string { } return defaultSystemBusAddress } + +// DialUnix establishes a new private connection to the message bus specified by UnixConn. +func DialUnix(conn *net.UnixConn, opts ...ConnOption) (*Conn, error) { + tr := newUnixTransportFromConn(conn) + return newConn(tr, opts...) +} + +func ConnectUnix(uconn *net.UnixConn, opts ...ConnOption) (*Conn, error) { + conn, err := DialUnix(uconn, opts...) + if err != nil { + return nil, err + } + if err = conn.Auth(conn.auth); err != nil { + _ = conn.Close() + return nil, err + } + if err = conn.Hello(); err != nil { + _ = conn.Close() + return nil, err + } + return conn, nil +} diff --git a/vendor/github.com/godbus/dbus/v5/dbus.go b/vendor/github.com/godbus/dbus/v5/dbus.go index 8f152dc2f30..d3622d80794 100644 --- a/vendor/github.com/godbus/dbus/v5/dbus.go +++ b/vendor/github.com/godbus/dbus/v5/dbus.go @@ -21,8 +21,8 @@ var ( signatureType = reflect.TypeOf(Signature{""}) objectPathType = reflect.TypeOf(ObjectPath("")) variantType = reflect.TypeOf(Variant{Signature{""}, nil}) - interfacesType = reflect.TypeOf([]interface{}{}) - interfaceType = reflect.TypeOf((*interface{})(nil)).Elem() + interfacesType = reflect.TypeOf([]any{}) + interfaceType = reflect.TypeOf((*any)(nil)).Elem() unixFDType = reflect.TypeOf(UnixFD(0)) unixFDIndexType = reflect.TypeOf(UnixFDIndex(0)) errType = reflect.TypeOf((*error)(nil)).Elem() @@ -42,7 +42,7 @@ func (e InvalidTypeError) Error() string { // pointers. It converts slices of interfaces from src to corresponding structs // in dest. An error is returned if the lengths of src and dest or the types of // their elements don't match. -func Store(src []interface{}, dest ...interface{}) error { +func Store(src []any, dest ...any) error { if len(src) != len(dest) { return errors.New("dbus.Store: length mismatch") } @@ -55,7 +55,7 @@ func Store(src []interface{}, dest ...interface{}) error { return nil } -func storeInterfaces(src, dest interface{}) error { +func storeInterfaces(src, dest any) error { return store(reflect.ValueOf(dest), reflect.ValueOf(src)) } @@ -222,7 +222,7 @@ func storeStruct(dest, src reflect.Value) error { if isVariant(dest.Type()) { return storeBase(dest, src) } - dval := make([]interface{}, 0, dest.NumField()) + dval := make([]any, 0, dest.NumField()) dtype := dest.Type() for i := 0; i < dest.NumField(); i++ { field := dest.Field(i) @@ -242,7 +242,7 @@ func storeStruct(dest, src reflect.Value) error { "enough fields need: %d have: %d", src.Len(), len(dval)) } - return Store(src.Interface().([]interface{}), dval...) + return Store(src.Interface().([]any), dval...) } func storeSliceIntoVariant(dest, src reflect.Value) error { diff --git a/vendor/github.com/godbus/dbus/v5/decoder.go b/vendor/github.com/godbus/dbus/v5/decoder.go index d03bdd8e877..1e6198f5bf1 100644 --- a/vendor/github.com/godbus/dbus/v5/decoder.go +++ b/vendor/github.com/godbus/dbus/v5/decoder.go @@ -53,13 +53,13 @@ func (dec *decoder) align(n int) { } // Calls binary.Read(dec.in, dec.order, v) and panics on read errors. -func (dec *decoder) binread(v interface{}) { +func (dec *decoder) binread(v any) { if err := binary.Read(dec.in, dec.order, v); err != nil { panic(err) } } -func (dec *decoder) Decode(sig Signature) (vs []interface{}, err error) { +func (dec *decoder) Decode(sig Signature) (vs []any, err error) { defer func() { var ok bool v := recover() @@ -69,7 +69,7 @@ func (dec *decoder) Decode(sig Signature) (vs []interface{}, err error) { } } }() - vs = make([]interface{}, 0) + vs = make([]any, 0) s := sig.str for s != "" { err, rem := validSingle(s, &depthCounter{}) @@ -106,7 +106,7 @@ func (dec *decoder) decodeU() uint32 { return dec.order.Uint32(dec.buf) } -func (dec *decoder) decode(s string, depth int) interface{} { +func (dec *decoder) decode(s string, depth int) any { dec.align(alignment(typeFor(s))) switch s[0] { case 'y': @@ -249,7 +249,7 @@ func (dec *decoder) decode(s string, depth int) interface{} { panic(FormatError("input exceeds container depth limit")) } dec.align(8) - v := make([]interface{}, 0) + v := make([]any, 0) s = s[1 : len(s)-1] for s != "" { err, rem := validSingle(s, &depthCounter{}) diff --git a/vendor/github.com/godbus/dbus/v5/default_handler.go b/vendor/github.com/godbus/dbus/v5/default_handler.go index 3da16b1ecb7..c17ab0b97de 100644 --- a/vendor/github.com/godbus/dbus/v5/default_handler.go +++ b/vendor/github.com/godbus/dbus/v5/default_handler.go @@ -52,9 +52,9 @@ func (h *defaultHandler) introspectPath(path ObjectPath) string { if p != "/" { p += "/" } - if strings.HasPrefix(string(obj), p) { - node_name := strings.Split(string(obj[len(p):]), "/")[0] - subpath[node_name] = struct{}{} + if after, ok := strings.CutPrefix(string(obj), p); ok { + name, _, _ := strings.Cut(after, "/") + subpath[name] = struct{}{} } } for s := range subpath { @@ -117,7 +117,7 @@ type exportedMethod struct { reflect.Value } -func (m exportedMethod) Call(args ...interface{}) ([]interface{}, error) { +func (m exportedMethod) Call(args ...any) ([]any, error) { t := m.Type() params := make([]reflect.Value, len(args)) @@ -143,7 +143,7 @@ func (m exportedMethod) Call(args ...interface{}) ([]interface{}, error) { ret = ret[:t.NumOut()-1] } } - out := make([]interface{}, len(ret)) + out := make([]any, len(ret)) for i, val := range ret { out[i] = val.Interface() } @@ -158,7 +158,7 @@ func (m exportedMethod) NumArguments() int { return m.Value.Type().NumIn() } -func (m exportedMethod) ArgumentValue(i int) interface{} { +func (m exportedMethod) ArgumentValue(i int) any { return reflect.Zero(m.Type().In(i)).Interface() } @@ -166,7 +166,7 @@ func (m exportedMethod) NumReturns() int { return m.Value.Type().NumOut() } -func (m exportedMethod) ReturnValue(i int) interface{} { +func (m exportedMethod) ReturnValue(i int) any { return reflect.Zero(m.Type().Out(i)).Interface() } diff --git a/vendor/github.com/godbus/dbus/v5/encoder.go b/vendor/github.com/godbus/dbus/v5/encoder.go index 015b26cd5c4..5901ab42a9c 100644 --- a/vendor/github.com/godbus/dbus/v5/encoder.go +++ b/vendor/github.com/godbus/dbus/v5/encoder.go @@ -59,7 +59,7 @@ func (enc *encoder) padding(offset, algn int) int { } // Calls binary.Write(enc.out, enc.order, v) and panics on write errors. -func (enc *encoder) binwrite(v interface{}) { +func (enc *encoder) binwrite(v any) { if err := binary.Write(enc.out, enc.order, v); err != nil { panic(err) } @@ -67,7 +67,7 @@ func (enc *encoder) binwrite(v interface{}) { // Encode encodes the given values to the underlying reader. All written values // are aligned properly as required by the D-Bus spec. -func (enc *encoder) Encode(vs ...interface{}) (err error) { +func (enc *encoder) Encode(vs ...any) (err error) { defer func() { err, _ = recover().(error) }() diff --git a/vendor/github.com/godbus/dbus/v5/export.go b/vendor/github.com/godbus/dbus/v5/export.go index fa009d2ce41..20d8cb38fa4 100644 --- a/vendor/github.com/godbus/dbus/v5/export.go +++ b/vendor/github.com/godbus/dbus/v5/export.go @@ -11,47 +11,47 @@ import ( var ( ErrMsgInvalidArg = Error{ "org.freedesktop.DBus.Error.InvalidArgs", - []interface{}{"Invalid type / number of args"}, + []any{"Invalid type / number of args"}, } ErrMsgNoObject = Error{ "org.freedesktop.DBus.Error.NoSuchObject", - []interface{}{"No such object"}, + []any{"No such object"}, } ErrMsgUnknownMethod = Error{ "org.freedesktop.DBus.Error.UnknownMethod", - []interface{}{"Unknown / invalid method"}, + []any{"Unknown / invalid method"}, } ErrMsgUnknownInterface = Error{ "org.freedesktop.DBus.Error.UnknownInterface", - []interface{}{"Object does not implement the interface"}, + []any{"Object does not implement the interface"}, } ) func MakeNoObjectError(path ObjectPath) Error { return Error{ "org.freedesktop.DBus.Error.NoSuchObject", - []interface{}{fmt.Sprintf("No such object '%s'", string(path))}, + []any{fmt.Sprintf("No such object '%s'", string(path))}, } } func MakeUnknownMethodError(methodName string) Error { return Error{ "org.freedesktop.DBus.Error.UnknownMethod", - []interface{}{fmt.Sprintf("Unknown / invalid method '%s'", methodName)}, + []any{fmt.Sprintf("Unknown / invalid method '%s'", methodName)}, } } func MakeUnknownInterfaceError(ifaceName string) Error { return Error{ "org.freedesktop.DBus.Error.UnknownInterface", - []interface{}{fmt.Sprintf("Object does not implement the interface '%s'", ifaceName)}, + []any{fmt.Sprintf("Object does not implement the interface '%s'", ifaceName)}, } } func MakeFailedError(err error) *Error { return &Error{ "org.freedesktop.DBus.Error.Failed", - []interface{}{err.Error()}, + []any{err.Error()}, } } @@ -67,7 +67,7 @@ func computeMethodName(name string, mapping map[string]string) string { return name } -func getMethods(in interface{}, mapping map[string]string) map[string]reflect.Value { +func getMethods(in any, mapping map[string]string) map[string]reflect.Value { if in == nil { return nil } @@ -91,7 +91,7 @@ func getMethods(in interface{}, mapping map[string]string) map[string]reflect.Va return methods } -func getAllMethods(in interface{}, mapping map[string]string) map[string]reflect.Value { +func getAllMethods(in any, mapping map[string]string) map[string]reflect.Value { if in == nil { return nil } @@ -107,9 +107,9 @@ func getAllMethods(in interface{}, mapping map[string]string) map[string]reflect return methods } -func standardMethodArgumentDecode(m Method, sender string, msg *Message, body []interface{}) ([]interface{}, error) { - pointers := make([]interface{}, m.NumArguments()) - decode := make([]interface{}, 0, len(body)) +func standardMethodArgumentDecode(m Method, sender string, msg *Message, body []any) ([]any, error) { + pointers := make([]any, m.NumArguments()) + decode := make([]any, 0, len(body)) for i := 0; i < m.NumArguments(); i++ { tp := reflect.TypeOf(m.ArgumentValue(i)) @@ -135,7 +135,7 @@ func standardMethodArgumentDecode(m Method, sender string, msg *Message, body [] return pointers, nil } -func (conn *Conn) decodeArguments(m Method, sender string, msg *Message) ([]interface{}, error) { +func (conn *Conn) decodeArguments(m Method, sender string, msg *Message) ([]any, error) { if decoder, ok := m.(ArgumentDecoder); ok { return decoder.DecodeArguments(conn, sender, msg, msg.Body) } @@ -204,7 +204,7 @@ func (conn *Conn) handleCall(msg *Message) { reply.Headers[FieldDestination] = msg.Headers[FieldSender] } reply.Headers[FieldReplySerial] = MakeVariant(msg.serial) - reply.Body = make([]interface{}, len(ret)) + reply.Body = make([]any, len(ret)) copy(reply.Body, ret) reply.Headers[FieldSignature] = MakeVariant(SignatureOf(reply.Body...)) @@ -218,7 +218,7 @@ func (conn *Conn) handleCall(msg *Message) { // Emit emits the given signal on the message bus. The name parameter must be // formatted as "interface.member", e.g., "org.freedesktop.DBus.NameLost". -func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) error { +func (conn *Conn) Emit(path ObjectPath, name string, values ...any) error { i := strings.LastIndex(name, ".") if i == -1 { return errors.New("dbus: invalid method name") @@ -274,7 +274,7 @@ func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) erro // the given combination of path and interface. // // Export returns an error if path is not a valid path name. -func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error { +func (conn *Conn) Export(v any, path ObjectPath, iface string) error { return conn.ExportWithMap(v, nil, path, iface) } @@ -286,7 +286,7 @@ func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error { // type parameter to your method signature. If the error returned is not nil, // it is sent back to the caller as an error. Otherwise, a method reply is // sent with the other return values as its body. -func (conn *Conn) ExportAll(v interface{}, path ObjectPath, iface string) error { +func (conn *Conn) ExportAll(v any, path ObjectPath, iface string) error { return conn.export(getAllMethods(v, nil), path, iface, false) } @@ -295,7 +295,7 @@ func (conn *Conn) ExportAll(v interface{}, path ObjectPath, iface string) error // // The keys in the map are the real method names (exported on the struct), and // the values are the method names to be exported on DBus. -func (conn *Conn) ExportWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error { +func (conn *Conn) ExportWithMap(v any, mapping map[string]string, path ObjectPath, iface string) error { return conn.export(getMethods(v, mapping), path, iface, false) } @@ -309,7 +309,7 @@ func (conn *Conn) ExportWithMap(v interface{}, mapping map[string]string, path O // Note that more specific export paths take precedence over less specific. For // example, a method call using the ObjectPath /foo/bar/baz will call a method // exported on /foo/bar before a method exported on /foo. -func (conn *Conn) ExportSubtree(v interface{}, path ObjectPath, iface string) error { +func (conn *Conn) ExportSubtree(v any, path ObjectPath, iface string) error { return conn.ExportSubtreeWithMap(v, nil, path, iface) } @@ -318,7 +318,7 @@ func (conn *Conn) ExportSubtree(v interface{}, path ObjectPath, iface string) er // // The keys in the map are the real method names (exported on the struct), and // the values are the method names to be exported on DBus. -func (conn *Conn) ExportSubtreeWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error { +func (conn *Conn) ExportSubtreeWithMap(v any, mapping map[string]string, path ObjectPath, iface string) error { return conn.export(getMethods(v, mapping), path, iface, true) } @@ -332,16 +332,16 @@ func (conn *Conn) ExportSubtreeWithMap(v interface{}, mapping map[string]string, // methods on the fly. // // Any non-function objects in the method table are ignored. -func (conn *Conn) ExportMethodTable(methods map[string]interface{}, path ObjectPath, iface string) error { +func (conn *Conn) ExportMethodTable(methods map[string]any, path ObjectPath, iface string) error { return conn.exportMethodTable(methods, path, iface, false) } // Like ExportSubtree, but with the same caveats as ExportMethodTable. -func (conn *Conn) ExportSubtreeMethodTable(methods map[string]interface{}, path ObjectPath, iface string) error { +func (conn *Conn) ExportSubtreeMethodTable(methods map[string]any, path ObjectPath, iface string) error { return conn.exportMethodTable(methods, path, iface, true) } -func (conn *Conn) exportMethodTable(methods map[string]interface{}, path ObjectPath, iface string, includeSubtree bool) error { +func (conn *Conn) exportMethodTable(methods map[string]any, path ObjectPath, iface string, includeSubtree bool) error { var out map[string]reflect.Value if methods != nil { out = make(map[string]reflect.Value) @@ -438,6 +438,18 @@ const ( ReleaseNameReplyNotOwner ) +func (rep ReleaseNameReply) String() string { + switch rep { + case ReleaseNameReplyReleased: + return "released" + case ReleaseNameReplyNonExistent: + return "non existent" + case ReleaseNameReplyNotOwner: + return "not owner" + } + return "unknown" +} + // RequestNameFlags represents the possible flags for a RequestName call. type RequestNameFlags uint32 @@ -456,3 +468,17 @@ const ( RequestNameReplyExists RequestNameReplyAlreadyOwner ) + +func (rep RequestNameReply) String() string { + switch rep { + case RequestNameReplyPrimaryOwner: + return "primary owner" + case RequestNameReplyInQueue: + return "in queue" + case RequestNameReplyExists: + return "exists" + case RequestNameReplyAlreadyOwner: + return "already owner" + } + return "unknown" +} diff --git a/vendor/github.com/godbus/dbus/v5/homedir.go b/vendor/github.com/godbus/dbus/v5/homedir.go deleted file mode 100644 index c44d9b5fc24..00000000000 --- a/vendor/github.com/godbus/dbus/v5/homedir.go +++ /dev/null @@ -1,25 +0,0 @@ -package dbus - -import ( - "os" - "os/user" -) - -// Get returns the home directory of the current user, which is usually the -// value of HOME environment variable. In case it is not set or empty, os/user -// package is used. -// -// If linking statically with cgo enabled against glibc, make sure the -// osusergo build tag is used. -// -// If needing to do nss lookups, do not disable cgo or set osusergo. -func getHomeDir() string { - homeDir := os.Getenv("HOME") - if homeDir != "" { - return homeDir - } - if u, err := user.Current(); err == nil { - return u.HomeDir - } - return "/" -} diff --git a/vendor/github.com/godbus/dbus/v5/message.go b/vendor/github.com/godbus/dbus/v5/message.go index 5ab6e9d9a15..097ca3a7fa8 100644 --- a/vendor/github.com/godbus/dbus/v5/message.go +++ b/vendor/github.com/godbus/dbus/v5/message.go @@ -108,7 +108,7 @@ type Message struct { Type Flags Headers map[HeaderField]Variant - Body []interface{} + Body []any serial uint32 } @@ -232,7 +232,7 @@ func (msg *Message) EncodeToWithFDs(out io.Writer, order binary.ByteOrder) (fds if err := msg.validateHeader(); err != nil { return nil, err } - var vs [7]interface{} + var vs [7]any switch order { case binary.LittleEndian: vs[0] = byte('l') diff --git a/vendor/github.com/godbus/dbus/v5/object.go b/vendor/github.com/godbus/dbus/v5/object.go index b4b1e939b39..954d3807123 100644 --- a/vendor/github.com/godbus/dbus/v5/object.go +++ b/vendor/github.com/godbus/dbus/v5/object.go @@ -9,15 +9,15 @@ import ( // BusObject is the interface of a remote object on which methods can be // invoked. type BusObject interface { - Call(method string, flags Flags, args ...interface{}) *Call - CallWithContext(ctx context.Context, method string, flags Flags, args ...interface{}) *Call - Go(method string, flags Flags, ch chan *Call, args ...interface{}) *Call - GoWithContext(ctx context.Context, method string, flags Flags, ch chan *Call, args ...interface{}) *Call + Call(method string, flags Flags, args ...any) *Call + CallWithContext(ctx context.Context, method string, flags Flags, args ...any) *Call + Go(method string, flags Flags, ch chan *Call, args ...any) *Call + GoWithContext(ctx context.Context, method string, flags Flags, ch chan *Call, args ...any) *Call AddMatchSignal(iface, member string, options ...MatchOption) *Call RemoveMatchSignal(iface, member string, options ...MatchOption) *Call GetProperty(p string) (Variant, error) - StoreProperty(p string, value interface{}) error - SetProperty(p string, v interface{}) error + StoreProperty(p string, value any) error + SetProperty(p string, v any) error Destination() string Path() ObjectPath } @@ -30,12 +30,12 @@ type Object struct { } // Call calls a method with (*Object).Go and waits for its reply. -func (o *Object) Call(method string, flags Flags, args ...interface{}) *Call { +func (o *Object) Call(method string, flags Flags, args ...any) *Call { return <-o.createCall(context.Background(), method, flags, make(chan *Call, 1), args...).Done } // CallWithContext acts like Call but takes a context -func (o *Object) CallWithContext(ctx context.Context, method string, flags Flags, args ...interface{}) *Call { +func (o *Object) CallWithContext(ctx context.Context, method string, flags Flags, args ...any) *Call { return <-o.createCall(ctx, method, flags, make(chan *Call, 1), args...).Done } @@ -89,16 +89,16 @@ func (o *Object) RemoveMatchSignal(iface, member string, options ...MatchOption) // // If the method parameter contains a dot ('.'), the part before the last dot // specifies the interface on which the method is called. -func (o *Object) Go(method string, flags Flags, ch chan *Call, args ...interface{}) *Call { +func (o *Object) Go(method string, flags Flags, ch chan *Call, args ...any) *Call { return o.createCall(context.Background(), method, flags, ch, args...) } // GoWithContext acts like Go but takes a context -func (o *Object) GoWithContext(ctx context.Context, method string, flags Flags, ch chan *Call, args ...interface{}) *Call { +func (o *Object) GoWithContext(ctx context.Context, method string, flags Flags, ch chan *Call, args ...any) *Call { return o.createCall(ctx, method, flags, ch, args...) } -func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch chan *Call, args ...interface{}) *Call { +func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch chan *Call, args ...any) *Call { if ctx == nil { panic("nil context") } @@ -136,7 +136,7 @@ func (o *Object) GetProperty(p string) (Variant, error) { // StoreProperty calls org.freedesktop.DBus.Properties.Get on the given // object. The property name must be given in interface.member notation. // It stores the returned property into the provided value. -func (o *Object) StoreProperty(p string, value interface{}) error { +func (o *Object) StoreProperty(p string, value any) error { idx := strings.LastIndex(p, ".") if idx == -1 || idx+1 == len(p) { return errors.New("dbus: invalid property " + p) @@ -152,7 +152,7 @@ func (o *Object) StoreProperty(p string, value interface{}) error { // SetProperty calls org.freedesktop.DBus.Properties.Set on the given // object. The property name must be given in interface.member notation. // Panics if v is not a valid Variant type. -func (o *Object) SetProperty(p string, v interface{}) error { +func (o *Object) SetProperty(p string, v any) error { // v might already be a variant... variant, ok := v.(Variant) if !ok { diff --git a/vendor/github.com/godbus/dbus/v5/server_interfaces.go b/vendor/github.com/godbus/dbus/v5/server_interfaces.go index aef3c772fa0..24d4ad6329b 100644 --- a/vendor/github.com/godbus/dbus/v5/server_interfaces.go +++ b/vendor/github.com/godbus/dbus/v5/server_interfaces.go @@ -38,17 +38,17 @@ type Interface interface { // A Method represents the exposed methods on D-Bus. type Method interface { // Call requires that all arguments are decoded before being passed to it. - Call(args ...interface{}) ([]interface{}, error) + Call(args ...any) ([]any, error) NumArguments() int NumReturns() int // ArgumentValue returns a representative value for the argument at position // it should be of the proper type. reflect.Zero would be a good mechanism // to use for this Value. - ArgumentValue(position int) interface{} + ArgumentValue(position int) any // ReturnValue returns a representative value for the return at position // it should be of the proper type. reflect.Zero would be a good mechanism // to use for this Value. - ReturnValue(position int) interface{} + ReturnValue(position int) any } // An Argument Decoder can decode arguments using the non-standard mechanism @@ -65,7 +65,7 @@ type ArgumentDecoder interface { // To decode the arguments of a method the sender and message are // provided in case the semantics of the implementer provides access // to these as part of the method invocation. - DecodeArguments(conn *Conn, sender string, msg *Message, args []interface{}) ([]interface{}, error) + DecodeArguments(conn *Conn, sender string, msg *Message, args []any) ([]any, error) } // A SignalHandler is responsible for delivering a signal. @@ -93,7 +93,7 @@ type SignalRegistrar interface { // "org.freedesktop.DBus.Error.Failed" error. By implementing this // interface as well a custom encoding may be provided. type DBusError interface { - DBusError() (string, []interface{}) + DBusError() (string, []any) } // SerialGenerator is responsible for serials generation. diff --git a/vendor/github.com/godbus/dbus/v5/sig.go b/vendor/github.com/godbus/dbus/v5/sig.go index 5bd797b62fc..ed5accc94d2 100644 --- a/vendor/github.com/godbus/dbus/v5/sig.go +++ b/vendor/github.com/godbus/dbus/v5/sig.go @@ -31,7 +31,7 @@ type Signature struct { // SignatureOf returns the concatenation of all the signatures of the given // values. It panics if one of them is not representable in D-Bus. -func SignatureOf(vs ...interface{}) Signature { +func SignatureOf(vs ...any) Signature { var s string for _, v := range vs { s += getSignature(reflect.TypeOf(v), &depthCounter{}) diff --git a/vendor/github.com/godbus/dbus/v5/transport_nonce_tcp.go b/vendor/github.com/godbus/dbus/v5/transport_nonce_tcp.go index a08d0891ce1..916e17b6eef 100644 --- a/vendor/github.com/godbus/dbus/v5/transport_nonce_tcp.go +++ b/vendor/github.com/godbus/dbus/v5/transport_nonce_tcp.go @@ -30,10 +30,12 @@ func newNonceTcpTransport(keys string) (transport, error) { } b, err := os.ReadFile(noncefile) if err != nil { + socket.Close() return nil, err } _, err = socket.Write(b) if err != nil { + socket.Close() return nil, err } return NewConn(socket) diff --git a/vendor/github.com/godbus/dbus/v5/transport_unix.go b/vendor/github.com/godbus/dbus/v5/transport_unix.go index 6840387a5f5..6a59637ae8a 100644 --- a/vendor/github.com/godbus/dbus/v5/transport_unix.go +++ b/vendor/github.com/godbus/dbus/v5/transport_unix.go @@ -55,6 +55,14 @@ type unixTransport struct { hasUnixFDs bool } +func newUnixTransportFromConn(conn *net.UnixConn) transport { + t := new(unixTransport) + t.UnixConn = conn + t.hasUnixFDs = true + + return t +} + func newUnixTransport(keys string) (transport, error) { var err error diff --git a/vendor/github.com/godbus/dbus/v5/variant.go b/vendor/github.com/godbus/dbus/v5/variant.go index ca3dbe16a44..bf98ddea735 100644 --- a/vendor/github.com/godbus/dbus/v5/variant.go +++ b/vendor/github.com/godbus/dbus/v5/variant.go @@ -11,17 +11,17 @@ import ( // Variant represents the D-Bus variant type. type Variant struct { sig Signature - value interface{} + value any } // MakeVariant converts the given value to a Variant. It panics if v cannot be // represented as a D-Bus type. -func MakeVariant(v interface{}) Variant { +func MakeVariant(v any) Variant { return MakeVariantWithSignature(v, SignatureOf(v)) } // MakeVariantWithSignature converts the given value to a Variant. -func MakeVariantWithSignature(v interface{}, s Signature) Variant { +func MakeVariantWithSignature(v any, s Signature) Variant { return Variant{s, v} } @@ -73,7 +73,7 @@ func (v Variant) format() (string, bool) { } rv := reflect.ValueOf(v.value) switch rv.Kind() { - case reflect.Slice: + case reflect.Slice, reflect.Array: if rv.Len() == 0 { return "[]", false } @@ -119,6 +119,25 @@ func (v Variant) format() (string, bool) { } buf.WriteByte('}') return buf.String(), unamb + case reflect.Struct: + if rv.NumField() == 0 { + return "()", false + } + unamb := true + var buf bytes.Buffer + buf.WriteByte('(') + for i := 0; i < rv.NumField(); i++ { + s, b := MakeVariant(rv.Field(i).Interface()).format() + unamb = unamb && b + buf.WriteString(s) + buf.WriteString(",") + if i != rv.NumField()-1 { + buf.WriteString(" ") + } + } + buf.WriteByte(')') + return buf.String(), unamb + } return `"INVALID"`, true } @@ -139,12 +158,12 @@ func (v Variant) String() string { } // Value returns the underlying value of v. -func (v Variant) Value() interface{} { +func (v Variant) Value() any { return v.value } // Store converts the variant into a native go type using the same // mechanism as the "Store" function. -func (v Variant) Store(value interface{}) error { +func (v Variant) Store(value any) error { return storeInterfaces(v.value, value) } diff --git a/vendor/github.com/godbus/dbus/v5/variant_lexer.go b/vendor/github.com/godbus/dbus/v5/variant_lexer.go index bf1398c8f05..a0649c5ca51 100644 --- a/vendor/github.com/godbus/dbus/v5/variant_lexer.go +++ b/vendor/github.com/godbus/dbus/v5/variant_lexer.go @@ -67,7 +67,7 @@ func (l *varLexer) emit(t varTokenType) { l.start = l.pos } -func (l *varLexer) errorf(format string, v ...interface{}) lexState { +func (l *varLexer) errorf(format string, v ...any) lexState { l.tokens = append(l.tokens, varToken{ tokError, fmt.Sprintf(format, v...), diff --git a/vendor/github.com/godbus/dbus/v5/variant_parser.go b/vendor/github.com/godbus/dbus/v5/variant_parser.go index 9532e36f3cc..3f45f0a757c 100644 --- a/vendor/github.com/godbus/dbus/v5/variant_parser.go +++ b/vendor/github.com/godbus/dbus/v5/variant_parser.go @@ -33,7 +33,7 @@ type varNode interface { Infer() (Signature, error) String() string Sigs() sigSet - Value(Signature) (interface{}, error) + Value(Signature) (any, error) } func varMakeNode(p *varParser) (varNode, error) { @@ -134,7 +134,7 @@ func (s sigSet) ToArray() sigSet { type numNode struct { sig Signature str string - val interface{} + val any } var numSigSet = sigSet{ @@ -169,7 +169,7 @@ func (n numNode) Sigs() sigSet { return numSigSet } -func (n numNode) Value(sig Signature) (interface{}, error) { +func (n numNode) Value(sig Signature) (any, error) { if n.sig.str != "" && n.sig != sig { return nil, varTypeError{n.str, sig} } @@ -190,7 +190,7 @@ func varMakeNumNode(tok varToken, sig Signature) (varNode, error) { return numNode{sig: sig, val: num}, nil } -func varNumAs(s string, sig Signature) (interface{}, error) { +func varNumAs(s string, sig Signature) (any, error) { isUnsigned := false size := 32 switch sig.str { @@ -220,20 +220,20 @@ func varNumAs(s string, sig Signature) (interface{}, error) { return nil, varTypeError{s, sig} } base := 10 - if strings.HasPrefix(s, "0x") { + if after, ok := strings.CutPrefix(s, "0x"); ok { base = 16 - s = s[2:] + s = after } - if strings.HasPrefix(s, "0") && len(s) != 1 { + if after, ok := strings.CutPrefix(s, "0"); ok && len(s) != 1 { base = 8 - s = s[1:] + s = after } if isUnsigned { i, err := strconv.ParseUint(s, base, size) if err != nil { return nil, err } - var v interface{} = i + var v any = i switch sig.str { case "y": v = byte(i) @@ -248,7 +248,7 @@ func varNumAs(s string, sig Signature) (interface{}, error) { if err != nil { return nil, err } - var v interface{} = i + var v any = i switch sig.str { case "n": v = int16(i) @@ -260,8 +260,8 @@ func varNumAs(s string, sig Signature) (interface{}, error) { type stringNode struct { sig Signature - str string // parsed - val interface{} // has correct type + str string // parsed + val any // has correct type } var stringSigSet = sigSet{ @@ -285,7 +285,7 @@ func (n stringNode) Sigs() sigSet { return stringSigSet } -func (n stringNode) Value(sig Signature) (interface{}, error) { +func (n stringNode) Value(sig Signature) (any, error) { if n.sig.str != "" && n.sig != sig { return nil, varTypeError{n.str, sig} } @@ -407,7 +407,7 @@ func (boolNode) Sigs() sigSet { return boolSigSet } -func (b boolNode) Value(sig Signature) (interface{}, error) { +func (b boolNode) Value(sig Signature) (any, error) { if sig.str != "b" { return nil, varTypeError{b.String(), sig} } @@ -445,7 +445,7 @@ func (n arrayNode) Sigs() sigSet { return n.set } -func (n arrayNode) Value(sig Signature) (interface{}, error) { +func (n arrayNode) Value(sig Signature) (any, error) { if n.set.Empty() { // no type information whatsoever, so this must be an empty slice return reflect.MakeSlice(typeFor(sig.str), 0, 0).Interface(), nil @@ -536,7 +536,7 @@ func (variantNode) Sigs() sigSet { return variantSet } -func (n variantNode) Value(sig Signature) (interface{}, error) { +func (n variantNode) Value(sig Signature) (any, error) { if sig.str != "v" { return nil, varTypeError{n.String(), sig} } @@ -612,7 +612,7 @@ func (n dictNode) Sigs() sigSet { return r } -func (n dictNode) Value(sig Signature) (interface{}, error) { +func (n dictNode) Value(sig Signature) (any, error) { set := n.Sigs() if set.Empty() { // no type information -> empty dict @@ -747,7 +747,7 @@ func (b byteStringNode) Sigs() sigSet { return byteStringSet } -func (b byteStringNode) Value(sig Signature) (interface{}, error) { +func (b byteStringNode) Value(sig Signature) (any, error) { if sig.str != "ay" { return nil, varTypeError{b.String(), sig} } diff --git a/vendor/modules.txt b/vendor/modules.txt index d46a6b68d96..7b7eaf2304e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -318,7 +318,7 @@ github.com/go-ole/go-ole/oleutil # github.com/go-task/slim-sprig/v3 v3.0.0 ## explicit; go 1.20 github.com/go-task/slim-sprig/v3 -# github.com/godbus/dbus/v5 v5.1.1-0.20241109141217-c266b19b28e9 +# github.com/godbus/dbus/v5 v5.2.0 ## explicit; go 1.20 github.com/godbus/dbus/v5 # github.com/gogo/protobuf v1.3.2