diff options
50 files changed, 2119 insertions, 505 deletions
@@ -1,3 +1,28 @@ +D-Bus 1.5.12 (2012-03-27) +== + +The “Big Book of Science” release. + +• Add public API to validate various string types: + dbus_validate_path(), dbus_validate_interface(), dbus_validate_member(), + dbus_validate_error_name(), dbus_validate_bus_name(), dbus_validate_utf8() + (fd.o #39549, Simon McVittie) + +• Turn DBusBasicValue into public API so bindings don't need to invent their + own "union of everything" type (fd.o #11191, Simon McVittie) + +• Enumerate data files included in the build rather than using find(1) + (fd.o #33840, Simon McVittie) + +• Add support for policy rules like <allow own_prefix="com.example.Service"/> + in dbus-daemon (fd.o #46273, Alban Crequy) + +• Windows-specific: + · make dbus-daemon.exe --print-address (and --print-pid) work again + on Win32, but not on WinCE (fd.o #46049, Simon McVittie) + · fix duplicate case value when compiling against mingw-w64 + (fd.o #47321, Andoni Morales Alastruey) + D-Bus 1.5.10 (2012-02-21) == diff --git a/bus/config-parser.c b/bus/config-parser.c index a8953627..07e8fbb6 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -1154,6 +1154,7 @@ append_rule_from_element (BusConfigParser *parser, const char *send_requested_reply; const char *receive_requested_reply; const char *own; + const char *own_prefix; const char *user; const char *group; @@ -1179,6 +1180,7 @@ append_rule_from_element (BusConfigParser *parser, "send_requested_reply", &send_requested_reply, "receive_requested_reply", &receive_requested_reply, "own", &own, + "own_prefix", &own_prefix, "user", &user, "group", &group, "log", &log, @@ -1190,7 +1192,7 @@ append_rule_from_element (BusConfigParser *parser, receive_interface || receive_member || receive_error || receive_sender || receive_type || receive_path || eavesdrop || send_requested_reply || receive_requested_reply || - own || user || group)) + own || own_prefix || user || group)) { dbus_set_error (error, DBUS_ERROR_FAILED, "Element <%s> must have one or more attributes", @@ -1218,7 +1220,7 @@ append_rule_from_element (BusConfigParser *parser, * base send_ can combine with send_destination, send_path, send_type, send_requested_reply * base receive_ with receive_sender, receive_path, receive_type, receive_requested_reply, eavesdrop * - * user, group, own must occur alone + * user, group, own, own_prefix must occur alone * * Pretty sure the below stuff is broken, FIXME think about it more. */ @@ -1229,7 +1231,7 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || @@ -1239,7 +1241,7 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || @@ -1248,7 +1250,7 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || @@ -1257,7 +1259,7 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || @@ -1266,7 +1268,7 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || @@ -1275,7 +1277,7 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || @@ -1284,33 +1286,35 @@ append_rule_from_element (BusConfigParser *parser, receive_error || receive_sender || receive_requested_reply || - own || + own || own_prefix || user || group)) || (receive_interface && (receive_error || - own || + own || own_prefix || user || group)) || (receive_member && (receive_error || - own || + own || own_prefix || user || group)) || - (receive_error && (own || + (receive_error && (own || own_prefix || user || group)) || - (eavesdrop && (own || + (eavesdrop && (own || own_prefix || user || group)) || - (receive_requested_reply && (own || + (receive_requested_reply && (own || own_prefix || user || group)) || - (own && (user || group)) || + (own && (own_prefix || user || group)) || + + (own_prefix && (own || user || group)) || (user && group)) { @@ -1488,18 +1492,29 @@ append_rule_from_element (BusConfigParser *parser, if (receive_sender && rule->d.receive.origin == NULL) goto nomem; } - else if (own) + else if (own || own_prefix) { rule = bus_policy_rule_new (BUS_POLICY_RULE_OWN, allow); if (rule == NULL) goto nomem; - if (IS_WILDCARD (own)) - own = NULL; + if (own) + { + if (IS_WILDCARD (own)) + own = NULL; - rule->d.own.service_name = _dbus_strdup (own); - if (own && rule->d.own.service_name == NULL) - goto nomem; + rule->d.own.prefix = 0; + rule->d.own.service_name = _dbus_strdup (own); + if (own && rule->d.own.service_name == NULL) + goto nomem; + } + else + { + rule->d.own.prefix = 1; + rule->d.own.service_name = _dbus_strdup (own_prefix); + if (rule->d.own.service_name == NULL) + goto nomem; + } } else if (user) { @@ -2731,9 +2746,60 @@ typedef enum } Validity; static dbus_bool_t +do_check_own_rules (BusPolicy *policy) +{ + const struct { + char *name; + dbus_bool_t allowed; + } checks[] = { + {"org.freedesktop", FALSE}, + {"org.freedesktop.ManySystem", FALSE}, + {"org.freedesktop.ManySystems", TRUE}, + {"org.freedesktop.ManySystems.foo", TRUE}, + {"org.freedesktop.ManySystems.foo.bar", TRUE}, + {"org.freedesktop.ManySystems2", FALSE}, + {"org.freedesktop.ManySystems2.foo", FALSE}, + {"org.freedesktop.ManySystems2.foo.bar", FALSE}, + {NULL, FALSE} + }; + int i = 0; + + while (checks[i].name) + { + DBusString service_name; + dbus_bool_t ret; + + if (!_dbus_string_init (&service_name)) + _dbus_assert_not_reached ("couldn't init string"); + if (!_dbus_string_append (&service_name, checks[i].name)) + _dbus_assert_not_reached ("couldn't append string"); + + ret = bus_policy_check_can_own (policy, &service_name); + printf (" Check name %s: %s\n", checks[i].name, + ret ? "allowed" : "not allowed"); + if (checks[i].allowed && !ret) + { + _dbus_warn ("Cannot own %s\n", checks[i].name); + return FALSE; + } + if (!checks[i].allowed && ret) + { + _dbus_warn ("Can own %s\n", checks[i].name); + return FALSE; + } + _dbus_string_free (&service_name); + + i++; + } + + return TRUE; +} + +static dbus_bool_t do_load (const DBusString *full_path, Validity validity, - dbus_bool_t oom_possible) + dbus_bool_t oom_possible, + dbus_bool_t check_own_rules) { BusConfigParser *parser; DBusError error; @@ -2770,6 +2836,11 @@ do_load (const DBusString *full_path, { _DBUS_ASSERT_ERROR_IS_CLEAR (&error); + if (check_own_rules && do_check_own_rules (parser->policy) == FALSE) + { + return FALSE; + } + bus_config_parser_unref (parser); if (validity == INVALID) @@ -2786,6 +2857,7 @@ typedef struct { const DBusString *full_path; Validity validity; + dbus_bool_t check_own_rules; } LoaderOomData; static dbus_bool_t @@ -2793,7 +2865,7 @@ check_loader_oom_func (void *data) { LoaderOomData *d = data; - return do_load (d->full_path, d->validity, TRUE); + return do_load (d->full_path, d->validity, TRUE, d->check_own_rules); } static dbus_bool_t @@ -2876,6 +2948,8 @@ process_test_valid_subdir (const DBusString *test_base_dir, d.full_path = &full_path; d.validity = validity; + d.check_own_rules = _dbus_string_ends_with_c_str (&full_path, + "check-own-rules.conf"); /* FIXME hackaround for an expat problem, see * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=124747 diff --git a/bus/policy.c b/bus/policy.c index 34e84469..379cea95 100644 --- a/bus/policy.c +++ b/bus/policy.c @@ -1240,25 +1240,26 @@ bus_client_policy_check_can_receive (BusClientPolicy *policy, return allowed; } -dbus_bool_t -bus_client_policy_check_can_own (BusClientPolicy *policy, - DBusConnection *connection, - const DBusString *service_name) + + +static dbus_bool_t +bus_rules_check_can_own (DBusList *rules, + const DBusString *service_name) { DBusList *link; dbus_bool_t allowed; - /* policy->rules is in the order the rules appeared + /* rules is in the order the rules appeared * in the config file, i.e. last rule that applies wins */ allowed = FALSE; - link = _dbus_list_get_first_link (&policy->rules); + link = _dbus_list_get_first_link (&rules); while (link != NULL) { BusPolicyRule *rule = link->data; - link = _dbus_list_get_next_link (&policy->rules, link); + link = _dbus_list_get_next_link (&rules, link); /* Rule is skipped if it specifies a different service name from * the desired one. @@ -1267,12 +1268,25 @@ bus_client_policy_check_can_own (BusClientPolicy *policy, if (rule->type != BUS_POLICY_RULE_OWN) continue; - if (rule->d.own.service_name != NULL) + if (!rule->d.own.prefix && rule->d.own.service_name != NULL) { if (!_dbus_string_equal_c_str (service_name, rule->d.own.service_name)) continue; } + else if (rule->d.own.prefix) + { + const char *data; + char next_char; + if (!_dbus_string_starts_with_c_str (service_name, + rule->d.own.service_name)) + continue; + + data = _dbus_string_get_const_data (service_name); + next_char = data[strlen (rule->d.own.service_name)]; + if (next_char != '\0' && next_char != '.') + continue; + } /* Use this rule */ allowed = rule->allow; @@ -1280,3 +1294,20 @@ bus_client_policy_check_can_own (BusClientPolicy *policy, return allowed; } + +dbus_bool_t +bus_client_policy_check_can_own (BusClientPolicy *policy, + const DBusString *service_name) +{ + return bus_rules_check_can_own (policy->rules, service_name); +} + +#ifdef DBUS_BUILD_TESTS +dbus_bool_t +bus_policy_check_can_own (BusPolicy *policy, + const DBusString *service_name) +{ + return bus_rules_check_can_own (policy->default_rules, service_name); +} +#endif /* DBUS_BUILD_TESTS */ + diff --git a/bus/policy.h b/bus/policy.h index 1782dbf3..3ff6f482 100644 --- a/bus/policy.h +++ b/bus/policy.h @@ -86,6 +86,8 @@ struct BusPolicyRule { /* can be NULL meaning "any" */ char *service_name; + /* if prefix is set, any name starting with service_name can be owned */ + unsigned int prefix : 1; } own; struct @@ -154,11 +156,14 @@ dbus_bool_t bus_client_policy_check_can_receive (BusClientPolicy *policy, DBusMessage *message, dbus_int32_t *toggles); dbus_bool_t bus_client_policy_check_can_own (BusClientPolicy *policy, - DBusConnection *connection, const DBusString *service_name); dbus_bool_t bus_client_policy_append_rule (BusClientPolicy *policy, BusPolicyRule *rule); void bus_client_policy_optimize (BusClientPolicy *policy); +#ifdef DBUS_BUILD_TESTS +dbus_bool_t bus_policy_check_can_own (BusPolicy *policy, + const DBusString *service_name); +#endif #endif /* BUS_POLICY_H */ diff --git a/bus/services.c b/bus/services.c index 68a7022a..6f380fac 100644 --- a/bus/services.c +++ b/bus/services.c @@ -459,8 +459,7 @@ bus_registry_acquire_service (BusRegistry *registry, goto out; } - if (!bus_client_policy_check_can_own (policy, connection, - service_name)) + if (!bus_client_policy_check_can_own (policy, service_name)) { dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED, "Connection \"%s\" is not allowed to own the service \"%s\" due " diff --git a/cmake/.CMakeLists.txt.swp b/cmake/.CMakeLists.txt.swp Binary files differdeleted file mode 100644 index 14894af3..00000000 --- a/cmake/.CMakeLists.txt.swp +++ /dev/null diff --git a/cmake/bus/dbus-daemon.xml b/cmake/bus/dbus-daemon.xml index c6f4db07..f331699c 100644 --- a/cmake/bus/dbus-daemon.xml +++ b/cmake/bus/dbus-daemon.xml @@ -512,6 +512,7 @@ statements, and works just like <deny> but with the inverse meaning.</para eavesdrop="true" | "false" own="name" + own_prefix="name" user="username" group="groupname" </literallayout> <!-- .fi --> @@ -590,6 +591,13 @@ the character "*" can be substituted, meaning "any." Complex globs like "foo.bar.*" aren't allowed for now because they'd be work to implement and maybe encourage sloppy security anyway.</para> +<para><allow own_prefix="a.b"/> allows you to own the name "a.b" or any +name whose first dot-separated elements are "a.b": in particular, +you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c". +This is useful when services like Telepathy and ReserveDevice +define a meaning for subtrees of well-known names, such as +org.freedesktop.Telepathy.ConnectionManager.(anything) +and org.freedesktop.ReserveDevice1.(anything).</para> <para>It does not make sense to deny a user or group inside a <policy> for a user or group; user/group denials can only be inside diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index edc203b0..13d6f87a 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -21,6 +21,7 @@ set (dbusinclude_HEADERS ${DBUS_DIR}/dbus-server.h ${DBUS_DIR}/dbus-shared.h ${DBUS_DIR}/dbus-signature.h + ${DBUS_DIR}/dbus-syntax.h ${DBUS_DIR}/dbus-threads.h ${DBUS_DIR}/dbus-types.h dbus-arch-deps.h @@ -51,6 +52,7 @@ set (DBUS_LIB_SOURCES ${DBUS_DIR}/dbus-server-debug-pipe.c ${DBUS_DIR}/dbus-sha.c ${DBUS_DIR}/dbus-signature.c + ${DBUS_DIR}/dbus-syntax.c ${DBUS_DIR}/dbus-timeout.c ${DBUS_DIR}/dbus-threads.c ${DBUS_DIR}/dbus-transport.c @@ -1,10 +1,10 @@ #! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. +# Wrapper for compilers which do not understand '-c -o'. -scriptversion=2009-10-06.20; # UTC +scriptversion=2012-01-04.17; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software -# Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free +# Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -29,21 +29,186 @@ scriptversion=2009-10-06.20; # UTC # bugs to <bug-automake@gnu.org> or send patches to # <automake-patches@gnu.org>. +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l*) + lib=${1#-l} + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + set x "$@" "$dir/$lib.dll.lib" + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + set x "$@" "$dir/$lib.lib" + break + fi + done + IFS=$save_IFS + + test "$found" != yes && set x "$@" "$lib.lib" + shift + ;; + -L*) + func_file_conv "${1#-L}" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + case $1 in '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. +right script to run: please start by reading the file 'INSTALL'. Report bugs to <bug-automake@gnu.org>. EOF @@ -53,11 +218,13 @@ EOF echo "compile $scriptversion" exit $? ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; esac ofile= cfile= -eat= for arg do @@ -66,8 +233,8 @@ do else case $1 in -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) @@ -94,10 +261,10 @@ do done if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a + # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also + # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi @@ -106,7 +273,7 @@ fi cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. -# Note: use `[/\\:.-]' here to ensure that we don't use the same name +# Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d diff --git a/config.guess b/config.guess index 40eaed48..d622a44e 100755 --- a/config.guess +++ b/config.guess @@ -2,9 +2,9 @@ # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. +# 2011, 2012 Free Software Foundation, Inc. -timestamp='2011-05-11' +timestamp='2012-02-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -17,9 +17,7 @@ timestamp='2011-05-11' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -57,8 +55,8 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -145,7 +143,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -792,13 +790,12 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) @@ -807,6 +804,9 @@ EOF *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 @@ -861,6 +861,13 @@ EOF i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -895,13 +902,16 @@ EOF echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu @@ -943,7 +953,7 @@ EOF test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) - echo or32-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu @@ -978,13 +988,13 @@ EOF echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-tilera-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -1315,6 +1325,9 @@ EOF i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -2,9 +2,9 @@ # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. +# 2011, 2012 Free Software Foundation, Inc. -timestamp='2011-03-23' +timestamp='2012-02-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -21,9 +21,7 @@ timestamp='2011-03-23' # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -76,8 +74,8 @@ version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -132,6 +130,10 @@ case $maybe_os in os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -247,17 +249,22 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ + | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ @@ -291,7 +298,7 @@ case $basic_machine in | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ - | rx \ + | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ @@ -300,7 +307,7 @@ case $basic_machine in | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ - | v850 | v850e \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -315,8 +322,7 @@ case $basic_machine in c6x) basic_machine=tic6x-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -329,7 +335,10 @@ case $basic_machine in strongarm | thumb | xscale) basic_machine=arm-unknown ;; - + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; xscaleeb) basic_machine=armeb-unknown ;; @@ -352,11 +361,13 @@ case $basic_machine in # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ @@ -365,8 +376,10 @@ case $basic_machine in | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ @@ -400,7 +413,7 @@ case $basic_machine in | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* | rx-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ @@ -408,10 +421,11 @@ case $basic_machine in | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile-* | tilegx-* \ + | tile*-* \ | tron-* \ | ubicom32-* \ - | v850-* | v850e-* | vax-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -711,7 +725,6 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -808,10 +821,18 @@ case $basic_machine in ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i386-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -1120,13 +1141,8 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - # This must be matched before tile*. - tilegx*) - basic_machine=tilegx-unknown - os=-linux-gnu - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1336,7 +1352,7 @@ case $os in | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ @@ -1548,9 +1564,6 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for dbus 1.5.10. +# Generated by GNU Autoconf 2.68 for dbus 1.5.12. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=dbus>. # @@ -571,8 +571,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dbus' PACKAGE_TARNAME='dbus' -PACKAGE_VERSION='1.5.10' -PACKAGE_STRING='dbus 1.5.10' +PACKAGE_VERSION='1.5.12' +PACKAGE_STRING='dbus 1.5.12' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=dbus' PACKAGE_URL='' @@ -1507,7 +1507,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dbus 1.5.10 to adapt to many kinds of systems. +\`configure' configures dbus 1.5.12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1581,7 +1581,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dbus 1.5.10:";; + short | recursive ) echo "Configuration of dbus 1.5.12:";; esac cat <<\_ACEOF @@ -1777,7 +1777,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dbus configure 1.5.10 +dbus configure 1.5.12 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2491,7 +2491,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dbus $as_me 1.5.10, which was +It was created by dbus $as_me 1.5.12, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3383,7 +3383,7 @@ fi # Define the identity of the package. PACKAGE='dbus' - VERSION='1.5.10' + VERSION='1.5.12' cat >>confdefs.h <<_ACEOF @@ -3590,16 +3590,16 @@ _ACEOF # ## increment if the interface has additions, changes, removals. -LT_CURRENT=9 +LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=5 +LT_REVISION=0 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has ## precedence over adding, so set to 0 if both happened. -LT_AGE=6 +LT_AGE=7 @@ -3607,8 +3607,8 @@ LT_AGE=6 DBUS_MAJOR_VERSION=1 DBUS_MINOR_VERSION=5 -DBUS_MICRO_VERSION=10 -DBUS_VERSION=1.5.10 +DBUS_MICRO_VERSION=12 +DBUS_VERSION=1.5.12 @@ -23168,7 +23168,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dbus $as_me 1.5.10, which was +This file was extended by dbus $as_me 1.5.12, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -23234,7 +23234,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dbus config.status 1.5.10 +dbus config.status 1.5.12 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 85c11ea2..fc323148 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [5]) -m4_define([dbus_micro_version], [10]) +m4_define([dbus_micro_version], [12]) m4_define([dbus_version], [dbus_major_version.dbus_minor_version.dbus_micro_version]) AC_INIT([dbus],[dbus_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=dbus],[dbus]) @@ -32,16 +32,16 @@ AC_DEFINE_UNQUOTED(DBUS_DAEMON_NAME,"dbus-daemon",[Name of executable]) # ## increment if the interface has additions, changes, removals. -LT_CURRENT=9 +LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=5 +LT_REVISION=0 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has ## precedence over adding, so set to 0 if both happened. -LT_AGE=6 +LT_AGE=7 AC_SUBST(LT_CURRENT) AC_SUBST(LT_REVISION) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index c8d35f75..bb5cccaf 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -132,6 +132,7 @@ dbusinclude_HEADERS= \ dbus-server.h \ dbus-shared.h \ dbus-signature.h \ + dbus-syntax.h \ dbus-threads.h \ dbus-types.h @@ -183,6 +184,7 @@ DBUS_LIB_SOURCES= \ dbus-sha.c \ dbus-sha.h \ dbus-signature.c \ + dbus-syntax.c \ dbus-timeout.c \ dbus-timeout.h \ dbus-threads-internal.h \ diff --git a/dbus/Makefile.in b/dbus/Makefile.in index 62ed1fc1..4b52d1c4 100644 --- a/dbus/Makefile.in +++ b/dbus/Makefile.in @@ -107,7 +107,7 @@ am__libdbus_1_la_SOURCES_DIST = dbus-address.c dbus-auth.c dbus-auth.h \ dbus-server-socket.c dbus-server-socket.h dbus-uuidgen.c \ dbus-uuidgen.h dbus-server-unix.c dbus-server-unix.h \ dbus-server-win.c dbus-server-win.h dbus-sha.c dbus-sha.h \ - dbus-signature.c dbus-timeout.c dbus-timeout.h \ + dbus-signature.c dbus-syntax.c dbus-timeout.c dbus-timeout.h \ dbus-threads-internal.h dbus-threads.c dbus-transport.c \ dbus-transport.h dbus-transport-protected.h \ dbus-transport-socket.c dbus-transport-socket.h dbus-watch.c \ @@ -145,8 +145,8 @@ am__objects_2 = libdbus_1_la-dbus-address.lo libdbus_1_la-dbus-auth.lo \ libdbus_1_la-dbus-server-debug-pipe.lo \ libdbus_1_la-dbus-server-socket.lo $(am__objects_1) \ libdbus_1_la-dbus-sha.lo libdbus_1_la-dbus-signature.lo \ - libdbus_1_la-dbus-timeout.lo libdbus_1_la-dbus-threads.lo \ - libdbus_1_la-dbus-transport.lo \ + libdbus_1_la-dbus-syntax.lo libdbus_1_la-dbus-timeout.lo \ + libdbus_1_la-dbus-threads.lo libdbus_1_la-dbus-transport.lo \ libdbus_1_la-dbus-transport-socket.lo \ libdbus_1_la-dbus-watch.lo @DBUS_ENABLE_LAUNCHD_TRUE@@DBUS_WIN_FALSE@am__objects_3 = libdbus_1_la-dbus-server-launchd.lo @@ -199,7 +199,7 @@ am__libdbus_internal_la_SOURCES_DIST = dbus-address.c dbus-auth.c \ dbus-server-socket.c dbus-server-socket.h dbus-uuidgen.c \ dbus-uuidgen.h dbus-server-unix.c dbus-server-unix.h \ dbus-server-win.c dbus-server-win.h dbus-sha.c dbus-sha.h \ - dbus-signature.c dbus-timeout.c dbus-timeout.h \ + dbus-signature.c dbus-syntax.c dbus-timeout.c dbus-timeout.h \ dbus-threads-internal.h dbus-threads.c dbus-transport.c \ dbus-transport.h dbus-transport-protected.h \ dbus-transport-socket.c dbus-transport-socket.h dbus-watch.c \ @@ -254,6 +254,7 @@ am__objects_8 = libdbus_internal_la-dbus-address.lo \ libdbus_internal_la-dbus-server-socket.lo $(am__objects_7) \ libdbus_internal_la-dbus-sha.lo \ libdbus_internal_la-dbus-signature.lo \ + libdbus_internal_la-dbus-syntax.lo \ libdbus_internal_la-dbus-timeout.lo \ libdbus_internal_la-dbus-threads.lo \ libdbus_internal_la-dbus-transport.lo \ @@ -657,6 +658,7 @@ dbusinclude_HEADERS = \ dbus-server.h \ dbus-shared.h \ dbus-signature.h \ + dbus-syntax.h \ dbus-threads.h \ dbus-types.h @@ -708,6 +710,7 @@ DBUS_LIB_SOURCES = \ dbus-sha.c \ dbus-sha.h \ dbus-signature.c \ + dbus-syntax.c \ dbus-timeout.c \ dbus-timeout.h \ dbus-threads-internal.h \ @@ -959,6 +962,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-sha.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-signature.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-string.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-syntax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-sysdeps-pthread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-sysdeps-thread-win.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-sysdeps-unix.Plo@am__quote@ @@ -1030,6 +1034,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-spawn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-string-util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-string.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-syntax.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-sysdeps-pthread.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-sysdeps-thread-win.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-sysdeps-unix.Plo@am__quote@ @@ -1248,6 +1253,13 @@ libdbus_1_la-dbus-signature.lo: dbus-signature.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_1_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_1_la-dbus-signature.lo `test -f 'dbus-signature.c' || echo '$(srcdir)/'`dbus-signature.c +libdbus_1_la-dbus-syntax.lo: dbus-syntax.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_1_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_1_la-dbus-syntax.lo -MD -MP -MF $(DEPDIR)/libdbus_1_la-dbus-syntax.Tpo -c -o libdbus_1_la-dbus-syntax.lo `test -f 'dbus-syntax.c' || echo '$(srcdir)/'`dbus-syntax.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_1_la-dbus-syntax.Tpo $(DEPDIR)/libdbus_1_la-dbus-syntax.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-syntax.c' object='libdbus_1_la-dbus-syntax.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_1_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_1_la-dbus-syntax.lo `test -f 'dbus-syntax.c' || echo '$(srcdir)/'`dbus-syntax.c + libdbus_1_la-dbus-timeout.lo: dbus-timeout.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_1_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_1_la-dbus-timeout.lo -MD -MP -MF $(DEPDIR)/libdbus_1_la-dbus-timeout.Tpo -c -o libdbus_1_la-dbus-timeout.lo `test -f 'dbus-timeout.c' || echo '$(srcdir)/'`dbus-timeout.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_1_la-dbus-timeout.Tpo $(DEPDIR)/libdbus_1_la-dbus-timeout.Plo @@ -1633,6 +1645,13 @@ libdbus_internal_la-dbus-signature.lo: dbus-signature.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_internal_la-dbus-signature.lo `test -f 'dbus-signature.c' || echo '$(srcdir)/'`dbus-signature.c +libdbus_internal_la-dbus-syntax.lo: dbus-syntax.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_internal_la-dbus-syntax.lo -MD -MP -MF $(DEPDIR)/libdbus_internal_la-dbus-syntax.Tpo -c -o libdbus_internal_la-dbus-syntax.lo `test -f 'dbus-syntax.c' || echo '$(srcdir)/'`dbus-syntax.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_internal_la-dbus-syntax.Tpo $(DEPDIR)/libdbus_internal_la-dbus-syntax.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-syntax.c' object='libdbus_internal_la-dbus-syntax.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_internal_la-dbus-syntax.lo `test -f 'dbus-syntax.c' || echo '$(srcdir)/'`dbus-syntax.c + libdbus_internal_la-dbus-timeout.lo: dbus-timeout.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_internal_la-dbus-timeout.lo -MD -MP -MF $(DEPDIR)/libdbus_internal_la-dbus-timeout.Tpo -c -o libdbus_internal_la-dbus-timeout.lo `test -f 'dbus-timeout.c' || echo '$(srcdir)/'`dbus-timeout.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_internal_la-dbus-timeout.Tpo $(DEPDIR)/libdbus_internal_la-dbus-timeout.Plo diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h index ac4158e9..3d37f188 100644 --- a/dbus/dbus-connection-internal.h +++ b/dbus/dbus-connection-internal.h @@ -114,6 +114,10 @@ void _dbus_connection_get_stats (DBusConnection *connection, dbus_uint32_t *out_peak_bytes, dbus_uint32_t *out_peak_fds); + +/* if DBUS_BUILD_TESTS */ +const char* _dbus_connection_get_address (DBusConnection *connection); + /* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems * silly for one function */ diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 74a9007c..ac0b2c0e 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -6258,4 +6258,18 @@ dbus_connection_get_outgoing_unix_fds (DBusConnection *connection) return res; } +#ifdef DBUS_BUILD_TESTS +/** + * Returns the address of the transport object of this connection + * + * @param connection the connection + * @returns the address string + */ +const char* +_dbus_connection_get_address (DBusConnection *connection) +{ + return _dbus_transport_get_address (connection->transport); +} +#endif + /** @} */ diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index b63761e9..88b19f36 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -65,6 +65,13 @@ _DBUS_STATIC_ASSERT (sizeof (dbus_uint64_t) == 8); _DBUS_ASSERT_ALIGNMENT (dbus_uint64_t, <=, 8); #endif +_DBUS_STATIC_ASSERT (sizeof (DBusBasicValue) >= 8); +/* The alignment of a DBusBasicValue might conceivably be > 8 because of the + * pointer, so we don't assert about it */ + +_DBUS_STATIC_ASSERT (sizeof (DBus8ByteStruct) == 8); +_DBUS_ASSERT_ALIGNMENT (DBus8ByteStruct, <=, 8); + /** * @defgroup DBusMarshal marshaling and unmarshaling * @ingroup DBusInternals @@ -119,7 +126,7 @@ pack_8_octets (DBusBasicValue value, else *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value.u64); #else - *(DBus8ByteStruct*)data = value.u64; + *(DBus8ByteStruct*)data = value.eight; swap_8_octets ((DBusBasicValue*)data, byte_order); #endif } @@ -169,7 +176,7 @@ swap_8_octets (DBusBasicValue *value, #ifdef DBUS_HAVE_INT64 value->u64 = DBUS_UINT64_SWAP_LE_BE (value->u64); #else - swap_bytes ((unsigned char *)value, 8); + swap_bytes (&value->bytes, 8); #endif } } @@ -190,7 +197,7 @@ unpack_8_octets (int byte_order, else r.u64 = DBUS_UINT64_FROM_BE (*(dbus_uint64_t*)data); #else - r.u64 = *(DBus8ByteStruct*)data; + r.eight = *(DBus8ByteStruct*)data; swap_8_octets (&r, byte_order); #endif diff --git a/dbus/dbus-marshal-basic.h b/dbus/dbus-marshal-basic.h index 1b345e36..034fdaba 100644 --- a/dbus/dbus-marshal-basic.h +++ b/dbus/dbus-marshal-basic.h @@ -146,40 +146,6 @@ # define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val)) #endif /* DBUS_HAVE_INT64 */ -#ifndef DBUS_HAVE_INT64 -/** - * An 8-byte struct you could use to access int64 without having - * int64 support - */ -typedef struct -{ - dbus_uint32_t first32; /**< first 32 bits in the 8 bytes (beware endian issues) */ - dbus_uint32_t second32; /**< second 32 bits in the 8 bytes (beware endian issues) */ -} DBus8ByteStruct; -#endif /* DBUS_HAVE_INT64 */ - -/** - * A simple 8-byte value union that lets you access 8 bytes as if they - * were various types; useful when dealing with basic types via - * void pointers and varargs. - */ -typedef union -{ - dbus_int16_t i16; /**< as int16 */ - dbus_uint16_t u16; /**< as int16 */ - dbus_int32_t i32; /**< as int32 */ - dbus_uint32_t u32; /**< as int32 */ -#ifdef DBUS_HAVE_INT64 - dbus_int64_t i64; /**< as int64 */ - dbus_uint64_t u64; /**< as int64 */ -#else - DBus8ByteStruct u64; /**< as 8-byte-struct */ -#endif - double dbl; /**< as double */ - unsigned char byt; /**< as byte */ - char *str; /**< as char* */ -} DBusBasicValue; - #ifdef DBUS_DISABLE_ASSERT #define _dbus_unpack_uint16(byte_order, data) \ (((byte_order) == DBUS_LITTLE_ENDIAN) ? \ diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c index e68e2748..95124140 100644 --- a/dbus/dbus-marshal-recursive-util.c +++ b/dbus/dbus-marshal-recursive-util.c @@ -38,8 +38,8 @@ basic_value_zero (DBusBasicValue *value) #ifdef DBUS_HAVE_INT64 value->u64 = 0; #else - value->u64.first32 = 0; - value->u64.second32 = 0; + value->eight.first32 = 0; + value->eight.second32 = 0; #endif } @@ -59,8 +59,8 @@ basic_value_equal (int type, #ifdef DBUS_HAVE_INT64 return lhs->u64 == rhs->u64; #else - return lhs->u64.first32 == rhs->u64.first32 && - lhs->u64.second32 == rhs->u64.second32; + return lhs->eight.first32 == rhs->eight.first32 && + lhs->eight.second32 == rhs->eight.second32; #endif } } diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index b02f490c..71bcee60 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2191,22 +2191,22 @@ dbus_message_iter_get_signature (DBusMessageIter *iter) * descriptors), you can get all the array elements at once with * dbus_message_iter_get_fixed_array(). Otherwise, you have to iterate * over the container's contents one value at a time. - * - * All basic-typed values are guaranteed to fit in 8 bytes. So you can - * write code like this: + * + * All basic-typed values are guaranteed to fit in a #DBusBasicValue, + * so in versions of libdbus that have that type, you can write code like this: * * @code - * dbus_uint64_t value; + * DBusBasicValue value; * int type; * dbus_message_iter_get_basic (&read_iter, &value); * type = dbus_message_iter_get_arg_type (&read_iter); * dbus_message_iter_append_basic (&write_iter, type, &value); * @endcode * - * On some really obscure platforms dbus_uint64_t might not exist, if - * you need to worry about this you will know. dbus_uint64_t is just - * one example of a type that's large enough to hold any possible - * value, you could use a struct or char[8] instead if you like. + * (All D-Bus basic types are either numeric and 8 bytes or smaller, or + * behave like a string; so in older versions of libdbus, DBusBasicValue + * can be replaced with union { char *string; unsigned char bytes[8]; }, + * for instance.) * * @param iter the iterator * @param value location to store the value diff --git a/dbus/dbus-pipe-unix.c b/dbus/dbus-pipe-unix.c index 1a2806e2..cfc57044 100644 --- a/dbus/dbus-pipe-unix.c +++ b/dbus/dbus-pipe-unix.c @@ -50,7 +50,7 @@ _dbus_pipe_write (DBusPipe *pipe, { int written; - written = _dbus_write (pipe->fd_or_handle, buffer, start, len); + written = _dbus_write (pipe->fd, buffer, start, len); if (written < 0) { dbus_set_error (error, DBUS_ERROR_FAILED, @@ -71,7 +71,7 @@ int _dbus_pipe_close (DBusPipe *pipe, DBusError *error) { - if (!_dbus_close (pipe->fd_or_handle, error)) + if (!_dbus_close (pipe->fd, error)) { return -1; } diff --git a/dbus/dbus-pipe-win.c b/dbus/dbus-pipe-win.c index f734518c..9c7c2570 100644 --- a/dbus/dbus-pipe-win.c +++ b/dbus/dbus-pipe-win.c @@ -29,6 +29,7 @@ #include "dbus-pipe.h" #include <windows.h> +#include <io.h> /** * write data to a pipe. @@ -47,19 +48,18 @@ _dbus_pipe_write (DBusPipe *pipe, int len, DBusError *error) { - DWORD written; - BOOL res; - const char *buffer_c = _dbus_string_get_const_data (buffer); + int written; - res = WriteFile ((HANDLE) pipe->fd_or_handle, buffer_c + start, len, &written, NULL); - if (res == 0 || written < 0) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Writing to pipe: %s\n", - _dbus_strerror_from_errno ()); - } - return written; + written = _write (pipe->fd, buffer_c + start, len); + + if (written >= 0) + return written; + + dbus_set_error (error, _dbus_error_from_system_errno (), + "Writing to pipe: %s", + _dbus_strerror_from_errno ()); + return -1; } /** @@ -75,10 +75,10 @@ _dbus_pipe_close (DBusPipe *pipe, { _DBUS_ASSERT_ERROR_IS_CLEAR (error); - if (CloseHandle ((HANDLE) pipe->fd_or_handle) == 0) + if (_close (pipe->fd) != 0) { dbus_set_error (error, _dbus_error_from_system_errno (), - "Could not close pipe %d: %s", pipe->fd_or_handle, + "Could not close pipe fd %d: %s", pipe->fd, _dbus_strerror_from_errno ()); return -1; } diff --git a/dbus/dbus-pipe.c b/dbus/dbus-pipe.c index 06560f16..7b5fe6d4 100644 --- a/dbus/dbus-pipe.c +++ b/dbus/dbus-pipe.c @@ -33,9 +33,9 @@ */ void _dbus_pipe_init (DBusPipe *pipe, - intptr_t fd) + int fd) { - pipe->fd_or_handle = fd; + pipe->fd = fd; } /** @@ -59,7 +59,7 @@ _dbus_pipe_init_stdout (DBusPipe *pipe) dbus_bool_t _dbus_pipe_is_valid(DBusPipe *pipe) { - return pipe->fd_or_handle >= 0; + return pipe->fd >= 0; } /** @@ -71,7 +71,7 @@ _dbus_pipe_is_valid(DBusPipe *pipe) dbus_bool_t _dbus_pipe_is_stdout_or_stderr (DBusPipe *pipe) { - return pipe->fd_or_handle == 1 || pipe->fd_or_handle == 2; + return pipe->fd == 1 || pipe->fd == 2; } /** @@ -81,5 +81,5 @@ _dbus_pipe_is_stdout_or_stderr (DBusPipe *pipe) void _dbus_pipe_invalidate (DBusPipe *pipe) { - pipe->fd_or_handle = -1; + pipe->fd = -1; } diff --git a/dbus/dbus-pipe.h b/dbus/dbus-pipe.h index f6eac5f9..c2063b5a 100644 --- a/dbus/dbus-pipe.h +++ b/dbus/dbus-pipe.h @@ -39,11 +39,11 @@ #include <dbus/dbus-sysdeps.h> struct DBusPipe { - intptr_t fd_or_handle; + int fd; }; void _dbus_pipe_init (DBusPipe *pipe, - intptr_t fd); + int fd); void _dbus_pipe_init_stdout (DBusPipe *pipe); int _dbus_pipe_write (DBusPipe *pipe, const DBusString *buffer, diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 85738c2f..9accdb19 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -2182,7 +2182,6 @@ _dbus_string_equal_c_str (const DBusString *a, return TRUE; } -#ifdef DBUS_BUILD_TESTS /** * Checks whether a string starts with the given C string. * @@ -2218,7 +2217,6 @@ _dbus_string_starts_with_c_str (const DBusString *a, else return FALSE; } -#endif /* DBUS_BUILD_TESTS */ /** * Appends a two-character hex digit to a string, where the hex digit diff --git a/dbus/dbus-syntax.c b/dbus/dbus-syntax.c new file mode 100644 index 00000000..47922875 --- /dev/null +++ b/dbus/dbus-syntax.c @@ -0,0 +1,309 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-syntax.c - utility functions for strings with special syntax + * + * Author: Simon McVittie <simon.mcvittie@collabora.co.uk> + * Copyright © 2011 Nokia Corporation + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <config.h> +#include "dbus-syntax.h" + +#include "dbus-internals.h" +#include "dbus-marshal-validate.h" +#include "dbus-shared.h" + +/** + * @defgroup DBusSyntax Utility functions for strings with special syntax + * @ingroup DBus + * @brief Parsing D-Bus type signatures + * @{ + */ + +/** + * Check an object path for validity. Remember that #NULL can always + * be passed instead of a DBusError *, if you don't care about having + * an error name and message. + * + * This function is suitable for validating C strings, but is not suitable + * for validating untrusted data from a network unless the string's length + * is also checked, since it assumes that the string ends at the first zero + * byte according to normal C conventions. + * + * @param path a potentially invalid object path, which must not be #NULL + * @param error error return + * @returns #TRUE if path is valid + */ +dbus_bool_t +dbus_validate_path (const char *path, + DBusError *error) +{ + DBusString str; + int len; + + _dbus_return_val_if_fail (path != NULL, FALSE); + + _dbus_string_init_const (&str, path); + len = _dbus_string_get_length (&str); + + /* In general, it ought to be valid... */ + if (_DBUS_LIKELY (_dbus_validate_path (&str, 0, len))) + return TRUE; + + /* slow path: string is invalid, find out why */ + + if (!_dbus_string_validate_utf8 (&str, 0, len)) + { + /* don't quote the actual string here, since a DBusError also needs to + * be valid UTF-8 */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Object path was not valid UTF-8"); + return FALSE; + } + + /* FIXME: later, diagnose exactly how it was invalid */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Object path was not valid: '%s'", path); + return FALSE; +} + +/** + * Check an interface name for validity. Remember that #NULL can always + * be passed instead of a DBusError *, if you don't care about having + * an error name and message. + * + * This function is suitable for validating C strings, but is not suitable + * for validating untrusted data from a network unless the string's length + * is also checked, since it assumes that the string ends at the first zero + * byte according to normal C conventions. + * + * @param path a potentially invalid interface name, which must not be #NULL + * @param error error return + * @returns #TRUE if name is valid + */ +dbus_bool_t +dbus_validate_interface (const char *name, + DBusError *error) +{ + DBusString str; + int len; + + _dbus_return_val_if_fail (name != NULL, FALSE); + + _dbus_string_init_const (&str, name); + len = _dbus_string_get_length (&str); + + /* In general, it ought to be valid... */ + if (_DBUS_LIKELY (_dbus_validate_interface (&str, 0, len))) + return TRUE; + + /* slow path: string is invalid, find out why */ + + if (!_dbus_string_validate_utf8 (&str, 0, len)) + { + /* don't quote the actual string here, since a DBusError also needs to + * be valid UTF-8 */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Interface name was not valid UTF-8"); + return FALSE; + } + + /* FIXME: later, diagnose exactly how it was invalid */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Interface name was not valid: '%s'", name); + return FALSE; +} + +/** + * Check a member (method/signal) name for validity. Remember that #NULL + * can always be passed instead of a DBusError *, if you don't care about + * having an error name and message. + * + * This function is suitable for validating C strings, but is not suitable + * for validating untrusted data from a network unless the string's length + * is also checked, since it assumes that the string ends at the first zero + * byte according to normal C conventions. + * + * @param path a potentially invalid member name, which must not be #NULL + * @param error error return + * @returns #TRUE if name is valid + */ +dbus_bool_t +dbus_validate_member (const char *name, + DBusError *error) +{ + DBusString str; + int len; + + _dbus_return_val_if_fail (name != NULL, FALSE); + + _dbus_string_init_const (&str, name); + len = _dbus_string_get_length (&str); + + /* In general, it ought to be valid... */ + if (_DBUS_LIKELY (_dbus_validate_member (&str, 0, len))) + return TRUE; + + /* slow path: string is invalid, find out why */ + + if (!_dbus_string_validate_utf8 (&str, 0, len)) + { + /* don't quote the actual string here, since a DBusError also needs to + * be valid UTF-8 */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Member name was not valid UTF-8"); + return FALSE; + } + + /* FIXME: later, diagnose exactly how it was invalid */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Member name was not valid: '%s'", name); + return FALSE; +} + +/** + * Check an error name for validity. Remember that #NULL + * can always be passed instead of a DBusError *, if you don't care about + * having an error name and message. + * + * This function is suitable for validating C strings, but is not suitable + * for validating untrusted data from a network unless the string's length + * is also checked, since it assumes that the string ends at the first zero + * byte according to normal C conventions. + * + * @param path a potentially invalid error name, which must not be #NULL + * @param error error return + * @returns #TRUE if name is valid + */ +dbus_bool_t +dbus_validate_error_name (const char *name, + DBusError *error) +{ + DBusString str; + int len; + + _dbus_return_val_if_fail (name != NULL, FALSE); + + _dbus_string_init_const (&str, name); + len = _dbus_string_get_length (&str); + + /* In general, it ought to be valid... */ + if (_DBUS_LIKELY (_dbus_validate_error_name (&str, 0, len))) + return TRUE; + + /* slow path: string is invalid, find out why */ + + if (!_dbus_string_validate_utf8 (&str, 0, len)) + { + /* don't quote the actual string here, since a DBusError also needs to + * be valid UTF-8 */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Error name was not valid UTF-8"); + return FALSE; + } + + /* FIXME: later, diagnose exactly how it was invalid */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Error name was not valid: '%s'", name); + return FALSE; +} + +/** + * Check a bus name for validity. Remember that #NULL + * can always be passed instead of a DBusError *, if you don't care about + * having an error name and message. + * + * This function is suitable for validating C strings, but is not suitable + * for validating untrusted data from a network unless the string's length + * is also checked, since it assumes that the string ends at the first zero + * byte according to normal C conventions. + * + * @param path a potentially invalid bus name, which must not be #NULL + * @param error error return + * @returns #TRUE if name is valid + */ +dbus_bool_t +dbus_validate_bus_name (const char *name, + DBusError *error) +{ + DBusString str; + int len; + + _dbus_return_val_if_fail (name != NULL, FALSE); + + _dbus_string_init_const (&str, name); + len = _dbus_string_get_length (&str); + + /* In general, it ought to be valid... */ + if (_DBUS_LIKELY (_dbus_validate_bus_name (&str, 0, len))) + return TRUE; + + /* slow path: string is invalid, find out why */ + + if (!_dbus_string_validate_utf8 (&str, 0, len)) + { + /* don't quote the actual string here, since a DBusError also needs to + * be valid UTF-8 */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Bus name was not valid UTF-8"); + return FALSE; + } + + /* FIXME: later, diagnose exactly how it was invalid */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "Bus name was not valid: '%s'", name); + return FALSE; +} + +/** + * Check a string for validity. Strings on D-Bus must be valid UTF-8. + * Remember that #NULL can always be passed instead of a DBusError *, + * if you don't care about having an error name and message. + * + * This function is suitable for validating C strings, but is not suitable + * for validating untrusted data from a network unless the string's length + * is also checked, since it assumes that the string ends at the first zero + * byte according to normal C conventions. + * + * @param alleged_utf8 a string to be checked, which must not be #NULL + * @param error error return + * @returns #TRUE if alleged_utf8 is valid UTF-8 + */ +dbus_bool_t +dbus_validate_utf8 (const char *alleged_utf8, + DBusError *error) +{ + DBusString str; + + _dbus_return_val_if_fail (alleged_utf8 != NULL, FALSE); + + _dbus_string_init_const (&str, alleged_utf8); + + if (_DBUS_LIKELY (_dbus_string_validate_utf8 (&str, 0, + _dbus_string_get_length (&str)))) + return TRUE; + + /* don't quote the actual string here, since a DBusError also needs to + * be valid UTF-8 */ + dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, + "String was not valid UTF-8"); + return FALSE; +} + +/** @} */ /* end of group */ diff --git a/dbus/dbus-syntax.h b/dbus/dbus-syntax.h new file mode 100644 index 00000000..daf20f06 --- /dev/null +++ b/dbus/dbus-syntax.h @@ -0,0 +1,58 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-syntax.h - utility functions for strings with special syntax + * + * Author: Simon McVittie <simon.mcvittie@collabora.co.uk> + * Copyright © 2011 Nokia Corporation + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_SYNTAX_H +#define DBUS_SYNTAX_H + +#include <dbus/dbus-macros.h> +#include <dbus/dbus-types.h> +#include <dbus/dbus-errors.h> + +DBUS_BEGIN_DECLS + +DBUS_EXPORT +dbus_bool_t dbus_validate_path (const char *path, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_interface (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_member (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_error_name (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_bus_name (const char *name, + DBusError *error); +DBUS_EXPORT +dbus_bool_t dbus_validate_utf8 (const char *alleged_utf8, + DBusError *error); + +DBUS_END_DECLS + +#endif /* multiple-inclusion guard */ diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index da3f0350..9fddca73 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -866,6 +866,96 @@ _dbus_connect_unix_socket (const char *path, } /** + * Creates a UNIX domain socket and connects it to the specified + * process to execute. + * + * This will set FD_CLOEXEC for the socket returned. + * + * @param path the path to the executable + * @param argv the argument list for the process to execute. + * argv[0] typically is identical to the path of the executable + * @param error return location for error code + * @returns connection file descriptor or -1 on error + */ +int +_dbus_connect_exec (const char *path, + char *const argv[], + DBusError *error) +{ + int fds[2]; + pid_t pid; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + _dbus_verbose ("connecting to process %s\n", path); + + if (socketpair (AF_UNIX, SOCK_STREAM +#ifdef SOCK_CLOEXEC + |SOCK_CLOEXEC +#endif + , 0, fds) < 0) + { + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to create socket pair: %s", + _dbus_strerror (errno)); + return -1; + } + + _dbus_fd_set_close_on_exec (fds[0]); + _dbus_fd_set_close_on_exec (fds[1]); + + pid = fork (); + if (pid < 0) + { + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to fork() to call %s: %s", + path, _dbus_strerror (errno)); + close (fds[0]); + close (fds[1]); + return -1; + } + + if (pid == 0) + { + /* child */ + close (fds[0]); + + dup2 (fds[1], STDIN_FILENO); + dup2 (fds[1], STDOUT_FILENO); + + if (fds[1] != STDIN_FILENO && + fds[1] != STDOUT_FILENO) + close (fds[1]); + + /* Inherit STDERR and the controlling terminal from the + parent */ + + _dbus_close_all (); + + execvp (path, argv); + + fprintf (stderr, "Failed to execute process %s: %s\n", path, _dbus_strerror (errno)); + + _exit(1); + } + + /* parent */ + close (fds[1]); + + if (!_dbus_set_fd_nonblocking (fds[0], error)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + + close (fds[0]); + return -1; + } + + return fds[0]; +} + +/** * Enables or disables the reception of credentials on the given socket during * the next message transmission. This is only effective if the #LOCAL_CREDS * system feature exists, in which case the other side of the connection does @@ -3124,7 +3214,6 @@ _read_subprocess_line_argv (const char *progpath, int ret; int status; int orig_len; - int i; dbus_bool_t retval; sigset_t new_set, old_set; @@ -3177,7 +3266,6 @@ _read_subprocess_line_argv (const char *progpath, if (pid == 0) { /* child process */ - int maxfds; int fd; fd = open ("/dev/null", O_RDWR); @@ -3201,15 +3289,7 @@ _read_subprocess_line_argv (const char *progpath, if (dup2 (errors_pipe[WRITE_END], 2) == -1) _exit (1); - maxfds = sysconf (_SC_OPEN_MAX); - /* Pick something reasonable if for some reason sysconf - * says unlimited. - */ - if (maxfds < 0) - maxfds = 1024; - /* close all inherited fds */ - for (i = 3; i < maxfds; i++) - close (i); + _dbus_close_all (); sigprocmask (SIG_SETMASK, &old_set, NULL); @@ -3920,4 +4000,69 @@ _dbus_replace_install_prefix (const char *configure_time_path) return configure_time_path; } +/** + * Closes all file descriptors except the first three (i.e. stdin, + * stdout, stderr). + */ +void +_dbus_close_all (void) +{ + int maxfds, i; + +#ifdef __linux__ + DIR *d; + + /* On Linux we can optimize this a bit if /proc is available. If it + isn't available, fall back to the brute force way. */ + + d = opendir ("/proc/self/fd"); + if (d) + { + for (;;) + { + struct dirent buf, *de; + int k, fd; + long l; + char *e = NULL; + + k = readdir_r (d, &buf, &de); + if (k != 0 || !de) + break; + + if (de->d_name[0] == '.') + continue; + + errno = 0; + l = strtol (de->d_name, &e, 10); + if (errno != 0 || e == NULL || *e != '\0') + continue; + + fd = (int) l; + if (fd < 3) + continue; + + if (fd == dirfd (d)) + continue; + + close (fd); + } + + closedir (d); + return; + } +#endif + + maxfds = sysconf (_SC_OPEN_MAX); + + /* Pick something reasonable if for some reason sysconf says + * unlimited. + */ + if (maxfds < 0) + maxfds = 1024; + + /* close all inherited fds */ + for (i = 3; i < maxfds; i++) + close (i); +} + /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-unix.h b/dbus/dbus-sysdeps-unix.h index 9f92dcd1..9b708967 100644 --- a/dbus/dbus-sysdeps-unix.h +++ b/dbus/dbus-sysdeps-unix.h @@ -70,6 +70,10 @@ int _dbus_listen_unix_socket (const char *path, dbus_bool_t abstract, DBusError *error); +int _dbus_connect_exec (const char *path, + char *const argv[], + DBusError *error); + int _dbus_listen_systemd_sockets (int **fd, DBusError *error); @@ -132,6 +136,8 @@ dbus_uid_t _dbus_geteuid (void); dbus_bool_t _dbus_parse_uid (const DBusString *uid_str, dbus_uid_t *uid); +void _dbus_close_all (void); + /** @} */ DBUS_END_DECLS diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index a1915cb3..ef86d738 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -254,8 +254,8 @@ _dbus_write_pid_to_file_and_pipe (const DBusString *pidfile, DBusString pid; int bytes; - _dbus_verbose ("writing our pid to pipe %"PRIuPTR"\n", - print_pid_pipe->fd_or_handle); + _dbus_verbose ("writing our pid to pipe %d\n", + print_pid_pipe->fd); if (!_dbus_string_init (&pid)) { diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index f5646f39..111db9ea 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -191,7 +191,7 @@ _dbus_write_pid_to_file_and_pipe (const DBusString *pidfile, DBusString pid; int bytes; - _dbus_verbose ("writing our pid to pipe %d\n", print_pid_pipe->fd_or_handle); + _dbus_verbose ("writing our pid to pipe %d\n", print_pid_pipe->fd); if (!_dbus_string_init (&pid)) { diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index c2258b3c..1a93cea7 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -614,16 +614,14 @@ _dbus_error_from_errno (int error_number) #ifdef EPROTONOSUPPORT case EPROTONOSUPPORT: return DBUS_ERROR_NOT_SUPPORTED; -#endif -#ifdef WSAEPROTONOSUPPORT +#elif defined(WSAEPROTONOSUPPORT) case WSAEPROTONOSUPPORT: return DBUS_ERROR_NOT_SUPPORTED; #endif #ifdef EAFNOSUPPORT case EAFNOSUPPORT: return DBUS_ERROR_NOT_SUPPORTED; -#endif -#ifdef WSAEAFNOSUPPORT +#elif defined(WSAEAFNOSUPPORT) case WSAEAFNOSUPPORT: return DBUS_ERROR_NOT_SUPPORTED; #endif @@ -654,32 +652,28 @@ _dbus_error_from_errno (int error_number) #ifdef ECONNREFUSED case ECONNREFUSED: return DBUS_ERROR_NO_SERVER; -#endif -#ifdef WSAECONNREFUSED +#elif defined(WSAECONNREFUSED) case WSAECONNREFUSED: return DBUS_ERROR_NO_SERVER; #endif #ifdef ETIMEDOUT case ETIMEDOUT: return DBUS_ERROR_TIMEOUT; -#endif -#ifdef WSAETIMEDOUT +#elif defined(WSAETIMEDOUT) case WSAETIMEDOUT: return DBUS_ERROR_TIMEOUT; #endif #ifdef ENETUNREACH case ENETUNREACH: return DBUS_ERROR_NO_NETWORK; -#endif -#ifdef WSAENETUNREACH +#elif defined(WSAENETUNREACH) case WSAENETUNREACH: return DBUS_ERROR_NO_NETWORK; #endif #ifdef EADDRINUSE case EADDRINUSE: return DBUS_ERROR_ADDRESS_IN_USE; -#endif -#ifdef WSAEADDRINUSE +#elif defined(WSAEADDRINUSE) case WSAEADDRINUSE: return DBUS_ERROR_ADDRESS_IN_USE; #endif diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index 02eaf89b..224a6c8c 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -154,6 +154,8 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *speci #ifdef DBUS_UNIX run_data_test ("userdb", specific_test, _dbus_userdb_test, test_data_dir); + + run_test ("transport-unix", specific_test, _dbus_transport_unix_test); #endif run_test ("keyring", specific_test, _dbus_keyring_test); diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h index d97d142a..f254388b 100644 --- a/dbus/dbus-test.h +++ b/dbus/dbus-test.h @@ -48,6 +48,7 @@ dbus_bool_t _dbus_data_slot_test (void); dbus_bool_t _dbus_sysdeps_test (void); dbus_bool_t _dbus_spawn_test (const char *test_data_dir); dbus_bool_t _dbus_userdb_test (const char *test_data_dir); +dbus_bool_t _dbus_transport_unix_test (void); dbus_bool_t _dbus_memory_test (void); dbus_bool_t _dbus_object_tree_test (void); dbus_bool_t _dbus_credentials_test (const char *test_data_dir); diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index a47756f2..6ba5c0b5 100644 --- a/dbus/dbus-transport-unix.c +++ b/dbus/dbus-transport-unix.c @@ -22,6 +22,9 @@ */ #include <config.h> + +#include <stdio.h> + #include "dbus-internals.h" #include "dbus-connection-internal.h" #include "dbus-transport-unix.h" @@ -29,6 +32,7 @@ #include "dbus-transport-protected.h" #include "dbus-watch.h" #include "dbus-sysdeps-unix.h" +#include "dbus-test.h" /** * @defgroup DBusTransportUnix DBusTransport implementations for UNIX @@ -108,6 +112,108 @@ _dbus_transport_new_for_domain_socket (const char *path, } /** + * Creates a new transport for the given binary and arguments. This + * creates a client-side of a transport. The process will be forked + * off and executed with stdin/stdout connected to a local AF_UNIX + * socket. + * + * @param path the path to the domain socket. + * @param argv Parameters list + * @param error address where an error can be returned. + * @returns a new transport, or #NULL on failure. + */ +static DBusTransport* +_dbus_transport_new_for_exec (const char *path, + char *const argv[], + DBusError *error) +{ + int fd; + DBusTransport *transport; + DBusString address; + unsigned i; + char *escaped; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (!_dbus_string_init (&address)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return NULL; + } + + fd = -1; + + escaped = dbus_address_escape_value (path); + if (!escaped) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed; + } + + if (!_dbus_string_append (&address, "unixexec:path=") || + !_dbus_string_append (&address, escaped)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + dbus_free (escaped); + goto failed; + } + + dbus_free (escaped); + + if (argv) + { + for (i = 0; argv[i]; i++) + { + dbus_bool_t success; + + escaped = dbus_address_escape_value (argv[i]); + if (!escaped) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed; + } + + success = _dbus_string_append_printf (&address, ",argv%u=%s", i, escaped); + dbus_free (escaped); + + if (!success) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed; + } + } + } + + fd = _dbus_connect_exec (path, argv, error); + if (fd < 0) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + goto failed; + } + + _dbus_verbose ("Successfully connected to process %s\n", + path); + + transport = _dbus_transport_new_for_socket (fd, NULL, &address); + if (transport == NULL) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto failed; + } + + _dbus_string_free (&address); + + return transport; + + failed: + if (fd >= 0) + _dbus_close_socket (fd, NULL); + + _dbus_string_free (&address); + return NULL; +} + +/** * Opens platform specific transport types. * * @param entry the address entry to try opening @@ -168,7 +274,81 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, { _DBUS_ASSERT_ERROR_IS_CLEAR (error); return DBUS_TRANSPORT_OPEN_OK; - } + } + } + else if (strcmp (method, "unixexec") == 0) + { + const char *path; + unsigned i; + char **argv; + + path = dbus_address_entry_get_value (entry, "path"); + if (path == NULL) + { + _dbus_set_bad_address (error, NULL, NULL, + "No process path specified"); + return DBUS_TRANSPORT_OPEN_BAD_ADDRESS; + } + + /* First count argv arguments */ + for (i = 1; ; i++) + { + char t[4+20+1]; /* "argv" plus space for a formatted base 10 64bit integer, plus NUL */ + + snprintf (t, sizeof(t), "argv%u", i); + + if (!dbus_address_entry_get_value (entry, t)) + break; + } + + /* Allocate string array */ + argv = dbus_new0 (char*, i+1); + if (!argv) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; + } + + /* Fill in string array */ + for (i = 0; ; i++) + { + char t[4+20+1]; + const char *p; + + snprintf (t, sizeof(t), "argv%u", i); + + p = dbus_address_entry_get_value (entry, t); + if (!p) + { + if (i == 0) + /* If argv0 isn't specified, fill in the path instead */ + p = path; + else + break; + } + + argv[i] = _dbus_strdup (p); + if (!argv[i]) + { + dbus_free_string_array (argv); + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; + } + } + + *transport_p = _dbus_transport_new_for_exec (path, argv, error); + dbus_free_string_array (argv); + + if (*transport_p == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; + } + else + { + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + return DBUS_TRANSPORT_OPEN_OK; + } } #ifdef DBUS_ENABLE_LAUNCHD else if (strcmp (method, "launchd") == 0) @@ -231,3 +411,32 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, } /** @} */ + +#ifdef DBUS_BUILD_TESTS + +dbus_bool_t +_dbus_transport_unix_test (void) +{ + DBusConnection *c; + DBusError error; + dbus_bool_t ret; + const char *address; + + dbus_error_init (&error); + + c = dbus_connection_open ("unixexec:argv0=false,argv1=foobar,path=/bin/false", &error); + _dbus_assert (c != NULL); + _dbus_assert (!dbus_error_is_set (&error)); + + address = _dbus_connection_get_address (c); + _dbus_assert (address != NULL); + + /* Let's see if the address got parsed, reordered and formatted correctly */ + ret = strcmp (address, "unixexec:path=/bin/false,argv0=false,argv1=foobar") == 0; + + dbus_connection_unref (c); + + return ret; +} + +#endif diff --git a/dbus/dbus-types.h b/dbus/dbus-types.h index 54f348f3..57fc586a 100644 --- a/dbus/dbus-types.h +++ b/dbus/dbus-types.h @@ -134,6 +134,45 @@ typedef dbus_uint32_t dbus_bool_t; * giving a literal such as "325145246765ULL" */ +/** + * An 8-byte struct you could use to access int64 without having + * int64 support + */ +typedef struct +{ + dbus_uint32_t first32; /**< first 32 bits in the 8 bytes (beware endian issues) */ + dbus_uint32_t second32; /**< second 32 bits in the 8 bytes (beware endian issues) */ +} DBus8ByteStruct; + +/** + * A simple value union that lets you access bytes as if they + * were various types; useful when dealing with basic types via + * void pointers and varargs. + * + * This union also contains a pointer member (which can be used + * to retrieve a string from dbus_message_iter_get_basic(), for + * instance), so on future platforms it could conceivably be larger + * than 8 bytes. + */ +typedef union +{ + unsigned char bytes[8]; /**< as 8 individual bytes */ + dbus_int16_t i16; /**< as int16 */ + dbus_uint16_t u16; /**< as int16 */ + dbus_int32_t i32; /**< as int32 */ + dbus_uint32_t u32; /**< as int32 */ + dbus_bool_t bool_val; /**< as boolean */ +#ifdef DBUS_HAVE_INT64 + dbus_int64_t i64; /**< as int64 */ + dbus_uint64_t u64; /**< as int64 */ +#endif + DBus8ByteStruct eight; /**< as 8-byte struct */ + double dbl; /**< as double */ + unsigned char byt; /**< as byte */ + char *str; /**< as char* (string, object path or signature) */ + int fd; /**< as Unix file descriptor */ +} DBusBasicValue; + /** @} */ #endif /* DBUS_TYPES_H */ diff --git a/dbus/dbus.h b/dbus/dbus.h index 1f099508..932ceab3 100644 --- a/dbus/dbus.h +++ b/dbus/dbus.h @@ -39,6 +39,7 @@ #include <dbus/dbus-server.h> #include <dbus/dbus-shared.h> #include <dbus/dbus-signature.h> +#include <dbus/dbus-syntax.h> #include <dbus/dbus-threads.h> #include <dbus/dbus-types.h> @@ -1,10 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-12-04.11; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free -# Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, +# 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ Environment variables: object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. + tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to <bug-automake@gnu.org>. @@ -90,10 +90,18 @@ if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 - cygpath_u="sed s,\\\\\\\\,/,g" + cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what @@ -158,10 +166,12 @@ gcc) ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as -## well. +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -405,6 +415,52 @@ tru64) rm -f "$tmpdepfile" ;; +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test "$stat" = 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/ \1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/ / + G + p +}' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. @@ -503,7 +559,9 @@ makedepend) touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation diff --git a/doc/dbus-daemon.1.in b/doc/dbus-daemon.1.in index b063e643..53856e91 100644 --- a/doc/dbus-daemon.1.in +++ b/doc/dbus-daemon.1.in @@ -501,6 +501,7 @@ The possible attributes of these elements are: eavesdrop="true" | "false" own="name" + own_prefix="name" user="username" group="groupname" .fi @@ -573,6 +574,15 @@ like "foo.bar.*" aren't allowed for now because they'd be work to implement and maybe encourage sloppy security anyway. .PP +<allow own_prefix="a.b"/> allows you to own the name "a.b" or any +name whose first dot-separated elements are "a.b": in particular, +you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c". +This is useful when services like Telepathy and ReserveDevice +define a meaning for subtrees of well-known names, such as +org.freedesktop.Telepathy.ConnectionManager.(anything) +and org.freedesktop.ReserveDevice1.(anything). + +.PP It does not make sense to deny a user or group inside a <policy> for a user or group; user/group denials can only be inside context="default" or context="mandatory" policies. diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 index 089e0f2c..a7687cad 100644 --- a/doc/dbus-launch.1 +++ b/doc/dbus-launch.1 @@ -19,7 +19,7 @@ backticks or the $() construct can be used to read information from \fIdbus\-launch\fP. With no arguments, \fIdbus\-launch\fP will launch a session bus -instance and print the address and pid of that instance to standard +instance and print the address and PID of that instance to standard output. You may specify a program to be run; in this case, \fIdbus\-launch\fP @@ -42,7 +42,7 @@ With the \-\-auto\-syntax option, \fIdbus\-launch\fP looks at the value of the SHELL environment variable to determine which shell syntax should be used. If SHELL ends in "csh", then csh\-compatible code is emitted; otherwise Bourne shell code is emitted. Instead of passing -\-\-auto\-syntax, you may explicity specify a particular one by using +\-\-auto\-syntax, you may explicitly specify a particular one by using \-\-sh\-syntax for Bourne syntax, or \-\-csh\-syntax for csh syntax. In scripts, it's more robust to avoid \-\-auto\-syntax and you hopefully know which shell your script is written in. diff --git a/doc/dbus-specification.html b/doc/dbus-specification.html index 8a08ba7d..314e3d69 100644 --- a/doc/dbus-specification.html +++ b/doc/dbus-specification.html @@ -16,7 +16,7 @@ and system services on Unix; document the systemd transport</td></tr><tr><td align="left">Revision 0.18</td><td align="left">29 July 2011</td><td align="left">smcv</td></tr><tr><td align="left" colspan="3">define eavesdropping, unicast, broadcast; add eavesdrop match keyword; promote type system to a top-level section</td></tr><tr><td align="left">Revision 0.17</td><td align="left">1 June 2011</td><td align="left">smcv/davidz</td></tr><tr><td align="left" colspan="3">define ObjectManager; reserve extra pseudo-type-codes used by GVariant</td></tr><tr><td align="left">Revision 0.16</td><td align="left">11 April 2011</td><td align="left"></td></tr><tr><td align="left" colspan="3">add path_namespace, arg0namespace; argNpath matches object - paths</td></tr><tr><td align="left">Revision 0.15</td><td align="left">3 November 2010</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.14</td><td align="left">12 May 2010</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.13</td><td align="left">23 Dezember 2009</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.12</td><td align="left">7 November, 2006</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.11</td><td align="left">6 February 2005</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.10</td><td align="left">28 January 2005</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.9</td><td align="left">7 Januar 2005</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.8</td><td align="left">06 September 2003</td><td align="left"></td></tr><tr><td align="left" colspan="3">First released document.</td></tr></table></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#introduction">Introduction</a></span></dt><dd><dl><dt><span class="sect2"><a href="#stability">Protocol and Specification Stability</a></span></dt></dl></dd><dt><span class="sect1"><a href="#type-system">Type System</a></span></dt><dd><dl><dt><span class="sect2"><a href="#message-protocol-signatures">Type Signatures</a></span></dt><dt><span class="sect2"><a href="#message-protocol-marshaling">Marshaling (Wire Format)</a></span></dt></dl></dd><dt><span class="sect1"><a href="#message-protocol">Message Protocol</a></span></dt><dd><dl><dt><span class="sect2"><a href="#message-protocol-messages">Message Format</a></span></dt><dt><span class="sect2"><a href="#message-protocol-names">Valid Names</a></span></dt><dt><span class="sect2"><a href="#message-protocol-types">Message Types</a></span></dt><dt><span class="sect2"><a href="#message-protocol-handling-invalid">Invalid Protocol and Spec Extensions</a></span></dt></dl></dd><dt><span class="sect1"><a href="#auth-protocol">Authentication Protocol</a></span></dt><dd><dl><dt><span class="sect2"><a href="#auth-protocol-overview">Protocol Overview</a></span></dt><dt><span class="sect2"><a href="#auth-nul-byte">Special credentials-passing nul byte</a></span></dt><dt><span class="sect2"><a href="#auth-command-auth">AUTH command</a></span></dt><dt><span class="sect2"><a href="#auth-command-cancel">CANCEL Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-data">DATA Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-begin">BEGIN Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-rejected">REJECTED Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-ok">OK Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-error">ERROR Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-negotiate-unix-fd">NEGOTIATE_UNIX_FD Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-agree-unix-fd">AGREE_UNIX_FD Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-future">Future Extensions</a></span></dt><dt><span class="sect2"><a href="#auth-examples">Authentication examples</a></span></dt><dt><span class="sect2"><a href="#auth-states">Authentication state diagrams</a></span></dt><dt><span class="sect2"><a href="#auth-mechanisms">Authentication mechanisms</a></span></dt></dl></dd><dt><span class="sect1"><a href="#addresses">Server Addresses</a></span></dt><dt><span class="sect1"><a href="#transports">Transports</a></span></dt><dd><dl><dt><span class="sect2"><a href="#transports-unix-domain-sockets">Unix Domain Sockets</a></span></dt><dt><span class="sect2"><a href="#transports-launchd">launchd</a></span></dt><dt><span class="sect2"><a href="#transports-systemd">systemd</a></span></dt><dt><span class="sect2"><a href="#transports-tcp-sockets">TCP Sockets</a></span></dt><dt><span class="sect2"><a href="#transports-nonce-tcp-sockets">Nonce-secured TCP Sockets</a></span></dt></dl></dd><dt><span class="sect1"><a href="#meta-transports">Meta Transports</a></span></dt><dd><dl><dt><span class="sect2"><a href="#meta-transports-autolaunch">Autolaunch</a></span></dt></dl></dd><dt><span class="sect1"><a href="#uuids">UUIDs</a></span></dt><dt><span class="sect1"><a href="#standard-interfaces">Standard Interfaces</a></span></dt><dd><dl><dt><span class="sect2"><a href="#standard-interfaces-peer"><code class="literal">org.freedesktop.DBus.Peer</code></a></span></dt><dt><span class="sect2"><a href="#standard-interfaces-introspectable"><code class="literal">org.freedesktop.DBus.Introspectable</code></a></span></dt><dt><span class="sect2"><a href="#standard-interfaces-properties"><code class="literal">org.freedesktop.DBus.Properties</code></a></span></dt><dt><span class="sect2"><a href="#standard-interfaces-objectmanager"><code class="literal">org.freedesktop.DBus.ObjectManager</code></a></span></dt></dl></dd><dt><span class="sect1"><a href="#introspection-format">Introspection Data Format</a></span></dt><dt><span class="sect1"><a href="#message-bus">Message Bus Specification</a></span></dt><dd><dl><dt><span class="sect2"><a href="#message-bus-overview">Message Bus Overview</a></span></dt><dt><span class="sect2"><a href="#message-bus-names">Message Bus Names</a></span></dt><dt><span class="sect2"><a href="#message-bus-routing">Message Bus Message Routing</a></span></dt><dt><span class="sect2"><a href="#message-bus-starting-services">Message Bus Starting Services</a></span></dt><dt><span class="sect2"><a href="#message-bus-types">Well-known Message Bus Instances</a></span></dt><dt><span class="sect2"><a href="#message-bus-messages">Message Bus Messages</a></span></dt></dl></dd><dt><span class="glossary"><a href="#idp5885776">Glossary</a></span></dt></dl></div><div class="sect1" title="Introduction"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="introduction"></a>Introduction</h2></div></div></div><p> + paths</td></tr><tr><td align="left">Revision 0.15</td><td align="left">3 November 2010</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.14</td><td align="left">12 May 2010</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.13</td><td align="left">23 Dezember 2009</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.12</td><td align="left">7 November, 2006</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.11</td><td align="left">6 February 2005</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.10</td><td align="left">28 January 2005</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.9</td><td align="left">7 Januar 2005</td><td align="left"></td></tr><tr><td align="left" colspan="3"></td></tr><tr><td align="left">Revision 0.8</td><td align="left">06 September 2003</td><td align="left"></td></tr><tr><td align="left" colspan="3">First released document.</td></tr></table></div></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#introduction">Introduction</a></span></dt><dd><dl><dt><span class="sect2"><a href="#stability">Protocol and Specification Stability</a></span></dt></dl></dd><dt><span class="sect1"><a href="#type-system">Type System</a></span></dt><dd><dl><dt><span class="sect2"><a href="#message-protocol-signatures">Type Signatures</a></span></dt><dt><span class="sect2"><a href="#message-protocol-marshaling">Marshaling (Wire Format)</a></span></dt></dl></dd><dt><span class="sect1"><a href="#message-protocol">Message Protocol</a></span></dt><dd><dl><dt><span class="sect2"><a href="#message-protocol-messages">Message Format</a></span></dt><dt><span class="sect2"><a href="#message-protocol-names">Valid Names</a></span></dt><dt><span class="sect2"><a href="#message-protocol-types">Message Types</a></span></dt><dt><span class="sect2"><a href="#message-protocol-handling-invalid">Invalid Protocol and Spec Extensions</a></span></dt></dl></dd><dt><span class="sect1"><a href="#auth-protocol">Authentication Protocol</a></span></dt><dd><dl><dt><span class="sect2"><a href="#auth-protocol-overview">Protocol Overview</a></span></dt><dt><span class="sect2"><a href="#auth-nul-byte">Special credentials-passing nul byte</a></span></dt><dt><span class="sect2"><a href="#auth-command-auth">AUTH command</a></span></dt><dt><span class="sect2"><a href="#auth-command-cancel">CANCEL Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-data">DATA Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-begin">BEGIN Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-rejected">REJECTED Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-ok">OK Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-error">ERROR Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-negotiate-unix-fd">NEGOTIATE_UNIX_FD Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-agree-unix-fd">AGREE_UNIX_FD Command</a></span></dt><dt><span class="sect2"><a href="#auth-command-future">Future Extensions</a></span></dt><dt><span class="sect2"><a href="#auth-examples">Authentication examples</a></span></dt><dt><span class="sect2"><a href="#auth-states">Authentication state diagrams</a></span></dt><dt><span class="sect2"><a href="#auth-mechanisms">Authentication mechanisms</a></span></dt></dl></dd><dt><span class="sect1"><a href="#addresses">Server Addresses</a></span></dt><dt><span class="sect1"><a href="#transports">Transports</a></span></dt><dd><dl><dt><span class="sect2"><a href="#transports-unix-domain-sockets">Unix Domain Sockets</a></span></dt><dt><span class="sect2"><a href="#transports-launchd">launchd</a></span></dt><dt><span class="sect2"><a href="#transports-systemd">systemd</a></span></dt><dt><span class="sect2"><a href="#transports-tcp-sockets">TCP Sockets</a></span></dt><dt><span class="sect2"><a href="#transports-nonce-tcp-sockets">Nonce-secured TCP Sockets</a></span></dt><dt><span class="sect2"><a href="#transports-exec">Executed Subprocesses on Unix</a></span></dt></dl></dd><dt><span class="sect1"><a href="#meta-transports">Meta Transports</a></span></dt><dd><dl><dt><span class="sect2"><a href="#meta-transports-autolaunch">Autolaunch</a></span></dt></dl></dd><dt><span class="sect1"><a href="#uuids">UUIDs</a></span></dt><dt><span class="sect1"><a href="#standard-interfaces">Standard Interfaces</a></span></dt><dd><dl><dt><span class="sect2"><a href="#standard-interfaces-peer"><code class="literal">org.freedesktop.DBus.Peer</code></a></span></dt><dt><span class="sect2"><a href="#standard-interfaces-introspectable"><code class="literal">org.freedesktop.DBus.Introspectable</code></a></span></dt><dt><span class="sect2"><a href="#standard-interfaces-properties"><code class="literal">org.freedesktop.DBus.Properties</code></a></span></dt><dt><span class="sect2"><a href="#standard-interfaces-objectmanager"><code class="literal">org.freedesktop.DBus.ObjectManager</code></a></span></dt></dl></dd><dt><span class="sect1"><a href="#introspection-format">Introspection Data Format</a></span></dt><dt><span class="sect1"><a href="#message-bus">Message Bus Specification</a></span></dt><dd><dl><dt><span class="sect2"><a href="#message-bus-overview">Message Bus Overview</a></span></dt><dt><span class="sect2"><a href="#message-bus-names">Message Bus Names</a></span></dt><dt><span class="sect2"><a href="#message-bus-routing">Message Bus Message Routing</a></span></dt><dt><span class="sect2"><a href="#message-bus-starting-services">Message Bus Starting Services</a></span></dt><dt><span class="sect2"><a href="#message-bus-types">Well-known Message Bus Instances</a></span></dt><dt><span class="sect2"><a href="#message-bus-messages">Message Bus Messages</a></span></dt></dl></dd><dt><span class="glossary"><a href="#idp5940272">Glossary</a></span></dt></dl></div><div class="sect1" title="Introduction"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="introduction"></a>Introduction</h2></div></div></div><p> D-Bus is a system for low-latency, low-overhead, easy to use interprocess communication (IPC). In more detail: </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> @@ -1006,14 +1006,14 @@ commands may be introduced both before, and after authentication, i.e. both before and after the OK command. </p></div><div class="sect2" title="Authentication examples"><div class="titlepage"><div><div><h3 class="title"><a name="auth-examples"></a>Authentication examples</h3></div></div></div><p> - </p><div class="figure"><a name="idp5176016"></a><p class="title"><b>Figure1.Example of successful magic cookie authentication</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5216608"></a><p class="title"><b>Figure1.Example of successful magic cookie authentication</b></p><div class="figure-contents"><pre class="programlisting"> (MAGIC_COOKIE is a made up mechanism) C: AUTH MAGIC_COOKIE 3138363935333137393635383634 S: OK 1234deadbeef C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5177840"></a><p class="title"><b>Figure2.Example of finding out mechanisms then picking one</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5218432"></a><p class="title"><b>Figure2.Example of finding out mechanisms then picking one</b></p><div class="figure-contents"><pre class="programlisting"> C: AUTH S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -1022,14 +1022,14 @@ S: OK 1234deadbeef C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5179744"></a><p class="title"><b>Figure3.Example of client sends unknown command then falls back to regular auth</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5220336"></a><p class="title"><b>Figure3.Example of client sends unknown command then falls back to regular auth</b></p><div class="figure-contents"><pre class="programlisting"> C: FOOBAR S: ERROR C: AUTH MAGIC_COOKIE 3736343435313230333039 S: OK 1234deadbeef C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5181632"></a><p class="title"><b>Figure4.Example of server doesn't support initial auth mechanism</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5222224"></a><p class="title"><b>Figure4.Example of server doesn't support initial auth mechanism</b></p><div class="figure-contents"><pre class="programlisting"> C: AUTH MAGIC_COOKIE 3736343435313230333039 S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -1038,7 +1038,7 @@ S: OK 1234deadbeef C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5183648"></a><p class="title"><b>Figure5.Example of wrong password or the like followed by successful retry</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5224240"></a><p class="title"><b>Figure5.Example of wrong password or the like followed by successful retry</b></p><div class="figure-contents"><pre class="programlisting"> C: AUTH MAGIC_COOKIE 3736343435313230333039 S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -1051,7 +1051,7 @@ S: OK 1234deadbeef C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5185824"></a><p class="title"><b>Figure6.Example of skey cancelled and restarted</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5226416"></a><p class="title"><b>Figure6.Example of skey cancelled and restarted</b></p><div class="figure-contents"><pre class="programlisting"> C: AUTH MAGIC_COOKIE 3736343435313230333039 S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -1064,7 +1064,7 @@ S: OK 1234deadbeef C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5187888"></a><p class="title"><b>Figure7.Example of successful magic cookie authentication with successful negotiation of Unix FD passing</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5228480"></a><p class="title"><b>Figure7.Example of successful magic cookie authentication with successful negotiation of Unix FD passing</b></p><div class="figure-contents"><pre class="programlisting"> (MAGIC_COOKIE is a made up mechanism) C: AUTH MAGIC_COOKIE 3138363935333137393635383634 @@ -1073,7 +1073,7 @@ S: AGREE_UNIX_FD C: BEGIN </pre></div></div><p><br class="figure-break"> - </p><div class="figure"><a name="idp5189888"></a><p class="title"><b>Figure8.Example of successful magic cookie authentication with unsuccessful negotiation of Unix FD passing</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5230480"></a><p class="title"><b>Figure8.Example of successful magic cookie authentication with unsuccessful negotiation of Unix FD passing</b></p><div class="figure-contents"><pre class="programlisting"> (MAGIC_COOKIE is a made up mechanism) C: AUTH MAGIC_COOKIE 3138363935333137393635383634 @@ -1351,7 +1351,7 @@ fails, the lock fails. Servers should retry for a reasonable period of time, then they may choose to delete an existing lock to keep users from having to manually delete a stale - lock. <sup>[<a name="idp5275920" href="#ftn.idp5275920" class="footnote">1</a>]</sup> + lock. <sup>[<a name="idp5316512" href="#ftn.idp5316512" class="footnote">1</a>]</sup> </p></li><li class="listitem"><p> Once the lockfile has been created, the server loads the cookie file. It should then delete any cookies that are old (the @@ -1430,7 +1430,7 @@ [FIXME we need to specify in detail each transport and its possible arguments] Current transports include: unix domain sockets (including - abstract namespace on linux), launchd, systemd, TCP/IP, and a debug/testing transport + abstract namespace on linux), launchd, systemd, TCP/IP, an executed subprocess and a debug/testing transport using in-process pipes. Future possible transports include one that tunnels over X11 protocol. </p><div class="sect2" title="Unix Domain Sockets"><div class="titlepage"><div><div><h3 class="title"><a name="transports-unix-domain-sockets"></a>Unix Domain Sockets</h3></div></div></div><p> @@ -1445,7 +1445,7 @@ length path name. Names which were shorter than the fixed length would be padded by Nul bytes. </p><p> - Unix domain sockets are not available on windows. + Unix domain sockets are not available on Windows. </p><div class="sect3" title="Server Address Format"><div class="titlepage"><div><div><h4 class="title"><a name="transports-unix-domain-sockets-addresses"></a>Server Address Format</h4></div></div></div><p> Unix domain socket addresses are identified by the "unix:" prefix and support the following key/value pairs: @@ -1488,7 +1488,7 @@ Using tcp transport without any additional secure authentification mechanismus over a network is unsecure. </p><p> - Windows notes: Because of the tcp stack on windows does not provide sending + Windows notes: Because of the tcp stack on Windows does not provide sending credentials over a tcp connection, the EXTERNAL authentification mechanismus does not work. </p><div class="sect3" title="Server Address Format"><div class="titlepage"><div><div><h4 class="title"><a name="transports-tcp-sockets-addresses"></a>Server Address Format</h4></div></div></div><p> @@ -1528,7 +1528,30 @@ </p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Name</th><th>Values</th><th>Description</th></tr></thead><tbody><tr><td>host</td><td>(string)</td><td>dns name or ip address</td></tr><tr><td>port</td><td>(number)</td><td>The tcp port the server will open. A zero value let the server choose a free port provided from the underlaying operating system. libdbus is able to retrieve the real used port from the server. - </td></tr><tr><td>family</td><td>(string)</td><td>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</td></tr><tr><td>noncefile</td><td>(path)</td><td>file location containing the secret</td></tr></tbody></table></div></div></div></div><div class="sect1" title="Meta Transports"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="meta-transports"></a>Meta Transports</h2></div></div></div><p> + </td></tr><tr><td>family</td><td>(string)</td><td>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</td></tr><tr><td>noncefile</td><td>(path)</td><td>file location containing the secret</td></tr></tbody></table></div></div></div><div class="sect2" title="Executed Subprocesses on Unix"><div class="titlepage"><div><div><h3 class="title"><a name="transports-exec"></a>Executed Subprocesses on Unix</h3></div></div></div><p> + This transport forks off a process and connects its standard + input and standard output with an anonymous Unix domain + socket. This socket is then used for communication by the + transport. This transport may be used to use out-of-process + forwarder programs as basis for the D-Bus protocol. + </p><p> + The forked process will inherit the standard error output and + process group from the parent process. + </p><p> + Executed subprocesses are not available on Windows. + </p><div class="sect3" title="Server Address Format"><div class="titlepage"><div><div><h4 class="title"><a name="transports-exec-addresses"></a>Server Address Format</h4></div></div></div><p> + Executed subprocess addresses are identified by the "unixexec:" prefix + and support the following key/value pairs: + </p><div class="informaltable"><table border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Name</th><th>Values</th><th>Description</th></tr></thead><tbody><tr><td>path</td><td>(path)</td><td>Path of the binary to execute, either an absolute + path or a binary name that is searched for in the default + search path of the OS. This corresponds to the first + argument of execlp(). This key is mandatory.</td></tr><tr><td>argv0</td><td>(string)</td><td>The program name to use when executing the + binary. If omitted the same value as specified for path= + will be used. This corresponds to the second argument of + execlp().</td></tr><tr><td>argv1, argv2, ...</td><td>(string)</td><td>Arguments to pass to the binary. This corresponds + to the third and later arguments of execlp(). If a + specific argvX is not specified no further argvY for Y > X + are taken into account.</td></tr></tbody></table></div></div></div></div><div class="sect1" title="Meta Transports"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="meta-transports"></a>Meta Transports</h2></div></div></div><p> Meta transports are a kind of transport with special enhancements or behavior. Currently available meta transports include: autolaunch </p><div class="sect2" title="Autolaunch"><div class="titlepage"><div><div><h3 class="title"><a name="meta-transports-autolaunch"></a>Autolaunch</h3></div></div></div><p>The autolaunch transport provides a way for dbus clients to autodetect @@ -2377,7 +2400,7 @@ </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>General syntax</p></li><li class="listitem"><p>Comment format</p></li></ul></div><p> - </p><div class="figure"><a name="idp5652496"></a><p class="title"><b>Figure9.Example service description file</b></p><div class="figure-contents"><pre class="programlisting"> + </p><div class="figure"><a name="idp5707424"></a><p class="title"><b>Figure9.Example service description file</b></p><div class="figure-contents"><pre class="programlisting"> # Sample service description file [D-BUS Service] Names=org.freedesktop.ConfigurationDatabase;org.gnome.GConf; @@ -2547,7 +2570,7 @@ allowing another process to set the selection between the verification and the setting (e.g., by using XGrabServer / XungrabServer). - </p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="idp5705696"></a></h5></div></div></div><p> + </p></div><div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="idp5760192"></a></h5></div></div></div><p> On Unix systems, the session bus should search for .service files in <code class="literal">$XDG_DATA_DIRS/dbus-1/services</code> as defined by the @@ -2577,7 +2600,7 @@ variable. If that variable is not set, applications should try to connect to the well-known address <code class="literal">unix:path=/var/run/dbus/system_bus_socket</code>. - <sup>[<a name="idp5714944" href="#ftn.idp5714944" class="footnote">2</a>]</sup> + <sup>[<a name="idp5769440" href="#ftn.idp5769440" class="footnote">2</a>]</sup> </p><p> On Unix systems, the system bus should default to searching for .service files in @@ -2587,7 +2610,7 @@ of precedence. It may also search other implementation-specific locations, but should not vary these locations based on environment variables. - <sup>[<a name="idp5719152" href="#ftn.idp5719152" class="footnote">3</a>]</sup> + <sup>[<a name="idp5773648" href="#ftn.idp5773648" class="footnote">3</a>]</sup> </p><p> Software packages should install their system .service files to their configured @@ -2779,7 +2802,7 @@ There is also a per-machine ID, described in <a class="xref" href="#standard-interfaces-peer" title="org.freedesktop.DBus.Peer">the section called “<code class="literal">org.freedesktop.DBus.Peer</code>”</a> and returned by org.freedesktop.DBus.Peer.GetMachineId(). For a desktop session bus, the bus ID can be used as a way to uniquely identify a user's session. - </p></div></div></div><div class="glossary" title="Glossary"><div class="titlepage"><div><div><h2 class="title"><a name="idp5885776"></a>Glossary</h2></div></div></div><p> + </p></div></div></div><div class="glossary" title="Glossary"><div class="titlepage"><div><div><h2 class="title"><a name="idp5940272"></a>Glossary</h2></div></div></div><p> This glossary defines some of the terms used in this specification. </p><dl><dt><a name="term-bus-name"></a>Bus Name</dt><dd><p> The message bus maintains an association between names and @@ -2860,14 +2883,14 @@ message bus. This name will never change owner, and will be unique (never reused during the lifetime of the message bus). It will begin with a ':' character. - </p></dd></dl></div><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a id="ftn.idp5275920" href="#idp5275920" class="para">1</a>] </sup>Lockfiles are used instead of real file + </p></dd></dl></div><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a id="ftn.idp5316512" href="#idp5316512" class="para">1</a>] </sup>Lockfiles are used instead of real file locking <code class="literal">fcntl()</code> because real locking implementations are still flaky on network - filesystems.</p></div><div class="footnote"><p><sup>[<a id="ftn.idp5714944" href="#idp5714944" class="para">2</a>] </sup> + filesystems.</p></div><div class="footnote"><p><sup>[<a id="ftn.idp5769440" href="#idp5769440" class="para">2</a>] </sup> The D-Bus reference implementation actually honors the <code class="literal">$(localstatedir)</code> configure option for this address, on both client and server side. - </p></div><div class="footnote"><p><sup>[<a id="ftn.idp5719152" href="#idp5719152" class="para">3</a>] </sup> + </p></div><div class="footnote"><p><sup>[<a id="ftn.idp5773648" href="#idp5773648" class="para">3</a>] </sup> The system bus is security-sensitive and is typically executed by an init system with a clean environment. Its launch helper process is particularly security-sensitive, and specifically diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 2ac82128..d806b8ea 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -2667,7 +2667,7 @@ [FIXME we need to specify in detail each transport and its possible arguments] Current transports include: unix domain sockets (including - abstract namespace on linux), launchd, systemd, TCP/IP, and a debug/testing transport + abstract namespace on linux), launchd, systemd, TCP/IP, an executed subprocess and a debug/testing transport using in-process pipes. Future possible transports include one that tunnels over X11 protocol. </para> @@ -2689,7 +2689,7 @@ would be padded by Nul bytes. </para> <para> - Unix domain sockets are not available on windows. + Unix domain sockets are not available on Windows. </para> <sect3 id="transports-unix-domain-sockets-addresses"> <title>Server Address Format</title> @@ -2806,7 +2806,7 @@ over a network is unsecure. </para> <para> - Windows notes: Because of the tcp stack on windows does not provide sending + Windows notes: Because of the tcp stack on Windows does not provide sending credentials over a tcp connection, the EXTERNAL authentification mechanismus does not work. </para> @@ -2924,6 +2924,67 @@ </informaltable> </sect3> </sect2> + <sect2 id="transports-exec"> + <title>Executed Subprocesses on Unix</title> + <para> + This transport forks off a process and connects its standard + input and standard output with an anonymous Unix domain + socket. This socket is then used for communication by the + transport. This transport may be used to use out-of-process + forwarder programs as basis for the D-Bus protocol. + </para> + <para> + The forked process will inherit the standard error output and + process group from the parent process. + </para> + <para> + Executed subprocesses are not available on Windows. + </para> + <sect3 id="transports-exec-addresses"> + <title>Server Address Format</title> + <para> + Executed subprocess addresses are identified by the "unixexec:" prefix + and support the following key/value pairs: + </para> + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Name</entry> + <entry>Values</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>path</entry> + <entry>(path)</entry> + <entry>Path of the binary to execute, either an absolute + path or a binary name that is searched for in the default + search path of the OS. This corresponds to the first + argument of execlp(). This key is mandatory.</entry> + </row> + <row> + <entry>argv0</entry> + <entry>(string)</entry> + <entry>The program name to use when executing the + binary. If omitted the same value as specified for path= + will be used. This corresponds to the second argument of + execlp().</entry> + </row> + <row> + <entry>argv1, argv2, ...</entry> + <entry>(string)</entry> + <entry>Arguments to pass to the binary. This corresponds + to the third and later arguments of execlp(). If a + specific argvX is not specified no further argvY for Y > X + are taken into account.</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </sect3> + </sect2> </sect1> <sect1 id="meta-transports"> <title>Meta Transports</title> @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -156,6 +156,10 @@ while test $# -ne 0; do -s) stripcmd=$stripprog;; -t) dst_arg=$2 + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac shift;; -T) no_target_directory=true;; @@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -200,7 +208,11 @@ if test $# -eq 0; then fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -228,9 +240,9 @@ fi for src do - # Protect names starting with `-'. + # Protect names problematic for `test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,12 +264,7 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. @@ -385,7 +392,7 @@ do case $dstdir in /*) prefix='/';; - -*) prefix='./';; + [-=\(\)!]*) prefix='./';; *) prefix='';; esac @@ -403,7 +410,7 @@ do for d do - test -z "$d" && continue + test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then @@ -5800,11 +5800,6 @@ func_mode_link () arg=$func_stripname_result ;; - -Wl,--as-needed|-Wl,--no-as-needed) - deplibs="$deplibs $arg" - continue - ;; - -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result @@ -6168,15 +6163,6 @@ func_mode_link () lib= found=no case $deplib in - -Wl,--as-needed|-Wl,--no-as-needed) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - fi - continue - ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then @@ -1,10 +1,10 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2009-04-28.21; # UTC +scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009 Free Software Foundation, Inc. +# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. # This program is free software; you can redistribute it and/or modify @@ -84,7 +84,6 @@ Supported PROGRAM values: help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and @@ -122,15 +121,6 @@ case $1 in # Not GNU programs, they don't have --version. ;; - tar*) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. @@ -226,7 +216,7 @@ WARNING: \`$1' $msg. You should only need it if \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then - eval LASTARG="\${$#}" + eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` @@ -256,7 +246,7 @@ WARNING: \`$1' is $msg. You should only need it if \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then - eval LASTARG="\${$#}" + eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` @@ -318,41 +308,6 @@ WARNING: \`$1' is $msg. You should only need it if touch $file ;; - tar*) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. diff --git a/test/Makefile.am b/test/Makefile.am index f2abe285..88a0e8cd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -105,6 +105,7 @@ installable_tests += \ test-marshal \ test-refs \ test-relay \ + test-syntax \ test-syslog \ $(NULL) endif DBUS_WITH_GLIB @@ -155,6 +156,10 @@ test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \ $(GLIB_LIBS) \ $(DBUS_GLIB_LIBS) +test_syntax_SOURCES = syntax.c +test_syntax_LDADD = $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) + if DBUS_ENABLE_MODULAR_TESTS TESTS += $(installable_tests) installcheck_tests += $(installable_tests) @@ -181,90 +186,138 @@ if DBUS_ENABLE_INSTALLED_TESTS $(testexec_PROGRAMS) endif DBUS_ENABLE_INSTALLED_TESTS -## keep these in creation order, i.e. uppermost dirs first -TESTDIRS= \ - data \ - data/valid-messages \ - data/invalid-messages \ - data/incomplete-messages \ - data/auth \ - data/sha-1 \ - data/valid-config-files \ - data/valid-config-files-system \ - data/valid-config-files/basic.d \ - data/valid-config-files/session.d \ - data/valid-config-files/system.d \ - data/valid-service-files \ - data/valid-service-files-system \ - data/invalid-service-files-system \ - data/invalid-config-files \ - data/invalid-config-files-system \ - data/equiv-config-files \ - data/equiv-config-files/basic \ - data/equiv-config-files/basic/basic.d \ - data/equiv-config-files/entities \ - data/equiv-config-files/entities/basic.d - - -FIND_TESTS=find . -type f -a \( -name "*.message" -o -name "*.message-raw" -o -name "*.auth-script" -o -name "*.sha1" -o -name "*.txt" -o -name "*.conf" -o -name "*.service" \) - -dist-hook: - for D in $(TESTDIRS); do \ - test -d $(distdir)/$$D || mkdir $(distdir)/$$D || exit 1 ; \ - done ; \ - FILES=`(cd $(srcdir) && $(FIND_TESTS) -o -name "*.in" -a -not -name Makefile.in | grep -Ev "(.svn|CVS)" )` ; \ - for F in $$FILES; do \ - B=`basename $$F`; \ - if test -e $$F.in; then \ - echo "-- Skipping file $$F (.in version exists)"; \ - elif test "x$$B" = xrun-with-tmp-session-bus.conf; then \ - echo "-- Skipping file $$F (generated)"; \ - elif test -e "$(top_srcdir)/bus/$$B"; then \ - echo "-- Skipping file $$F (from /bus/)"; \ - else \ - echo '-- Disting file '$$F ; \ - cp -f $(srcdir)/$$F $(distdir)/$$F || exit 1; \ - fi; \ - done - -## copy tests to builddir so that generated tests and static tests +in_data = \ + data/valid-config-files-system/debug-allow-all-fail.conf.in \ + data/valid-config-files-system/debug-allow-all-pass.conf.in \ + data/valid-config-files/debug-allow-all-sha1.conf.in \ + data/valid-config-files/debug-allow-all.conf.in \ + data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \ + data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \ + data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \ + $(NULL) + +EXTRA_DIST += $(in_data) + +static_data = \ + name-test/tmp-session-like-system.conf \ + data/auth/anonymous-client-successful.auth-script \ + data/auth/anonymous-server-successful.auth-script \ + data/auth/cancel.auth-script \ + data/auth/client-out-of-mechanisms.auth-script \ + data/auth/external-failed.auth-script \ + data/auth/external-root.auth-script \ + data/auth/external-silly.auth-script \ + data/auth/external-successful.auth-script \ + data/auth/extra-bytes.auth-script \ + data/auth/fail-after-n-attempts.auth-script \ + data/auth/fallback.auth-script \ + data/auth/invalid-command-client.auth-script \ + data/auth/invalid-command.auth-script \ + data/auth/invalid-hex-encoding.auth-script \ + data/auth/mechanisms.auth-script \ + data/equiv-config-files/basic/basic-1.conf \ + data/equiv-config-files/basic/basic-2.conf \ + data/equiv-config-files/basic/basic.d/basic.conf \ + data/equiv-config-files/entities/basic.d/basic.conf \ + data/equiv-config-files/entities/entities-1.conf \ + data/equiv-config-files/entities/entities-2.conf \ + data/incomplete-messages/missing-body.message \ + data/invalid-config-files/badselinux-1.conf \ + data/invalid-config-files/badselinux-2.conf \ + data/invalid-config-files/circular-1.conf \ + data/invalid-config-files/circular-2.conf \ + data/invalid-config-files/circular-3.conf \ + data/invalid-config-files/not-well-formed.conf \ + data/invalid-config-files/truncated-file.conf \ + data/invalid-messages/array-of-nil.message \ + data/invalid-messages/array-with-mixed-types.message \ + data/invalid-messages/bad-boolean-array.message \ + data/invalid-messages/bad-boolean.message \ + data/invalid-messages/bad-endian.message \ + data/invalid-messages/bad-header-field-alignment.message \ + data/invalid-messages/boolean-has-no-value.message-raw \ + data/invalid-messages/local-namespace.message \ + data/invalid-messages/no-dot-in-name.message \ + data/invalid-messages/not-nul-header-padding.message \ + data/invalid-messages/overlong-name.message \ + data/invalid-messages/too-little-header-padding.message \ + data/invalid-messages/too-much-header-padding-by-far.message \ + data/invalid-messages/too-much-header-padding.message \ + data/invalid-messages/too-short-dict.message \ + data/sha-1/Readme.txt \ + data/sha-1/bit-hashes.sha1 \ + data/sha-1/bit-messages.sha1 \ + data/sha-1/byte-hashes.sha1 \ + data/sha-1/byte-messages.sha1 \ + data/valid-config-files/basic.conf \ + data/valid-config-files/basic.d/basic.conf \ + data/valid-config-files/entities.conf \ + data/valid-config-files/incoming-limit.conf \ + data/valid-config-files/many-rules.conf \ + data/valid-config-files/system.d/test.conf \ + data/valid-messages/array-of-array-of-uint32.message \ + data/valid-messages/dict-simple.message \ + data/valid-messages/dict.message \ + data/valid-messages/emptiness.message \ + data/valid-messages/lots-of-arguments.message \ + data/valid-messages/no-padding.message \ + data/valid-messages/opposite-endian.message \ + data/valid-messages/recursive-types.message \ + data/valid-messages/simplest-manual.message \ + data/valid-messages/simplest.message \ + data/valid-messages/standard-acquire-service.message \ + data/valid-messages/standard-hello.message \ + data/valid-messages/standard-list-services.message \ + data/valid-messages/standard-service-exists.message \ + data/valid-messages/unknown-header-field.message \ + $(NULL) + +EXTRA_DIST += $(static_data) + +## copy tests to builddir so that generated tests and static tests ## are all in one place. all-local: - $(AM_V_at)for D in $(TESTDIRS); do \ - test -d $(top_builddir)/test/$$D || mkdir $(top_builddir)/test/$$D || exit 1 ; \ - done ; \ - if ! (test $(srcdir) = . || test $(srcdir) -ef .) ; then \ - FILES=`(cd $(srcdir) && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ; \ - for F in $$FILES; do \ - SRC=$(srcdir)/$$F ; \ - DEST=$(top_builddir)/test/$$F ; \ - echo '-- Copying test file '$$F ; \ - cp $$SRC $$DEST || exit 1 ; \ - chmod u+w $$DEST || exit 1 ; \ - done ; \ - else \ - echo '-- No need to copy test data as srcdir = builddir' ; \ - fi ; \ - echo '-- Copying' $(top_builddir)/bus/*.conf 'to test directory' ; \ - cp $(top_builddir)/bus/*.conf $(top_builddir)/test/data/valid-config-files || exit 1 ; \ - chmod u+w $(top_builddir)/test/data/valid-config-files/*.conf || exit 1 - -## this doesn't clean generated test data files when srcdir=builddir + $(AM_V_at)$(INSTALL) -d data/valid-config-files/session.d + $(AM_V_at)set -e && \ + if test $(srcdir) = . || test $(srcdir) -ef .; then \ + echo '-- No need to copy test data as srcdir = builddir'; \ + else \ + for F in $(static_data); do \ + $(INSTALL) -d $${F%/*}; \ + $(INSTALL_DATA) $(srcdir)/$$F $$F; \ + done; \ + fi + +## this doesn't clean most copied test data files when srcdir=builddir clean-local: - if test $(srcdir) != . ; then \ - FILES=`(cd $(top_builddir)/test && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ; \ - for F in $$FILES; do \ - DEST=$(top_builddir)/test/$$F ; \ - echo '-- Deleting test file '$$F ; \ - rm $$DEST || exit 1 ; \ - done ; \ - REVERSEDIRS= ; \ - for D in $(TESTDIRS); do \ - REVERSEDIRS="$$D $$REVERSEDIRS" ; \ - done ; \ - for D in $$REVERSEDIRS; do \ - rmdir $(top_builddir)/test/$$D || \ - test ! -d $(top_builddir)/test/$$D || \ - exit 1 ; \ - done ; \ + $(AM_V_at)if test $(srcdir) = . || test $(srcdir) -ef .; then \ + echo '-- No need to clean test data as srcdir = builddir'; \ + else \ + rm -f $(static_data); \ fi + +imported_data = \ + data/valid-config-files/session.conf \ + data/valid-config-files/system.conf \ + $(NULL) + +noinst_DATA = $(imported_data) +CLEANFILES = $(noinst_DATA) + +data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf + $(AM_V_at)$(INSTALL) -d data/valid-config-files + $(AM_V_GEN)$(INSTALL_DATA) $< $@ + +data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf + $(AM_V_at)$(INSTALL) -d data/valid-config-files + $(AM_V_GEN)$(INSTALL_DATA) $< $@ diff --git a/test/Makefile.in b/test/Makefile.in index 00019c8b..d833edce 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -16,6 +16,7 @@ @SET_MAKE@ + VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ @@ -51,6 +52,7 @@ testexec_PROGRAMS = $(am__EXEEXT_5) @DBUS_WITH_GLIB_TRUE@ test-marshal \ @DBUS_WITH_GLIB_TRUE@ test-refs \ @DBUS_WITH_GLIB_TRUE@ test-relay \ +@DBUS_WITH_GLIB_TRUE@ test-syntax \ @DBUS_WITH_GLIB_TRUE@ test-syslog \ @DBUS_WITH_GLIB_TRUE@ $(NULL) @@ -93,7 +95,8 @@ am__v_lt_0 = --silent @DBUS_WITH_GLIB_TRUE@ test-dbus-daemon-eavesdrop$(EXEEXT) \ @DBUS_WITH_GLIB_TRUE@ test-loopback$(EXEEXT) \ @DBUS_WITH_GLIB_TRUE@ test-marshal$(EXEEXT) test-refs$(EXEEXT) \ -@DBUS_WITH_GLIB_TRUE@ test-relay$(EXEEXT) test-syslog$(EXEEXT) +@DBUS_WITH_GLIB_TRUE@ test-relay$(EXEEXT) test-syntax$(EXEEXT) \ +@DBUS_WITH_GLIB_TRUE@ test-syslog$(EXEEXT) am__EXEEXT_3 = shell-test$(EXEEXT) $(am__EXEEXT_2) @DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_4 = $(am__EXEEXT_3) @DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_5 = $(am__EXEEXT_3) @@ -159,6 +162,10 @@ test_shell_service_DEPENDENCIES = libdbus-testutils.la test_sleep_forever_SOURCES = test-sleep-forever.c test_sleep_forever_OBJECTS = test-sleep-forever.$(OBJEXT) test_sleep_forever_LDADD = $(LDADD) +am_test_syntax_OBJECTS = syntax.$(OBJEXT) +test_syntax_OBJECTS = $(am_test_syntax_OBJECTS) +test_syntax_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ + $(am__DEPENDENCIES_1) am_test_syslog_OBJECTS = test_syslog-syslog.$(OBJEXT) test_syslog_OBJECTS = $(am_test_syslog_OBJECTS) test_syslog_DEPENDENCIES = libdbus-testutils.la $(am__DEPENDENCIES_1) @@ -194,7 +201,7 @@ SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c spawn-test.c \ $(test_loopback_SOURCES) $(test_marshal_SOURCES) test-names.c \ $(test_refs_SOURCES) $(test_relay_SOURCES) test-segfault.c \ test-service.c test-shell-service.c test-sleep-forever.c \ - $(test_syslog_SOURCES) + $(test_syntax_SOURCES) $(test_syslog_SOURCES) DIST_SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c \ spawn-test.c $(test_corrupt_SOURCES) \ $(test_dbus_daemon_SOURCES) \ @@ -202,7 +209,7 @@ DIST_SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c \ $(test_loopback_SOURCES) $(test_marshal_SOURCES) test-names.c \ $(test_refs_SOURCES) $(test_relay_SOURCES) test-segfault.c \ test-service.c test-shell-service.c test-sleep-forever.c \ - $(test_syslog_SOURCES) + $(test_syntax_SOURCES) $(test_syslog_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -210,6 +217,7 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive +DATA = $(noinst_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ @@ -509,7 +517,7 @@ test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) test_syslog_SOURCES = internals/syslog.c test_syslog_CPPFLAGS = $(static_cppflags) test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) -EXTRA_DIST = dbus-test-runner +EXTRA_DIST = dbus-test-runner $(in_data) $(static_data) testexecdir = $(libdir)/dbus-1.0/test installable_tests = shell-test $(NULL) $(am__append_2) installcheck_tests = $(am__append_4) @@ -558,30 +566,111 @@ test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \ $(GLIB_LIBS) \ $(DBUS_GLIB_LIBS) -TESTDIRS = \ - data \ - data/valid-messages \ - data/invalid-messages \ - data/incomplete-messages \ - data/auth \ - data/sha-1 \ - data/valid-config-files \ - data/valid-config-files-system \ - data/valid-config-files/basic.d \ - data/valid-config-files/session.d \ - data/valid-config-files/system.d \ - data/valid-service-files \ - data/valid-service-files-system \ - data/invalid-service-files-system \ - data/invalid-config-files \ - data/invalid-config-files-system \ - data/equiv-config-files \ - data/equiv-config-files/basic \ - data/equiv-config-files/basic/basic.d \ - data/equiv-config-files/entities \ - data/equiv-config-files/entities/basic.d - -FIND_TESTS = find . -type f -a \( -name "*.message" -o -name "*.message-raw" -o -name "*.auth-script" -o -name "*.sha1" -o -name "*.txt" -o -name "*.conf" -o -name "*.service" \) +test_syntax_SOURCES = syntax.c +test_syntax_LDADD = $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) + +in_data = \ + data/valid-config-files-system/debug-allow-all-fail.conf.in \ + data/valid-config-files-system/debug-allow-all-pass.conf.in \ + data/valid-config-files/debug-allow-all-sha1.conf.in \ + data/valid-config-files/debug-allow-all.conf.in \ + data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \ + data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \ + data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \ + data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \ + data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \ + $(NULL) + +static_data = \ + name-test/tmp-session-like-system.conf \ + data/auth/anonymous-client-successful.auth-script \ + data/auth/anonymous-server-successful.auth-script \ + data/auth/cancel.auth-script \ + data/auth/client-out-of-mechanisms.auth-script \ + data/auth/external-failed.auth-script \ + data/auth/external-root.auth-script \ + data/auth/external-silly.auth-script \ + data/auth/external-successful.auth-script \ + data/auth/extra-bytes.auth-script \ + data/auth/fail-after-n-attempts.auth-script \ + data/auth/fallback.auth-script \ + data/auth/invalid-command-client.auth-script \ + data/auth/invalid-command.auth-script \ + data/auth/invalid-hex-encoding.auth-script \ + data/auth/mechanisms.auth-script \ + data/equiv-config-files/basic/basic-1.conf \ + data/equiv-config-files/basic/basic-2.conf \ + data/equiv-config-files/basic/basic.d/basic.conf \ + data/equiv-config-files/entities/basic.d/basic.conf \ + data/equiv-config-files/entities/entities-1.conf \ + data/equiv-config-files/entities/entities-2.conf \ + data/incomplete-messages/missing-body.message \ + data/invalid-config-files/badselinux-1.conf \ + data/invalid-config-files/badselinux-2.conf \ + data/invalid-config-files/circular-1.conf \ + data/invalid-config-files/circular-2.conf \ + data/invalid-config-files/circular-3.conf \ + data/invalid-config-files/not-well-formed.conf \ + data/invalid-config-files/truncated-file.conf \ + data/invalid-messages/array-of-nil.message \ + data/invalid-messages/array-with-mixed-types.message \ + data/invalid-messages/bad-boolean-array.message \ + data/invalid-messages/bad-boolean.message \ + data/invalid-messages/bad-endian.message \ + data/invalid-messages/bad-header-field-alignment.message \ + data/invalid-messages/boolean-has-no-value.message-raw \ + data/invalid-messages/local-namespace.message \ + data/invalid-messages/no-dot-in-name.message \ + data/invalid-messages/not-nul-header-padding.message \ + data/invalid-messages/overlong-name.message \ + data/invalid-messages/too-little-header-padding.message \ + data/invalid-messages/too-much-header-padding-by-far.message \ + data/invalid-messages/too-much-header-padding.message \ + data/invalid-messages/too-short-dict.message \ + data/sha-1/Readme.txt \ + data/sha-1/bit-hashes.sha1 \ + data/sha-1/bit-messages.sha1 \ + data/sha-1/byte-hashes.sha1 \ + data/sha-1/byte-messages.sha1 \ + data/valid-config-files/basic.conf \ + data/valid-config-files/basic.d/basic.conf \ + data/valid-config-files/entities.conf \ + data/valid-config-files/incoming-limit.conf \ + data/valid-config-files/many-rules.conf \ + data/valid-config-files/system.d/test.conf \ + data/valid-messages/array-of-array-of-uint32.message \ + data/valid-messages/dict-simple.message \ + data/valid-messages/dict.message \ + data/valid-messages/emptiness.message \ + data/valid-messages/lots-of-arguments.message \ + data/valid-messages/no-padding.message \ + data/valid-messages/opposite-endian.message \ + data/valid-messages/recursive-types.message \ + data/valid-messages/simplest-manual.message \ + data/valid-messages/simplest.message \ + data/valid-messages/standard-acquire-service.message \ + data/valid-messages/standard-hello.message \ + data/valid-messages/standard-list-services.message \ + data/valid-messages/standard-service-exists.message \ + data/valid-messages/unknown-header-field.message \ + $(NULL) + +imported_data = \ + data/valid-config-files/session.conf \ + data/valid-config-files/system.conf \ + $(NULL) + +noinst_DATA = $(imported_data) +CLEANFILES = $(noinst_DATA) all: all-recursive .SUFFIXES: @@ -724,6 +813,9 @@ test-shell-service$(EXEEXT): $(test_shell_service_OBJECTS) $(test_shell_service_ test-sleep-forever$(EXEEXT): $(test_sleep_forever_OBJECTS) $(test_sleep_forever_DEPENDENCIES) $(EXTRA_test_sleep_forever_DEPENDENCIES) @rm -f test-sleep-forever$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_sleep_forever_OBJECTS) $(test_sleep_forever_LDADD) $(LIBS) +test-syntax$(EXEEXT): $(test_syntax_OBJECTS) $(test_syntax_DEPENDENCIES) $(EXTRA_test_syntax_DEPENDENCIES) + @rm -f test-syntax$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_syntax_OBJECTS) $(test_syntax_LDADD) $(LIBS) test-syslog$(EXEEXT): $(test_syslog_OBJECTS) $(test_syslog_DEPENDENCIES) $(EXTRA_test_syslog_DEPENDENCIES) @rm -f test-syslog$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_syslog_OBJECTS) $(test_syslog_LDADD) $(LIBS) @@ -742,6 +834,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell_test-shell-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spawn_test-spawn-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syntax.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-exit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-segfault.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sleep-forever.Po@am__quote@ @@ -1184,13 +1277,10 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) all-local +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) all-local installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(testexecdir)"; do \ @@ -1218,6 +1308,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -1305,19 +1396,18 @@ uninstall-am: uninstall-testexecPROGRAMS all all-am all-local check check-TESTS check-am clean \ clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ - clean-testexecPROGRAMS ctags ctags-recursive dist-hook \ - distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip \ - install-testexecPROGRAMS installcheck installcheck-am \ - installcheck-local installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am \ + clean-testexecPROGRAMS ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip install-testexecPROGRAMS installcheck \ + installcheck-am installcheck-local installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-testexecPROGRAMS @@ -1333,64 +1423,33 @@ installcheck-local: @DBUS_ENABLE_INSTALLED_TESTS_TRUE@ $(testexecdir) \ @DBUS_ENABLE_INSTALLED_TESTS_TRUE@ $(testexec_PROGRAMS) -dist-hook: - for D in $(TESTDIRS); do \ - test -d $(distdir)/$$D || mkdir $(distdir)/$$D || exit 1 ; \ - done ; \ - FILES=`(cd $(srcdir) && $(FIND_TESTS) -o -name "*.in" -a -not -name Makefile.in | grep -Ev "(.svn|CVS)" )` ; \ - for F in $$FILES; do \ - B=`basename $$F`; \ - if test -e $$F.in; then \ - echo "-- Skipping file $$F (.in version exists)"; \ - elif test "x$$B" = xrun-with-tmp-session-bus.conf; then \ - echo "-- Skipping file $$F (generated)"; \ - elif test -e "$(top_srcdir)/bus/$$B"; then \ - echo "-- Skipping file $$F (from /bus/)"; \ - else \ - echo '-- Disting file '$$F ; \ - cp -f $(srcdir)/$$F $(distdir)/$$F || exit 1; \ - fi; \ - done - all-local: - $(AM_V_at)for D in $(TESTDIRS); do \ - test -d $(top_builddir)/test/$$D || mkdir $(top_builddir)/test/$$D || exit 1 ; \ - done ; \ - if ! (test $(srcdir) = . || test $(srcdir) -ef .) ; then \ - FILES=`(cd $(srcdir) && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ; \ - for F in $$FILES; do \ - SRC=$(srcdir)/$$F ; \ - DEST=$(top_builddir)/test/$$F ; \ - echo '-- Copying test file '$$F ; \ - cp $$SRC $$DEST || exit 1 ; \ - chmod u+w $$DEST || exit 1 ; \ - done ; \ - else \ - echo '-- No need to copy test data as srcdir = builddir' ; \ - fi ; \ - echo '-- Copying' $(top_builddir)/bus/*.conf 'to test directory' ; \ - cp $(top_builddir)/bus/*.conf $(top_builddir)/test/data/valid-config-files || exit 1 ; \ - chmod u+w $(top_builddir)/test/data/valid-config-files/*.conf || exit 1 + $(AM_V_at)$(INSTALL) -d data/valid-config-files/session.d + $(AM_V_at)set -e && \ + if test $(srcdir) = . || test $(srcdir) -ef .; then \ + echo '-- No need to copy test data as srcdir = builddir'; \ + else \ + for F in $(static_data); do \ + $(INSTALL) -d $${F%/*}; \ + $(INSTALL_DATA) $(srcdir)/$$F $$F; \ + done; \ + fi clean-local: - if test $(srcdir) != . ; then \ - FILES=`(cd $(top_builddir)/test && $(FIND_TESTS) | grep -Ev "(.svn|CVS)" )` ; \ - for F in $$FILES; do \ - DEST=$(top_builddir)/test/$$F ; \ - echo '-- Deleting test file '$$F ; \ - rm $$DEST || exit 1 ; \ - done ; \ - REVERSEDIRS= ; \ - for D in $(TESTDIRS); do \ - REVERSEDIRS="$$D $$REVERSEDIRS" ; \ - done ; \ - for D in $$REVERSEDIRS; do \ - rmdir $(top_builddir)/test/$$D || \ - test ! -d $(top_builddir)/test/$$D || \ - exit 1 ; \ - done ; \ + $(AM_V_at)if test $(srcdir) = . || test $(srcdir) -ef .; then \ + echo '-- No need to clean test data as srcdir = builddir'; \ + else \ + rm -f $(static_data); \ fi +data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf + $(AM_V_at)$(INSTALL) -d data/valid-config-files + $(AM_V_GEN)$(INSTALL_DATA) $< $@ + +data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf + $(AM_V_at)$(INSTALL) -d data/valid-config-files + $(AM_V_GEN)$(INSTALL_DATA) $< $@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/test/data/valid-config-files/many-rules.conf b/test/data/valid-config-files/many-rules.conf index 089908b4..23931626 100644 --- a/test/data/valid-config-files/many-rules.conf +++ b/test/data/valid-config-files/many-rules.conf @@ -14,6 +14,7 @@ <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"/> @@ -32,6 +33,7 @@ <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"/> diff --git a/test/syntax.c b/test/syntax.c new file mode 100644 index 00000000..88db9638 --- /dev/null +++ b/test/syntax.c @@ -0,0 +1,289 @@ +/* Simple sanity-check for D-Bus syntax validation. + * + * Author: Simon McVittie <simon.mcvittie@collabora.co.uk> + * Copyright © 2010-2011 Nokia Corporation + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <config.h> + +#include <glib.h> + +#include <dbus/dbus.h> + +typedef struct { + DBusError e; +} Fixture; + +typedef struct { + dbus_bool_t (*function) (const char *, DBusError *); + const char * const * valid; + const char * const * invalid; +} Test; + +Test paths, interfaces, members, errors, bus_names, signatures, + single_signatures, strings; + +const char * const valid_paths[] = { + "/", + "/a", + "/_", + "/a/b/c", + "/com/example/123", + "/org/freedesktop/DBus", + "/org/freedesktop/Telepathy/AccountManager", + NULL +}; + +const char * const invalid_paths[] = { + "", + ".", + "//", + "/a/", + "/-", + "/com//example/MyApp", + "/$", + "/\xa9", /* © in latin-1 */ + "/\xc2\xa9", /* © in UTF-8 */ + NULL +}; + +const char * const valid_interfaces[] = { + "com.example", + "com.example.a0", + "org.freedesktop.DBus", + NULL +}; + +const char * const invalid_interfaces[] = { + "", + "com", + "com.example.", + "com.example..a0", + "com.example.0a", + "com.example.a$", + "com.example.a\xa9", + "com.example.a\xc2\xa9", + NULL +}; + +const char * const valid_members[] = { + "_", + "a", + "a0", + "GetAll", + "BadgerMushroomSnake", + NULL +}; + +const char * const invalid_members[] = { + "", + "-", + "a-", + "0", + "0_", + "Badger.Mushroom", + "a$", + "a\xa9", + "a\xc2\xa9", + NULL +}; + +const char * const valid_errors[] = { + "com.example", + "com.example.a0", + "org.freedesktop.DBus.NameHasNoOwner", + NULL +}; + +const char * const invalid_errors[] = { + "", + "com", + "com.example.", + "com.example..a0", + "com.example.0a", + "com.example.a$", + "com.example.a\xa9", + "com.example.a\xc2\xa9", + NULL +}; + +const char * const valid_bus_names[] = { + "com.example", + "com.example.a0", + "com.example._", + ":1.42", + ":1.2.3.4.5", + ":com.example", + "org.freedesktop.DBus", + NULL +}; + +const char * const invalid_bus_names[] = { + "", + "com", + "com.example.", + "com.example..a0", + "com.example.0a", + "com.example.a:b", + "com.example.a\xa9", + "com.example.a\xc2\xa9", + NULL +}; + +const char * const valid_signatures[] = { + "", + "a{sv}", + NULL +}; + +const char * const invalid_signatures[] = { + "a", + "a{s_}", + NULL +}; + +const char * const valid_single_signatures[] = { + "s", + "a{sv}", + NULL +}; + +const char * const invalid_single_signatures[] = { + "", + "a", + "sv", + "a{sv}as", + NULL +}; + +const char * const valid_strings[] = { + "", + "\xc2\xa9", + NULL +}; + +const char * const invalid_strings[] = { + "\xa9", + NULL +}; + +static void +setup (Fixture *f, + gconstpointer arg G_GNUC_UNUSED) +{ + dbus_error_init (&f->e); + +#define FILL_TEST(name, func) \ + do { \ + (name).function = (func); \ + (name).valid = valid_ ## name; \ + (name).invalid = invalid_ ## name; \ + } while (0) + + FILL_TEST (paths, dbus_validate_path); + FILL_TEST (interfaces, dbus_validate_interface); + FILL_TEST (members, dbus_validate_member); + FILL_TEST (errors, dbus_validate_error_name); + FILL_TEST (bus_names, dbus_validate_bus_name); + FILL_TEST (signatures, dbus_signature_validate); + FILL_TEST (single_signatures, dbus_signature_validate_single); + FILL_TEST (strings, dbus_validate_utf8); +} + +static void +test_syntax (Fixture *f, + gconstpointer arg) +{ + const Test *test = arg; + int i; + + g_assert (test != NULL); + g_assert (test->function != NULL); + g_assert (test->valid != NULL); + g_assert (test->invalid != NULL); + + for (i = 0; test->valid[i] != NULL; i++) + { + dbus_bool_t ok = test->function (test->valid[i], &f->e); + + if (dbus_error_is_set (&f->e)) + g_error ("%s was considered invalid: %s: %s", test->valid[i], + f->e.name, f->e.message); + + if (!ok) + g_error ("%s was considered invalid without an error", test->valid[i]); + } + + for (i = 0; test->invalid[i] != NULL; i++) + { + dbus_bool_t ok = test->function (test->invalid[i], &f->e); + + if (ok) + g_error ("%s should have been considered invalid", test->invalid[i]); + + if (!dbus_error_is_set (&f->e)) + g_error ("%s should have an error set", test->invalid[i]); + + if (!dbus_validate_error_name (f->e.name, NULL)) + g_error ("%s produced an invalid error name: %s", + test->invalid[i], f->e.name); + + if (!dbus_validate_utf8 (f->e.message, NULL)) + g_error ("%s produced an invalid error message: %s", + test->invalid[i], f->e.message); + + dbus_error_free (&f->e); + } +} + +static void +teardown (Fixture *f, + gconstpointer arg G_GNUC_UNUSED) +{ + dbus_error_free (&f->e); +} + +int +main (int argc, + char **argv) +{ + g_test_init (&argc, &argv, NULL); + + g_test_add ("/syntax/path", Fixture, &paths, setup, test_syntax, teardown); + g_test_add ("/syntax/interface", Fixture, &interfaces, + setup, test_syntax, teardown); + g_test_add ("/syntax/error", Fixture, &errors, + setup, test_syntax, teardown); + g_test_add ("/syntax/member", Fixture, &members, + setup, test_syntax, teardown); + g_test_add ("/syntax/bus-name", Fixture, &bus_names, + setup, test_syntax, teardown); + g_test_add ("/syntax/signature", Fixture, &signatures, + setup, test_syntax, teardown); + g_test_add ("/syntax/single-signature", Fixture, &single_signatures, + setup, test_syntax, teardown); + g_test_add ("/syntax/utf8", Fixture, &strings, + setup, test_syntax, teardown); + + return g_test_run (); +} |