Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting invalid properties to connman service causes txdbus client to disconnect (cleanly) #45

Open
sherpya opened this issue May 22, 2017 · 4 comments

Comments

@sherpya
Copy link

sherpya commented May 22, 2017

I'm trying to call SetProperty of a connman service, and it works fine if params are ok, when I use invalid params txdbus client apparently disconnects cleanly

I've defined a custom datatype:

class VariantList(list):
    dbusSignature = 'a(v)'

here is the debug log:

2017-05-22T18:06:38+0200 [twisted.internet.defer#critical] Unhandled error in Deferred:
2017-05-22T18:06:38+0200 [twisted.internet.defer#critical] (debug:  C: Deferred was created:
	 C:  File "/root/venv/bin/twistd", line 18, in <module>
	 C:    run()
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 29, in run
	 C:    app.run(runApp, ServerOptions)
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 643, in run
	 C:    runApp(config)
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 25, in runApp
	 C:    _SomeApplicationRunner(config).run()
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 378, in run
	 C:    self.postApplication()
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/scripts/_twistd_unix.py", line 222, in postApplication
	 C:    self.startReactor(None, self.oldstdout, self.oldstderr)
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 390, in startReactor
	 C:    self.config, oldstdout, oldstderr, self.profiler, reactor)
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 311, in runReactorWithLogging
	 C:    reactor.run()
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1194, in run
	 C:    self.mainLoop()
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1203, in mainLoop
	 C:    self.runUntilCurrent()
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/base.py", line 825, in runUntilCurrent
	 C:    call.func(*call.args, **call.kw)
	 C:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1274, in unwindGenerator
	 C:    return _inlineCallbacks(None, gen, Deferred())
	 I: First Invoker was:
	 I:  File "/root/venv/bin/twistd", line 18, in <module>
	 I:    run()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 29, in run
	 I:    app.run(runApp, ServerOptions)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 643, in run
	 I:    runApp(config)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line 25, in runApp
	 I:    _SomeApplicationRunner(config).run()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 378, in run
	 I:    self.postApplication()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/scripts/_twistd_unix.py", line 222, in postApplication
	 I:    self.startReactor(None, self.oldstdout, self.oldstderr)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 390, in startReactor
	 I:    self.config, oldstdout, oldstderr, self.profiler, reactor)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/application/app.py", line 311, in runReactorWithLogging
	 I:    reactor.run()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1194, in run
	 I:    self.mainLoop()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/base.py", line 1206, in mainLoop
	 I:    self.doIteration(t)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/epollreactor.py", line 396, in doPoll
	 I:    log.callWithLogger(selectable, _drdw, selectable, fd, event)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/python/log.py", line 101, in callWithLogger
	 I:    return callWithContext({"system": lp}, func, *args, **kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/python/log.py", line 84, in callWithContext
	 I:    return context.call({ILogContext: newCtx}, func, *args, **kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
	 I:    return self.currentContext().callWithContext(ctx, func, *args, **kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
	 I:    return func(*args,**kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 610, in _doReadOrWrite
	 I:    self._disconnectSelectable(selectable, why, inRead)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 252, in _disconnectSelectable
	 I:    selectable.readConnectionLost(f)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 273, in readConnectionLost
	 I:    self.connectionLost(reason)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 479, in connectionLost
	 I:    self._commonConnection.connectionLost(self, reason)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 293, in connectionLost
	 I:    protocol.connectionLost(reason)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/endpoints.py", line 129, in connectionLost
	 I:    return self._wrappedProtocol.connectionLost(reason)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/txdbus/client.py", line 105, in connectionLost
	 I:    d.errback(reason)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 434, in errback
	 I:    self._startRunCallbacks(fail)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
	 I:    self._runCallbacks()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks
	 I:    current.result = callback(current.result, *args, **kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1184, in gotResult
	 I:    _inlineCallbacks(r, g, deferred)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1174, in _inlineCallbacks
	 I:    deferred.errback()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 434, in errback
	 I:    self._startRunCallbacks(fail)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
	 I:    self._runCallbacks()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks
	 I:    current.result = callback(current.result, *args, **kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1184, in gotResult
	 I:    _inlineCallbacks(r, g, deferred)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1174, in _inlineCallbacks
	 I:    deferred.errback()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 434, in errback
	 I:    self._startRunCallbacks(fail)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
	 I:    self._runCallbacks()
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks
	 I:    current.result = callback(current.result, *args, **kw)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1184, in gotResult
	 I:    _inlineCallbacks(r, g, deferred)
	 I:  File "/root/venv/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1174, in _inlineCallbacks
	 I:    deferred.errback()
	)

Traceback (most recent call last):
Failure: twisted.internet.error.ConnectionDone: Connection was closed cleanly.
2017-05-22T18:06:38+0200 [txdbus.client.DBusClientFactory#info] Stopping factory <txdbus.client.DBusClientFactory instance at 0x7f87a0690368>

and the dbus monitor output:

method call sender=:1.35 -> dest=net.connman serial=37 path=/net/connman/service/ethernet_080027b88135_cable; interface=org.freedesktop.DBus.Introspectable; member=Introspect
method return sender=:1.2 -> dest=:1.35 reply_serial=37
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node><interface name="org.freedesktop.DBus.Introspectable"><method name="Introspect"><arg name="xml" type="s" direction="out"/>
</method></interface><interface name="net.connman.Service"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="SetProperty"><arg name="name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method><method name="ClearProperty"><arg name="name" type="s" direction="in"/>
</method><method name="Connect"></method><method name="Disconnect"></method><method name="Remove"></method><method name="MoveBefore"><arg name="service" type="o" direction="in"/>
</method><method name="MoveAfter"><arg name="service" type="o" direction="in"/>
</method><method name="ResetCounters"></method><signal name="PropertyChanged"><arg name="name" type="s"/>
<arg name="value" type="v"/>
</signal>
</interface></node>"
method call sender=:1.35 -> dest=net.connman serial=38 path=/net/connman/service/ethernet_080027b88135_cable; interface=net.connman.Service; member=SetProperty
   string "Domains.Configuration"
   variant       array [
         struct {
            variant                string "n"
         }
      ]
signal sender=:1.2 -> dest=(null destination) serial=683 path=/net/connman/service/ethernet_080027b88135_cable; interface=net.connman.Service; member=PropertyChanged
   string "Domains.Configuration"
   variant       array [
      ]
signal sender=:1.2 -> dest=(null destination) serial=684 path=/net/connman/service/ethernet_080027b88135_cable; interface=net.connman.Service; member=PropertyChanged
   string "Domains"
   variant       array [
      ]
method return sender=:1.2 -> dest=:1.35 reply_serial=38
method call sender=:1.35 -> dest=net.connman serial=39 path=/net/connman/service/ethernet_080027b88135_cable; interface=org.freedesktop.DBus.Introspectable; member=Introspect
method return sender=:1.2 -> dest=:1.35 reply_serial=39
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node><interface name="org.freedesktop.DBus.Introspectable"><method name="Introspect"><arg name="xml" type="s" direction="out"/>
</method></interface><interface name="net.connman.Service"><method name="GetProperties"><arg name="properties" type="a{sv}" direction="out"/>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/></method><method name="SetProperty"><arg name="name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method><method name="ClearProperty"><arg name="name" type="s" direction="in"/>
</method><method name="Connect"></method><method name="Disconnect"></method><method name="Remove"></method><method name="MoveBefore"><arg name="service" type="o" direction="in"/>
</method><method name="MoveAfter"><arg name="service" type="o" direction="in"/>
</method><method name="ResetCounters"></method><signal name="PropertyChanged"><arg name="name" type="s"/>
<arg name="value" type="v"/>
</signal>
</interface></node>"
@sherpya
Copy link
Author

sherpya commented May 22, 2017

testcase:

#!/usr/bin/env python
from twisted.internet import reactor, defer
from txdbus import client

defer.setDebugging(True)


class VariantList(list):
    dbusSignature = 'a(v)'


@defer.inlineCallbacks
def testcase():
    conn = yield client.connect(reactor, 'system')
    manager = yield conn.getRemoteObject('net.connman', '/')
    services = yield manager.callRemote('GetServices', interface='net.connman.Manager')

    service = None
    for k, v in services:
        if v['Type'] == 'ethernet':
            service = k
            break

    if service is None:
        print 'No ethernet service found'
        reactor.stop()
        defer.returnValue(None)

    remote = yield conn.getRemoteObject('net.connman', service)
    # params = ['8.8.8.8']  # ok with this value
    params = ['8.8.8.8', '']
    try:
        yield remote.callRemote('SetProperty',
                                'Nameservers.Configuration',
                                VariantList(params),
                                interface='net.connman.Service')
    finally:
        reactor.stop()

    print 'success'


if __name__ == '__main__':
    reactor.callWhenRunning(testcase)
    reactor.run()

@sherpya
Copy link
Author

sherpya commented May 23, 2017

btw the signature for nameservers configuration it's simply alist

@cocagne
Copy link
Owner

cocagne commented May 23, 2017 via email

@sherpya
Copy link
Author

sherpya commented May 24, 2017

the correct way to pass domains lists and dns lists is a simpe list, I made by mistake VariantList because I need this structure to pass IPv4 settings:

class VariantDict(dict):
    dbusSignature = 'a{sv}'

perhaps It's not a good idea to have a connection dropped if there is an error, because I need to reregister signals etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants