ruby-dbus 0.16.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +288 -3
- data/README.md +3 -5
- data/Rakefile +27 -12
- data/VERSION +1 -1
- data/doc/Reference.md +109 -10
- data/examples/doc/_extract_examples +7 -0
- data/examples/no-bus/pulseaudio.rb +50 -0
- data/examples/no-introspect/nm-test.rb +2 -0
- data/examples/no-introspect/tracker-test.rb +3 -1
- data/examples/rhythmbox/playpause.rb +2 -1
- data/examples/service/call_service.rb +2 -1
- data/examples/service/complex-property.rb +21 -0
- data/examples/service/service_newapi.rb +3 -3
- data/examples/simple/call_introspect.rb +1 -0
- data/examples/simple/get_id.rb +6 -3
- data/examples/simple/properties.rb +2 -0
- data/examples/utils/listnames.rb +10 -1
- data/examples/utils/notify.rb +1 -0
- data/lib/dbus/api_options.rb +9 -0
- data/lib/dbus/auth.rb +307 -217
- data/lib/dbus/bus.rb +155 -588
- data/lib/dbus/bus_name.rb +12 -8
- data/lib/dbus/connection.rb +363 -0
- data/lib/dbus/core_ext/class/attribute.rb +1 -1
- data/lib/dbus/data.rb +821 -0
- data/lib/dbus/emits_changed_signal.rb +83 -0
- data/lib/dbus/error.rb +4 -2
- data/lib/dbus/introspect.rb +133 -31
- data/lib/dbus/logger.rb +6 -3
- data/lib/dbus/main.rb +66 -0
- data/lib/dbus/marshall.rb +247 -296
- data/lib/dbus/matchrule.rb +16 -16
- data/lib/dbus/message.rb +66 -57
- data/lib/dbus/message_queue.rb +40 -25
- data/lib/dbus/node_tree.rb +105 -0
- data/lib/dbus/object.rb +442 -33
- data/lib/dbus/object_manager.rb +61 -0
- data/lib/dbus/object_path.rb +11 -6
- data/lib/dbus/object_server.rb +149 -0
- data/lib/dbus/org.freedesktop.DBus.xml +97 -0
- data/lib/dbus/platform.rb +26 -0
- data/lib/dbus/proxy_object.rb +30 -11
- data/lib/dbus/proxy_object_factory.rb +13 -7
- data/lib/dbus/proxy_object_interface.rb +63 -30
- data/lib/dbus/proxy_service.rb +107 -0
- data/lib/dbus/raw_message.rb +91 -0
- data/lib/dbus/type.rb +319 -86
- data/lib/dbus/xml.rb +40 -19
- data/lib/dbus.rb +28 -17
- data/ruby-dbus.gemspec +13 -6
- data/spec/async_spec.rb +2 -0
- data/spec/auth_spec.rb +225 -0
- data/spec/binding_spec.rb +2 -0
- data/spec/bus_and_xml_backend_spec.rb +5 -1
- data/spec/bus_connection_spec.rb +93 -0
- data/spec/bus_name_spec.rb +3 -1
- data/spec/bus_spec.rb +2 -0
- data/spec/byte_array_spec.rb +2 -0
- data/spec/client_robustness_spec.rb +4 -2
- data/spec/connection_spec.rb +37 -0
- data/spec/coverage_helper.rb +39 -0
- data/spec/data/marshall.yaml +1667 -0
- data/spec/data_spec.rb +673 -0
- data/spec/dbus_spec.rb +22 -0
- data/spec/emits_changed_signal_spec.rb +58 -0
- data/spec/err_msg_spec.rb +2 -0
- data/spec/introspect_xml_parser_spec.rb +2 -0
- data/spec/introspection_spec.rb +2 -0
- data/spec/main_loop_spec.rb +17 -1
- data/spec/message_spec.rb +21 -0
- data/spec/mock-service/cockpit-dbustests.rb +29 -0
- data/spec/mock-service/com.redhat.Cockpit.DBusTests.xml +180 -0
- data/spec/mock-service/org.ruby.service.service +4 -0
- data/spec/mock-service/org.rubygems.ruby_dbus.DBusTests.service +4 -0
- data/spec/{service_newapi.rb → mock-service/spaghetti-monster.rb} +122 -75
- data/spec/node_spec.rb +65 -0
- data/spec/object_manager_spec.rb +33 -0
- data/spec/object_path_spec.rb +3 -0
- data/spec/object_server_spec.rb +138 -0
- data/spec/object_spec.rb +194 -0
- data/spec/packet_marshaller_spec.rb +41 -0
- data/spec/packet_unmarshaller_spec.rb +248 -0
- data/spec/platform_spec.rb +14 -0
- data/spec/property_spec.rb +214 -12
- data/spec/proxy_object_interface_spec.rb +35 -0
- data/spec/proxy_object_spec.rb +2 -0
- data/spec/{bus_driver_spec.rb → proxy_service_spec.rb} +15 -8
- data/spec/raw_message_spec.rb +32 -0
- data/spec/server_robustness_spec.rb +20 -6
- data/spec/session_bus_spec.rb +36 -1
- data/spec/session_bus_spec_manual.rb +2 -0
- data/spec/signal_spec.rb +16 -3
- data/spec/spec_helper.rb +25 -33
- data/spec/thread_safety_spec.rb +55 -12
- data/spec/tools/dbus-launch-simple +9 -6
- data/spec/tools/dbus-limited-session.conf +32 -0
- data/spec/tools/test_env +26 -6
- data/spec/type_spec.rb +214 -6
- data/spec/value_spec.rb +16 -1
- data/spec/variant_spec.rb +4 -2
- data/spec/zzz_quit_spec.rb +16 -0
- metadata +92 -20
- data/examples/gdbus/gdbus +0 -257
- data/examples/gdbus/gdbus.glade +0 -98
- data/examples/gdbus/launch.sh +0 -4
- data/spec/server_spec.rb +0 -53
- data/spec/tools/test_server +0 -39
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env rspec
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
# Test that a server survives various error cases
|
|
3
5
|
require_relative "spec_helper"
|
|
4
6
|
require "dbus"
|
|
@@ -14,7 +16,7 @@ describe "ServerRobustnessTest" do
|
|
|
14
16
|
it "tests no such path with introspection" do
|
|
15
17
|
obj = @svc.object "/org/ruby/NotMyInstance"
|
|
16
18
|
expect { obj.introspect }.to raise_error(DBus::Error) do |e|
|
|
17
|
-
expect(e).to_not match(/timeout/)
|
|
19
|
+
expect(e.message).to_not match(/timeout/)
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
@@ -23,7 +25,19 @@ describe "ServerRobustnessTest" do
|
|
|
23
25
|
ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.SampleInterface")
|
|
24
26
|
ifc.define_method("the_answer", "out n:i")
|
|
25
27
|
expect { ifc.the_answer }.to raise_error(DBus::Error) do |e|
|
|
26
|
-
expect(e).to_not match(/timeout/)
|
|
28
|
+
expect(e.message).to_not match(/timeout/)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context "an existing path without an object" do
|
|
33
|
+
let(:obj) { @svc.object "/org" }
|
|
34
|
+
|
|
35
|
+
it "errors without a timeout" do
|
|
36
|
+
ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.SampleInterface")
|
|
37
|
+
ifc.define_method("the_answer", "out n:i")
|
|
38
|
+
expect { ifc.the_answer }.to raise_error(DBus::Error) do |e|
|
|
39
|
+
expect(e.message).to_not match(/timeout/)
|
|
40
|
+
end
|
|
27
41
|
end
|
|
28
42
|
end
|
|
29
43
|
|
|
@@ -31,7 +45,7 @@ describe "ServerRobustnessTest" do
|
|
|
31
45
|
obj = @svc.object "/org/ruby/MyInstance"
|
|
32
46
|
obj.default_iface = "org.ruby.SampleInterface"
|
|
33
47
|
expect { obj.will_raise }.to raise_error(DBus::Error) do |e|
|
|
34
|
-
expect(e).to_not match(/timeout/)
|
|
48
|
+
expect(e.message).to_not match(/timeout/)
|
|
35
49
|
end
|
|
36
50
|
end
|
|
37
51
|
|
|
@@ -39,7 +53,7 @@ describe "ServerRobustnessTest" do
|
|
|
39
53
|
obj = @svc.object "/org/ruby/MyInstance"
|
|
40
54
|
obj.default_iface = "org.ruby.SampleInterface"
|
|
41
55
|
expect { obj.will_raise_name_error }.to raise_error(DBus::Error) do |e|
|
|
42
|
-
expect(e).to_not match(/timeout/)
|
|
56
|
+
expect(e.message).to_not match(/timeout/)
|
|
43
57
|
end
|
|
44
58
|
end
|
|
45
59
|
|
|
@@ -49,7 +63,7 @@ describe "ServerRobustnessTest" do
|
|
|
49
63
|
ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.SampleInterface")
|
|
50
64
|
ifc.define_method("not_the_answer", "out n:i")
|
|
51
65
|
expect { ifc.not_the_answer }.to raise_error(DBus::Error) do |e|
|
|
52
|
-
expect(e).to_not match(/timeout/)
|
|
66
|
+
expect(e.message).to_not match(/timeout/)
|
|
53
67
|
end
|
|
54
68
|
end
|
|
55
69
|
|
|
@@ -58,7 +72,7 @@ describe "ServerRobustnessTest" do
|
|
|
58
72
|
ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.NoSuchInterface")
|
|
59
73
|
ifc.define_method("the_answer", "out n:i")
|
|
60
74
|
expect { ifc.the_answer }.to raise_error(DBus::Error) do |e|
|
|
61
|
-
expect(e).to_not match(/timeout/)
|
|
75
|
+
expect(e.message).to_not match(/timeout/)
|
|
62
76
|
end
|
|
63
77
|
end
|
|
64
78
|
end
|
data/spec/session_bus_spec.rb
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env rspec
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
require_relative "spec_helper"
|
|
3
5
|
require "dbus"
|
|
4
6
|
|
|
7
|
+
describe DBus::ASystemBus do
|
|
8
|
+
describe "#initialize" do
|
|
9
|
+
it "will use DBUS_SYSTEM_BUS_ADDRESS or the well known address" do
|
|
10
|
+
expect(ENV)
|
|
11
|
+
.to receive(:[])
|
|
12
|
+
.with("DBUS_SYSTEM_BUS_ADDRESS")
|
|
13
|
+
.and_return(nil)
|
|
14
|
+
expect(DBus::MessageQueue)
|
|
15
|
+
.to receive(:new)
|
|
16
|
+
.with("unix:path=/var/run/dbus/system_bus_socket")
|
|
17
|
+
expect_any_instance_of(described_class).to receive(:send_hello)
|
|
18
|
+
|
|
19
|
+
described_class.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
5
24
|
describe DBus::ASessionBus do
|
|
6
25
|
subject(:dbus_session_bus_address) { "unix:abstract=/tmp/dbus-foo,guid=123" }
|
|
7
26
|
|
|
@@ -16,6 +35,22 @@ describe DBus::ASessionBus do
|
|
|
16
35
|
ENV["DBUS_SESSION_BUS_ADDRESS"] = dbus_session_bus_address
|
|
17
36
|
expect(DBus::ASessionBus.session_bus_address).to eq(dbus_session_bus_address)
|
|
18
37
|
end
|
|
38
|
+
|
|
39
|
+
it "uses launchd on macOS when ENV and file fail" do
|
|
40
|
+
ENV["DBUS_SESSION_BUS_ADDRESS"] = nil
|
|
41
|
+
expect(described_class).to receive(:address_from_file).and_return(nil)
|
|
42
|
+
expect(DBus::Platform).to receive(:macos?).and_return(true)
|
|
43
|
+
|
|
44
|
+
expect(described_class.session_bus_address).to start_with "launchd:"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "raises a readable exception when all addresses fail" do
|
|
48
|
+
ENV["DBUS_SESSION_BUS_ADDRESS"] = nil
|
|
49
|
+
expect(described_class).to receive(:address_from_file).and_return(nil)
|
|
50
|
+
expect(DBus::Platform).to receive(:macos?).and_return(false)
|
|
51
|
+
|
|
52
|
+
expect { described_class.session_bus_address }.to raise_error(NotImplementedError, /Cannot find session bus/)
|
|
53
|
+
end
|
|
19
54
|
end
|
|
20
55
|
|
|
21
56
|
describe "#address_from_file" do
|
|
@@ -23,7 +58,7 @@ describe DBus::ASessionBus do
|
|
|
23
58
|
|
|
24
59
|
before do
|
|
25
60
|
# mocks of files for address_from_file method
|
|
26
|
-
machine_id_path = File.expand_path("/etc/machine-id",
|
|
61
|
+
machine_id_path = File.expand_path("/etc/machine-id", __dir__)
|
|
27
62
|
expect(Dir).to receive(:[]).with(any_args) { [machine_id_path] }
|
|
28
63
|
expect(File).to receive(:read).with(machine_id_path) { "baz" }
|
|
29
64
|
expect(File).to receive(:exist?).with(session_bus_file_path) { true }
|
data/spec/signal_spec.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env rspec
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
# Test the signal handlers
|
|
3
5
|
require_relative "spec_helper"
|
|
4
6
|
require "dbus"
|
|
@@ -29,7 +31,7 @@ describe "SignalHandlerTest" do
|
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
# testing for commit 017c83 (kkaempf)
|
|
32
|
-
it "tests overriding a handler" do
|
|
34
|
+
it "tests overriding a handler", slow: true do
|
|
33
35
|
DBus.logger.debug "Inside test_overriding_a_handler"
|
|
34
36
|
counter = 0
|
|
35
37
|
|
|
@@ -52,7 +54,7 @@ describe "SignalHandlerTest" do
|
|
|
52
54
|
expect(counter).to eq(1)
|
|
53
55
|
end
|
|
54
56
|
|
|
55
|
-
it "tests on signal overload" do
|
|
57
|
+
it "tests on signal overload", slow: true do
|
|
56
58
|
DBus.logger.debug "Inside test_on_signal_overload"
|
|
57
59
|
counter = 0
|
|
58
60
|
started = false
|
|
@@ -74,7 +76,7 @@ describe "SignalHandlerTest" do
|
|
|
74
76
|
expect { @intf.on_signal "to", "many", "yarrrrr!" }.to raise_error(ArgumentError)
|
|
75
77
|
end
|
|
76
78
|
|
|
77
|
-
it "is possible to add signal handlers from within handlers" do
|
|
79
|
+
it "is possible to add signal handlers from within handlers", slow: true do
|
|
78
80
|
ended = false
|
|
79
81
|
@intf.on_signal "LongTaskStart" do
|
|
80
82
|
@intf.on_signal "LongTaskEnd" do
|
|
@@ -101,4 +103,15 @@ describe "SignalHandlerTest" do
|
|
|
101
103
|
it "tests removing a nonexistent rule" do
|
|
102
104
|
@obj.on_signal "DoesNotExist"
|
|
103
105
|
end
|
|
106
|
+
|
|
107
|
+
describe DBus::ProxyObject do
|
|
108
|
+
describe "#on_signal" do
|
|
109
|
+
it "raises a descriptive error when the default_iface is wrong" do
|
|
110
|
+
open_quote = RUBY_VERSION >= "3.4" ? "'" : "`"
|
|
111
|
+
@obj.default_iface = "org.ruby.NoSuchInterface"
|
|
112
|
+
expect { @obj.on_signal("Foo") {} }
|
|
113
|
+
.to raise_error(NoMethodError, /undefined signal.*interface #{open_quote}org.ruby.NoSuchInterface'/)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
104
117
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
ENV["COVERAGE"] == "true"
|
|
3
|
-
else
|
|
4
|
-
# heuristics: enable for interactive builds (but not in OBS)
|
|
5
|
-
# or in Travis
|
|
6
|
-
ENV["DISPLAY"] || ENV["TRAVIS"]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
if coverage
|
|
10
|
-
require "simplecov"
|
|
11
|
-
SimpleCov.root File.expand_path("../..", __FILE__)
|
|
12
|
-
|
|
13
|
-
# do not cover specs
|
|
14
|
-
SimpleCov.add_filter "_spec.rb"
|
|
15
|
-
# do not cover the activesupport helpers
|
|
16
|
-
SimpleCov.add_filter "/core_ext/"
|
|
17
|
-
|
|
18
|
-
# use coveralls for on-line code coverage reporting at Travis CI
|
|
19
|
-
if ENV["TRAVIS"]
|
|
20
|
-
require "coveralls"
|
|
21
|
-
end
|
|
22
|
-
SimpleCov.start
|
|
23
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
24
2
|
|
|
25
|
-
|
|
3
|
+
require_relative "coverage_helper"
|
|
26
4
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
|
6
|
+
|
|
7
|
+
# http://betterspecs.org/#expect
|
|
8
|
+
RSpec.configure do |config|
|
|
9
|
+
config.expect_with :rspec do |c|
|
|
10
|
+
c.syntax = :expect
|
|
33
11
|
end
|
|
34
12
|
end
|
|
35
13
|
|
|
36
14
|
require "tempfile"
|
|
37
15
|
require "timeout"
|
|
38
16
|
|
|
39
|
-
TOPDIR = File.expand_path("
|
|
17
|
+
TOPDIR = File.expand_path("..", __dir__)
|
|
40
18
|
|
|
41
19
|
# path of config file for a private bus
|
|
42
20
|
def config_file_path
|
|
@@ -86,7 +64,7 @@ end
|
|
|
86
64
|
|
|
87
65
|
def with_service_by_activation(&block)
|
|
88
66
|
name = "org.ruby.service"
|
|
89
|
-
exec = "#{TOPDIR}/spec/
|
|
67
|
+
exec = "#{TOPDIR}/spec/mock-service/spaghetti-monster.rb"
|
|
90
68
|
|
|
91
69
|
service_dir = "#{ENV["XDG_DATA_DIRS"]}/dbus-1/services"
|
|
92
70
|
FileUtils.mkdir_p service_dir
|
|
@@ -102,5 +80,19 @@ def with_service_by_activation(&block)
|
|
|
102
80
|
|
|
103
81
|
block.call
|
|
104
82
|
|
|
105
|
-
|
|
83
|
+
# This would kill also other instances,
|
|
84
|
+
# namely on the bus set up by test_env.
|
|
85
|
+
## system "pkill -f #{exec}"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Make a binary string from readable YAML pieces; see data/marshall.yaml
|
|
89
|
+
def buffer_from_yaml(parts)
|
|
90
|
+
strings = parts.flatten.map do |part|
|
|
91
|
+
if part.is_a? Integer
|
|
92
|
+
part.chr
|
|
93
|
+
else
|
|
94
|
+
part
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
strings.join.force_encoding(Encoding::BINARY)
|
|
106
98
|
end
|
data/spec/thread_safety_spec.rb
CHANGED
|
@@ -1,30 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env rspec
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
2
4
|
# Test thread safety
|
|
3
5
|
require_relative "spec_helper"
|
|
4
6
|
require "dbus"
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
class TestSignalRace < DBus::Object
|
|
9
|
+
dbus_interface "org.ruby.ServerTest" do
|
|
10
|
+
dbus_signal :signal_without_arguments
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Run *count* threads all doing *body*, wait for their finish
|
|
15
|
+
def race_threads(count, &body)
|
|
16
|
+
jobs = count.times.map do |j|
|
|
17
|
+
Thread.new do
|
|
18
|
+
Thread.current.abort_on_exception = true
|
|
19
|
+
|
|
20
|
+
body.call(j)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
jobs.each(&:join)
|
|
24
|
+
end
|
|
13
25
|
|
|
26
|
+
# Repeat *count* times: { random sleep, *body* }, printing progress
|
|
27
|
+
def repeat_with_jitter(count, &body)
|
|
28
|
+
count.times do |i|
|
|
29
|
+
sleep 0.1 * rand
|
|
30
|
+
print "#{i} "
|
|
31
|
+
$stdout.flush
|
|
32
|
+
|
|
33
|
+
body.call
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe "thread safety" do
|
|
38
|
+
context "R/W: when the threads call methods with return values" do
|
|
39
|
+
it "it works with separate bus connections" do
|
|
40
|
+
race_threads(5) do |_j|
|
|
14
41
|
# use separate connections to avoid races
|
|
15
42
|
bus = DBus::ASessionBus.new
|
|
16
43
|
svc = bus.service("org.ruby.service")
|
|
17
44
|
obj = svc.object("/org/ruby/MyInstance")
|
|
18
45
|
obj.default_iface = "org.ruby.SampleInterface"
|
|
19
46
|
|
|
20
|
-
10
|
|
21
|
-
print "#{i} "
|
|
22
|
-
$stdout.flush
|
|
47
|
+
repeat_with_jitter(10) do
|
|
23
48
|
expect(obj.the_answer[0]).to eq(42)
|
|
24
|
-
sleep 0.1 * rand
|
|
25
49
|
end
|
|
26
50
|
end
|
|
51
|
+
puts
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "W/O: when the threads only send signals" do
|
|
56
|
+
it "it works with a shared bus connection" do
|
|
57
|
+
# shared connection
|
|
58
|
+
bus = DBus::SessionBus.instance
|
|
59
|
+
svc = bus.object_server
|
|
60
|
+
obj = TestSignalRace.new "/org/ruby/Foo"
|
|
61
|
+
svc.export obj
|
|
62
|
+
|
|
63
|
+
race_threads(5) do |_j|
|
|
64
|
+
repeat_with_jitter(10) do
|
|
65
|
+
obj.signal_without_arguments
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
svc.unexport(obj)
|
|
70
|
+
puts
|
|
27
71
|
end
|
|
28
|
-
jobs.each(&:join)
|
|
29
72
|
end
|
|
30
73
|
end
|
|
@@ -12,13 +12,16 @@ my_dbus_launch () {
|
|
|
12
12
|
AF=`mktemp dbus.addr.XXXXXX` || exit
|
|
13
13
|
RM_FILES="$RM_FILES $PF $AF"
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# For debugging:
|
|
16
|
+
# DBUS_DAEMON=~/svn/dbus/bus/dbus-daemon DBUS_VERBOSE=1 ./spec/tools/test_env env PS1="TEST $PS1" bash
|
|
17
|
+
: ${DBUS_DAEMON=dbus-daemon}
|
|
18
|
+
$DBUS_DAEMON --config-file=$(dirname $0)/dbus-limited-session.conf --print-address=3 3>$AF --print-pid=4 4>$PF &
|
|
16
19
|
# wait for the daemon to print the info
|
|
17
20
|
TRIES=0
|
|
18
21
|
while [ ! -s $AF -o ! -s $PF ]; do
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
sleep 0.1
|
|
23
|
+
TRIES=`expr $TRIES + 1`
|
|
24
|
+
if [ $TRIES -gt 100 ]; then echo "dbus-daemon failed?"; exit 1; fi
|
|
22
25
|
done
|
|
23
26
|
DBUS_SESSION_BUS_PID=$(cat $PF)
|
|
24
27
|
export DBUS_SESSION_BUS_ADDRESS=$(cat $AF)
|
|
@@ -26,10 +29,10 @@ my_dbus_launch () {
|
|
|
26
29
|
# dbus-monitor &
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
my_dbus_launch
|
|
30
|
-
|
|
31
32
|
# Clean up at exit.
|
|
32
33
|
trap "kill \$KILLS; rm -rf \$RM_FILES" EXIT TERM INT
|
|
33
34
|
|
|
35
|
+
my_dbus_launch
|
|
36
|
+
|
|
34
37
|
# run the payload; the return value is passed on
|
|
35
38
|
"$@"
|
|
@@ -7,7 +7,31 @@
|
|
|
7
7
|
<!-- Our well-known bus type, don't change this -->
|
|
8
8
|
<type>session</type>
|
|
9
9
|
|
|
10
|
+
<!-- Authentication:
|
|
11
|
+
This was useful during refactoring, but meanwhile RSpec mocking has
|
|
12
|
+
replaced it. -->
|
|
13
|
+
<!-- Explicitly list all known authentication mechanisms,
|
|
14
|
+
their order is not important.
|
|
15
|
+
By default the daemon allows all but this lets me disable some. -->
|
|
16
|
+
<auth>EXTERNAL</auth>
|
|
17
|
+
<auth>DBUS_COOKIE_SHA1</auth>
|
|
18
|
+
<auth>ANONYMOUS</auth>
|
|
19
|
+
<!-- Insecure, other users could call us and exploit debug APIs/bugs -->
|
|
20
|
+
<!--
|
|
21
|
+
<allow_anonymous/>
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<!-- Give clients a variety of addresses to connect to -->
|
|
10
25
|
<listen>unix:tmpdir=/tmp</listen>
|
|
26
|
+
<listen>unix:dir=/tmp</listen>
|
|
27
|
+
<!-- runtime will happily steal the actual session bus! -->
|
|
28
|
+
<!--
|
|
29
|
+
<listen>unix:runtime=yes</listen>
|
|
30
|
+
-->
|
|
31
|
+
<!-- openSUSE Build Service does not set up IPv6 at build time -->
|
|
32
|
+
<!--
|
|
33
|
+
<listen>tcp:host=%3a%3a1,family=ipv6</listen>
|
|
34
|
+
-->
|
|
11
35
|
<listen>tcp:host=127.0.0.1</listen>
|
|
12
36
|
|
|
13
37
|
<standard_session_servicedirs />
|
|
@@ -19,10 +43,18 @@
|
|
|
19
43
|
<allow eavesdrop="true"/>
|
|
20
44
|
<!-- Allow anyone to own anything -->
|
|
21
45
|
<allow own="*"/>
|
|
46
|
+
|
|
47
|
+
<!-- To test how request_name handles bus errors -->
|
|
48
|
+
<deny own="org.rubygems.ruby_dbus.NobodyCanOwnThisName"/>
|
|
22
49
|
</policy>
|
|
23
50
|
|
|
24
51
|
<!-- Do not increase the limits.
|
|
25
52
|
Instead, lower some so that we can test resource leaks. -->
|
|
26
53
|
<limit name="max_match_rules_per_connection">50</limit><!-- was 512 -->
|
|
54
|
+
<limit name="reply_timeout">5000</limit><!-- 5 seconds -->
|
|
27
55
|
|
|
56
|
+
<!--
|
|
57
|
+
dbus-daemon[1700]: [session uid=1001 pid=1700] Unable to set up new connection: Failed to get AppArmor confinement information of socket peer: Protocol not available
|
|
58
|
+
-->
|
|
59
|
+
<apparmor mode="disabled"/>
|
|
28
60
|
</busconfig>
|
data/spec/tools/test_env
CHANGED
|
@@ -2,13 +2,33 @@
|
|
|
2
2
|
# test_env: set up the environment needed to run tests:
|
|
3
3
|
# - set up a private bus
|
|
4
4
|
# - run a test server on it
|
|
5
|
+
set -o errexit
|
|
5
6
|
|
|
6
7
|
#export DBUS_VERBOSE=1
|
|
7
8
|
#export RUBYOPT="-d"
|
|
8
9
|
export RUBYOPT="$RUBYOPT -w"
|
|
9
|
-
|
|
10
|
-
$
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
MYDIR=$(dirname $0)
|
|
11
|
+
TOPDIR=$(realpath $MYDIR/../..)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Clean up at exit.
|
|
15
|
+
trap "rm -rf \$RM_FILES" EXIT TERM INT
|
|
16
|
+
|
|
17
|
+
export XDG_DATA_DIRS=`mktemp -d dbus.activation.XXXXXX`
|
|
18
|
+
RM_FILES="$RM_FILES $XDG_DATA_DIRS"
|
|
19
|
+
|
|
20
|
+
SVCDIR=$XDG_DATA_DIRS/dbus-1/services
|
|
21
|
+
mkdir -p $SVCDIR
|
|
22
|
+
for SVC in $TOPDIR/spec/mock-service/*.service; do
|
|
23
|
+
SVCBASE=${SVC##*/}
|
|
24
|
+
sed -e "s@\(Exec\)=/usr/bin/@\1=$TOPDIR/spec/mock-service/@" $SVC > $SVCDIR/$SVCBASE
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# no command given -> run an interactive shell
|
|
29
|
+
if [ $# = 0 ]; then
|
|
30
|
+
set -- env PS1="TEST_ENV \w> " bash
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
$MYDIR/dbus-launch-simple \
|
|
34
|
+
"$@"
|