]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Test system bus config files on Unix only
authorRalf Habacker <ralf.habacker@freenet.de>
Mon, 2 Nov 2015 23:23:56 +0000 (00:23 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Tue, 3 Nov 2015 13:22:30 +0000 (14:22 +0100)
Previously, we didn't consistently test parsing of every file in
valid-config-files-system/ everywhere that we tested valid-config-files/.
We now test it on Unix.

The system bus is not supported on Windows, so we do not test
valid-config-files-system/ there.

valid-config-files/many-rules.conf contains <user> and <group> rules
which are not applicable to Windows. Copy the original many-rules.conf
to valid-config-files-system/ so that it will be tested on Unix, and
remove the non-portable rules from valid-config-files/many-rules.conf.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[rh:base patch came from Simon]

bus/config-parser-trivial.c
bus/config-parser.c
cmake/test/CMakeLists.txt
test/Makefile.am
test/data/valid-config-files-system/many-rules.conf [new file with mode: 0644]
test/data/valid-config-files-system/system.d/test.conf [moved from test/data/valid-config-files/system.d/test.conf with 85% similarity]
test/data/valid-config-files/.gitignore
test/data/valid-config-files/many-rules.conf

index 64a05c3a76117b4dbc959df60d753b23bb704f93..03ad8382b661585d5d565b756b5164bfa092ea22 100644 (file)
@@ -684,6 +684,13 @@ bus_config_parser_trivial_test (const DBusString *test_data_dir)
   if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
     goto finish;
 
+#ifndef DBUS_WIN
+  /* We already test default_session_servicedirs and default_system_servicedirs
+   * in bus_config_parser_test() */
+  if (!process_test_valid_subdir (test_data_dir, "valid-config-files-system", VALID))
+    goto finish;
+#endif
+
   /* we don't process all the invalid files, as the trivial parser can't hope
    * to validate them all for all different syntaxes. We just check one broken
    * file to see if junk is received */
@@ -693,14 +700,16 @@ bus_config_parser_trivial_test (const DBusString *test_data_dir)
     goto finish;
   _dbus_string_free (&full_path);
 
+#ifndef DBUS_WIN
   /* just test if the check_file_valid works okay and we got sane values */
-  if (!make_full_path (test_data_dir, "valid-config-files", "system.conf", &full_path))
+  if (!make_full_path (test_data_dir, "valid-config-files-system", "system.conf", &full_path))
     goto finish;
   if (!check_file_valid (&full_path, VALID))
     goto finish;
   /* check to see if we got the correct values from the parser */
   if (!check_return_values (&full_path))
     goto finish;
+#endif
 
   /* woot! */
   retval = TRUE;
index 1925d435d22301feaaad32189e24a7a122cac93c..d9f6042c6be7bad048b327c677b9e2aaa149bfa7 100644 (file)
@@ -3680,6 +3680,11 @@ bus_config_parser_test (const DBusString *test_data_dir)
   if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
     return FALSE;
 
+#ifndef DBUS_WIN
+  if (!process_test_valid_subdir (test_data_dir, "valid-config-files-system", VALID))
+    return FALSE;
+#endif
+
   if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID))
     return FALSE;
 
index 1a12f5a81e185cde9b7c3ced28b79e886d8594c6..eb4b1f10f58b7d77c763060eb37b06821eb552ff 100644 (file)
@@ -122,8 +122,8 @@ set (TESTDIRS
     test/data/valid-config-files
     test/data/valid-config-files/basic.d
     test/data/valid-config-files/session.d
-    test/data/valid-config-files/system.d
     test/data/valid-config-files-system
+    test/data/valid-config-files-system/system.d
     test/data/valid-introspection-files
     test/data/valid-messages
     test/data/valid-service-files
@@ -140,13 +140,16 @@ set (TESTDIRS
 )
 set (CONFIG_VERBOSE 0)
 
+FOREACH(DIR ${TESTDIRS})
+    FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
+ENDFOREACH(DIR)
+
 ### copy tests to builddir so that generated tests and static tests 
 ### are all in one place.
 MESSAGE(STATUS "Copying test files to test directory")
 FOREACH(FILE_TYPE *.message *.message-raw *.auth-script *.sha1 *.txt *.conf *.service)
     FOREACH(DIR ${TESTDIRS})
         FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" )
-        FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
         FOREACH(FILE ${FILES})
             GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME)
             SET (TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME})
@@ -164,7 +167,6 @@ MESSAGE(STATUS "Generating test files from templates into test directory")
 FOREACH(FILE_TYPE *.conf.in *.service.in)
   FOREACH(DIR ${TESTDIRS})
     FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" )
-    FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
     FOREACH(FILE ${FILES})
       GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME)
       STRING(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME})
@@ -178,19 +180,5 @@ FOREACH(FILE_TYPE *.conf.in *.service.in)
 ENDFOREACH(FILE_TYPE)
 
 MESSAGE(STATUS "Copying generated bus config files to test directory")
-set (OUTDIR ${CMAKE_BINARY_DIR}/test/data/valid-config-files)
-
-SET(FILES
-  "${CMAKE_SOURCE_DIR}/../bus/session.conf.in"
-  "${CMAKE_SOURCE_DIR}/../bus/system.conf.in"
-)
-FILE(MAKE_DIRECTORY ${OUTDIR})
-FOREACH(FILE ${FILES})
-    GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME)
-    STRING(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME})
-    SET (TARGET ${OUTDIR}/${FILENAME})
-    configure_file(${FILE} ${TARGET} @ONLY)
-    IF (CONFIG_VERBOSE)
-        MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n")
-    ENDIF (CONFIG_VERBOSE)
-ENDFOREACH(FILE)
+configure_file("${CMAKE_SOURCE_DIR}/../bus/session.conf.in" ${CMAKE_BINARY_DIR}/test/data/valid-config-files/session.conf @ONLY)
+configure_file("${CMAKE_SOURCE_DIR}/../bus/system.conf.in" ${CMAKE_BINARY_DIR}/test/data/valid-config-files-system/system.conf @ONLY)
index 5812c1a99492601a31380ca46f5f9e5a73174427..b7f40bb01dd625a2c07c2abbf4ad0a79c1853692 100644 (file)
@@ -384,7 +384,7 @@ static_data = \
        data/valid-config-files/entities.conf \
        data/valid-config-files/listen-unix-runtime.conf \
        data/valid-config-files/many-rules.conf \
-       data/valid-config-files/system.d/test.conf \
+       data/valid-config-files-system/system.d/test.conf \
        data/valid-messages/array-of-array-of-uint32.message \
        data/valid-messages/dict-simple.message \
        data/valid-messages/dict.message \
@@ -468,7 +468,7 @@ if DBUS_ENABLE_INSTALLED_TESTS
                install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \
        done
        ln -nfs $(datadir)/dbus-1/session.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/session.conf
-       ln -nfs $(datadir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/system.conf
+       ln -nfs $(datadir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files-system/system.conf
 else
        @:
 endif
@@ -486,7 +486,7 @@ clean-local:
 
 imported_data = \
        data/valid-config-files/session.conf \
-       data/valid-config-files/system.conf \
+       data/valid-config-files-system/system.conf \
        $(NULL)
 
 noinst_DATA = $(imported_data)
@@ -496,10 +496,14 @@ CLEANFILES += \
        installable \
        $(NULL)
 
-$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf
+data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf
        $(AM_V_at)$(MKDIR_P) data/valid-config-files
        $(AM_V_GEN)cp $< $@
 
+data/valid-config-files-system/system.conf: $(top_builddir)/bus/system.conf
+       $(AM_V_at)$(MKDIR_P) data/valid-config-files-system
+       $(AM_V_GEN)cp $< $@
+
 $(installable_test_meta): %.test: %$(EXEEXT) Makefile
        $(AM_V_GEN) ( \
                echo '[Test]'; \
diff --git a/test/data/valid-config-files-system/many-rules.conf b/test/data/valid-config-files-system/many-rules.conf
new file mode 100644 (file)
index 0000000..8537fd9
--- /dev/null
@@ -0,0 +1,60 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+  <user>mybususer</user>
+  <listen>unix:path=/foo/bar</listen>
+  <listen>tcp:port=1234</listen>
+  <includedir>basic.d</includedir>
+  <standard_session_servicedirs />
+  <servicedir>/usr/share/foo</servicedir>
+  <include ignore_missing="yes">nonexistent.conf</include>
+  <policy context="default">
+    <allow user="*"/>
+    <deny send_interface="org.freedesktop.System" send_member="Reboot"/>
+    <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/>
+    <deny send_path="/foo/bar/SystemObjectThing" send_member="Reboot"/>
+    <deny own="org.freedesktop.System"/>
+    <deny own_prefix="org.freedesktop.ManySystems"/>
+    <deny send_destination="org.freedesktop.System"/>
+    <deny receive_sender="org.freedesktop.System"/>
+    <deny user="root"/>
+    <deny group="bin"/>
+    <allow send_type="error"/>
+    <allow send_type="method_call"/>
+    <allow send_type="method_return"/>
+    <allow send_type="signal"/>
+    <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo"/>
+    <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo" send_type="method_call"/>
+  </policy>
+
+  <policy context="mandatory">
+    <allow user="*"/>
+    <deny send_interface="org.freedesktop.System" send_member="Reboot"/>
+    <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/>
+    <deny send_path="/foo/bar/SystemObjectThing" send_member="Reboot"/>
+    <deny own="org.freedesktop.System"/>
+    <deny own_prefix="org.freedesktop.ManySystems"/>
+    <deny send_destination="org.freedesktop.System"/>
+    <deny receive_sender="org.freedesktop.System"/>
+    <deny user="root"/>
+    <deny group="bin"/>
+    <allow send_type="error"/>
+    <allow send_type="method_call"/>
+    <allow send_type="method_return"/>
+    <allow send_type="signal"/>
+    <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo"/>
+    <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo" send_type="method_call"/>
+  </policy>
+
+  <limit name="max_incoming_bytes">5000</limit>
+  <limit name="max_outgoing_bytes">5000</limit>
+  <limit name="max_message_size">300</limit>
+  <limit name="service_start_timeout">5000</limit>
+  <limit name="auth_timeout">6000</limit>
+  <limit name="max_completed_connections">50</limit>
+  <limit name="max_incomplete_connections">80</limit>
+  <limit name="max_connections_per_user">64</limit>
+  <limit name="max_pending_service_starts">64</limit>
+  <limit name="max_names_per_connection">256</limit>
+  <limit name="max_match_rules_per_connection">512</limit>
+</busconfig>
similarity index 85%
rename from test/data/valid-config-files/system.d/test.conf
rename to test/data/valid-config-files-system/system.d/test.conf
index 5b60a1fc597ed963ee8da074a9d60b4822669069..ee6afcdfbb390a58ec6a9613e46b70d24b1e8bed 100644 (file)
@@ -1,18 +1,18 @@
 <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 <busconfig>
-  <!-- The following demonstrates how to punch holes in a default deny-all 
-       policy so that a particular user can own a service, and other 
+  <!-- The following demonstrates how to punch holes in a default deny-all
+       policy so that a particular user can own a service, and other
        connections can get messages from it -->
 
-  <!-- Only root can own the FooService service, and 
+  <!-- Only root can own the FooService service, and
        this user can only send the one kind of message -->
   <policy user="root">
     <allow own="org.foo.FooService"/>
     <allow send_interface="org.foo.FooBroadcastInterface"/>
   </policy>
 
-  <!-- Allow any connection to receive the message, but 
+  <!-- Allow any connection to receive the message, but
        only if the message is sent by the owner of FooService -->
   <policy context="default">
     <allow receive_interface="org.foo.FooBroadcastInterface" receive_sender="org.foo.FooService"/>
index 2a09552ec75963623e6310003503a35a053dd127..b6929096bd7a7c5124334b03dcd2f9a13dfbbb35 100644 (file)
@@ -2,6 +2,5 @@ debug-allow-all.conf
 debug-allow-all-sha1.conf
 incoming-limit.conf
 session.conf
-system.conf
 run-with-tmp-session-bus.conf
 finite-timeout.conf
index 23931626511aac8c0a6519be1a2d83cd336aa5e9..df9a994323feeaa8e589c27fa2453654af66077b 100644 (file)
@@ -17,8 +17,6 @@
     <deny own_prefix="org.freedesktop.ManySystems"/>
     <deny send_destination="org.freedesktop.System"/>
     <deny receive_sender="org.freedesktop.System"/>
-    <deny user="root"/>
-    <deny group="bin"/>
     <allow send_type="error"/>
     <allow send_type="method_call"/>
     <allow send_type="method_return"/>
@@ -36,8 +34,6 @@
     <deny own_prefix="org.freedesktop.ManySystems"/>
     <deny send_destination="org.freedesktop.System"/>
     <deny receive_sender="org.freedesktop.System"/>
-    <deny user="root"/>
-    <deny group="bin"/>
     <allow send_type="error"/>
     <allow send_type="method_call"/>
     <allow send_type="method_return"/>