diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.in | 212 | ||||
-rw-r--r-- | tools/dbus-launch.c | 10 | ||||
-rw-r--r-- | tools/dbus-print-message.c | 174 |
3 files changed, 318 insertions, 78 deletions
diff --git a/tools/Makefile.in b/tools/Makefile.in index db619be6..dd562f10 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11.6 from Makefile.am. +# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -16,23 +15,51 @@ @SET_MAKE@ VPATH = @srcdir@ -am__make_dryrun = \ - { \ - am__dry=no; \ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ - echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ - | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ - *) \ - for am__flg in $$MAKEFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - *n*) am__dry=yes; break;; \ - esac; \ - done;; \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ esac; \ - test $$am__dry = yes; \ - } + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -60,7 +87,8 @@ bin_PROGRAMS = dbus-launch$(EXEEXT) dbus-monitor$(EXEEXT) \ @DBUS_UNIX_TRUE@ $(NULL) subdir = tools -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ $(top_srcdir)/m4/compiler.m4 $(top_srcdir)/m4/libtool.m4 \ @@ -86,6 +114,7 @@ dbus_cleanup_sockets_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent +am__v_lt_1 = am__dbus_launch_SOURCES_DIST = dbus-launch.c dbus-launch-x11.c \ dbus-launch.h dbus-launch-win.c @DBUS_WIN_FALSE@am_dbus_launch_OBJECTS = dbus-launch.$(OBJEXT) \ @@ -112,6 +141,18 @@ dbus_send_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la am_dbus_uuidgen_OBJECTS = dbus-uuidgen.$(OBJEXT) dbus_uuidgen_OBJECTS = $(am_dbus_uuidgen_OBJECTS) dbus_uuidgen_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -124,20 +165,16 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = SOURCES = $(dbus_cleanup_sockets_SOURCES) $(dbus_launch_SOURCES) \ $(dbus_monitor_SOURCES) $(dbus_run_session_SOURCES) \ $(dbus_send_SOURCES) $(dbus_uuidgen_SOURCES) @@ -150,6 +187,23 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -205,7 +259,6 @@ DBUS_USER = @DBUS_USER@ DBUS_VERSION = @DBUS_VERSION@ DBUS_X_CFLAGS = @DBUS_X_CFLAGS@ DBUS_X_LIBS = @DBUS_X_LIBS@ -DEFAULT_MESSAGE_UNIX_FDS = @DEFAULT_MESSAGE_UNIX_FDS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -466,10 +519,12 @@ install-binPROGRAMS: $(bin_PROGRAMS) fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p || test -f $$p1; \ - then echo "$$p"; echo "$$p"; else :; fi; \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ - sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ @@ -490,7 +545,8 @@ uninstall-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' `; \ + -e 's/$$/$(EXEEXT)/' \ + `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files @@ -503,21 +559,27 @@ clean-binPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list + dbus-cleanup-sockets$(EXEEXT): $(dbus_cleanup_sockets_OBJECTS) $(dbus_cleanup_sockets_DEPENDENCIES) $(EXTRA_dbus_cleanup_sockets_DEPENDENCIES) @rm -f dbus-cleanup-sockets$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbus_cleanup_sockets_OBJECTS) $(dbus_cleanup_sockets_LDADD) $(LIBS) + dbus-launch$(EXEEXT): $(dbus_launch_OBJECTS) $(dbus_launch_DEPENDENCIES) $(EXTRA_dbus_launch_DEPENDENCIES) @rm -f dbus-launch$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbus_launch_OBJECTS) $(dbus_launch_LDADD) $(LIBS) + dbus-monitor$(EXEEXT): $(dbus_monitor_OBJECTS) $(dbus_monitor_DEPENDENCIES) $(EXTRA_dbus_monitor_DEPENDENCIES) @rm -f dbus-monitor$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbus_monitor_OBJECTS) $(dbus_monitor_LDADD) $(LIBS) + dbus-run-session$(EXEEXT): $(dbus_run_session_OBJECTS) $(dbus_run_session_DEPENDENCIES) $(EXTRA_dbus_run_session_DEPENDENCIES) @rm -f dbus-run-session$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbus_run_session_OBJECTS) $(dbus_run_session_LDADD) $(LIBS) + dbus-send$(EXEEXT): $(dbus_send_OBJECTS) $(dbus_send_DEPENDENCIES) $(EXTRA_dbus_send_DEPENDENCIES) @rm -f dbus-send$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbus_send_OBJECTS) $(dbus_send_LDADD) $(LIBS) + dbus-uuidgen$(EXEEXT): $(dbus_uuidgen_OBJECTS) $(dbus_uuidgen_DEPENDENCIES) $(EXTRA_dbus_uuidgen_DEPENDENCIES) @rm -f dbus-uuidgen$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbus_uuidgen_OBJECTS) $(dbus_uuidgen_LDADD) $(LIBS) @@ -543,14 +605,14 @@ distclean-compile: @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -565,26 +627,15 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -596,15 +647,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $$unique; \ fi; \ fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -613,6 +660,21 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -757,20 +819,20 @@ uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-libtool ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am \ - install-data-local 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 installcheck \ - installcheck-am installcheck-local installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-binPROGRAMS +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-data-local 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 installcheck installcheck-am installcheck-local \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-binPROGRAMS # create the /var/lib/dbus directory for dbus-uuidgen diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 7ecee63e..41a20e83 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -406,6 +406,9 @@ static pid_t bus_pid_to_kill = -1; static void kill_bus(void) { + if (bus_pid_to_kill <= 0) + return; + verbose ("Killing message bus and exiting babysitter\n"); kill (bus_pid_to_kill, SIGTERM); sleep (3); @@ -533,7 +536,7 @@ kill_bus_when_session_ends (void) if (tty_fd < 0 && x_fd < 0) { fprintf (stderr, "No terminal on standard input and no X display; cannot attach message bus to session lifetime\n"); - exit (1); + kill_bus_and_exit (1); } while (TRUE) @@ -1275,6 +1278,10 @@ main (int argc, char **argv) bus_pid = val; + /* Have to initialize bus_pid_to_kill ASAP, so that the + X error callback can kill it if an error happens. */ + bus_pid_to_kill = bus_pid; + close (bus_pid_to_launcher_pipe[READ_END]); #ifdef DBUS_ENABLE_X11_AUTOLAUNCH @@ -1291,7 +1298,6 @@ main (int argc, char **argv) { char *address = NULL; /* another window got added. Return its address */ - bus_pid_to_kill = bus_pid; if (x11_get_address (&address, &bus_pid, &wid) && address != NULL) { diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index 75d00aca..6f02ea38 100644 --- a/tools/dbus-print-message.c +++ b/tools/dbus-print-message.c @@ -23,6 +23,17 @@ #include <config.h> #include "dbus-print-message.h" +#ifdef DBUS_UNIX +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <unistd.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <arpa/inet.h> +#endif + #include <stdlib.h> #include "config.h" @@ -143,6 +154,151 @@ print_ay (DBusMessageIter *iter, int depth) } static void +print_fd (int fd, int depth) +{ +#ifdef DBUS_UNIX + int ret; + struct stat statbuf = {0,}; + union { + struct sockaddr sa; + struct sockaddr_storage storage; + struct sockaddr_un un; + struct sockaddr_in ipv4; + struct sockaddr_in6 ipv6; + } addr, peer; + char hostip[INET6_ADDRSTRLEN]; + int addrlen = sizeof (addr); + int peerlen = sizeof (peer); + int has_peer; +#endif + + /* Don't print the fd number: it is different in every process and since + * dbus-monitor closes the fd after reading it, the same number would be + * printed again and again. + */ + printf ("file descriptor\n"); + if (fd == -1) + return; + +#ifdef DBUS_UNIX + ret = fstat (fd, &statbuf); + if (ret == -1) + return; + + indent (depth+1); + printf ("inode: %d\n", (int) statbuf.st_ino); + + indent (depth+1); + printf ("type: "); + if (S_ISREG(statbuf.st_mode)) + printf ("file\n"); + if (S_ISDIR(statbuf.st_mode)) + printf ("directory\n"); + if (S_ISCHR(statbuf.st_mode)) + printf ("char\n"); + if (S_ISBLK(statbuf.st_mode)) + printf ("block\n"); + if (S_ISFIFO(statbuf.st_mode)) + printf ("fifo\n"); + if (S_ISLNK(statbuf.st_mode)) + printf ("link\n"); + if (S_ISSOCK(statbuf.st_mode)) + printf ("socket\n"); + + /* If it's not a socket, getsockname will just return -1 with errno + * ENOTSOCK. */ + + memset (&addr, 0, sizeof (addr)); + memset (&peer, 0, sizeof (peer)); + + if (getsockname(fd, &addr.sa, &addrlen)) + return; + + has_peer = !getpeername(fd, &peer.sa, &peerlen); + + indent (depth+1); + printf ("address family: "); + switch (addr.sa.sa_family) + { + case AF_UNIX: + printf("unix\n"); + if (addr.un.sun_path[0] == '\0') + { + /* Abstract socket might not be zero-terminated and length is + * variable. Who designed this interface? + * Write the name in the same way as /proc/net/unix + * See manual page unix(7) + */ + indent (depth+1); + printf ("name @%.*s\n", + (int) (addrlen - sizeof (sa_family_t) - 1), + &(addr.un.sun_path[1])); + + if (has_peer) + { + indent (depth+1); + printf ("peer @%.*s\n", + (int) (addrlen - sizeof (sa_family_t) - 1), + &(addr.un.sun_path[1])); + } + } + else + { + indent (depth+1); + printf ("name %s\n", addr.un.sun_path); + if (has_peer) + { + indent (depth+1); + printf ("peer %s\n", peer.un.sun_path); + } + } + break; + + case AF_INET: + printf ("inet\n"); + if (inet_ntop (AF_INET, &addr.ipv4.sin_addr, hostip, sizeof (hostip))) + { + indent (depth+1); + printf ("name %s port %u\n", hostip, ntohs (addr.ipv4.sin_port)); + } + if (has_peer && inet_ntop (AF_INET, &peer.ipv4.sin_addr, hostip, sizeof (hostip))) + { + indent (depth+1); + printf ("peer %s port %u\n", hostip, ntohs (peer.ipv4.sin_port)); + } + + break; + +#ifdef AF_INET6 + case AF_INET6: + printf ("inet6\n"); + if (inet_ntop (AF_INET6, &addr.ipv6.sin6_addr, hostip, sizeof (hostip))) + { + indent (depth+1); + printf ("name %s port %u\n", hostip, ntohs (addr.ipv6.sin6_port)); + } + if (has_peer && inet_ntop (AF_INET6, &peer.ipv6.sin6_addr, hostip, sizeof (hostip))) + { + indent (depth+1); + printf ("peer %s port %u\n", hostip, ntohs (peer.ipv6.sin6_port)); + } + break; +#endif + +#ifdef AF_BLUETOOTH + case AF_BLUETOOTH: + printf ("bluetooth\n"); + break; +#endif + + default: + printf ("unknown (%d)\n", addr.sa.sa_family); + break; + } +#endif +} + +static void print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth) { do @@ -346,7 +502,23 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth) printf("}\n"); break; } - + + case DBUS_TYPE_UNIX_FD: + { + int fd; + dbus_message_iter_get_basic (iter, &fd); + + print_fd (fd, depth+1); + + /* dbus_message_iter_get_basic() duplicated the fd, we need to + * close it after use. The original fd will be closed when the + * DBusMessage is released. + */ + close (fd); + + break; + } + default: printf (" (dbus-monitor too dumb to decipher arg type '%c')\n", type); break; |