Updating dependency github.com/godbus/dbus to version v0.0.0-20190422162347-ade71ed3457e

This commit is contained in:
Davanum Srinivas 2020-03-24 13:18:06 -04:00
parent b117d2dc25
commit cccdf5cde6
11 changed files with 85 additions and 17 deletions

2
go.mod
View File

@ -292,7 +292,7 @@ replace (
github.com/go-toolsmith/strparse => github.com/go-toolsmith/strparse v1.0.0
github.com/go-toolsmith/typep => github.com/go-toolsmith/typep v1.0.0
github.com/gobwas/glob => github.com/gobwas/glob v0.2.3
github.com/godbus/dbus => github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f
github.com/godbus/dbus => github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.1
github.com/golang/freetype => github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/golang/glog => github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b

4
go.sum
View File

@ -213,8 +213,8 @@ github.com/go-toolsmith/pkgload v1.0.0/go.mod h1:5eFArkbO80v7Z0kdngIxsRXRMTaX4Il
github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8=
github.com/go-toolsmith/typep v1.0.0/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f h1:zlOR3rOlPAVvtfuxGKoghCmop5B0TRyu/ZieziZuGiM=
github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e h1:BWhy2j3IXJhjCbC68FptL43tDKIq8FladmaTs3Xs7Z8=
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=

View File

@ -134,6 +134,8 @@ func SystemBus() (conn *Conn, err error) {
}
// SystemBusPrivate returns a new private connection to the system bus.
// Note: this connection is not ready to use. One must perform Auth and Hello
// on the connection before it is useable.
func SystemBusPrivate(opts ...ConnOption) (*Conn, error) {
return Dial(getSystemBusPlatformAddress(), opts...)
}
@ -267,7 +269,7 @@ func (conn *Conn) Eavesdrop(ch chan<- *Message) {
conn.eavesdroppedLck.Unlock()
}
// GetSerial returns an unused serial.
// getSerial returns an unused serial.
func (conn *Conn) getSerial() uint32 {
return conn.serialGen.GetSerial()
}
@ -381,8 +383,6 @@ func (conn *Conn) Object(dest string, path ObjectPath) BusObject {
return &Object{conn, dest, path}
}
// outWorker runs in an own goroutine, encoding and sending messages that are
// sent to conn.out.
func (conn *Conn) sendMessage(msg *Message) {
conn.sendMessageAndIfClosed(msg, func() {})
}

View File

@ -14,8 +14,10 @@ import (
"strings"
)
var execCommand = exec.Command
func getSessionBusPlatformAddress() (string, error) {
cmd := exec.Command("dbus-launch")
cmd := execCommand("dbus-launch")
b, err := cmd.CombinedOutput()
if err != nil {
@ -25,7 +27,7 @@ func getSessionBusPlatformAddress() (string, error) {
i := bytes.IndexByte(b, '=')
j := bytes.IndexByte(b, '\n')
if i == -1 || j == -1 {
if i == -1 || j == -1 || i > j {
return "", errors.New("dbus: couldn't determine address of session bus")
}

View File

@ -188,8 +188,14 @@ func (dec *decoder) decode(s string, depth int) interface{} {
if depth >= 64 {
panic(FormatError("input exceeds container depth limit"))
}
sig := s[1:]
length := dec.decode("u", depth).(uint32)
v := reflect.MakeSlice(reflect.SliceOf(typeFor(s[1:])), 0, int(length))
// capacity can be determined only for fixed-size element types
var capacity int
if s := sigByteSize(sig); s != 0 {
capacity = int(length) / s
}
v := reflect.MakeSlice(reflect.SliceOf(typeFor(sig)), 0, capacity)
// Even for empty arrays, the correct padding must be included
align := alignment(typeFor(s[1:]))
if len(s) > 1 && s[1] == '(' {
@ -227,6 +233,51 @@ func (dec *decoder) decode(s string, depth int) interface{} {
}
}
// sigByteSize tries to calculates size of the given signature in bytes.
//
// It returns zero when it can't, for example when it contains non-fixed size
// types such as strings, maps and arrays that require reading of the transmitted
// data, for that we would need to implement the unread method for Decoder first.
func sigByteSize(sig string) int {
var total int
for offset := 0; offset < len(sig); {
switch sig[offset] {
case 'y':
total += 1
offset += 1
case 'n', 'q':
total += 2
offset += 1
case 'b', 'i', 'u', 'h':
total += 4
offset += 1
case 'x', 't', 'd':
total += 8
offset += 1
case '(':
i := 1
depth := 1
for i < len(sig[offset:]) && depth != 0 {
if sig[offset+i] == '(' {
depth++
} else if sig[offset+i] == ')' {
depth--
}
i++
}
s := sigByteSize(sig[offset+1 : offset+i-1])
if s == 0 {
return 0
}
total += s
offset += i
default:
return 0
}
}
return total
}
// A FormatError is an error in the wire format.
type FormatError string

View File

@ -263,13 +263,13 @@ func (sh *defaultSignalHandler) DeliverSignal(intf, name string, signal *Signal)
case <-sh.closeChan:
return
default:
go func() {
go func(ch chan<- *Signal) {
select {
case ch <- signal:
case <-sh.closeChan:
return
}
}()
}(ch)
}
}
}

View File

@ -1 +1,3 @@
module github.com/godbus/dbus
go 1.12

View File

@ -16,6 +16,7 @@ type BusObject interface {
AddMatchSignal(iface, member string, options ...MatchOption) *Call
RemoveMatchSignal(iface, member string, options ...MatchOption) *Call
GetProperty(p string) (Variant, error)
SetProperty(p string, v interface{}) error
Destination() string
Path() ObjectPath
}
@ -146,7 +147,7 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch
}
if msg.Flags&FlagNoReplyExpected == 0 {
if ch == nil {
ch = make(chan *Call, 10)
ch = make(chan *Call, 1)
} else if cap(ch) == 0 {
panic("dbus: unbuffered channel passed to (*Object).Go")
}
@ -187,7 +188,7 @@ func (o *Object) createCall(ctx context.Context, method string, flags Flags, ch
return call
}
// GetProperty calls org.freedesktop.DBus.Properties.GetProperty on the given
// GetProperty calls org.freedesktop.DBus.Properties.Get on the given
// object. The property name must be given in interface.member notation.
func (o *Object) GetProperty(p string) (Variant, error) {
idx := strings.LastIndex(p, ".")
@ -208,6 +209,20 @@ func (o *Object) GetProperty(p string) (Variant, error) {
return result, nil
}
// SetProperty calls org.freedesktop.DBus.Properties.Set on the given
// object. The property name must be given in interface.member notation.
func (o *Object) SetProperty(p string, v interface{}) error {
idx := strings.LastIndex(p, ".")
if idx == -1 || idx+1 == len(p) {
return errors.New("dbus: invalid property " + p)
}
iface := p[:idx]
prop := p[idx+1:]
return o.Call("org.freedesktop.DBus.Properties.Set", 0, iface, prop, v).Err
}
// Destination returns the destination that calls on (o *Object) are sent to.
func (o *Object) Destination() string {
return o.dest

View File

@ -1,5 +1,3 @@
//+build !windows
package dbus
import (

View File

@ -203,7 +203,7 @@ func (t *unixTransport) SendMessage(msg *Message) error {
}
} else {
if err := msg.EncodeTo(t, nativeEndian); err != nil {
return nil
return err
}
}
return nil

2
vendor/modules.txt vendored
View File

@ -301,7 +301,7 @@ github.com/go-ozzo/ozzo-validation
github.com/go-ozzo/ozzo-validation/is
# github.com/go-stack/stack v1.8.0 => github.com/go-stack/stack v1.8.0
github.com/go-stack/stack
# github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e => github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f
# github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e => github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e
github.com/godbus/dbus
# github.com/gogo/protobuf v1.3.1 => github.com/gogo/protobuf v1.3.1
github.com/gogo/protobuf/gogoproto