From sk@sethwklein.net Sat Nov 1 02:22:58 2003 From: sk@sethwklein.net (Seth W. Klein) Date: Fri, 31 Oct 2003 21:22:58 -0500 Subject: HTML of D-BUS man pages Message-ID: <20031101022258.GA23975@bubook.sethwklein.net> On http://www.freedesktop.org/Software/dbus there are several links to man pages. They all go to a page that says: Someone tell me how to convert a man page to html on Debian, Red Hat 'man' package has a man2html, Debian man2html package is some sort of CGI script Answer: groff -man -Thtml foo.1 >foo.1.html I've put the resulting HTML for D-BUS's pages up at http://www.freedesktop.org/~sk/ A script to create the HTML is also there. It uses the pages from the most recent dbus release tarball it can find. cheers, Seth W. "Jzalae" Klein -- sk@sethwklein.net http://www.sethwklein.net/ From hp@redhat.com Sat Nov 1 06:01:13 2003 From: hp@redhat.com (Havoc Pennington) Date: Sat, 01 Nov 2003 01:01:13 -0500 Subject: HTML of D-BUS man pages In-Reply-To: <20031101022258.GA23975@bubook.sethwklein.net> References: <20031101022258.GA23975@bubook.sethwklein.net> Message-ID: <1067666473.19882.6.camel@localhost.localdomain> On Fri, 2003-10-31 at 21:22, Seth W. Klein wrote: > Answer: groff -man -Thtml foo.1 >foo.1.html > Thanks much, the cron job on freedesktop.org is now fixed so the man page links work. Havoc From willem.dantuma@dobs.nl Sun Nov 2 11:21:02 2003 From: willem.dantuma@dobs.nl (Willem Dantuma) Date: 02 Nov 2003 12:21:02 +0100 Subject: Delayed authentication Message-ID: <1067772061.2482.9.camel@wodan.dobs.nl> --=-4XSEb5XKy0ef8HIOY0XW Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi I'am still working ( on and of, my time is very limited ) on enabling SASL authentication in D-Bus. It's almost functional, but now i need a way to delay the authentication process, right now it is started during a dbus_connection_open but i want to be able do someting like this: conn = dbus_connection_open(..) dbus_connection_set_username(conn,..) dbus_connection_set_password(conn,..) dbus_connection_set_sasl_prop(conn,...) dbus_connection_start(conn) Any Ideas how to accomplish this. Willem Dantuma --=-4XSEb5XKy0ef8HIOY0XW Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi

I'am still working ( on and of, my time is very limited ) on enabling SASL authentication in D-Bus. It's almost functional, but now i need a way to delay the authentication process, right now it is started during a dbus_connection_open but i want to be able do someting like this:

conn = dbus_connection_open(..)
dbus_connection_set_username(conn,..)
dbus_connection_set_password(conn,..)
dbus_connection_set_sasl_prop(conn,...)
dbus_connection_start(conn)

Any Ideas how to accomplish this.



Willem Dantuma

--=-4XSEb5XKy0ef8HIOY0XW-- From murrayc@usa.net Thu Nov 6 19:19:37 2003 From: murrayc@usa.net (Murray Cumming) Date: Thu, 06 Nov 2003 20:19:37 +0100 Subject: C++ bindings Message-ID: <1068146377.2173.61.camel@localhost.localdomain> I'm playing around at doing some DBUS C++ bindings. Do you really want to ship bindings with DBUS itself? If you do, then I'll probably need to put them under the dbus directory, e.g. dbus/dbus/C sources dbus/dbus/cpp/C++ bindings or put dbus in the name, unlike the other bindings. e.g. dbus/dbus/C sources dbus/dbus-cpp/C++ bindings. This will allow my headers to use a full path in #includes. Do you have a preference? -- Murray Cumming murrayc@usa.net www.murrayc.com From hp@redhat.com Thu Nov 6 19:29:51 2003 From: hp@redhat.com (Havoc Pennington) Date: Thu, 06 Nov 2003 14:29:51 -0500 Subject: C++ bindings In-Reply-To: <1068146377.2173.61.camel@localhost.localdomain> References: <1068146377.2173.61.camel@localhost.localdomain> Message-ID: <1068146991.4591.44.camel@localhost.localdomain> On Thu, 2003-11-06 at 14:19, Murray Cumming wrote: > I'm playing around at doing some DBUS C++ bindings. > > Do you really want to ship bindings with DBUS itself? It's up to you. Since people would be downloading gtkmm stuff already, maybe shipping it with that makes more sense (I don't mean same tarball, just same ftp site, etc.) > If you do, then > I'll probably need to put them under the dbus directory, e.g. > dbus/dbus/C sources > dbus/dbus/cpp/C++ bindings > or put dbus in the name, unlike the other bindings. e.g. > dbus/dbus/C sources > dbus/dbus-cpp/C++ bindings. > This will allow my headers to use a full path in #includes. Do you have > a preference? Could you do cxx/dbus/dbus.h perhaps? cpp means "C preprocessor" to me but maybe not to others. I would suggest you probably want to do some code generation, and you could use the same code generator as dbus-glib. (Though this generator is not really written, it's half-started-on.) By code generation I mean either IDL -> sourcecode (CORBA model), or sourcecode -> IDL -> typelib (moc/DCOP model). Or IDL -> typelib perhaps, if you want to make people do more typing. Havoc From hp@redhat.com Fri Nov 7 14:34:30 2003 From: hp@redhat.com (Havoc Pennington) Date: 07 Nov 2003 09:34:30 -0500 Subject: C++ bindings In-Reply-To: <258B0164D480D5118D900800062B385801840B76@vihsx09a.vih.infineon.com> References: <258B0164D480D5118D900800062B385801840B76@vihsx09a.vih.infineon.com> Message-ID: <1068215670.1662.26.camel@dhcppc3> On Fri, 2003-11-07 at 09:08, Murray.Cumming@Comneon.com wrote: > I'll definitely keep that in mind, but what I've seen so far suggests that > there will be too many special cases. However, I have only explored a > fraction of the API and I don't think I've fully understood everything yet. I'm not saying autogen the bindings. I'm saying the way people would _use_ the bindings may involve generating code, as it does for CORBA or DCOP or the GLib bindings. > I'm in no rush personally, but I'll try to put some crap in cvs so that > others can look at it. Would you like me to put my crap in the freedesktop > cvs or GNOME's? It's up to you, if the bindings are generic C++ the freedesktop cvs probably makes sense. > > By code generation I mean either IDL -> sourcecode (CORBA model), or > > sourcecode -> IDL -> typelib (moc/DCOP model). Or IDL -> > > typelib perhaps, if you want to make people do more typing. > > Thanks for the tip. I didn't realise that the glib bindings were generated. They aren't, but the idea is that application code would (partially) be. Specifically what the generator would create is a metadata blob in the form of a static variable. You then #include this blob in your GObject subclass implementation and it allows the glib bindings to type-safely dynamically marshal methods on your object when dbus messages are received. This isn't implemented yet, though. It's the way the DCOP/Qt stuff works. There are some messages in the archives discussing this more IIRC. > I'll be trying to wrap the lower level API as well as creating a higher > level API like in the python bindings. The lower level API is designed almost purely for the use of bindings; wrapping the main loop glue (DBusWatch, connection_set_watch_functions) and the object data set/getters is probably pointless bloat/confusion in your binding API. Havoc From hp@redhat.com Sat Nov 8 01:24:56 2003 From: hp@redhat.com (Havoc Pennington) Date: 07 Nov 2003 20:24:56 -0500 Subject: C++ bindings In-Reply-To: <258B0164D480D5118D900800062B385801840B83@vihsx09a.vih.infineon.com> References: <258B0164D480D5118D900800062B385801840B83@vihsx09a.vih.infineon.com> Message-ID: <1068254696.2242.0.camel@dhcppc3> On Fri, 2003-11-07 at 11:36, Murray.Cumming@Comneon.com wrote: > Yes, I'm not planning any dependencies on glibmm or libsigc++, for instance. > Can you fix me up with a cvs account? However, I'm not likely to put > anything in cvs for a couple of weeks. An account is easy, sure. I just need the name of your project to create the CVSROOT, preferred login name, and an ssh v2 public key. Havoc From Murray.Cumming@Comneon.com Fri Nov 7 16:36:18 2003 From: Murray.Cumming@Comneon.com (Murray.Cumming@Comneon.com) Date: Fri, 7 Nov 2003 17:36:18 +0100 Subject: C++ bindings Message-ID: <258B0164D480D5118D900800062B385801840B83@vihsx09a.vih.infineon.com> > From: Havoc Pennington [mailto:hp@redhat.com] > > I'm in no rush personally, but I'll try to put some crap in cvs so > > that others can look at it. Would you like me to put my crap in the > > freedesktop cvs or GNOME's? > > It's up to you, if the bindings are generic C++ the > freedesktop cvs probably makes sense. Yes, I'm not planning any dependencies on glibmm or libsigc++, for instance. Can you fix me up with a cvs account? However, I'm not likely to put anything in cvs for a couple of weeks. > > > By code generation I mean either IDL -> sourcecode (CORBA > model), or > > > sourcecode -> IDL -> typelib (moc/DCOP model). Or IDL -> > > > typelib perhaps, if you want to make people do more typing. > > > > Thanks for the tip. I didn't realise that the glib bindings were > > generated. > > They aren't, but the idea is that application code would > (partially) be. Oh, I see. I've tried not to think about the IDL issue, because code-generation is so unpleasant even with CORBA. I'm personally interested in dbus for very simple message passing and notification. So if I don't do the IDL stuff then hopefully someone else can do it on top of my bindings. > Specifically what the generator would create > is a metadata blob in the form of a static variable. You then > #include this blob in your GObject subclass implementation > and it allows the glib bindings to type-safely dynamically > marshal methods on your object when dbus messages are received. > > This isn't implemented yet, though. It's the way the DCOP/Qt > stuff works. > > There are some messages in the archives discussing this more IIRC. Cheers. > > I'll be trying to wrap the lower level API as well as creating a > > higher level API like in the python bindings. > > The lower level API is designed almost purely for the use of > bindings; > wrapping the main loop glue (DBusWatch, > connection_set_watch_functions) and the object data > set/getters is probably pointless bloat/confusion in your binding API. Cheers again. Murray Cumming www.murrayc.com murrayc@usa.net From willem.dantuma@dobs.nl Sun Nov 9 10:18:32 2003 From: willem.dantuma@dobs.nl (Willem Dantuma) Date: 09 Nov 2003 11:18:32 +0100 Subject: Proposed API Change ( was delayed authentication ) In-Reply-To: <1067772061.2482.9.camel@wodan.dobs.nl> References: <1067772061.2482.9.camel@wodan.dobs.nl> Message-ID: <1068373037.2094.32.camel@wodan.dobs.nl> Hi, After not getting much response to my previous mail, i dug into it myself and found dbus_bus_get blocking in dbus_bus_register. So i would like to propose a change to the curent API. Something like this: conn=dbus_bus_get(DBUS_BUS_ACTIVATION,&error) or conn=dbus_connection_open(address,&error) dbus_connection_set_username(&conn,username) dbus_connection_set_password(&conn,password) dbus_connection_set_sasl_prop(&conn,...) ...... dbus_connection_start(&conn) /* takes care of authenticating, TLS etc */ dbus_bus_register(&conn) or maybe in the bus case: conn=dbus_bus_get(DBUS_BUS_ACTIVATION,&error,argv,argc) Comments ?? Willem On Sun, 2003-11-02 at 12:21, Willem Dantuma wrote: > Hi > > I'am still working ( on and of, my time is very limited ) on enabling > SASL authentication in D-Bus. It's almost functional, but now i need a > way to delay the authentication process, right now it is started > during a dbus_connection_open but i want to be able do someting like > this: > > conn = dbus_connection_open(..) > dbus_connection_set_username(conn,..) > dbus_connection_set_password(conn,..) > dbus_connection_set_sasl_prop(conn,...) > dbus_connection_start(conn) > > Any Ideas how to accomplish this. > > > > Willem Dantuma From hp@redhat.com Sun Nov 9 15:05:24 2003 From: hp@redhat.com (Havoc Pennington) Date: 09 Nov 2003 10:05:24 -0500 Subject: Proposed API Change ( was delayed authentication ) In-Reply-To: <1068373037.2094.32.camel@wodan.dobs.nl> References: <1067772061.2482.9.camel@wodan.dobs.nl> <1068373037.2094.32.camel@wodan.dobs.nl> Message-ID: <1068390323.3449.70.camel@dhcppc3> On Sun, 2003-11-09 at 05:18, Willem Dantuma wrote: > After not getting much response to my previous mail, i dug into it > myself and found dbus_bus_get blocking in dbus_bus_register. So i would > like to propose a change to the curent API. Your previous mail is not in my message-bus-list folder, fwiw. If it's in the archives maybe my mail setup ate it somehow. Note that if you dbus_connection_open(), no IO is intended to take place immediately (the function should be nonblocking), only the socket setup will happen. So in principle you could set up the auth details after that. However, where does your password come from? It seems to me that it has to come from a dialog with the user, only when a password is actually required. So this would mean that after deciding on a mechanism that requires a password, dbus would have to call back to the app and get it to open an auth dialog. The app couldn't unconditionally ask the user for all possible passwords. So the API we need would be some type of dbus_connection_set_auth_functions() or something like that. Havoc From hp@redhat.com Mon Nov 10 01:57:55 2003 From: hp@redhat.com (Havoc Pennington) Date: Sun, 09 Nov 2003 20:57:55 -0500 Subject: Proposed API Change ( was delayed authentication ) In-Reply-To: <1068397303.3236.28.camel@wodan.dobs.nl> References: <1067772061.2482.9.camel@wodan.dobs.nl> <1068373037.2094.32.camel@wodan.dobs.nl> <1068390323.3449.70.camel@dhcppc3> <1068397303.3236.28.camel@wodan.dobs.nl> Message-ID: <1068429475.4531.12.camel@localhost.localdomain> On Sun, 2003-11-09 at 12:01, Willem Dantuma wrote: > This is the way i was doing it, it only didn't work in my test with > dbus_monitor ( which is calling dbus_bus_get ). Right, dbus_bus_get() does some round trip messages to register with the bus and blocks for that reason. > Actually i'am using sasl callbacks internally allready for username and > password, i only think the need to provide callback functions doesn't > simplify the API and that's exactly what youre trying to do with the > dbus_bus_get wrapper. > > But i'am happy to implement it that way I'm all for simplifying the API, but the API still has to do the job, right? Havoc From hp@redhat.com Tue Nov 11 01:06:44 2003 From: hp@redhat.com (Havoc Pennington) Date: Mon, 10 Nov 2003 20:06:44 -0500 Subject: AFL 2.0 license change In-Reply-To: <1068484223.2689.315.camel@chili.home.hallendal.net> References: <1064087000.604.37.camel@dhcppc3> <1068484223.2689.315.camel@chili.home.hallendal.net> Message-ID: <1068512804.5225.5.camel@localhost.localdomain> On Mon, 2003-11-10 at 12:10, Mikael Hallendal wrote: > What happened to this. The COPYING files says version 2.0 but all source > files still says 1.2. Someone we are still waiting for to reply? No, I just forgot to do the sed job yet. Havoc From david@fubar.dk Tue Nov 11 20:12:09 2003 From: david@fubar.dk (David Zeuthen) Date: Tue, 11 Nov 2003 21:12:09 +0100 Subject: Python signals Message-ID: <1068581528.2972.3.camel@laptop.fubar.dk> Hi, Below very small patch to let D-BUS signal handlers in python chew on the message and extract the parameters, since we allow signals to carry parameters, yes? Ok to commit? Thanks, David Index: dbus.py =================================================================== RCS file: /cvs/dbus/dbus/python/dbus.py,v retrieving revision 1.2 diff -u -r1.2 dbus.py --- dbus.py 30 Sep 2003 02:40:49 -0000 1.2 +++ dbus.py 11 Nov 2003 20:07:43 -0000 @@ -103,7 +103,7 @@ if (self._match_rule_to_receivers.has_key(match_rule)): receivers = self._match_rule_to_receivers[match_rule] - args = [interface, member, service, path] + args = [interface, member, service, path, message] for receiver in receivers: receiver(*args) From solca@guug.org Thu Nov 13 22:18:09 2003 From: solca@guug.org (Otto Solares) Date: Thu, 13 Nov 2003 16:18:09 -0600 Subject: dbus basic question Message-ID: <20031113221809.GB6200@guug.org> Hi! I want to use dbus to implement messaging in my gpl desktop project. I don't use X in any way but i would like to support Keith Packard's kdrive server if i am able to compile it without input, nor fonts, just server and dri/glx extensions. I have read dbus's specs and the (unfinished) tutorial and have no clue where to begin, someone could point me to a simple example? i want to integrate dbus in the main loop. This is my server organization: -Input using input layer from 2.6 on a separate thread. -Sound using openal via alsa on a separate thread. -Graphics using fbdev/dri standalone mesa on separates threads each different thread for different gl capable card. -Network using separate thread for listening to remote clients. -System bus thread. As you can see my server is heavily threaded and my objective is async subsystem handling, threads allow me to simplify my code a lot and i don't note any slowdown at all, it's pretty fast. Currently, threads communication are handled via pointers to shared memory and posix locking. I think that the proper use of dbus will allow me to simplify the subsystem's comm routines. The question is: does dbus will be overkill for thread communication? I don't want systemwide comm, just comm in the same process. Another point is that the last threads are precisely for system notifications and client comm, obviously that is the primary task for dbus (i suppose), does hotplug and init rc.d scripts will talk to dbus so projects like mine will benefit for listening to system events? Is any project out there with this objective in mind? One last thing: i am currently using epoll sets for listening to network and system devices nodes, does dbus uses epoll sets for eficient polling of file descriptors in the current implementation? I know i ask too many questions but i am really impressed with dbus objectives and i am pretty confident that it will help me in my needs if i just manage to get started with it. TIA, -solca From lutchann-dbuslist@litech.org Sat Nov 15 21:09:54 2003 From: lutchann-dbuslist@litech.org (Nathan Lutchansky) Date: Sat, 15 Nov 2003 16:09:54 -0500 Subject: Using debug-pipe connections in real apps Message-ID: <20031115210954.GB18377@litech.org> --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi all, I'm writing a server app that uses DBus for IPC, and I need to be able to create DBus connections between the supervisor process and the forked worker processes. Right now I'm doing this by creating a DBusServer with a UNIX socket for the supervisor and having each worker open a DBusConnection to it, but it would make more sense and be more secure to create "connection pairs" with sockets that are only created internally. I see that DBus uses "debug-pipe" connetions for build tests, which are created using socketpair. This is exactly what I'd like to use in my app, but it seems limited to DBus internal debugging. Could this type of connection be promoted to a fully-supported DBus feature? -Nathan --=20 *** Help filter spam! PGP-sign your email. *** Expand your PGP Web of Trust with http://www.biglumber.com/ --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/tpYiTviDkW8mhycRAiAhAJ9orbdQyf42bD0kgAZvUdRvXsl6LwCggGTs IYShdr/ROQafKUEdMexJyh8= =Z3Mr -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4-- From hp@redhat.com Mon Nov 17 23:18:06 2003 From: hp@redhat.com (Havoc Pennington) Date: Mon, 17 Nov 2003 18:18:06 -0500 Subject: Using debug-pipe connections in real apps In-Reply-To: <20031115210954.GB18377@litech.org> References: <20031115210954.GB18377@litech.org> Message-ID: <1069111086.7144.1.camel@localhost.localdomain> On Sat, 2003-11-15 at 16:09, Nathan Lutchansky wrote: > I see that DBus uses "debug-pipe" connetions for build tests, which are > created using socketpair. This is exactly what I'd like to use in my app, > but it seems limited to DBus internal debugging. Could this type of > connection be promoted to a fully-supported DBus feature? -Nathan I don't see why not; seems pretty straightforward. Maybe just rename the method to "pipe" instead of "debug-pipe" and build it even with tests disabled? Havoc From lutchann-dbuslist@litech.org Mon Nov 17 23:37:56 2003 From: lutchann-dbuslist@litech.org (Nathan Lutchansky) Date: Mon, 17 Nov 2003 18:37:56 -0500 Subject: Using debug-pipe connections in real apps In-Reply-To: <1069111086.7144.1.camel@localhost.localdomain> References: <20031115210954.GB18377@litech.org> <1069111086.7144.1.camel@localhost.localdomain> Message-ID: <20031117233755.GC18377@litech.org> --tjCHc7DPkfUGtrlw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 17, 2003 at 06:18:06PM -0500, Havoc Pennington wrote: > On Sat, 2003-11-15 at 16:09, Nathan Lutchansky wrote: > > I see that DBus uses "debug-pipe" connetions for build tests, which are > > created using socketpair. This is exactly what I'd like to use in my a= pp, > > but it seems limited to DBus internal debugging. Could this type of > > connection be promoted to a fully-supported DBus feature? -Nathan >=20 > I don't see why not; seems pretty straightforward. Maybe just rename the > method to "pipe" instead of "debug-pipe" and build it even with tests > disabled? OK then, if it sounds acceptable to you, I'll make a patch as soon as I=20 move from dbus-0.13 to current CVS. Thanks! -Nathan --=20 *** Help filter spam! PGP-sign your email. *** Expand your PGP Web of Trust with http://www.biglumber.com/ --tjCHc7DPkfUGtrlw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/uVvTTviDkW8mhycRAsYUAJ9w1Spi4/LstpXKoI7/pt0B9ZQ81gCfZ7vJ q3pWo2qpARayHCtKK4zWNqM= =2Mi3 -----END PGP SIGNATURE----- --tjCHc7DPkfUGtrlw-- From hp@redhat.com Wed Nov 19 21:56:07 2003 From: hp@redhat.com (Havoc Pennington) Date: Wed, 19 Nov 2003 16:56:07 -0500 Subject: 0.20 released Message-ID: <1069278967.17309.40.camel@localhost.localdomain> Hi, I made a release of the current cvs D-BUS. http://pdx.freedesktop.org/Software/dbus Havoc From willem.dantuma@dobs.nl Thu Nov 20 00:52:17 2003 From: willem.dantuma@dobs.nl (Willem Dantuma) Date: 20 Nov 2003 01:52:17 +0100 Subject: SASL implementation Message-ID: <1069289536.3166.14.camel@wodan.dobs.nl> --=-CztVctplTNL1o+sia54b Content-Type: multipart/alternative; boundary="=-w1yXIDF+g/FS3SYYLr3u" --=-w1yXIDF+g/FS3SYYLr3u Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Well here it is my first shot at the sasl implementation of DBusAuth, i only tested it with the sasl PLAIN method so far. It still needs a major cleanup and some function reshuffeling. This implementation merges the existing two authentication methods with all possible sasl methods, the dbus_connection_set_get_password_function and dbus_connection_set_get_username_function where added to the api to set the callback funtions used to promt for the username and password ( if needed ). dbus-monitor and dbus-send still needs to be modified to support this but these are waiting for the change of dbus_bus_get which i have not done yet. Willem Dantuma --=-w1yXIDF+g/FS3SYYLr3u Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi,

Well here it is my first shot at the sasl implementation of DBusAuth, i only tested it with the sasl PLAIN method so far.

It still needs a major cleanup and some function reshuffeling.

This implementation merges the existing two authentication methods with all possible sasl methods, the dbus_connection_set_get_password_function and dbus_connection_set_get_username_function where added to the api to set the callback funtions used to promt for the username and password ( if needed ).

dbus-monitor and dbus-send still needs to be modified to support this but these are waiting for the change of dbus_bus_get which i have not done yet.


Willem Dantuma --=-w1yXIDF+g/FS3SYYLr3u-- --=-CztVctplTNL1o+sia54b Content-Disposition: attachment; filename=dbus-sasl.diff Content-Type: text/x-patch; name=dbus-sasl.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.438 diff -u -p -r1.438 ChangeLog --- ChangeLog 19 Nov 2003 21:51:09 -0000 1.438 +++ ChangeLog 19 Nov 2003 23:36:28 -0000 @@ -1,3 +1,43 @@ +2003-11-19 Willem Dantuma + + * configure.in: add option and cheks for sasl + + * dbus/Makefile.am: add sasl libraries + + * dbus/dbus-auth.h: prototypes for the new functions + _dbus_auth_set_remote_ip, dbus_auth_set_local_ip, + _dbus_auth_set_host, _dbus_auth_set_get_username_function + and _dbus_auth_set_get_password_function + + * dbus/dbus-auth.c: fairly large change implementing the sasl stuff, + the two existing authentication mechanims are merged with the available + sasl mecanisms. Several new and modififications to existing functions + also added fields to the DBusAuth, DBusAuthClient and DBusAuthServer + structures facilitate all this. + + * dbus/dbus-connection.h: new functions + dbus_connection_set_get_username_function and + dbus_connection_set_get_password_function + + * dbus/dbus-connection.c: implementations + + * dbus/dbus-sysdeps.h: new functions + _dbus_transport_is_inet + _dbus_transport_get_local_ip and + _dbus_transport_get_remote_ip + + * dbus/dbus-sysdeps.c: implementations + + * dbus/dbus-transport-unix.c: modifications to + _dbus_transport_new_for_fd to add the remote_ip, local_ip and host + information to the DBusAuth class + + * dbus/dbus-transport.h: new functions + _dbus_transport_set_get_username_function and + _dbus_transport_set_get_password_function + + * dbus/dbus-transport.c: implementations + 2003-11-19 Havoc Pennington * NEWS: update Index: configure.in =================================================================== RCS file: /cvs/dbus/dbus/configure.in,v retrieving revision 1.76 diff -u -p -r1.76 configure.in --- configure.in 19 Nov 2003 21:51:09 -0000 1.76 +++ configure.in 19 Nov 2003 22:40:56 -0000 @@ -37,7 +37,7 @@ AC_ARG_ENABLE(abstract-sockets, [ --ena AC_ARG_ENABLE(gcj, [ --enable-gcj build gcj bindings],enable_gcj=$enableval,enable_gcj=no) AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings],enable_mono=$enableval,enable_mono=no) AC_ARG_ENABLE(python, [ --enable-python build python bindings],enable_python=$enableval,enable_python=auto) - +AC_ARG_ENABLE(sasl, [ --enable-sasl enable sasl authentication],enable_sasl=$enableval,enable_sasl=no) AC_ARG_WITH(xml, [ --with-xml=[libxml/expat] XML library to use]) AC_ARG_WITH(init-scripts, [ --with-init-scripts=[redhat] Style of init scripts to install]) @@ -670,6 +670,34 @@ dnl Qt flags AC_SUBST(DBUS_QT_CXXFLAGS) AC_SUBST(DBUS_QT_LIBS) + +### SASL detection +have_sasl=no + +AC_CHECK_HEADERS(sasl/sasl.h) + +if test $ac_cv_header_sasl_sasl_h = yes ; then + have_sasl=yes + AC_CHECK_LIB(sasl2, sasl_client_init, + [DBUS_SASL_LIBS="-lsasl2"],[have_sasl=no]) +fi + +if test x$enable_sasl = xyes; then + if test x$have_sasl = xno; then + AC_MSG_ERROR([SASL explicitly required, and SASL libraries not found]) + else + AC_DEFINE(HAVE_SASL,1,[define if you have sasl]) + fi +fi + +if test x$enable_sasl = xno; then + have_sasl=no; +fi + +AC_SUBST(DBUS_SASL_LIBS) + + + ### X11 detection AC_PATH_XTRA @@ -1019,6 +1047,7 @@ echo " Using XML parser: ${with_xml} Init scripts style: ${with_init_scripts} Abstract socket names: ${have_abstract_sockets} + SASL Authentication: ${enable_sasl} System bus socket: ${DBUS_SYSTEM_SOCKET} System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} System bus PID file: ${DBUS_SYSTEM_PID_FILE} Index: dbus/Makefile.am =================================================================== RCS file: /cvs/dbus/dbus/dbus/Makefile.am,v retrieving revision 1.58 diff -u -p -r1.58 Makefile.am --- dbus/Makefile.am 15 Oct 2003 21:09:40 -0000 1.58 +++ dbus/Makefile.am 19 Nov 2003 22:41:34 -0000 @@ -124,7 +124,9 @@ EXTRA_DIST=dbus-arch-deps.h.in ## and is only used for static linking within the dbus package. noinst_LTLIBRARIES=libdbus-convenience.la -libdbus_1_la_LIBADD= $(DBUS_CLIENT_LIBS) +libdbus_convenience_la_LIBADD= $(DBUS_SASL_LIBS) + +libdbus_1_la_LIBADD= $(DBUS_CLIENT_LIBS) ${DBUS_SASL_LIBS} ## don't export symbols that start with "_" (we use this ## convention for internal symbols) libdbus_1_la_LDFLAGS= -export-symbols-regex "^[^_].*" Index: dbus/dbus-auth.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.h,v retrieving revision 1.6 diff -u -p -r1.6 dbus-auth.h --- dbus/dbus-auth.h 1 Apr 2003 05:33:01 -0000 1.6 +++ dbus/dbus-auth.h 19 Nov 2003 22:41:52 -0000 @@ -2,6 +2,7 @@ /* dbus-auth.h Authentication * * Copyright (C) 2002 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -27,6 +28,7 @@ #include #include #include +#include DBUS_BEGIN_DECLS; @@ -42,39 +44,53 @@ typedef enum DBUS_AUTH_STATE_AUTHENTICATED } DBusAuthState; -DBusAuth* _dbus_auth_server_new (void); -DBusAuth* _dbus_auth_client_new (void); -void _dbus_auth_ref (DBusAuth *auth); -void _dbus_auth_unref (DBusAuth *auth); -dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, - const char **mechanisms); -DBusAuthState _dbus_auth_do_work (DBusAuth *auth); -dbus_bool_t _dbus_auth_get_bytes_to_send (DBusAuth *auth, - const DBusString **str); -void _dbus_auth_bytes_sent (DBusAuth *auth, - int bytes_sent); -void _dbus_auth_get_buffer (DBusAuth *auth, - DBusString **buffer); -void _dbus_auth_return_buffer (DBusAuth *auth, - DBusString *buffer, - int bytes_read); -void _dbus_auth_get_unused_bytes (DBusAuth *auth, - const DBusString **str); -void _dbus_auth_delete_unused_bytes (DBusAuth *auth); -dbus_bool_t _dbus_auth_needs_encoding (DBusAuth *auth); -dbus_bool_t _dbus_auth_encode_data (DBusAuth *auth, - const DBusString *plaintext, - DBusString *encoded); -dbus_bool_t _dbus_auth_needs_decoding (DBusAuth *auth); -dbus_bool_t _dbus_auth_decode_data (DBusAuth *auth, - const DBusString *encoded, - DBusString *plaintext); -void _dbus_auth_set_credentials (DBusAuth *auth, - const DBusCredentials *credentials); -void _dbus_auth_get_identity (DBusAuth *auth, - DBusCredentials *credentials); -dbus_bool_t _dbus_auth_set_context (DBusAuth *auth, - const DBusString *context); + +DBusAuth* _dbus_auth_server_new (void); +DBusAuth* _dbus_auth_client_new (void); +dbus_bool_t _dbus_auth_start (DBusAuth *auth); +void _dbus_auth_ref (DBusAuth *auth); +void _dbus_auth_unref (DBusAuth *auth); +dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, + const char **mechanisms); +DBusAuthState _dbus_auth_do_work (DBusAuth *auth); +dbus_bool_t _dbus_auth_get_bytes_to_send (DBusAuth *auth, + const DBusString **str); +void _dbus_auth_bytes_sent (DBusAuth *auth, + int bytes_sent); +void _dbus_auth_get_buffer (DBusAuth *auth, + DBusString **buffer); +void _dbus_auth_return_buffer (DBusAuth *auth, + DBusString *buffer, + int bytes_read); +void _dbus_auth_get_unused_bytes (DBusAuth *auth, + const DBusString **str); +void _dbus_auth_delete_unused_bytes (DBusAuth *auth); +dbus_bool_t _dbus_auth_needs_encoding (DBusAuth *auth); +dbus_bool_t _dbus_auth_encode_data (DBusAuth *auth, + const DBusString *plaintext, + DBusString *encoded); +dbus_bool_t _dbus_auth_needs_decoding (DBusAuth *auth); +dbus_bool_t _dbus_auth_decode_data (DBusAuth *auth, + const DBusString *encoded, + DBusString *plaintext); +void _dbus_auth_set_credentials (DBusAuth *auth, + const DBusCredentials *credentials); +void _dbus_auth_get_identity (DBusAuth *auth, + DBusCredentials *credentials); +dbus_bool_t _dbus_auth_set_context (DBusAuth *auth, + const DBusString *context); +dbus_bool_t _dbus_auth_set_remote_ip (DBusAuth *auth, + DBusString *remote_ip); +dbus_bool_t _dbus_auth_set_local_ip (DBusAuth *auth, + DBusString *local_ip); +dbus_bool_t _dbus_auth_set_host (DBusAuth *auth, + const char *host); +void _dbus_auth_set_get_username_function (DBusAuth *auth, + DBusGetUsernameFunction function); +void _dbus_auth_set_get_password_function (DBusAuth *auth, + DBusGetPasswordFunction function); + + DBUS_END_DECLS; Index: dbus/dbus-auth.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.c,v retrieving revision 1.29 diff -u -p -r1.29 dbus-auth.c --- dbus/dbus-auth.c 30 Sep 2003 02:32:52 -0000 1.29 +++ dbus/dbus-auth.c 19 Nov 2003 22:42:05 -0000 @@ -2,6 +2,7 @@ /* dbus-auth.c Authentication * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -27,6 +28,9 @@ #include "dbus-keyring.h" #include "dbus-sha.h" #include "dbus-userdb.h" +#ifdef HAVE_SASL +#include +#endif /* HAVE_SASL */ /** * @defgroup DBusAuth Authentication @@ -82,6 +86,7 @@ typedef struct DBusProcessAuthCommandFunction func; /**< Function to handle the command */ } DBusAuthCommandHandler; + /** * This function appends an initial client response to the given string */ @@ -89,7 +94,7 @@ typedef dbus_bool_t (* DBusInitialRespon DBusString *response); /** - * This function processes a block of data received from the peer. + * This function processes a block of data received from the peer * i.e. handles a DATA command. */ typedef dbus_bool_t (* DBusAuthDataFunction) (DBusAuth *auth, @@ -112,14 +117,30 @@ typedef dbus_bool_t (* DBusAuthDecodeFun /** * This function is called when the mechanism is abandoned. */ -typedef void (* DBusAuthShutdownFunction) (DBusAuth *auth); +typedef void (* DBusAuthShutdownFunction) (DBusAuth *auth); + +#ifdef HAVE_SASL + +int _dbus_sasl_log (void *context, + int priority, + const char *message); +int _dbus_sasl_get_username_callback (void *context, + int id, + const char **result, + unsigned *len); +int _dbus_sasl_get_password_callback (sasl_conn_t *conn, + void *context, + int id, + sasl_secret_t **psecret); + +#endif /** * Virtual table representing a particular auth mechanism. */ typedef struct { - const char *mechanism; /**< Name of the mechanism */ + DBusString mechanism; /**< Name of the mechanism */ DBusAuthDataFunction server_data_func; /**< Function on server side for DATA */ DBusAuthEncodeFunction server_encode_func; /**< Function on server side to encode */ DBusAuthDecodeFunction server_decode_func; /**< Function on server side to decode */ @@ -131,6 +152,7 @@ typedef struct DBusAuthShutdownFunction client_shutdown_func; /**< Function on client side for shutdown */ } DBusAuthMechanismHandler; + /** * Internal members of DBusAuth. */ @@ -176,6 +198,11 @@ struct DBusAuth unsigned int already_got_mechanisms : 1; /**< Client already got mech list */ unsigned int already_asked_for_initial_response : 1; /**< Already sent a blank challenge to get an initial response */ unsigned int buffer_outstanding : 1; /**< Buffer is "checked out" for reading data into */ + DBusAuthMechanismHandler *all_mechanisms; /**< All possible auth mechanisms */ + DBusString local_ip; /**< Local IP address in case of a tcp domain socket */ + DBusString remote_ip; /**< Remote IP address in case of a tcp domain socket */ + void *sasl_context; /**< SASL context or NULL when SASL isn't enabled */ + void *sasl_callbacks; /**< pointer to a sasl_callback_t */ }; /** @@ -186,21 +213,33 @@ typedef struct DBusAuth base; /**< Parent class */ DBusList *mechs_to_try; /**< Mechanisms we got from the server that we're going to try using */ - + DBusString host; /**< FQDN of host connecting to */ + DBusString username; /** username */ + DBusGetUsernameFunction get_username_function; /** function to call when a username is needed */ + DBusString password; /** password */ + DBusGetPasswordFunction get_password_function; /** function to call when a password is needed */ + void *sasl_secret; /** pointer to a sasl_secret_t */ } DBusAuthClient; -/** +/** if(!_dbus_string_init(& DBUS_AUTH_CLIENT(auth)->host)) + goto nomem; + * "Subclass" of DBusAuth for server side. */ typedef struct { - DBusAuth base; /**< Parent class */ + DBusAuth base; /**< Parent class */ - int failures; /**< Number of times client has been rejected */ - int max_failures; /**< Number of times we reject before disconnect */ + int failures; /**< Number of times client has been rejected */ + int max_failures; /**< Number of times we reject before disconnect */ + dbus_bool_t allready_replyed; /**< TRUE if we allready replyed to a first response */ } DBusAuthServer; +static dbus_bool_t get_word (const DBusString *str, + int *start, + DBusString *word); +static dbus_bool_t init_all_mechanisms (DBusAuth *auth); static dbus_bool_t process_auth (DBusAuth *auth, const DBusString *command, const DBusString *args); @@ -232,6 +271,8 @@ static dbus_bool_t process_error_client static dbus_bool_t client_try_next_mechanism (DBusAuth *auth); static dbus_bool_t send_rejected (DBusAuth *auth); +static dbus_bool_t dbus_auth_sasl_client_new (DBusAuth *auth); +static dbus_bool_t dbus_auth_sasl_server_new (DBusAuth *auth); static DBusAuthCommandHandler server_handlers[] = { @@ -280,6 +321,13 @@ client_handlers[] = { */ #define DBUS_AUTH_NAME(auth) (DBUS_AUTH_IS_SERVER(auth) ? "server" : "client") + +#ifdef HAVE_SASL +static dbus_bool_t sasl_client_initialized = FALSE; +static dbus_bool_t sasl_server_initialized = FALSE; +#endif /* HAVE_SASL */ + + static DBusAuth* _dbus_auth_new (int size) { @@ -324,9 +372,16 @@ _dbus_auth_new (int size) /* default context if none is specified */ if (!_dbus_string_append (&auth->context, "org_freedesktop_general")) goto enomem_5; - - return auth; + if (!_dbus_string_init (&auth->remote_ip)) + goto enomem_5; + + if (!_dbus_string_init (&auth->local_ip)) + goto enomem_6; + + return auth; + enomem_6: + _dbus_string_free (&auth->remote_ip); enomem_5: _dbus_string_free (&auth->challenge); enomem_4: @@ -357,7 +412,7 @@ shutdown_mech (DBusAuth *auth) if (auth->mech != NULL) { _dbus_verbose ("%s: Shutting down mechanism %s\n", - DBUS_AUTH_NAME (auth), auth->mech->mechanism); + DBUS_AUTH_NAME (auth), _dbus_string_get_const_data(&auth->mech->mechanism)); if (DBUS_AUTH_IS_CLIENT (auth)) (* auth->mech->client_shutdown_func) (auth); @@ -388,7 +443,8 @@ sha1_compute_hash (DBusAuth *aut retval = FALSE; if (!_dbus_string_init (&cookie)) - return FALSE; + return FALSE; + if (!_dbus_keyring_get_hex_key (auth->keyring, cookie_id, &cookie)) @@ -612,7 +668,7 @@ sha1_handle_second_client_response (DBus { /* We are expecting a response which is the hex-encoded client * challenge, space, then SHA-1 hash of the concatenation of our - * challenge, ":", client challenge, ":", secret key, all + * challenge, ":", client challenge, "s:", secret key, all * hex-encoded. */ int i; @@ -869,7 +925,6 @@ handle_client_data_cookie_sha1_mech (DBu _dbus_assert (!dbus_error_is_set (&error)); } } - _dbus_assert (auth->keyring != NULL); if (!_dbus_string_init (&tmp)) @@ -1119,54 +1174,534 @@ handle_client_shutdown_external_mech (DB } -/* Put mechanisms here in order of preference. - * What I eventually want to have is: - * - * - a mechanism that checks UNIX domain socket credentials - * - a simple magic cookie mechanism like X11 or ICE - * - mechanisms that chain to Cyrus SASL, so we can use anything it - * offers such as Kerberos, X509, whatever. - * - */ -static const DBusAuthMechanismHandler -all_mechanisms[] = { - { "EXTERNAL", - handle_server_data_external_mech, - NULL, NULL, - handle_server_shutdown_external_mech, - handle_client_initial_response_external_mech, - handle_client_data_external_mech, - NULL, NULL, - handle_client_shutdown_external_mech }, - { "DBUS_COOKIE_SHA1", - handle_server_data_cookie_sha1_mech, - NULL, NULL, - handle_server_shutdown_cookie_sha1_mech, - handle_client_initial_response_cookie_sha1_mech, - handle_client_data_cookie_sha1_mech, - NULL, NULL, - handle_client_shutdown_cookie_sha1_mech }, - { NULL, NULL } -}; + +#ifdef HAVE_SASL + +static dbus_bool_t +handle_server_data_sasl_mech (DBusAuth *auth, + const DBusString *data) +{ + int result,outlen; + const char *out; + DBusString server_response; + dbus_bool_t retval = FALSE; + + if(!_dbus_string_init(&server_response)) + return retval; + + if(! DBUS_AUTH_SERVER(auth)->allready_replyed) + { + result=sasl_server_start((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(&auth->mech->mechanism), + _dbus_string_get_const_data(data), + _dbus_string_get_length(data), + &out, + &outlen); + } + else + { + result=sasl_server_step((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(data), + _dbus_string_get_length(data), + &out, + &outlen); + } + if(result != SASL_OK && result != SASL_CONTINUE ) + { + _dbus_string_free(&server_response); + return send_rejected(auth); + } + + DBUS_AUTH_SERVER(auth)->allready_replyed = TRUE; + + if(result == SASL_CONTINUE) + { + if(!_dbus_string_append_len(&server_response,out,outlen)) + goto out_1; + + if(!_dbus_string_append(&auth->outgoing,"DATA ")) + goto out_1; + + if (!_dbus_string_base64_encode (&server_response, 0, + &auth->outgoing, + _dbus_string_get_length (&auth->outgoing))) + goto out_1; + retval=TRUE; + } + else + { + DBusString username; + const char *sasl_username=NULL; + + if(sasl_getprop((sasl_conn_t *) auth->sasl_context,SASL_USERNAME,(const void **) &sasl_username) == SASL_OK + && sasl_username != NULL ) + { + _dbus_string_init_const(&username,sasl_username); + if(!_dbus_credentials_from_username (&username, &auth->authorized_identity)) + goto out_1; + } + + if(!_dbus_string_append(&auth->outgoing,"OK\r\n")) + goto out_1; + + auth->authenticated_pending_begin = TRUE; + retval=TRUE; + } + +out_1: + _dbus_string_free(&server_response); + + return retval; + +} + + +static void +handle_server_shutdown_sasl_mech (DBusAuth *auth) +{ +} + + +static dbus_bool_t +handle_client_initial_response_sasl_mech (DBusAuth *auth, + DBusString *response) +{ + int result,outlen; + const char *out,*mech_using=NULL; + DBusString client_response; + dbus_bool_t retval = FALSE; + + + if(!_dbus_string_init(&client_response)) + return retval; + + result=sasl_client_start((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(&auth->mech->mechanism), + NULL, + &out, + &outlen, + &mech_using); + + if(result == SASL_OK || result == SASL_CONTINUE) + { + if(!_dbus_string_append_len(&client_response,out,outlen)) + goto out_1; + if (!_dbus_string_base64_encode (&client_response, 0, + response, + _dbus_string_get_length (response))) + goto out_1; + retval=TRUE; + } + +out_1: + _dbus_string_free(&client_response); + + return retval; +} + + +static dbus_bool_t +handle_client_data_sasl_mech (DBusAuth *auth, + const DBusString *data) +{ + int result,outlen; + const char *out; + DBusString client_response; + dbus_bool_t retval = FALSE; + + if(!_dbus_string_init(&client_response)) + return retval; + + result=sasl_client_step((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(data), + _dbus_string_get_length(data), + NULL, + &out, + &outlen); + + + if(result == SASL_CONTINUE) + { + if(!_dbus_string_append_len(&client_response,out,outlen)) + goto out_1; + if(!_dbus_string_append(&auth->outgoing,"DATA ")) + goto out_1; + if (!_dbus_string_base64_encode (&client_response, 0, + &auth->outgoing, + _dbus_string_get_length (&auth->outgoing))) + goto out_1; + retval=TRUE; + } + + if(result == SASL_OK) + retval =TRUE; + +out_1: + _dbus_string_free(&client_response); + + return retval; + +} + +static void +handle_client_shutdown_sasl_mech (DBusAuth *auth) +{ +} + + +int +_dbus_sasl_log(void *context, + int priority, + const char *message) +{ + if(priority == SASL_LOG_ERR || priority == SASL_LOG_WARN ) + _dbus_verbose("SASL :%s\n",message); + + return SASL_OK; +} + +int +_dbus_sasl_get_username_callback(void *context, + int id, + const char **result, + unsigned *len) +{ + char const *username=NULL; + + if(! DBUS_AUTH_IS_CLIENT((DBusAuth *) context)) + return SASL_BADPARAM; + if(!result) + return SASL_BADPARAM; + + DBusAuthClient *auth = DBUS_AUTH_CLIENT(context); + + switch(id) + { + case SASL_CB_AUTHNAME: + case SASL_CB_USER: + if(auth->get_username_function) + { + if((*auth->get_username_function) (&username) && username) + { + if(! _dbus_string_set_length(&auth->username,0)) + goto out_1; + if(! _dbus_string_append(&auth->username,username)) + goto out_1; + } + } + *result=_dbus_string_get_const_data(&auth->username); + if(len) + *len=_dbus_string_get_length(&auth->username); + break; + default: + return SASL_BADPARAM; + } + + return SASL_OK; +out_1: + return SASL_FAIL; +} + + +int +_dbus_sasl_get_password_callback(sasl_conn_t *conn, + void *context, + int id, + sasl_secret_t **psecret) +{ + char const *password; + + if(!conn || !psecret || id != SASL_CB_PASS) + return SASL_BADPARAM; + + DBusAuthClient *auth = DBUS_AUTH_CLIENT(context); + + if(auth->sasl_secret) + dbus_free(auth->sasl_secret); + + if(auth->get_username_function) + { + if((*auth->get_password_function) (&password) && password) + { + if(! _dbus_string_set_length(&auth->password,0)) + goto out_1; + if(! _dbus_string_append(&auth->password,password)) + goto out_1; + } + } + + auth->sasl_secret=(void *) dbus_malloc0(sizeof(sasl_secret_t)+ _dbus_string_get_length(&auth->password)); + if(!auth->sasl_secret) + return SASL_NOMEM; + + *psecret=(sasl_secret_t *) auth->sasl_secret; + + strcpy((char *) (*psecret)->data, _dbus_string_get_data(&auth->password)); + (*psecret)->len=_dbus_string_get_length(&auth->password); + + return SASL_OK; + out_1: + return SASL_FAIL; +} + + +static dbus_bool_t +dbus_auth_sasl_server_new(DBusAuth *auth) +{ + int result; + sasl_conn_t *context; + const char *local_ip=NULL; + const char *remote_ip=NULL; + + /* TODO locking */ + if(!sasl_server_initialized) { + static sasl_callback_t server_callbacks[] = { + { SASL_CB_LOG, &_dbus_sasl_log, NULL }, + { SASL_CB_LIST_END, NULL, NULL } + }; + + result=sasl_server_init(server_callbacks,"dbus"); + if(result != SASL_OK ) + return FALSE; + sasl_server_initialized = TRUE; + } + + if(_dbus_string_get_length(&auth->local_ip)) + local_ip=_dbus_string_get_const_data(&auth->local_ip); + if(_dbus_string_get_length(&auth->remote_ip)) + remote_ip=_dbus_string_get_const_data(&auth->remote_ip); + + result=sasl_server_new("dbus",NULL,NULL,local_ip,remote_ip,NULL,0,&context); + if( result != SASL_OK ) + return FALSE; + + auth->sasl_context=(void *) context; + + return TRUE; +} + + +static dbus_bool_t +dbus_auth_sasl_client_new(DBusAuth *auth) +{ + int result; + sasl_conn_t *context; + sasl_callback_t *callback=(sasl_callback_t *) auth->sasl_callbacks; + const char *local_ip=NULL; + const char *remote_ip=NULL; + const char *host=NULL; + + /* TODO locking ? */ + if(!sasl_client_initialized) { + callback->id = SASL_CB_USER; + callback->proc = &_dbus_sasl_get_username_callback; + callback->context = (void *) auth; + callback++; + callback->id = SASL_CB_AUTHNAME; + callback->proc = &_dbus_sasl_get_username_callback; + callback->context = (void *) auth; + callback++; + callback->id = SASL_CB_PASS; + callback->proc = &_dbus_sasl_get_password_callback; + callback->context = (void *) auth; + callback++; + callback->id = SASL_CB_LIST_END; + callback->proc = NULL; + callback->context = NULL; + + result=sasl_client_init((sasl_callback_t *) auth->sasl_callbacks); + if(result != SASL_OK ) + return FALSE; + sasl_client_initialized = TRUE; + } + + if(_dbus_string_get_length(& DBUS_AUTH_CLIENT(auth)->host)) + host=_dbus_string_get_const_data(& DBUS_AUTH_CLIENT(auth)->host); + if(_dbus_string_get_length(&auth->local_ip)) + local_ip=_dbus_string_get_const_data(&auth->local_ip); + if(_dbus_string_get_length(&auth->remote_ip)) + remote_ip=_dbus_string_get_const_data(&auth->remote_ip); + + result=sasl_client_new("dbus",host,local_ip,remote_ip,NULL,0,&context); + if( result != SASL_OK ) + return FALSE; + + auth->sasl_context=(void *) context; + + return TRUE; +} + +#endif /* HAVE_SASL */ + + + +/* Initialize all mechanisms we can handle */ + +dbus_bool_t static +init_all_mechanisms (DBusAuth *auth) +{ + DBusAuthMechanismHandler *mechanism; + int number_of_sasl_mechanisms = 0; + + if(auth->all_mechanisms) + return TRUE; + +#ifdef HAVE_SASL + int length; + const char *sasl_mechanisms; + int result; + dbus_bool_t sasl_initialized; + + auth->sasl_callbacks=dbus_new0(sasl_callback_t,4); + if(auth->sasl_callbacks) + { + if(DBUS_AUTH_IS_CLIENT(auth)) + { + sasl_initialized=dbus_auth_sasl_client_new(auth); + } + else + { + sasl_initialized=dbus_auth_sasl_server_new(auth); + } + + if(sasl_initialized) + { + result=sasl_listmech((sasl_conn_t * ) auth->sasl_context, + NULL, + "", + " ", + "", + &sasl_mechanisms, + &length, + &number_of_sasl_mechanisms); + if( result != SASL_OK ) + number_of_sasl_mechanisms=0; + } + } +#endif /* HAVE_SASL */ + mechanism=(DBusAuthMechanismHandler *) dbus_malloc0((3+number_of_sasl_mechanisms) * sizeof(DBusAuthMechanismHandler)); + if ( mechanism == NULL ) + return FALSE; + + auth->all_mechanisms=mechanism; + + _dbus_string_init_const (&mechanism->mechanism, "EXTERNAL"); + mechanism->server_data_func = handle_server_data_external_mech; + mechanism->server_encode_func = NULL; + mechanism->server_decode_func = NULL; + mechanism->server_shutdown_func = handle_server_shutdown_external_mech; + mechanism->client_initial_response_func = handle_client_initial_response_external_mech; + mechanism->client_data_func = handle_client_data_external_mech; + mechanism->client_encode_func = NULL; + mechanism->client_decode_func = NULL; + mechanism->client_shutdown_func = handle_client_shutdown_external_mech; + + mechanism++; + _dbus_string_init_const (&mechanism->mechanism, "DBUS_COOKIE_SHA1"); + mechanism->server_data_func = handle_server_data_cookie_sha1_mech; + mechanism->server_encode_func = NULL; + mechanism->server_decode_func = NULL; + mechanism->server_shutdown_func = handle_server_shutdown_cookie_sha1_mech; + mechanism->client_initial_response_func = handle_client_initial_response_cookie_sha1_mech; + mechanism->client_data_func = handle_client_data_cookie_sha1_mech; + mechanism->client_encode_func = NULL; + mechanism->client_decode_func = NULL; + mechanism->client_shutdown_func = handle_client_shutdown_cookie_sha1_mech; + +#ifdef HAVE_SASL + + if(number_of_sasl_mechanisms) + _dbus_verbose("%s: Merge SASL mechanisms (%s)\n",DBUS_AUTH_NAME (auth),sasl_mechanisms); + + int i; + int next = 0; + DBusString sasl_mechanisms_copy; + + + if(!_dbus_string_init(&sasl_mechanisms_copy)) + goto out_1; + if(!_dbus_string_append(&sasl_mechanisms_copy,sasl_mechanisms)) + goto out_2; + + for(i=0;imechanism)) + goto out_3; + if(!get_word (&sasl_mechanisms_copy,&next, &mechanism->mechanism)) + goto out_4; + mechanism->server_data_func = handle_server_data_sasl_mech; + mechanism->server_encode_func = NULL; + mechanism->server_decode_func = NULL; + mechanism->server_shutdown_func = handle_server_shutdown_sasl_mech; + mechanism->client_initial_response_func = handle_client_initial_response_sasl_mech; + mechanism->client_data_func = handle_client_data_sasl_mech; + mechanism->client_encode_func = NULL; + mechanism->client_decode_func = NULL; + mechanism->client_shutdown_func = handle_client_shutdown_sasl_mech; + } + + goto out_2; + + out_4: + _dbus_string_free(&mechanism->mechanism); + out_3: + mechanism--; + out_2: + _dbus_string_free(&sasl_mechanisms_copy); + out_1: +#endif /* HAVE_SASL */ + + mechanism++; + _dbus_string_init_const(&mechanism->mechanism,""); + mechanism->server_data_func = NULL; + + return TRUE; +} + + +static void +free_all_mechanisms (DBusAuth *auth) +{ + int i; + + if( auth->all_mechanisms ) + { + i = 0; + while (auth->all_mechanisms[i].server_data_func != NULL) + { + _dbus_string_free( &auth->all_mechanisms[i].mechanism ); + i++; + } + /* and the last one */ + _dbus_string_free( &auth->all_mechanisms[i].mechanism ); + + dbus_free(auth->all_mechanisms); + + auth->all_mechanisms = NULL; + } +} + static const DBusAuthMechanismHandler* -find_mech (const DBusString *name, - char **allowed_mechs) +find_mech (DBusAuth *auth, + const DBusString *name, + char **allowed_mechs) { int i; - + if (allowed_mechs != NULL && !_dbus_string_array_contains ((const char**) allowed_mechs, _dbus_string_get_const_data (name))) return NULL; i = 0; - while (all_mechanisms[i].mechanism != NULL) + while (auth->all_mechanisms[i].server_data_func != NULL) { - if (_dbus_string_equal_c_str (name, - all_mechanisms[i].mechanism)) + if (_dbus_string_equal (name, + &auth->all_mechanisms[i].mechanism)) - return &all_mechanisms[i]; + return &auth->all_mechanisms[i]; ++i; } @@ -1174,6 +1709,7 @@ find_mech (const DBusString *name, return NULL; } + static dbus_bool_t send_rejected (DBusAuth *auth) { @@ -1188,20 +1724,37 @@ send_rejected (DBusAuth *auth) "REJECTED")) goto nomem; - i = 0; - while (all_mechanisms[i].mechanism != NULL) - { - if (!_dbus_string_append (&command, + if (auth->allowed_mechs != NULL ) + { + i = 0; + while(auth->allowed_mechs[i] != NULL ) + { + if (!_dbus_string_append (&command, " ")) - goto nomem; + goto nomem; - if (!_dbus_string_append (&command, - all_mechanisms[i].mechanism)) - goto nomem; + if (!_dbus_string_append (&command,auth->allowed_mechs[i])) + goto nomem; + + i++; + } + } + else + { + i = 0; + while (auth->all_mechanisms[i].server_data_func != NULL) + { + if (!_dbus_string_append (&command, + " ")) + goto nomem; + + if (!_dbus_string_append (&command, + _dbus_string_get_const_data(&auth->all_mechanisms[i].mechanism))) + goto nomem; - ++i; - } - + ++i; + } + } if (!_dbus_string_append (&command, "\r\n")) goto nomem; @@ -1229,6 +1782,9 @@ process_auth (DBusAuth *auth, const DBusString *command, const DBusString *args) { + + if(!init_all_mechanisms(auth)) + return FALSE; if (auth->mech) { /* We are already using a mechanism, client is on crack */ @@ -1280,13 +1836,13 @@ process_auth (DBusAuth *auth, if (!_dbus_string_base64_decode (&base64_response, 0, &decoded_response, 0)) goto failed; - - auth->mech = find_mech (&mech, auth->allowed_mechs); + + auth->mech = find_mech (auth, &mech, auth->allowed_mechs); if (auth->mech != NULL) { _dbus_verbose ("%s: Trying mechanism %s with initial response of %d bytes\n", DBUS_AUTH_NAME (auth), - auth->mech->mechanism, + _dbus_string_get_const_data(&auth->mech->mechanism), _dbus_string_get_length (&decoded_response)); if (!(* auth->mech->server_data_func) (auth, @@ -1445,14 +2001,14 @@ record_mechanisms (DBusAuth *aut if (!_dbus_string_init (&m)) goto nomem; - + if (!get_word (args, &next, &m)) { _dbus_string_free (&m); goto nomem; } - mech = find_mech (&m, auth->allowed_mechs); + mech = find_mech (auth, &m, auth->allowed_mechs); if (mech != NULL) { @@ -1466,7 +2022,7 @@ record_mechanisms (DBusAuth *aut */ _dbus_verbose ("%s: Adding mechanism %s to list we will try\n", - DBUS_AUTH_NAME (auth), mech->mechanism); + DBUS_AUTH_NAME (auth), _dbus_string_get_const_data(&mech->mechanism)); if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, (void*) mech)) @@ -1512,11 +2068,11 @@ client_try_next_mechanism (DBusAuth *aut if (auth->allowed_mechs != NULL && !_dbus_string_array_contains ((const char**) auth->allowed_mechs, - mech->mechanism)) + _dbus_string_get_const_data(&mech->mechanism))) { /* don't try this one after all */ _dbus_verbose ("%s: Mechanism %s isn't in the list of allowed mechanisms\n", - DBUS_AUTH_NAME (auth), mech->mechanism); + DBUS_AUTH_NAME (auth), _dbus_string_get_const_data(&mech->mechanism)); mech = NULL; _dbus_list_pop_first (& client->mechs_to_try); } @@ -1538,12 +2094,14 @@ client_try_next_mechanism (DBusAuth *aut } if (!_dbus_string_append (&auth_command, - mech->mechanism)) + _dbus_string_get_const_data(&mech->mechanism))) { _dbus_string_free (&auth_command); return FALSE; } + auth->mech = mech; + if (mech->client_initial_response_func != NULL) { if (!_dbus_string_append (&auth_command, " ")) @@ -1554,6 +2112,8 @@ client_try_next_mechanism (DBusAuth *aut if (!(* mech->client_initial_response_func) (auth, &auth_command)) { + /* pop this one to avoid looping */ + _dbus_list_pop_first (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); _dbus_string_free (&auth_command); return FALSE; } @@ -1574,12 +2134,11 @@ client_try_next_mechanism (DBusAuth *aut return FALSE; } - auth->mech = mech; _dbus_list_pop_first (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); _dbus_verbose ("%s: Trying mechanism %s\n", DBUS_AUTH_NAME (auth), - auth->mech->mechanism); + _dbus_string_get_const_data(&auth->mech->mechanism)); _dbus_string_free (&auth_command); @@ -1669,7 +2228,7 @@ process_data_client (DBusAuth *a "ERROR \"Got DATA when not in an auth exchange\"\r\n")) return FALSE; } - + return TRUE; } @@ -1850,10 +2409,11 @@ _dbus_auth_server_new (void) */ server_auth->failures = 0; server_auth->max_failures = 6; - + return auth; } + /** * Creates a new auth conversation object for the client side. * See doc/dbus-sasl-profile.txt for full details on what @@ -1865,6 +2425,7 @@ DBusAuth* _dbus_auth_client_new (void) { DBusAuth *auth; + DBusAuthClient *client_auth; auth = _dbus_auth_new (sizeof (DBusAuthClient)); if (auth == NULL) @@ -1872,24 +2433,50 @@ _dbus_auth_client_new (void) auth->handlers = client_handlers; - /* Add a default mechanism to try */ - if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, - (void*) &all_mechanisms[0])) - { - _dbus_auth_unref (auth); - return NULL; - } + client_auth = DBUS_AUTH_CLIENT (auth); - /* Now try the mechanism we just added */ - if (!client_try_next_mechanism (auth)) - { - _dbus_auth_unref (auth); - return NULL; - } - + if(!_dbus_string_init(& client_auth->host)) + goto nomem; + + if(!_dbus_string_init(& client_auth->username)) + goto nomem; + if(!_dbus_string_init(& client_auth->password)) + goto nomem; + return auth; +nomem: + _dbus_auth_unref(auth); + + return NULL; } + +/** + * Starts the client side authentication process + * + * @param auth the auth conversation + * @returns #TRUE if successfull + */ +dbus_bool_t +_dbus_auth_start (DBusAuth *auth) + { + if(DBUS_AUTH_IS_CLIENT(auth)) + { + if (!init_all_mechanisms(auth)) + return FALSE; + /* Add a default mechanism to try */ + if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, + (void*) &auth->all_mechanisms[0])) + return FALSE; + if (!client_try_next_mechanism (auth)) + return FALSE; + + return TRUE; + } + return FALSE; + } + + /** * Increments the refcount of an auth object. * @@ -1922,6 +2509,11 @@ _dbus_auth_unref (DBusAuth *auth) if (DBUS_AUTH_IS_CLIENT (auth)) { _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); + _dbus_string_free(& DBUS_AUTH_CLIENT (auth)->host); + _dbus_string_free(& DBUS_AUTH_CLIENT (auth)->username); + _dbus_string_free(& DBUS_AUTH_CLIENT (auth)->password); + if(DBUS_AUTH_CLIENT (auth)->sasl_secret) + dbus_free(DBUS_AUTH_CLIENT (auth)->sasl_secret); } if (auth->keyring) @@ -1932,13 +2524,126 @@ _dbus_auth_unref (DBusAuth *auth) _dbus_string_free (&auth->identity); _dbus_string_free (&auth->incoming); _dbus_string_free (&auth->outgoing); + _dbus_string_free (&auth->local_ip); + _dbus_string_free (&auth->remote_ip); dbus_free_string_array (auth->allowed_mechs); + + free_all_mechanisms(auth); + +#ifdef HAVE_SASL + if(auth->sasl_context) + sasl_dispose((sasl_conn_t **) &auth->sasl_context); + if(auth->sasl_callbacks) + dbus_free(auth->sasl_callbacks); +#endif /* HAVE_SASL */ dbus_free (auth); } } + +/** + * Sets the remote ip + * + * @param auth the auth conversation + * @param remote_ip the remote ip adress + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_auth_set_remote_ip(DBusAuth *auth, + DBusString *remote_ip) +{ + int p; + + if(!_dbus_string_copy(remote_ip,0,&auth->remote_ip,0)) + return FALSE; + if(!_dbus_string_find(&auth->remote_ip,0,":",&p)) + return FALSE; + _dbus_string_set_byte(&auth->remote_ip,p,';'); + + return TRUE; +} + + +/** + * Sets the local ip + * + * @param auth the auth conversation + * @param local_ip the local ip adress + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_auth_set_local_ip(DBusAuth *auth, + DBusString *local_ip) +{ + int p; + + if(!_dbus_string_copy(local_ip,0,&auth->local_ip,0)) + return FALSE; + if(!_dbus_string_find(&auth->local_ip,0,":",&p)) + return FALSE; + _dbus_string_set_byte(&auth->local_ip,p,';'); + + return TRUE; +} + + +/** + * Sets the host name + * + * @param auth the auth conversation + * @param host host connecting to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_auth_set_host(DBusAuth *auth, + const char *host) +{ + if(DBUS_AUTH_IS_CLIENT(auth)) + { + if(!_dbus_string_set_length(& DBUS_AUTH_CLIENT(auth)->host,0)) + return FALSE; + if(!_dbus_string_append(& DBUS_AUTH_CLIENT(auth)->host,host)) + return FALSE; + return TRUE; + } + return FALSE; +} + +/** + * see dbus_connection_set_get_username_function() + * + * @param auth the auth conversation + * @param function to call when a username is needed + */ +void +_dbus_auth_set_get_username_function (DBusAuth *auth, + DBusGetUsernameFunction function) +{ + if(DBUS_AUTH_IS_CLIENT(auth)) + { + DBUS_AUTH_CLIENT (auth)->get_username_function=function; + } +} + +/** + * see dbus_connection_set_get_password_function() + * + * @param auth the auth conversation + * @param function to call when a password is needed + */ +void +_dbus_auth_set_get_password_function (DBusAuth *auth, + DBusGetPasswordFunction function) +{ + if(DBUS_AUTH_IS_CLIENT(auth)) + { + DBUS_AUTH_CLIENT (auth)->get_password_function=function; + } +} + + /** * Sets an array of authentication mechanism names * that we are willing to use. @@ -1969,6 +2674,7 @@ _dbus_auth_set_mechanisms (DBusAuth * return TRUE; } + /** * @param auth the auth conversation object * @returns #TRUE if we're in a final state Index: dbus/dbus-connection.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v retrieving revision 1.25 diff -u -p -r1.25 dbus-connection.h --- dbus/dbus-connection.h 30 Sep 2003 02:32:52 -0000 1.25 +++ dbus/dbus-connection.h 19 Nov 2003 22:42:20 -0000 @@ -2,6 +2,7 @@ /* dbus-connection.h DBusConnection object * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -84,6 +85,8 @@ typedef void (* DBusWakeupMainFun typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection, unsigned long uid, void *data); +typedef dbus_bool_t (* DBusGetPasswordFunction) (const char **password); +typedef dbus_bool_t (* DBusGetUsernameFunction) (const char **username); typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending, void *user_data); @@ -148,6 +151,11 @@ void dbus_connection_set_u DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function); +void dbus_connection_set_get_username_function (DBusConnection *connection, + DBusGetUsernameFunction function); +void dbus_connection_set_get_password_function (DBusConnection *connection, + DBusGetPasswordFunction function); + int dbus_watch_get_fd (DBusWatch *watch); Index: dbus/dbus-connection.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v retrieving revision 1.73 diff -u -p -r1.73 dbus-connection.c --- dbus/dbus-connection.c 26 Oct 2003 15:36:15 -0000 1.73 +++ dbus/dbus-connection.c 19 Nov 2003 22:42:35 -0000 @@ -2,6 +2,7 @@ /* dbus-connection.c DBusConnection object * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -3015,6 +3016,42 @@ dbus_connection_set_unix_user_function ( } /** + * Set the function to call when a username is needed for authentication + * + * @param connection the connection + * @param function to call when username is needed + */ +void +dbus_connection_set_get_username_function (DBusConnection *connection, + DBusGetUsernameFunction function) +{ + + _dbus_return_if_fail (connection != NULL); + CONNECTION_LOCK (connection); + _dbus_transport_set_get_username_function (connection->transport, + function); + CONNECTION_UNLOCK (connection); + +} + +/** + * Set the function to call when a password is needed for authentication + * + * @param connection the connection + * @param function to call when password is needed + */ +void +dbus_connection_set_get_password_function (DBusConnection *connection, + DBusGetPasswordFunction function) +{ + _dbus_return_if_fail (connection != NULL); + CONNECTION_LOCK (connection); + _dbus_transport_set_get_password_function (connection->transport, + function); + CONNECTION_UNLOCK (connection); +} + +/** * Adds a message filter. Filters are handlers that are run on all * incoming messages, prior to the objects registered with * dbus_connection_register_object_path(). Filters are run in the Index: dbus/dbus-sysdeps.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v retrieving revision 1.36 diff -u -p -r1.36 dbus-sysdeps.h --- dbus/dbus-sysdeps.h 30 Sep 2003 02:32:53 -0000 1.36 +++ dbus/dbus-sysdeps.h 19 Nov 2003 22:42:47 -0000 @@ -3,6 +3,7 @@ * * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -120,6 +121,12 @@ int _dbus_listen_tcp_socket (const cha dbus_uint32_t port, DBusError *error); int _dbus_accept (int listen_fd); +dbus_bool_t _dbus_transport_is_inet (int transport_fd); +dbus_bool_t _dbus_transport_get_remote_ip (int transport_fd, + DBusString *address); +dbus_bool_t _dbus_transport_get_local_ip (int transport_fd, + DBusString *address); + dbus_bool_t _dbus_read_credentials_unix_socket (int client_fd, DBusCredentials *credentials, Index: dbus/dbus-sysdeps.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v retrieving revision 1.67 diff -u -p -r1.67 dbus-sysdeps.c --- dbus/dbus-sysdeps.c 16 Oct 2003 06:34:51 -0000 1.67 +++ dbus/dbus-sysdeps.c 19 Nov 2003 22:42:59 -0000 @@ -3,6 +3,7 @@ * * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -44,6 +45,7 @@ #include #include #include +#include #include #include @@ -583,7 +585,7 @@ _dbus_listen_unix_socket (const char * nonblocking. * * @param host the host name to connect to - * @param port the prot to connect to + * @param port the port to connect to * @param error return location for error code * @returns connection file descriptor or -1 on error */ @@ -752,6 +754,7 @@ write_credentials_byte (int if (bytes_written < 0) { + _dbus_verbose("Errno=%d",errno); dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to write credentials byte: %s", _dbus_strerror (errno)); @@ -968,6 +971,104 @@ _dbus_accept (int listen_fd) return client_fd; } + +static dbus_bool_t +get_address (DBusString *address, + struct sockaddr_storage *sa) + +{ + char buffer[INET6_ADDRSTRLEN + 1]; + + if(sa->ss_family == AF_INET ) + { + if(inet_ntop(sa->ss_family,&((struct sockaddr_in *)sa)->sin_addr,(char *) buffer,INET6_ADDRSTRLEN)== NULL ) + return FALSE; + if(!_dbus_string_append(address,buffer)) + return FALSE; + if(!_dbus_string_append(address,":")) + return FALSE; + if(!_dbus_string_append_printf(address,"%hu",ntohs(((struct sockaddr_in *)sa)->sin_port))) + return FALSE; + } + else if(sa->ss_family == AF_INET6 ) + { + if(inet_ntop(sa->ss_family,&((struct sockaddr_in6 *)sa)->sin6_addr,(char *) buffer,INET6_ADDRSTRLEN)== NULL ) + return FALSE; + if(!_dbus_string_append(address,":")) + return FALSE; + if(!_dbus_string_append_printf(address,"%hu",ntohs(((struct sockaddr_in6 *)sa)->sin6_port))) + return FALSE; + } + else + return FALSE; + + return TRUE; +} + +/** + * Returns true if the address type of the transport_fd is INET + * + * @param transport_fd the transport file descriptor + * @returns #TRUE when address type is AF_INET or AF_INET6 + */ +dbus_bool_t +_dbus_transport_is_inet(int transport_fd) +{ + struct sockaddr_storage sa; + int len=sizeof(sa); + + if(getsockname(transport_fd,(struct sockaddr *) &sa, &len) == -1 ) + return FALSE; + + if(sa.ss_family == AF_INET || sa.ss_family == AF_INET6 ) + return TRUE; + + return FALSE; +} + + +/** + * Get the remote IP address from a transport fd. + * + * @param transport_fd the transport file descriptor + * @param ip_address filled with the remote IP address + * @returns #TRUE when successfull + */ +dbus_bool_t +_dbus_transport_get_remote_ip (int transport_fd, + DBusString *address) +{ + struct sockaddr_storage sa; + int len=sizeof(sa); + + if(getpeername(transport_fd,(struct sockaddr *) &sa,&len) == -1 ) + return FALSE; + + return get_address(address,&sa); +} + + +/** + * Get the local IP address from a transport fd. + * + * @param transport_fd the transport file descriptor + * @param ip_address filled with the local IP address + * @returns #TRUE when successfull + */ +dbus_bool_t +_dbus_transport_get_local_ip (int transport_fd, + DBusString *address) +{ + struct sockaddr_storage sa; + int len=sizeof(sa); + + if(getsockname(transport_fd,(struct sockaddr *) &sa,&len) == -1 ) + return FALSE; + + return get_address(address,&sa); +} + + /** @} */ /** Index: dbus/dbus-transport-unix.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport-unix.c,v retrieving revision 1.33 diff -u -p -r1.33 dbus-transport-unix.c --- dbus/dbus-transport-unix.c 21 Jun 2003 07:51:39 -0000 1.33 +++ dbus/dbus-transport-unix.c 19 Nov 2003 22:43:24 -0000 @@ -2,6 +2,7 @@ /* dbus-transport-unix.c UNIX socket subclasses of DBusTransport * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -1024,6 +1025,7 @@ _dbus_transport_new_for_fd (int const DBusString *address) { DBusTransportUnix *unix_transport; + DBusString ip; unix_transport = dbus_new0 (DBusTransportUnix, 1); if (unix_transport == NULL) @@ -1056,6 +1058,23 @@ _dbus_transport_new_for_fd (int unix_transport->fd = fd; unix_transport->message_bytes_written = 0; + + /* if this is a tcp socket set the local and remote address on the auth object */ + if(_dbus_transport_is_inet(fd)) { + if(!_dbus_string_init(&ip)) + goto failed_5; + if(!_dbus_transport_get_remote_ip(fd,&ip)) + goto failed_6; + if(!_dbus_auth_set_remote_ip( ((DBusTransport *) unix_transport)->auth,&ip)) + goto failed_6; + if(!_dbus_string_set_length(&ip,0)) + goto failed_6; + if(!_dbus_transport_get_local_ip(fd,&ip)) + goto failed_6; + if(!_dbus_auth_set_local_ip(((DBusTransport *) unix_transport)->auth,&ip)) + goto failed_6; + _dbus_string_free(&ip); + } /* These values should probably be tunable or something. */ unix_transport->max_bytes_read_per_iteration = 2048; @@ -1063,6 +1082,10 @@ _dbus_transport_new_for_fd (int return (DBusTransport*) unix_transport; + failed_6: + _dbus_string_free(&ip); + failed_5: + _dbus_transport_finalize_base ((DBusTransport *) unix_transport); failed_4: _dbus_watch_unref (unix_transport->read_watch); failed_3: @@ -1205,8 +1228,17 @@ _dbus_transport_new_for_tcp_socket (cons } _dbus_string_free (&address); + + if(!_dbus_auth_set_host(transport->auth,host)) + goto nomem; return transport; + +nomem: + _dbus_close(fd,NULL); + unix_finalize(transport); + + return NULL; } /** @} */ Index: dbus/dbus-transport.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.h,v retrieving revision 1.11 diff -u -p -r1.11 dbus-transport.h --- dbus/dbus-transport.h 16 Apr 2003 23:01:33 -0000 1.11 +++ dbus/dbus-transport.h 19 Nov 2003 22:43:39 -0000 @@ -30,43 +30,46 @@ DBUS_BEGIN_DECLS; typedef struct DBusTransport DBusTransport; -DBusTransport* _dbus_transport_open (const char *address, - DBusError *error); -void _dbus_transport_ref (DBusTransport *transport); -void _dbus_transport_unref (DBusTransport *transport); -void _dbus_transport_disconnect (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); -const char* _dbus_transport_get_address (DBusTransport *transport); -dbus_bool_t _dbus_transport_handle_watch (DBusTransport *transport, - DBusWatch *watch, - unsigned int condition); -dbus_bool_t _dbus_transport_set_connection (DBusTransport *transport, - DBusConnection *connection); -void _dbus_transport_messages_pending (DBusTransport *transport, - int queue_length); -void _dbus_transport_do_iteration (DBusTransport *transport, - unsigned int flags, - int timeout_milliseconds); -DBusDispatchStatus _dbus_transport_get_dispatch_status (DBusTransport *transport); -dbus_bool_t _dbus_transport_queue_messages (DBusTransport *transport); -void _dbus_transport_set_max_message_size (DBusTransport *transport, - long size); -long _dbus_transport_get_max_message_size (DBusTransport *transport); -void _dbus_transport_set_max_received_size (DBusTransport *transport, - long size); -long _dbus_transport_get_max_received_size (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_unix_user (DBusTransport *transport, - unsigned long *uid); -void _dbus_transport_set_unix_user_function (DBusTransport *transport, - DBusAllowUnixUserFunction function, - void *data, - DBusFreeFunction free_data_function, - void **old_data, - DBusFreeFunction *old_free_data_function); -dbus_bool_t _dbus_transport_set_auth_mechanisms (DBusTransport *transport, - const char **mechanisms); - +DBusTransport* _dbus_transport_open (const char *address, + DBusError *error); +void _dbus_transport_ref (DBusTransport *transport); +void _dbus_transport_unref (DBusTransport *transport); +void _dbus_transport_disconnect (DBusTransport *transport); +dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); +dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); +const char* _dbus_transport_get_address (DBusTransport *transport); +dbus_bool_t _dbus_transport_handle_watch (DBusTransport *transport, + DBusWatch *watch, + unsigned int condition); +dbus_bool_t _dbus_transport_set_connection (DBusTransport *transport, + DBusConnection *connection); +void _dbus_transport_messages_pending (DBusTransport *transport, + int queue_length); +void _dbus_transport_do_iteration (DBusTransport *transport, + unsigned int flags, + int timeout_milliseconds); +DBusDispatchStatus _dbus_transport_get_dispatch_status (DBusTransport *transport); +dbus_bool_t _dbus_transport_queue_messages (DBusTransport *transport); +void _dbus_transport_set_max_message_size (DBusTransport *transport, + long size); +long _dbus_transport_get_max_message_size (DBusTransport *transport); +void _dbus_transport_set_max_received_size (DBusTransport *transport, + long size); +long _dbus_transport_get_max_received_size (DBusTransport *transport); +dbus_bool_t _dbus_transport_get_unix_user (DBusTransport *transport, + unsigned long *uid); +void _dbus_transport_set_unix_user_function (DBusTransport *transport, + DBusAllowUnixUserFunction function, + void *data, + DBusFreeFunction free_data_function, + void **old_data, + DBusFreeFunction *old_free_data_function); +dbus_bool_t _dbus_transport_set_auth_mechanisms (DBusTransport *transport, + const char **mechanisms); +void _dbus_transport_set_get_username_function (DBusTransport *transport, + DBusGetUsernameFunction function); +void _dbus_transport_set_get_password_function (DBusTransport *transport, + DBusGetPasswordFunction function) Index: dbus/dbus-transport.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v retrieving revision 1.35 diff -u -p -r1.35 dbus-transport.c --- dbus/dbus-transport.c 26 Oct 2003 15:36:15 -0000 1.35 +++ dbus/dbus-transport.c 19 Nov 2003 22:43:49 -0000 @@ -116,7 +116,7 @@ _dbus_transport_init_base (DBusTransport _dbus_message_loader_unref (loader); return FALSE; } - + if (server) { _dbus_assert (address == NULL); @@ -340,10 +340,13 @@ _dbus_transport_open (const char *ad } else { + _dbus_auth_start(transport->auth); dbus_error_free (&first_error); } dbus_address_entries_free (entries); + + return transport; bad_address: @@ -979,5 +982,31 @@ _dbus_transport_set_auth_mechanisms (DBu return _dbus_auth_set_mechanisms (transport->auth, mechanisms); } +/** + * see dbus_connection_set_get_username_function() + * + * @param transport the transport + * @param function the function to call when a username is needed + */ +void +_dbus_transport_set_get_username_function (DBusTransport *transport, + DBusGetUsernameFunction function) +{ + _dbus_auth_set_get_username_function (transport->auth,function); +} + +/** + * see dbus_connection_set_get_password_function() + * + * @param transport the transport + * @param function the function to call when a password is needed + */ +void +_dbus_transport_set_get_password_function (DBusTransport *transport, + DBusGetPasswordFunction function) +{ + _dbus_auth_set_get_password_function (transport->auth,function); +} + /** @} */ Index: doc/TODO =================================================================== RCS file: /cvs/dbus/dbus/doc/TODO,v retrieving revision 1.34 diff -u -p -r1.34 TODO --- doc/TODO 1 Nov 2003 18:24:32 -0000 1.34 +++ doc/TODO 19 Nov 2003 23:35:02 -0000 @@ -128,3 +128,15 @@ - rename HEADER_FIELD_SERVICE -> HEADER_FIELD_DESTINATION and HEADER_FIELD_SENDER_SERVICE -> HEADER_FIELD_SENDER for both dbus-protocol.h and in the spec + + - cleanup sasl stuff, maybe move most of it to dbus-sysdeps + in one go with implement the state machine :-) + ( see above ) + + - maybe don't compile sasl as an option so we can use the + sasl base64 en/decoding implementations + + - modify the dbus-monitor and dbus-send utilities to support + the username and password callbacks. + + - remove the implicit call to dbus_bus_register in dbus_bus_get --=-CztVctplTNL1o+sia54b-- From micke@imendio.com Fri Nov 21 11:45:40 2003 From: micke@imendio.com (Mikael Hallendal) Date: Fri, 21 Nov 2003 12:45:40 +0100 Subject: Bug in the boxing of DBusMessage in Glib layer Message-ID: <1069415140.20885.8.camel@chili.home.hallendal.net> Hi! Playing around with the gproxy signals yesterday and stumbled over a bug. Seems that when boxing DBusMessage dbus_message_ref() was used for copy-function. Took me a time to realize that this wouldn't work since unlike for example g_object_ref() in glib this function doesn't return the pointer it just reffed. So I started on a patch that would make the dbus_*_ref() functions return the reffed pointer but then I thought I should ask first if it doesn't return the reffed pointer for a reason. The other solution would be to make a wrapped copy-function (that just call dbus_message_ref() and then returns the pointer in the GLib layer. Let me know which way is the preferred and I'll send a patch for it. Regards, Mikael Hallendal -- Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 From hp@redhat.com Sat Nov 22 17:38:37 2003 From: hp@redhat.com (Havoc Pennington) Date: Sat, 22 Nov 2003 12:38:37 -0500 Subject: Bug in the boxing of DBusMessage in Glib layer In-Reply-To: <1069415140.20885.8.camel@chili.home.hallendal.net> References: <1069415140.20885.8.camel@chili.home.hallendal.net> Message-ID: <1069522717.24752.21.camel@localhost.localdomain> On Fri, 2003-11-21 at 06:45, Mikael Hallendal wrote: > So I started on a patch that would make the dbus_*_ref() functions > return the reffed pointer but then I thought I should ask first if it > doesn't return the reffed pointer for a reason. No reason, just ignorance. I'd say make _ref() return a pointer. Havoc From zack@kde.org Mon Nov 24 06:08:40 2003 From: zack@kde.org (Zack Rusin) Date: Mon, 24 Nov 2003 01:08:40 -0500 Subject: Qt bindings Message-ID: <200311240108.40088.zack@kde.org> Ave, I started working on getting Qt bindings up to speed. I'm starting the thanksgiving break on Wednesday and I hope to get it done over that break. Wednesday me and Ian will have a small hackfest so hopefully we'll get code generation working. Currently a sample usage looks as follows: using DBusQt; Connection *connection = new Connection( "unix:/var/whatever" ); ... Message msg( service, path, interface, method ); msg << "Hello World"; msg << 13.54; connection->sendMessage( msg ); So yeah. The api is going to probably totally change as I work on it this week, making it a little bit more DCOP like. Either way, feel free to be changing anything you want, especially that currently I'm lot more concerned with getting the whole thing nicely integrated into Qt then having super fancy, DCOP resembling api. Zack -- "There is hope... but not for us." -Kafka From david@fubar.dk Mon Nov 24 20:27:19 2003 From: david@fubar.dk (David Zeuthen) Date: Mon, 24 Nov 2003 21:27:19 +0100 Subject: dbus python signals Message-ID: <1069705639.4936.3.camel@laptop.fubar.dk> Hi Seth, below is a small patch for the python bindings such that the payload of a signal can be examined. There's also a function for removing a signal handler. Ok to commit? Thanks, David Index: dbus.py =================================================================== RCS file: /cvs/dbus/dbus/python/dbus.py,v retrieving revision 1.2 diff -u -r1.2 dbus.py --- dbus.py 30 Sep 2003 02:40:49 -0000 1.2 +++ dbus.py 24 Nov 2003 20:20:35 -0000 @@ -75,7 +75,15 @@ self._match_rule_to_receivers[match_rule].append(receiver) dbus_bindings.bus_add_match(self._connection, match_rule) - + + def remove_signal_receiver(self, receiver, interface=None, service=None, path=None): + match_rule = self._get_match_rule(interface, service, path) + + if self._match_rule_to_receivers.has_key(match_rule): + if self._match_rule_to_receivers[match_rule].__contains__(receiver): + self._match_rule_to_receivers[match_rule].remove(receiver) + dbus_bindings.bus_remove_match(self._connection, match_rule) + def get_connection(self): """Get the dbus_bindings.Connection object associated with this Bus""" return self._connection @@ -103,7 +111,7 @@ if (self._match_rule_to_receivers.has_key(match_rule)): receivers = self._match_rule_to_receivers[match_rule] - args = [interface, member, service, path] + args = [interface, member, service, path, message] for receiver in receivers: receiver(*args) From micke@imendio.com Tue Nov 25 23:50:28 2003 From: micke@imendio.com (Mikael Hallendal) Date: Wed, 26 Nov 2003 00:50:28 +0100 Subject: Objectpath argument for register_object_path and unregister_object_path Message-ID: <1069804228.14302.1.camel@chili.home.hallendal.net> Hi! Is there a special reason why you have to build a string array yourself to pass to dbus_connection_register_object_path and dbus_connection_unregister_object_path? Wouldn't it be simpler to use if you could just pass a string "/org/myproject/Object" instead of having to build {"org", "myproject", "Object" } before passing? Cheers, Mikael Hallendal -- Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 From hp@redhat.com Wed Nov 26 05:20:46 2003 From: hp@redhat.com (Havoc Pennington) Date: Wed, 26 Nov 2003 00:20:46 -0500 Subject: Objectpath argument for register_object_path and unregister_object_path In-Reply-To: <1069804228.14302.1.camel@chili.home.hallendal.net> References: <1069804228.14302.1.camel@chili.home.hallendal.net> Message-ID: <1069824046.5754.73.camel@localhost.localdomain> On Tue, 2003-11-25 at 18:50, Mikael Hallendal wrote: > > Is there a special reason why you have to build a string array yourself > to pass to dbus_connection_register_object_path and > dbus_connection_unregister_object_path? > > Wouldn't it be simpler to use if you could just pass a string > "/org/myproject/Object" instead of having to build {"org", "myproject", > "Object" } before passing? > Yes, probably. There are a couple other places with weirdness like this, too, I think. Havoc From micke@imendio.com Wed Nov 26 10:35:10 2003 From: micke@imendio.com (Mikael Hallendal) Date: Wed, 26 Nov 2003 11:35:10 +0100 Subject: Bug in the boxing of DBusMessage in Glib layer In-Reply-To: <1069522717.24752.21.camel@localhost.localdomain> References: <1069415140.20885.8.camel@chili.home.hallendal.net> <1069522717.24752.21.camel@localhost.localdomain> Message-ID: <1069842910.14302.16.camel@chili.home.hallendal.net> --=-WnuRFg0Sci+c8D6sLmHI Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable l=F6r 2003-11-22 klockan 18.38 skrev Havoc Pennington: > On Fri, 2003-11-21 at 06:45, Mikael Hallendal wrote: > > So I started on a patch that would make the dbus_*_ref() functions > > return the reffed pointer but then I thought I should ask first if it > > doesn't return the reffed pointer for a reason. >=20 > No reason, just ignorance. I'd say make _ref() return a pointer. Patch that make all (I hope) _ref() functions return the pointer. Not sure if I still have a cvs account there (how would I apply for one?) Regards, Mikael Hallendal --=20 Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 --=-WnuRFg0Sci+c8D6sLmHI Content-Disposition: attachment; filename=ref-return-pointer.patch Content-Type: text/x-patch; name=ref-return-pointer.patch; charset=iso-8859-15 Content-Transfer-Encoding: 7bit ? Doxyfile ? Makefile ? Makefile.in ? aclocal.m4 ? autom4te.cache ? config.guess ? config.h ? config.h.in ? config.log ? config.status ? config.sub ? configure ? dbus-1.pc ? dbus-glib-1.pc ? libtool ? ltmain.sh ? stamp-h1 ? python/.deps ? python/.libs ? python/Makefile ? python/Makefile.in ? python/dbus_bindings.c ? python/dbus_bindings.la ? python/dbus_bindings.lo ? python/dbus_bindings.pyx ? test/glib/.deps ? test/glib/.libs ? test/glib/Makefile ? test/glib/Makefile.in ? test/glib/test-dbus-glib ? test/glib/test-profile ? test/glib/test-service-glib ? test/glib/test-thread-client ? test/glib/test-thread-server ? tools/dbus-viewer Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.442 diff -u -b -B -p -r1.442 ChangeLog --- ChangeLog 25 Nov 2003 15:30:03 -0000 1.442 +++ ChangeLog 26 Nov 2003 10:20:13 -0000 @@ -1,3 +1,9 @@ +2003-11-26 Mikael Hallendal + + * bus/*.[ch]: + * dbus/*.[ch]: + * glib/*.[ch]: Made ref functions return the pointer + 2003-11-25 Zack Rusin * qt/integrator.h, qt/integrator.cpp: Adding handling of DBusServer, Index: bus/activation.c =================================================================== RCS file: /cvs/dbus/dbus/bus/activation.c,v retrieving revision 1.29 diff -u -b -B -p -r1.29 activation.c --- bus/activation.c 16 Oct 2003 06:34:51 -0000 1.29 +++ bus/activation.c 26 Nov 2003 10:20:13 -0000 @@ -99,11 +99,13 @@ handle_timeout_callback (DBusTimeout * _dbus_wait_for_memory (); } -static void +static BusPendingActivation * bus_pending_activation_ref (BusPendingActivation *pending_activation) { _dbus_assert (pending_activation->refcount > 0); pending_activation->refcount += 1; + + return pending_activation; } static void @@ -445,12 +447,14 @@ bus_activation_new (BusContext *c return NULL; } -void +BusActivation * bus_activation_ref (BusActivation *activation) { _dbus_assert (activation->refcount > 0); activation->refcount += 1; + + return activation; } void Index: bus/activation.h =================================================================== RCS file: /cvs/dbus/dbus/bus/activation.h,v retrieving revision 1.9 diff -u -b -B -p -r1.9 activation.h --- bus/activation.h 2 Apr 2003 20:14:52 -0000 1.9 +++ bus/activation.h 26 Nov 2003 10:20:13 -0000 @@ -32,7 +32,7 @@ BusActivation* bus_activation_new const DBusString *address, DBusList **directories, DBusError *error); -void bus_activation_ref (BusActivation *activation); +BusActivation* bus_activation_ref (BusActivation *activation); void bus_activation_unref (BusActivation *activation); dbus_bool_t bus_activation_activate_service (BusActivation *activation, DBusConnection *connection, Index: bus/bus.c =================================================================== RCS file: /cvs/dbus/dbus/bus/bus.c,v retrieving revision 1.46 diff -u -b -B -p -r1.46 bus.c --- bus/bus.c 22 Oct 2003 16:01:08 -0000 1.46 +++ bus/bus.c 26 Nov 2003 10:20:13 -0000 @@ -670,11 +670,13 @@ bus_context_shutdown (BusContext *conte } } -void +BusContext * bus_context_ref (BusContext *context) { _dbus_assert (context->refcount > 0); context->refcount += 1; + + return context; } void Index: bus/bus.h =================================================================== RCS file: /cvs/dbus/dbus/bus/bus.h,v retrieving revision 1.20 diff -u -b -B -p -r1.20 bus.h --- bus/bus.h 14 Oct 2003 05:16:56 -0000 1.20 +++ bus/bus.h 26 Nov 2003 10:20:13 -0000 @@ -66,7 +66,7 @@ BusContext* bus_context_new int print_pid_fd, DBusError *error); void bus_context_shutdown (BusContext *context); -void bus_context_ref (BusContext *context); +BusContext* bus_context_ref (BusContext *context); void bus_context_unref (BusContext *context); const char* bus_context_get_type (BusContext *context); const char* bus_context_get_address (BusContext *context); Index: bus/config-parser.c =================================================================== RCS file: /cvs/dbus/dbus/bus/config-parser.c,v retrieving revision 1.25 diff -u -b -B -p -r1.25 config-parser.c --- bus/config-parser.c 14 Oct 2003 22:16:03 -0000 1.25 +++ bus/config-parser.c 26 Nov 2003 10:20:14 -0000 @@ -345,12 +345,14 @@ bus_config_parser_new (const DBusString return parser; } -void +BusConfigParser * bus_config_parser_ref (BusConfigParser *parser) { _dbus_assert (parser->refcount > 0); parser->refcount += 1; + + return parser; } void Index: bus/config-parser.h =================================================================== RCS file: /cvs/dbus/dbus/bus/config-parser.h,v retrieving revision 1.11 diff -u -b -B -p -r1.11 config-parser.h --- bus/config-parser.h 28 Apr 2003 19:29:41 -0000 1.11 +++ bus/config-parser.h 26 Nov 2003 10:20:14 -0000 @@ -37,7 +37,7 @@ typedef struct BusConfigParser BusConfig BusConfigParser* bus_config_parser_new (const DBusString *basedir, dbus_bool_t is_toplevel); -void bus_config_parser_ref (BusConfigParser *parser); +BusConfigParser* bus_config_parser_ref (BusConfigParser *parser); void bus_config_parser_unref (BusConfigParser *parser); dbus_bool_t bus_config_parser_check_doctype (BusConfigParser *parser, const char *doctype, Index: bus/connection.c =================================================================== RCS file: /cvs/dbus/dbus/bus/connection.c,v retrieving revision 1.51 diff -u -b -B -p -r1.51 connection.c --- bus/connection.c 28 Oct 2003 23:51:24 -0000 1.51 +++ bus/connection.c 26 Nov 2003 10:20:14 -0000 @@ -471,11 +471,13 @@ bus_connections_new (BusContext *context return NULL; } -void +BusConnections * bus_connections_ref (BusConnections *connections) { _dbus_assert (connections->refcount > 0); connections->refcount += 1; + + return connections; } void Index: bus/connection.h =================================================================== RCS file: /cvs/dbus/dbus/bus/connection.h,v retrieving revision 1.17 diff -u -b -B -p -r1.17 connection.h --- bus/connection.h 14 Oct 2003 05:16:56 -0000 1.17 +++ bus/connection.h 26 Nov 2003 10:20:14 -0000 @@ -33,7 +33,7 @@ typedef dbus_bool_t (* BusConnectionFore BusConnections* bus_connections_new (BusContext *context); -void bus_connections_ref (BusConnections *connections); +BusConnections* bus_connections_ref (BusConnections *connections); void bus_connections_unref (BusConnections *connections); dbus_bool_t bus_connections_setup_connection (BusConnections *connections, DBusConnection *connection); Index: bus/policy.c =================================================================== RCS file: /cvs/dbus/dbus/bus/policy.c,v retrieving revision 1.16 diff -u -b -B -p -r1.16 policy.c --- bus/policy.c 14 Oct 2003 22:16:03 -0000 1.16 +++ bus/policy.c 26 Nov 2003 10:20:14 -0000 @@ -68,12 +68,14 @@ bus_policy_rule_new (BusPolicyRuleType t return rule; } -void +BusPolicyRule * bus_policy_rule_ref (BusPolicyRule *rule) { _dbus_assert (rule->refcount > 0); rule->refcount += 1; + + return rule; } void @@ -178,12 +180,14 @@ bus_policy_new (void) return NULL; } -void +BusPolicy * bus_policy_ref (BusPolicy *policy) { _dbus_assert (policy->refcount > 0); policy->refcount += 1; + + return policy; } void @@ -628,12 +632,14 @@ bus_client_policy_new (void) return policy; } -void +BusClientPolicy * bus_client_policy_ref (BusClientPolicy *policy) { _dbus_assert (policy->refcount > 0); policy->refcount += 1; + + return policy; } static void Index: bus/policy.h =================================================================== RCS file: /cvs/dbus/dbus/bus/policy.h,v retrieving revision 1.11 diff -u -b -B -p -r1.11 policy.h --- bus/policy.h 14 Oct 2003 22:16:03 -0000 1.11 +++ bus/policy.h 26 Nov 2003 10:20:14 -0000 @@ -101,11 +101,11 @@ struct BusPolicyRule BusPolicyRule* bus_policy_rule_new (BusPolicyRuleType type, dbus_bool_t allow); -void bus_policy_rule_ref (BusPolicyRule *rule); +BusPolicyRule* bus_policy_rule_ref (BusPolicyRule *rule); void bus_policy_rule_unref (BusPolicyRule *rule); BusPolicy* bus_policy_new (void); -void bus_policy_ref (BusPolicy *policy); +BusPolicy* bus_policy_ref (BusPolicy *policy); void bus_policy_unref (BusPolicy *policy); BusClientPolicy* bus_policy_create_client_policy (BusPolicy *policy, DBusConnection *connection, @@ -127,7 +127,7 @@ dbus_bool_t bus_policy_merge BusPolicy *to_absorb); BusClientPolicy* bus_client_policy_new (void); -void bus_client_policy_ref (BusClientPolicy *policy); +BusClientPolicy* bus_client_policy_ref (BusClientPolicy *policy); void bus_client_policy_unref (BusClientPolicy *policy); dbus_bool_t bus_client_policy_check_can_send (BusClientPolicy *policy, BusRegistry *registry, Index: bus/services.c =================================================================== RCS file: /cvs/dbus/dbus/bus/services.c,v retrieving revision 1.16 diff -u -b -B -p -r1.16 services.c --- bus/services.c 30 Sep 2003 02:32:50 -0000 1.16 +++ bus/services.c 26 Nov 2003 10:20:14 -0000 @@ -82,11 +82,13 @@ bus_registry_new (BusContext *context) return NULL; } -void +BusRegistry * bus_registry_ref (BusRegistry *registry) { _dbus_assert (registry->refcount > 0); registry->refcount += 1; + + return registry; } void @@ -713,12 +715,14 @@ bus_service_remove_owner (BusService return TRUE; } -void +BusService * bus_service_ref (BusService *service) { _dbus_assert (service->refcount > 0); service->refcount += 1; + + return service; } void Index: bus/services.h =================================================================== RCS file: /cvs/dbus/dbus/bus/services.h,v retrieving revision 1.8 diff -u -b -B -p -r1.8 services.h --- bus/services.h 11 Apr 2003 00:03:06 -0000 1.8 +++ bus/services.h 26 Nov 2003 10:20:14 -0000 @@ -33,7 +33,7 @@ typedef void (* BusServiceForeachFunctio void *data); BusRegistry* bus_registry_new (BusContext *context); -void bus_registry_ref (BusRegistry *registry); +BusRegistry* bus_registry_ref (BusRegistry *registry); void bus_registry_unref (BusRegistry *registry); BusService* bus_registry_lookup (BusRegistry *registry, const DBusString *service_name); @@ -56,7 +56,7 @@ dbus_bool_t bus_registry_acquire_servic BusTransaction *transaction, DBusError *error); -void bus_service_ref (BusService *service); +BusService* bus_service_ref (BusService *service); void bus_service_unref (BusService *service); dbus_bool_t bus_service_add_owner (BusService *service, DBusConnection *owner, Index: bus/signals.c =================================================================== RCS file: /cvs/dbus/dbus/bus/signals.c,v retrieving revision 1.5 diff -u -b -B -p -r1.5 signals.c --- bus/signals.c 16 Oct 2003 06:34:51 -0000 1.5 +++ bus/signals.c 26 Nov 2003 10:20:15 -0000 @@ -59,12 +59,14 @@ bus_match_rule_new (DBusConnection *matc return rule; } -void +BusMatchRule * bus_match_rule_ref (BusMatchRule *rule) { _dbus_assert (rule->refcount > 0); rule->refcount += 1; + + return rule; } void @@ -765,12 +767,14 @@ bus_matchmaker_new (void) return matchmaker; } -void +BusMatchmaker * bus_matchmaker_ref (BusMatchmaker *matchmaker) { _dbus_assert (matchmaker->refcount > 0); matchmaker->refcount += 1; + + return matchmaker; } void Index: bus/signals.h =================================================================== RCS file: /cvs/dbus/dbus/bus/signals.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 signals.h --- bus/signals.h 30 Sep 2003 02:32:50 -0000 1.2 +++ bus/signals.h 26 Nov 2003 10:20:15 -0000 @@ -40,7 +40,7 @@ typedef enum } BusMatchFlags; BusMatchRule* bus_match_rule_new (DBusConnection *matches_go_to); -void bus_match_rule_ref (BusMatchRule *rule); +BusMatchRule* bus_match_rule_ref (BusMatchRule *rule); void bus_match_rule_unref (BusMatchRule *rule); dbus_bool_t bus_match_rule_set_message_type (BusMatchRule *rule, @@ -61,7 +61,7 @@ BusMatchRule* bus_match_rule_parse (DBus DBusError *error); BusMatchmaker* bus_matchmaker_new (void); -void bus_matchmaker_ref (BusMatchmaker *matchmaker); +BusMatchmaker* bus_matchmaker_ref (BusMatchmaker *matchmaker); void bus_matchmaker_unref (BusMatchmaker *matchmaker); dbus_bool_t bus_matchmaker_add_rule (BusMatchmaker *matchmaker, Index: dbus/dbus-auth.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.c,v retrieving revision 1.29 diff -u -b -B -p -r1.29 dbus-auth.c --- dbus/dbus-auth.c 30 Sep 2003 02:32:52 -0000 1.29 +++ dbus/dbus-auth.c 26 Nov 2003 10:20:15 -0000 @@ -1894,13 +1894,16 @@ _dbus_auth_client_new (void) * Increments the refcount of an auth object. * * @param auth the auth conversation + * @returns the auth conversation */ -void +DBusAuth * _dbus_auth_ref (DBusAuth *auth) { _dbus_assert (auth != NULL); auth->refcount += 1; + + return auth; } /** Index: dbus/dbus-auth.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.h,v retrieving revision 1.6 diff -u -b -B -p -r1.6 dbus-auth.h --- dbus/dbus-auth.h 1 Apr 2003 05:33:01 -0000 1.6 +++ dbus/dbus-auth.h 26 Nov 2003 10:20:15 -0000 @@ -44,7 +44,7 @@ typedef enum DBusAuth* _dbus_auth_server_new (void); DBusAuth* _dbus_auth_client_new (void); -void _dbus_auth_ref (DBusAuth *auth); +DBusAuth* _dbus_auth_ref (DBusAuth *auth); void _dbus_auth_unref (DBusAuth *auth); dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, const char **mechanisms); Index: dbus/dbus-connection-internal.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection-internal.h,v retrieving revision 1.14 diff -u -b -B -p -r1.14 dbus-connection-internal.h --- dbus/dbus-connection-internal.h 26 Oct 2003 15:36:15 -0000 1.14 +++ dbus/dbus-connection-internal.h 26 Nov 2003 10:20:15 -0000 @@ -46,7 +46,7 @@ typedef enum void _dbus_connection_lock (DBusConnection *connection); void _dbus_connection_unlock (DBusConnection *connection); -void _dbus_connection_ref_unlocked (DBusConnection *connection); +DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection); void _dbus_connection_unref_unlocked (DBusConnection *connection); dbus_bool_t _dbus_connection_queue_received_message (DBusConnection *connection, DBusMessage *message); Index: dbus/dbus-connection.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v retrieving revision 1.73 diff -u -b -B -p -r1.73 dbus-connection.c --- dbus/dbus-connection.c 26 Oct 2003 15:36:15 -0000 1.73 +++ dbus/dbus-connection.c 26 Nov 2003 10:20:16 -0000 @@ -219,11 +219,13 @@ static void _dbus_connecti DBusDispatchStatus new_status); static void _dbus_connection_last_unref (DBusConnection *connection); -static void +static DBusMessageFilter * _dbus_message_filter_ref (DBusMessageFilter *filter) { _dbus_assert (filter->refcount.value > 0); _dbus_atomic_inc (&filter->refcount); + + return filter; } static void @@ -963,8 +965,9 @@ _dbus_connection_new_for_transport (DBus * Requires that the caller already holds the connection lock. * * @param connection the connection. + * @returns the connection. */ -void +DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection) { #ifdef DBUS_HAVE_ATOMIC_INT @@ -973,6 +976,8 @@ _dbus_connection_ref_unlocked (DBusConne _dbus_assert (connection->refcount.value > 0); connection->refcount.value += 1; #endif + + return connection; } /** @@ -1117,11 +1122,12 @@ dbus_connection_open (const char *ad * Increments the reference count of a DBusConnection. * * @param connection the connection. + * @returns the connection. */ -void +DBusConnection * dbus_connection_ref (DBusConnection *connection) { - _dbus_return_if_fail (connection != NULL); + _dbus_return_val_if_fail (connection != NULL, NULL); /* The connection lock is better than the global * lock in the atomic increment fallback @@ -1136,6 +1142,8 @@ dbus_connection_ref (DBusConnection *con connection->refcount.value += 1; CONNECTION_UNLOCK (connection); #endif + + return connection; } static void Index: dbus/dbus-connection.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v retrieving revision 1.25 diff -u -b -B -p -r1.25 dbus-connection.h --- dbus/dbus-connection.h 30 Sep 2003 02:32:52 -0000 1.25 +++ dbus/dbus-connection.h 26 Nov 2003 10:20:16 -0000 @@ -95,7 +95,7 @@ typedef DBusHandlerResult (* DBusHandleM DBusConnection* dbus_connection_open (const char *address, DBusError *error); -void dbus_connection_ref (DBusConnection *connection); +DBusConnection* dbus_connection_ref (DBusConnection *connection); void dbus_connection_unref (DBusConnection *connection); void dbus_connection_disconnect (DBusConnection *connection); dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); Index: dbus/dbus-hash.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-hash.c,v retrieving revision 1.15 diff -u -b -B -p -r1.15 dbus-hash.c --- dbus/dbus-hash.c 30 Sep 2003 02:32:52 -0000 1.15 +++ dbus/dbus-hash.c 26 Nov 2003 10:20:16 -0000 @@ -348,11 +348,14 @@ _dbus_hash_table_new (DBusHashType t * Increments the reference count for a hash table. * * @param table the hash table to add a reference to. + * @returns the hash table. */ -void +DBusHashTable * _dbus_hash_table_ref (DBusHashTable *table) { table->refcount += 1; + + return table; } /** Index: dbus/dbus-hash.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-hash.h,v retrieving revision 1.10 diff -u -b -B -p -r1.10 dbus-hash.h --- dbus/dbus-hash.h 30 Sep 2003 02:32:52 -0000 1.10 +++ dbus/dbus-hash.h 26 Nov 2003 10:20:16 -0000 @@ -61,7 +61,7 @@ typedef enum DBusHashTable* _dbus_hash_table_new (DBusHashType type, DBusFreeFunction key_free_function, DBusFreeFunction value_free_function); -void _dbus_hash_table_ref (DBusHashTable *table); +DBusHashTable* _dbus_hash_table_ref (DBusHashTable *table); void _dbus_hash_table_unref (DBusHashTable *table); void _dbus_hash_iter_init (DBusHashTable *table, DBusHashIter *iter); Index: dbus/dbus-keyring.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-keyring.c,v retrieving revision 1.19 diff -u -b -B -p -r1.19 dbus-keyring.c --- dbus/dbus-keyring.c 30 Sep 2003 02:32:52 -0000 1.19 +++ dbus/dbus-keyring.c 26 Nov 2003 10:20:16 -0000 @@ -657,11 +657,14 @@ _dbus_keyring_reload (DBusKeyring *keyri * Increments reference count of the keyring * * @param keyring the keyring + * @returns the keyring */ -void +DBusKeyring * _dbus_keyring_ref (DBusKeyring *keyring) { keyring->refcount += 1; + + return keyring; } /** Index: dbus/dbus-keyring.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-keyring.h,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-keyring.h --- dbus/dbus-keyring.h 5 Mar 2003 02:01:34 -0000 1.4 +++ dbus/dbus-keyring.h 26 Nov 2003 10:20:16 -0000 @@ -34,7 +34,7 @@ typedef struct DBusKeyring DBusKeyring; DBusKeyring* _dbus_keyring_new_homedir (const DBusString *username, const DBusString *context, DBusError *error); -void _dbus_keyring_ref (DBusKeyring *keyring); +DBusKeyring* _dbus_keyring_ref (DBusKeyring *keyring); void _dbus_keyring_unref (DBusKeyring *keyring); dbus_bool_t _dbus_keyring_validate_context (const DBusString *context); int _dbus_keyring_get_best_key (DBusKeyring *keyring, Index: dbus/dbus-mainloop.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-mainloop.c,v retrieving revision 1.13 diff -u -b -B -p -r1.13 dbus-mainloop.c --- dbus/dbus-mainloop.c 30 Sep 2003 02:32:52 -0000 1.13 +++ dbus/dbus-mainloop.c 26 Nov 2003 10:20:16 -0000 @@ -123,12 +123,14 @@ timeout_callback_new (DBusTimeout return cb; } -static void +static Callback * callback_ref (Callback *cb) { _dbus_assert (cb->refcount > 0); cb->refcount += 1; + + return cb; } static void @@ -204,13 +206,15 @@ _dbus_loop_new (void) return loop; } -void +DBusLoop * _dbus_loop_ref (DBusLoop *loop) { _dbus_assert (loop != NULL); _dbus_assert (loop->refcount > 0); loop->refcount += 1; + + return loop; } void Index: dbus/dbus-mainloop.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-mainloop.h,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-mainloop.h --- dbus/dbus-mainloop.h 30 Sep 2003 02:32:52 -0000 1.4 +++ dbus/dbus-mainloop.h 26 Nov 2003 10:20:16 -0000 @@ -37,7 +37,7 @@ typedef void (* DBusTimeoutFuncti void *data); DBusLoop* _dbus_loop_new (void); -void _dbus_loop_ref (DBusLoop *loop); +DBusLoop* _dbus_loop_ref (DBusLoop *loop); void _dbus_loop_unref (DBusLoop *loop); dbus_bool_t _dbus_loop_add_watch (DBusLoop *loop, DBusWatch *watch, Index: dbus/dbus-message-handler.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message-handler.c,v retrieving revision 1.9 diff -u -b -B -p -r1.9 dbus-message-handler.c --- dbus/dbus-message-handler.c 12 May 2003 02:44:44 -0000 1.9 +++ dbus/dbus-message-handler.c 26 Nov 2003 10:20:17 -0000 @@ -189,13 +189,16 @@ dbus_message_handler_new (DBusHandleMess * Increments the reference count on a message handler. * * @param handler the handler + * @returns the handler */ -void +DBusMessageHandler * dbus_message_handler_ref (DBusMessageHandler *handler) { _dbus_return_if_fail (handler != NULL); _dbus_atomic_inc (&handler->refcount); + + return handler; } /** Index: dbus/dbus-message-handler.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message-handler.h,v retrieving revision 1.1 diff -u -b -B -p -r1.1 dbus-message-handler.h --- dbus/dbus-message-handler.h 24 Dec 2002 06:37:32 -0000 1.1 +++ dbus/dbus-message-handler.h 26 Nov 2003 10:20:17 -0000 @@ -43,7 +43,7 @@ DBusMessageHandler* dbus_message_handler DBusFreeFunction free_user_data); -void dbus_message_handler_ref (DBusMessageHandler *handler); +DBusMessageHandler* dbus_message_handler_ref (DBusMessageHandler *handler); void dbus_message_handler_unref (DBusMessageHandler *handler); Index: dbus/dbus-message-internal.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message-internal.h,v retrieving revision 1.14 diff -u -b -B -p -r1.14 dbus-message-internal.h --- dbus/dbus-message-internal.h 12 May 2003 02:44:44 -0000 1.14 +++ dbus/dbus-message-internal.h 26 Nov 2003 10:20:17 -0000 @@ -48,7 +48,7 @@ void _dbus_message_remove_size_co DBusList **link_return); DBusMessageLoader* _dbus_message_loader_new (void); -void _dbus_message_loader_ref (DBusMessageLoader *loader); +DBusMessageLoader* _dbus_message_loader_ref (DBusMessageLoader *loader); void _dbus_message_loader_unref (DBusMessageLoader *loader); void _dbus_message_loader_get_buffer (DBusMessageLoader *loader, Index: dbus/dbus-message.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v retrieving revision 1.114 diff -u -b -B -p -r1.114 dbus-message.c --- dbus/dbus-message.c 29 Oct 2003 00:29:52 -0000 1.114 +++ dbus/dbus-message.c 26 Nov 2003 10:20:18 -0000 @@ -1504,17 +1504,20 @@ dbus_message_copy (const DBusMessage *me * Increments the reference count of a DBusMessage. * * @param message The message + * @returns the message * @see dbus_message_unref */ -void +DBusMessage * dbus_message_ref (DBusMessage *message) { dbus_int32_t old_refcount; - _dbus_return_if_fail (message != NULL); + _dbus_return_val_if_fail (message != NULL, NULL); old_refcount = _dbus_atomic_inc (&message->refcount); _dbus_assert (old_refcount >= 1); + + return message; } static void @@ -4781,11 +4784,14 @@ _dbus_message_loader_new (void) * Increments the reference count of the loader. * * @param loader the loader. + * @returns the loader */ -void +DBusMessageLoader * _dbus_message_loader_ref (DBusMessageLoader *loader) { loader->refcount += 1; + + return loader; } /** Index: dbus/dbus-message.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message.h,v retrieving revision 1.47 diff -u -b -B -p -r1.47 dbus-message.h --- dbus/dbus-message.h 21 Oct 2003 05:46:51 -0000 1.47 +++ dbus/dbus-message.h 26 Nov 2003 10:20:18 -0000 @@ -73,9 +73,9 @@ DBusMessage* dbus_message_new_error const char *error_name, const char *error_message); -DBusMessage *dbus_message_copy (const DBusMessage *message); +DBusMessage* dbus_message_copy (const DBusMessage *message); -void dbus_message_ref (DBusMessage *message); +DBusMessage* dbus_message_ref (DBusMessage *message); void dbus_message_unref (DBusMessage *message); int dbus_message_get_type (DBusMessage *message); dbus_bool_t dbus_message_set_path (DBusMessage *message, Index: dbus/dbus-object-tree.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-object-tree.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-object-tree.c --- dbus/dbus-object-tree.c 30 Sep 2003 02:32:53 -0000 1.2 +++ dbus/dbus-object-tree.c 26 Nov 2003 10:20:18 -0000 @@ -46,7 +46,7 @@ typedef struct DBusObjectSubtree DBusObj static DBusObjectSubtree* _dbus_object_subtree_new (const char *name, const DBusObjectPathVTable *vtable, void *user_data); -static void _dbus_object_subtree_ref (DBusObjectSubtree *subtree); +static DBusObjectSubtree* _dbus_object_subtree_ref (DBusObjectSubtree *subtree); static void _dbus_object_subtree_unref (DBusObjectSubtree *subtree); /** @@ -121,13 +121,16 @@ _dbus_object_tree_new (DBusConnection *c /** * Increment the reference count * @param tree the object tree + * @returns the object tree */ -void +DBusObjectTree * _dbus_object_tree_ref (DBusObjectTree *tree) { _dbus_assert (tree->refcount > 0); tree->refcount += 1; + + return tree; } /** @@ -859,11 +862,13 @@ _dbus_object_subtree_new (const char return NULL; } -static void +static DBusObjectSubtree * _dbus_object_subtree_ref (DBusObjectSubtree *subtree) { _dbus_assert (subtree->refcount.value > 0); _dbus_atomic_inc (&subtree->refcount); + + return subtree; } static void Index: dbus/dbus-object-tree.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-object-tree.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-object-tree.h --- dbus/dbus-object-tree.h 30 Sep 2003 02:32:53 -0000 1.2 +++ dbus/dbus-object-tree.h 26 Nov 2003 10:20:18 -0000 @@ -30,7 +30,7 @@ DBUS_BEGIN_DECLS; typedef struct DBusObjectTree DBusObjectTree; DBusObjectTree* _dbus_object_tree_new (DBusConnection *connection); -void _dbus_object_tree_ref (DBusObjectTree *tree); +DBusObjectTree* _dbus_object_tree_ref (DBusObjectTree *tree); void _dbus_object_tree_unref (DBusObjectTree *tree); dbus_bool_t _dbus_object_tree_register (DBusObjectTree *tree, Index: dbus/dbus-pending-call.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-pending-call.c,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-pending-call.c --- dbus/dbus-pending-call.c 16 Oct 2003 06:34:51 -0000 1.4 +++ dbus/dbus-pending-call.c 26 Nov 2003 10:20:18 -0000 @@ -138,13 +138,16 @@ _dbus_pending_call_notify (DBusPendingCa * Increments the reference count on a pending call. * * @param pending the pending call object + * @returns the pending call object */ -void +DBusPendingCall * dbus_pending_call_ref (DBusPendingCall *pending) { _dbus_return_if_fail (pending != NULL); _dbus_atomic_inc (&pending->refcount); + + return pending; } /** Index: dbus/dbus-pending-call.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-pending-call.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-pending-call.h --- dbus/dbus-pending-call.h 30 Sep 2003 02:32:53 -0000 1.2 +++ dbus/dbus-pending-call.h 26 Nov 2003 10:20:18 -0000 @@ -33,7 +33,7 @@ DBUS_BEGIN_DECLS; -void dbus_pending_call_ref (DBusPendingCall *pending); +DBusPendingCall* dbus_pending_call_ref (DBusPendingCall *pending); void dbus_pending_call_unref (DBusPendingCall *pending); dbus_bool_t dbus_pending_call_set_notify (DBusPendingCall *pending, DBusPendingCallNotifyFunction function, Index: dbus/dbus-resources.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-resources.c,v retrieving revision 1.1 diff -u -b -B -p -r1.1 dbus-resources.c --- dbus/dbus-resources.c 19 Jan 2003 03:33:35 -0000 1.1 +++ dbus/dbus-resources.c 26 Nov 2003 10:20:18 -0000 @@ -96,13 +96,16 @@ _dbus_counter_new (void) * Increments refcount of the counter * * @param counter the counter + * @returns the counter */ -void +DBusCounter * _dbus_counter_ref (DBusCounter *counter) { _dbus_assert (counter->refcount > 0); counter->refcount += 1; + + return counter; } /** Index: dbus/dbus-resources.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-resources.h,v retrieving revision 1.1 diff -u -b -B -p -r1.1 dbus-resources.h --- dbus/dbus-resources.h 19 Jan 2003 03:33:35 -0000 1.1 +++ dbus/dbus-resources.h 26 Nov 2003 10:20:18 -0000 @@ -35,7 +35,7 @@ typedef void (* DBusCounterNotifyFunctio void *user_data); DBusCounter* _dbus_counter_new (void); -void _dbus_counter_ref (DBusCounter *counter); +DBusCounter* _dbus_counter_ref (DBusCounter *counter); void _dbus_counter_unref (DBusCounter *counter); void _dbus_counter_adjust (DBusCounter *counter, long delta); Index: dbus/dbus-server.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-server.c,v retrieving revision 1.30 diff -u -b -B -p -r1.30 dbus-server.c --- dbus/dbus-server.c 30 Sep 2003 02:32:53 -0000 1.30 +++ dbus/dbus-server.c 26 Nov 2003 10:20:18 -0000 @@ -450,13 +450,16 @@ dbus_server_listen (const char *addr * Increments the reference count of a DBusServer. * * @param server the server. + * @returns the server */ -void +DBusServer * dbus_server_ref (DBusServer *server) { _dbus_return_if_fail (server != NULL); server->refcount += 1; + + return server; } /** Index: dbus/dbus-server.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-server.h,v retrieving revision 1.13 diff -u -b -B -p -r1.13 dbus-server.h --- dbus/dbus-server.h 22 Jun 2003 19:39:47 -0000 1.13 +++ dbus/dbus-server.h 26 Nov 2003 10:20:18 -0000 @@ -41,7 +41,7 @@ typedef void (* DBusNewConnectionFunctio DBusServer* dbus_server_listen (const char *address, DBusError *error); -void dbus_server_ref (DBusServer *server); +DBusServer* dbus_server_ref (DBusServer *server); void dbus_server_unref (DBusServer *server); void dbus_server_disconnect (DBusServer *server); dbus_bool_t dbus_server_get_is_connected (DBusServer *server); Index: dbus/dbus-spawn.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-spawn.c,v retrieving revision 1.13 diff -u -b -B -p -r1.13 dbus-spawn.c --- dbus/dbus-spawn.c 30 Sep 2003 02:32:53 -0000 1.13 +++ dbus/dbus-spawn.c 26 Nov 2003 10:20:18 -0000 @@ -235,14 +235,17 @@ _dbus_babysitter_new (void) * Increment the reference count on the babysitter object. * * @param sitter the babysitter + * @returns the babysitter */ -void +DBusBabysitter * _dbus_babysitter_ref (DBusBabysitter *sitter) { _dbus_assert (sitter != NULL); _dbus_assert (sitter->refcount > 0); sitter->refcount += 1; + + return sitter; } /** Index: dbus/dbus-spawn.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-spawn.h,v retrieving revision 1.3 diff -u -b -B -p -r1.3 dbus-spawn.h --- dbus/dbus-spawn.h 18 Apr 2003 04:18:57 -0000 1.3 +++ dbus/dbus-spawn.h 26 Nov 2003 10:20:18 -0000 @@ -40,7 +40,7 @@ dbus_bool_t _dbus_spawn_async_with_babys DBusSpawnChildSetupFunc child_setup, void *user_data, DBusError *error); -void _dbus_babysitter_ref (DBusBabysitter *sitter); +DBusBabysitter* _dbus_babysitter_ref (DBusBabysitter *sitter); void _dbus_babysitter_unref (DBusBabysitter *sitter); void _dbus_babysitter_kill_child (DBusBabysitter *sitter); dbus_bool_t _dbus_babysitter_get_child_exited (DBusBabysitter *sitter); Index: dbus/dbus-timeout.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-timeout.c,v retrieving revision 1.11 diff -u -b -B -p -r1.11 dbus-timeout.c --- dbus/dbus-timeout.c 30 Sep 2003 02:32:53 -0000 1.11 +++ dbus/dbus-timeout.c 26 Nov 2003 10:20:18 -0000 @@ -86,11 +86,14 @@ _dbus_timeout_new (int i * Increments the reference count of a DBusTimeout object. * * @param timeout the timeout object. + * @returns the timeout object. */ -void +DBusTimeout * _dbus_timeout_ref (DBusTimeout *timeout) { timeout->refcount += 1; + + return timeout; } /** Index: dbus/dbus-timeout.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-timeout.h,v retrieving revision 1.6 diff -u -b -B -p -r1.6 dbus-timeout.h --- dbus/dbus-timeout.h 24 Apr 2003 21:26:25 -0000 1.6 +++ dbus/dbus-timeout.h 26 Nov 2003 10:20:18 -0000 @@ -38,7 +38,7 @@ DBusTimeout* _dbus_timeout_new DBusTimeoutHandler handler, void *data, DBusFreeFunction free_data_function); -void _dbus_timeout_ref (DBusTimeout *timeout); +DBusTimeout* _dbus_timeout_ref (DBusTimeout *timeout); void _dbus_timeout_unref (DBusTimeout *timeout); void _dbus_timeout_set_interval (DBusTimeout *timeout, int interval); Index: dbus/dbus-transport.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v retrieving revision 1.35 diff -u -b -B -p -r1.35 dbus-transport.c --- dbus/dbus-transport.c 26 Oct 2003 15:36:15 -0000 1.35 +++ dbus/dbus-transport.c 26 Nov 2003 10:20:19 -0000 @@ -365,13 +365,16 @@ _dbus_transport_open (const char *ad * Increments the reference count for the transport. * * @param transport the transport. + * @returns the transport. */ -void +DBusTransport * _dbus_transport_ref (DBusTransport *transport) { _dbus_assert (transport->refcount > 0); transport->refcount += 1; + + return transport; } /** Index: dbus/dbus-transport.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.h,v retrieving revision 1.11 diff -u -b -B -p -r1.11 dbus-transport.h --- dbus/dbus-transport.h 16 Apr 2003 23:01:33 -0000 1.11 +++ dbus/dbus-transport.h 26 Nov 2003 10:20:19 -0000 @@ -32,7 +32,7 @@ typedef struct DBusTransport DBusTranspo DBusTransport* _dbus_transport_open (const char *address, DBusError *error); -void _dbus_transport_ref (DBusTransport *transport); +DBusTransport* _dbus_transport_ref (DBusTransport *transport); void _dbus_transport_unref (DBusTransport *transport); void _dbus_transport_disconnect (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); Index: dbus/dbus-userdb.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.c,v retrieving revision 1.5 diff -u -b -B -p -r1.5 dbus-userdb.c --- dbus/dbus-userdb.c 30 Sep 2003 02:32:53 -0000 1.5 +++ dbus/dbus-userdb.c 26 Nov 2003 10:20:19 -0000 @@ -635,13 +635,16 @@ _dbus_user_database_new (void) /** * Increments refcount of user database. * @param db the database + * @returns the database */ -void +DBusUserDatabase * _dbus_user_database_ref (DBusUserDatabase *db) { _dbus_assert (db->refcount > 0); db->refcount += 1; + + return db; } /** Index: dbus/dbus-userdb.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-userdb.h --- dbus/dbus-userdb.h 17 Apr 2003 23:17:04 -0000 1.2 +++ dbus/dbus-userdb.h 26 Nov 2003 10:20:19 -0000 @@ -31,7 +31,7 @@ DBUS_BEGIN_DECLS; typedef struct DBusUserDatabase DBusUserDatabase; DBusUserDatabase* _dbus_user_database_new (void); -void _dbus_user_database_ref (DBusUserDatabase *db); +DBusUserDatabase* _dbus_user_database_ref (DBusUserDatabase *db); void _dbus_user_database_unref (DBusUserDatabase *db); dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db, dbus_uid_t uid, Index: dbus/dbus-watch.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-watch.c,v retrieving revision 1.14 diff -u -b -B -p -r1.14 dbus-watch.c --- dbus/dbus-watch.c 30 Sep 2003 02:32:53 -0000 1.14 +++ dbus/dbus-watch.c 26 Nov 2003 10:20:19 -0000 @@ -97,11 +97,14 @@ _dbus_watch_new (int fd, * Increments the reference count of a DBusWatch object. * * @param watch the watch object. + * @returns the watch object. */ -void +DBusWatch * _dbus_watch_ref (DBusWatch *watch) { watch->refcount += 1; + + return watch; } /** Index: dbus/dbus-watch.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-watch.h,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-watch.h --- dbus/dbus-watch.h 18 Apr 2003 04:18:57 -0000 1.4 +++ dbus/dbus-watch.h 26 Nov 2003 10:20:19 -0000 @@ -42,7 +42,7 @@ DBusWatch* _dbus_watch_new DBusWatchHandler handler, void *data, DBusFreeFunction free_data_function); -void _dbus_watch_ref (DBusWatch *watch); +DBusWatch* _dbus_watch_ref (DBusWatch *watch); void _dbus_watch_unref (DBusWatch *watch); void _dbus_watch_invalidate (DBusWatch *watch); void _dbus_watch_sanitize_condition (DBusWatch *watch, Index: glib/dbus-gidl.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gidl.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gidl.c --- glib/dbus-gidl.c 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gidl.c 26 Nov 2003 10:20:19 -0000 @@ -67,13 +67,15 @@ struct ArgInfo ArgDirection direction; }; -void +BaseInfo * base_info_ref (BaseInfo *info) { g_return_if_fail (info != NULL); g_return_if_fail (info->refcount > 0); info->refcount += 1; + + return info; } static void @@ -222,10 +224,12 @@ node_info_new (const char *name) return info; } -void +NodeInfo * node_info_ref (NodeInfo *info) { info->base.refcount += 1; + + return info; } void @@ -287,10 +291,12 @@ interface_info_new (const char *name) return info; } -void +InterfaceInfo * interface_info_ref (InterfaceInfo *info) { info->base.refcount += 1; + + return info; } void @@ -366,10 +372,12 @@ method_info_new (const char *name) return info; } -void +MethodInfo * method_info_ref (MethodInfo *info) { info->base.refcount += 1; + + return info; } void @@ -416,10 +425,12 @@ signal_info_new (const char *name) return info; } -void +SignalInfo * signal_info_ref (SignalInfo *info) { info->base.refcount += 1; + + return info; } void @@ -472,10 +483,12 @@ arg_info_new (const char *name, return info; } -void +ArgInfo * arg_info_ref (ArgInfo *info) { info->base.refcount += 1; + + return info; } void Index: glib/dbus-gidl.h =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gidl.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gidl.h --- glib/dbus-gidl.h 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gidl.h 26 Nov 2003 10:20:19 -0000 @@ -54,7 +54,7 @@ typedef enum } InfoType; -void base_info_ref (BaseInfo *info); +BaseInfo* base_info_ref (BaseInfo *info); void base_info_unref (BaseInfo *info); InfoType base_info_get_type (BaseInfo *info); const char* base_info_get_name (BaseInfo *info); @@ -65,7 +65,7 @@ GType base_info_get_gtype NodeInfo* node_info_new (const char *name); -void node_info_ref (NodeInfo *info); +NodeInfo* node_info_ref (NodeInfo *info); void node_info_unref (NodeInfo *info); const char* node_info_get_name (NodeInfo *info); GSList* node_info_get_interfaces (NodeInfo *info); @@ -76,7 +76,7 @@ void node_info_add_node NodeInfo *child); InterfaceInfo* interface_info_new (const char *name); -void interface_info_ref (InterfaceInfo *info); +InterfaceInfo* interface_info_ref (InterfaceInfo *info); void interface_info_unref (InterfaceInfo *info); const char* interface_info_get_name (InterfaceInfo *info); GSList* interface_info_get_methods (InterfaceInfo *info); @@ -87,7 +87,7 @@ void interface_info_add_signal SignalInfo *signal); MethodInfo* method_info_new (const char *name); -void method_info_ref (MethodInfo *info); +MethodInfo* method_info_ref (MethodInfo *info); void method_info_unref (MethodInfo *info); const char* method_info_get_name (MethodInfo *info); @@ -96,7 +96,7 @@ void method_info_add_arg ArgInfo *arg); SignalInfo* signal_info_new (const char *name); -void signal_info_ref (SignalInfo *info); +SignalInfo* signal_info_ref (SignalInfo *info); void signal_info_unref (SignalInfo *info); const char* signal_info_get_name (SignalInfo *info); @@ -107,7 +107,7 @@ void signal_info_add_arg ArgInfo* arg_info_new (const char *name, ArgDirection direction, int type); -void arg_info_ref (ArgInfo *info); +ArgInfo* arg_info_ref (ArgInfo *info); void arg_info_unref (ArgInfo *info); const char* arg_info_get_name (ArgInfo *info); int arg_info_get_type (ArgInfo *info); Index: glib/dbus-gmain.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gmain.c,v retrieving revision 1.25 diff -u -b -B -p -r1.25 dbus-gmain.c --- glib/dbus-gmain.c 12 Oct 2003 05:59:39 -0000 1.25 +++ glib/dbus-gmain.c 26 Nov 2003 10:20:19 -0000 @@ -88,10 +88,12 @@ watch_fd_new (void) return watch_fd; } -static void +static WatchFD * watch_fd_ref (WatchFD *watch_fd) { watch_fd->refcount += 1; + + return watch_fd; } static void Index: glib/dbus-gparser.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gparser.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gparser.c --- glib/dbus-gparser.c 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gparser.c 26 Nov 2003 10:20:19 -0000 @@ -184,10 +184,12 @@ parser_new (void) return parser; } -void +Parser * parser_ref (Parser *parser) { parser->refcount += 1; + + return parser; } void Index: glib/dbus-gparser.h =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gparser.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gparser.h --- glib/dbus-gparser.h 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gparser.h 26 Nov 2003 10:20:19 -0000 @@ -32,7 +32,7 @@ G_BEGIN_DECLS typedef struct Parser Parser; Parser* parser_new (void); -void parser_ref (Parser *parser); +Parser* parser_ref (Parser *parser); void parser_unref (Parser *parser); gboolean parser_check_doctype (Parser *parser, const char *doctype, Index: glib/dbus-gproxy.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gproxy.c,v retrieving revision 1.6 diff -u -b -B -p -r1.6 dbus-gproxy.c --- glib/dbus-gproxy.c 21 Oct 2003 05:46:52 -0000 1.6 +++ glib/dbus-gproxy.c 26 Nov 2003 10:20:19 -0000 @@ -93,7 +93,7 @@ struct DBusGProxyManager }; -static void dbus_gproxy_manager_ref (DBusGProxyManager *manager); +static DBusGProxyManager *dbus_gproxy_manager_ref (DBusGProxyManager *manager); static DBusHandlerResult dbus_gproxy_manager_filter (DBusConnection *connection, DBusMessage *message, void *user_data); @@ -152,7 +152,7 @@ dbus_gproxy_manager_get (DBusConnection return manager; } -static void +static DBusGProxyManager * dbus_gproxy_manager_ref (DBusGProxyManager *manager) { g_assert (manager != NULL); @@ -163,6 +163,8 @@ dbus_gproxy_manager_ref (DBusGProxyManag manager->refcount += 1; UNLOCK_MANAGER (manager); + + return manager; } static void --=-WnuRFg0Sci+c8D6sLmHI-- From micke@imendio.com Thu Nov 27 01:29:48 2003 From: micke@imendio.com (Mikael Hallendal) Date: Thu, 27 Nov 2003 02:29:48 +0100 Subject: Bug in the boxing of DBusMessage in Glib layer In-Reply-To: <1069842910.14302.16.camel@chili.home.hallendal.net> References: <1069415140.20885.8.camel@chili.home.hallendal.net> <1069522717.24752.21.camel@localhost.localdomain> <1069842910.14302.16.camel@chili.home.hallendal.net> Message-ID: <1069896588.2365.51.camel@chili.home.hallendal.net> ons 2003-11-26 klockan 11.35 skrev Mikael Hallendal: > Patch that make all (I hope) _ref() functions return the pointer. Commited after approval from Havoc. Cheers, Mikael Hallendal -- Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 From richard@imendio.com Sun Nov 30 15:58:22 2003 From: richard@imendio.com (Richard Hult) Date: Sun, 30 Nov 2003 16:58:22 +0100 Subject: Dict in dict bug Message-ID: <1070207901.7273.20.camel@carrot> --=-637lgiX7YncIj0Pb8DMo Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Currently, you can't put a dict inside a dict, since iter->wrote_dict_key isn't reset like when appending other types to a dict. The attached patch fixes that, and adds a test case for the bug. Does it look OK? /Richard --=-637lgiX7YncIj0Pb8DMo Content-Disposition: attachment; filename=dict-in-dict.patch Content-Type: text/x-patch; name=dict-in-dict.patch; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.443 diff -u -b -B -p -r1.443 ChangeLog --- ChangeLog 27 Nov 2003 01:25:49 -0000 1.443 +++ ChangeLog 30 Nov 2003 15:57:42 -0000 @@ -1,3 +1,13 @@ +2003-11-30 Richard Hult + + * dbus/dbus-message.c (dbus_message_iter_append_dict): Set + wrote_dict_key to FALSE on the iter that the dict is appended to, + just like when appending other types. Fixes a bug where a dict + couldn't be put inside a dict. + (dbus_message_iter_append_dict_key): Fix typo in warning message. + (message_iter_test, _dbus_message_test): Add test case for dict + inside dict. + 2003-11-26 Mikael Hallendal * bus/*.[ch]: Index: dbus/dbus-message.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v retrieving revision 1.115 diff -u -b -B -p -r1.115 dbus-message.c --- dbus/dbus-message.c 27 Nov 2003 01:25:49 -0000 1.115 +++ dbus/dbus-message.c 30 Nov 2003 15:57:42 -0000 @@ -3874,7 +3874,7 @@ dbus_message_iter_append_dict_key (DBusM if (real->wrote_dict_key) { - _dbus_warn ("Appendinging multiple dict key names\n"); + _dbus_warn ("Appending multiple dict key names\n"); return FALSE; } @@ -4082,6 +4082,8 @@ dbus_message_iter_append_dict (DBusMessa dbus_message_iter_append_done (dict_real); + real->wrote_dict_key = FALSE; + return TRUE; } @@ -5800,7 +5802,7 @@ dbus_message_type_from_string (const cha static void message_iter_test (DBusMessage *message) { - DBusMessageIter iter, dict, array, array2; + DBusMessageIter iter, dict, dict2, array, array2; char *str; unsigned char *data; dbus_int32_t *our_int_array; @@ -5899,6 +5900,32 @@ message_iter_test (DBusMessage *message) if (dbus_message_iter_get_uint32 (&dict) != 0xDEADBEEF) _dbus_assert_not_reached ("wrong dict entry value"); + /* dict (in dict) */ + + if (!dbus_message_iter_next (&dict)) + _dbus_assert_not_reached ("reached end of dict"); + + if (dbus_message_iter_get_arg_type (&dict) != DBUS_TYPE_DICT) + _dbus_assert_not_reached ("not dict type"); + + dbus_message_iter_init_dict_iterator (&dict, &dict2); + + str = dbus_message_iter_get_dict_key (&dict2); + if (str == NULL || strcmp (str, "dictkey") != 0) + _dbus_assert_not_reached ("wrong dict key"); + dbus_free (str); + + if (dbus_message_iter_get_arg_type (&dict2) != DBUS_TYPE_STRING) + _dbus_assert_not_reached ("wrong dict entry type"); + + str = dbus_message_iter_get_string (&dict2); + if (str == NULL || strcmp (str, "dictvalue") != 0) + _dbus_assert_not_reached ("wrong dict entry value"); + dbus_free (str); + + if (dbus_message_iter_next (&dict2)) + _dbus_assert_not_reached ("didn't reach end of dict"); + if (!dbus_message_iter_next (&dict)) _dbus_assert_not_reached ("reached end of dict"); @@ -7107,6 +7135,13 @@ _dbus_message_test (const char *test_dat dbus_message_iter_append_dict_key (&child_iter, "test"); dbus_message_iter_append_uint32 (&child_iter, 0xDEADBEEF); + /* dict (in dict) */ + dbus_message_iter_append_dict_key (&child_iter, "testdict"); + dbus_message_iter_append_dict (&child_iter, &child_iter2); + + dbus_message_iter_append_dict_key (&child_iter2, "dictkey"); + dbus_message_iter_append_string (&child_iter2, "dictvalue"); + /* array of array of int32 (in dict) */ dbus_message_iter_append_dict_key (&child_iter, "array"); dbus_message_iter_append_array (&child_iter, &child_iter2, DBUS_TYPE_ARRAY); --=-637lgiX7YncIj0Pb8DMo-- From hp@redhat.com Sun Nov 30 18:32:31 2003 From: hp@redhat.com (Havoc Pennington) Date: Sun, 30 Nov 2003 13:32:31 -0500 Subject: Dict in dict bug In-Reply-To: <1070207901.7273.20.camel@carrot> References: <1070207901.7273.20.camel@carrot> Message-ID: <1070217151.4479.50.camel@localhost.localdomain> On Sun, 2003-11-30 at 10:58, Richard Hult wrote: > Hi, > > Currently, you can't put a dict inside a dict, since > iter->wrote_dict_key isn't reset like when appending other types to a > dict. The attached patch fixes that, and adds a test case for the bug. > > Does it look OK? > Looks sane, thanks. Havoc From sk@sethwklein.net Sat Nov 1 02:22:58 2003 From: sk@sethwklein.net (Seth W. Klein) Date: Fri, 31 Oct 2003 21:22:58 -0500 Subject: HTML of D-BUS man pages Message-ID: <20031101022258.GA23975@bubook.sethwklein.net> On http://www.freedesktop.org/Software/dbus there are several links to man pages. They all go to a page that says: Someone tell me how to convert a man page to html on Debian, Red Hat 'man' package has a man2html, Debian man2html package is some sort of CGI script Answer: groff -man -Thtml foo.1 >foo.1.html I've put the resulting HTML for D-BUS's pages up at http://www.freedesktop.org/~sk/ A script to create the HTML is also there. It uses the pages from the most recent dbus release tarball it can find. cheers, Seth W. "Jzalae" Klein -- sk@sethwklein.net http://www.sethwklein.net/ From hp@redhat.com Sat Nov 1 06:01:13 2003 From: hp@redhat.com (Havoc Pennington) Date: Sat, 01 Nov 2003 01:01:13 -0500 Subject: HTML of D-BUS man pages In-Reply-To: <20031101022258.GA23975@bubook.sethwklein.net> References: <20031101022258.GA23975@bubook.sethwklein.net> Message-ID: <1067666473.19882.6.camel@localhost.localdomain> On Fri, 2003-10-31 at 21:22, Seth W. Klein wrote: > Answer: groff -man -Thtml foo.1 >foo.1.html > Thanks much, the cron job on freedesktop.org is now fixed so the man page links work. Havoc From willem.dantuma@dobs.nl Sun Nov 2 11:21:02 2003 From: willem.dantuma@dobs.nl (Willem Dantuma) Date: 02 Nov 2003 12:21:02 +0100 Subject: Delayed authentication Message-ID: <1067772061.2482.9.camel@wodan.dobs.nl> --=-4XSEb5XKy0ef8HIOY0XW Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi I'am still working ( on and of, my time is very limited ) on enabling SASL authentication in D-Bus. It's almost functional, but now i need a way to delay the authentication process, right now it is started during a dbus_connection_open but i want to be able do someting like this: conn = dbus_connection_open(..) dbus_connection_set_username(conn,..) dbus_connection_set_password(conn,..) dbus_connection_set_sasl_prop(conn,...) dbus_connection_start(conn) Any Ideas how to accomplish this. Willem Dantuma --=-4XSEb5XKy0ef8HIOY0XW Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi

I'am still working ( on and of, my time is very limited ) on enabling SASL authentication in D-Bus. It's almost functional, but now i need a way to delay the authentication process, right now it is started during a dbus_connection_open but i want to be able do someting like this:

conn = dbus_connection_open(..)
dbus_connection_set_username(conn,..)
dbus_connection_set_password(conn,..)
dbus_connection_set_sasl_prop(conn,...)
dbus_connection_start(conn)

Any Ideas how to accomplish this.



Willem Dantuma

--=-4XSEb5XKy0ef8HIOY0XW-- From murrayc@usa.net Thu Nov 6 19:19:37 2003 From: murrayc@usa.net (Murray Cumming) Date: Thu, 06 Nov 2003 20:19:37 +0100 Subject: C++ bindings Message-ID: <1068146377.2173.61.camel@localhost.localdomain> I'm playing around at doing some DBUS C++ bindings. Do you really want to ship bindings with DBUS itself? If you do, then I'll probably need to put them under the dbus directory, e.g. dbus/dbus/C sources dbus/dbus/cpp/C++ bindings or put dbus in the name, unlike the other bindings. e.g. dbus/dbus/C sources dbus/dbus-cpp/C++ bindings. This will allow my headers to use a full path in #includes. Do you have a preference? -- Murray Cumming murrayc@usa.net www.murrayc.com From hp@redhat.com Thu Nov 6 19:29:51 2003 From: hp@redhat.com (Havoc Pennington) Date: Thu, 06 Nov 2003 14:29:51 -0500 Subject: C++ bindings In-Reply-To: <1068146377.2173.61.camel@localhost.localdomain> References: <1068146377.2173.61.camel@localhost.localdomain> Message-ID: <1068146991.4591.44.camel@localhost.localdomain> On Thu, 2003-11-06 at 14:19, Murray Cumming wrote: > I'm playing around at doing some DBUS C++ bindings. > > Do you really want to ship bindings with DBUS itself? It's up to you. Since people would be downloading gtkmm stuff already, maybe shipping it with that makes more sense (I don't mean same tarball, just same ftp site, etc.) > If you do, then > I'll probably need to put them under the dbus directory, e.g. > dbus/dbus/C sources > dbus/dbus/cpp/C++ bindings > or put dbus in the name, unlike the other bindings. e.g. > dbus/dbus/C sources > dbus/dbus-cpp/C++ bindings. > This will allow my headers to use a full path in #includes. Do you have > a preference? Could you do cxx/dbus/dbus.h perhaps? cpp means "C preprocessor" to me but maybe not to others. I would suggest you probably want to do some code generation, and you could use the same code generator as dbus-glib. (Though this generator is not really written, it's half-started-on.) By code generation I mean either IDL -> sourcecode (CORBA model), or sourcecode -> IDL -> typelib (moc/DCOP model). Or IDL -> typelib perhaps, if you want to make people do more typing. Havoc From hp@redhat.com Fri Nov 7 14:34:30 2003 From: hp@redhat.com (Havoc Pennington) Date: 07 Nov 2003 09:34:30 -0500 Subject: C++ bindings In-Reply-To: <258B0164D480D5118D900800062B385801840B76@vihsx09a.vih.infineon.com> References: <258B0164D480D5118D900800062B385801840B76@vihsx09a.vih.infineon.com> Message-ID: <1068215670.1662.26.camel@dhcppc3> On Fri, 2003-11-07 at 09:08, Murray.Cumming@Comneon.com wrote: > I'll definitely keep that in mind, but what I've seen so far suggests that > there will be too many special cases. However, I have only explored a > fraction of the API and I don't think I've fully understood everything yet. I'm not saying autogen the bindings. I'm saying the way people would _use_ the bindings may involve generating code, as it does for CORBA or DCOP or the GLib bindings. > I'm in no rush personally, but I'll try to put some crap in cvs so that > others can look at it. Would you like me to put my crap in the freedesktop > cvs or GNOME's? It's up to you, if the bindings are generic C++ the freedesktop cvs probably makes sense. > > By code generation I mean either IDL -> sourcecode (CORBA model), or > > sourcecode -> IDL -> typelib (moc/DCOP model). Or IDL -> > > typelib perhaps, if you want to make people do more typing. > > Thanks for the tip. I didn't realise that the glib bindings were generated. They aren't, but the idea is that application code would (partially) be. Specifically what the generator would create is a metadata blob in the form of a static variable. You then #include this blob in your GObject subclass implementation and it allows the glib bindings to type-safely dynamically marshal methods on your object when dbus messages are received. This isn't implemented yet, though. It's the way the DCOP/Qt stuff works. There are some messages in the archives discussing this more IIRC. > I'll be trying to wrap the lower level API as well as creating a higher > level API like in the python bindings. The lower level API is designed almost purely for the use of bindings; wrapping the main loop glue (DBusWatch, connection_set_watch_functions) and the object data set/getters is probably pointless bloat/confusion in your binding API. Havoc From hp@redhat.com Sat Nov 8 01:24:56 2003 From: hp@redhat.com (Havoc Pennington) Date: 07 Nov 2003 20:24:56 -0500 Subject: C++ bindings In-Reply-To: <258B0164D480D5118D900800062B385801840B83@vihsx09a.vih.infineon.com> References: <258B0164D480D5118D900800062B385801840B83@vihsx09a.vih.infineon.com> Message-ID: <1068254696.2242.0.camel@dhcppc3> On Fri, 2003-11-07 at 11:36, Murray.Cumming@Comneon.com wrote: > Yes, I'm not planning any dependencies on glibmm or libsigc++, for instance. > Can you fix me up with a cvs account? However, I'm not likely to put > anything in cvs for a couple of weeks. An account is easy, sure. I just need the name of your project to create the CVSROOT, preferred login name, and an ssh v2 public key. Havoc From Murray.Cumming@Comneon.com Fri Nov 7 16:36:18 2003 From: Murray.Cumming@Comneon.com (Murray.Cumming@Comneon.com) Date: Fri, 7 Nov 2003 17:36:18 +0100 Subject: C++ bindings Message-ID: <258B0164D480D5118D900800062B385801840B83@vihsx09a.vih.infineon.com> > From: Havoc Pennington [mailto:hp@redhat.com] > > I'm in no rush personally, but I'll try to put some crap in cvs so > > that others can look at it. Would you like me to put my crap in the > > freedesktop cvs or GNOME's? > > It's up to you, if the bindings are generic C++ the > freedesktop cvs probably makes sense. Yes, I'm not planning any dependencies on glibmm or libsigc++, for instance. Can you fix me up with a cvs account? However, I'm not likely to put anything in cvs for a couple of weeks. > > > By code generation I mean either IDL -> sourcecode (CORBA > model), or > > > sourcecode -> IDL -> typelib (moc/DCOP model). Or IDL -> > > > typelib perhaps, if you want to make people do more typing. > > > > Thanks for the tip. I didn't realise that the glib bindings were > > generated. > > They aren't, but the idea is that application code would > (partially) be. Oh, I see. I've tried not to think about the IDL issue, because code-generation is so unpleasant even with CORBA. I'm personally interested in dbus for very simple message passing and notification. So if I don't do the IDL stuff then hopefully someone else can do it on top of my bindings. > Specifically what the generator would create > is a metadata blob in the form of a static variable. You then > #include this blob in your GObject subclass implementation > and it allows the glib bindings to type-safely dynamically > marshal methods on your object when dbus messages are received. > > This isn't implemented yet, though. It's the way the DCOP/Qt > stuff works. > > There are some messages in the archives discussing this more IIRC. Cheers. > > I'll be trying to wrap the lower level API as well as creating a > > higher level API like in the python bindings. > > The lower level API is designed almost purely for the use of > bindings; > wrapping the main loop glue (DBusWatch, > connection_set_watch_functions) and the object data > set/getters is probably pointless bloat/confusion in your binding API. Cheers again. Murray Cumming www.murrayc.com murrayc@usa.net From willem.dantuma@dobs.nl Sun Nov 9 10:18:32 2003 From: willem.dantuma@dobs.nl (Willem Dantuma) Date: 09 Nov 2003 11:18:32 +0100 Subject: Proposed API Change ( was delayed authentication ) In-Reply-To: <1067772061.2482.9.camel@wodan.dobs.nl> References: <1067772061.2482.9.camel@wodan.dobs.nl> Message-ID: <1068373037.2094.32.camel@wodan.dobs.nl> Hi, After not getting much response to my previous mail, i dug into it myself and found dbus_bus_get blocking in dbus_bus_register. So i would like to propose a change to the curent API. Something like this: conn=dbus_bus_get(DBUS_BUS_ACTIVATION,&error) or conn=dbus_connection_open(address,&error) dbus_connection_set_username(&conn,username) dbus_connection_set_password(&conn,password) dbus_connection_set_sasl_prop(&conn,...) ...... dbus_connection_start(&conn) /* takes care of authenticating, TLS etc */ dbus_bus_register(&conn) or maybe in the bus case: conn=dbus_bus_get(DBUS_BUS_ACTIVATION,&error,argv,argc) Comments ?? Willem On Sun, 2003-11-02 at 12:21, Willem Dantuma wrote: > Hi > > I'am still working ( on and of, my time is very limited ) on enabling > SASL authentication in D-Bus. It's almost functional, but now i need a > way to delay the authentication process, right now it is started > during a dbus_connection_open but i want to be able do someting like > this: > > conn = dbus_connection_open(..) > dbus_connection_set_username(conn,..) > dbus_connection_set_password(conn,..) > dbus_connection_set_sasl_prop(conn,...) > dbus_connection_start(conn) > > Any Ideas how to accomplish this. > > > > Willem Dantuma From hp@redhat.com Sun Nov 9 15:05:24 2003 From: hp@redhat.com (Havoc Pennington) Date: 09 Nov 2003 10:05:24 -0500 Subject: Proposed API Change ( was delayed authentication ) In-Reply-To: <1068373037.2094.32.camel@wodan.dobs.nl> References: <1067772061.2482.9.camel@wodan.dobs.nl> <1068373037.2094.32.camel@wodan.dobs.nl> Message-ID: <1068390323.3449.70.camel@dhcppc3> On Sun, 2003-11-09 at 05:18, Willem Dantuma wrote: > After not getting much response to my previous mail, i dug into it > myself and found dbus_bus_get blocking in dbus_bus_register. So i would > like to propose a change to the curent API. Your previous mail is not in my message-bus-list folder, fwiw. If it's in the archives maybe my mail setup ate it somehow. Note that if you dbus_connection_open(), no IO is intended to take place immediately (the function should be nonblocking), only the socket setup will happen. So in principle you could set up the auth details after that. However, where does your password come from? It seems to me that it has to come from a dialog with the user, only when a password is actually required. So this would mean that after deciding on a mechanism that requires a password, dbus would have to call back to the app and get it to open an auth dialog. The app couldn't unconditionally ask the user for all possible passwords. So the API we need would be some type of dbus_connection_set_auth_functions() or something like that. Havoc From hp@redhat.com Mon Nov 10 01:57:55 2003 From: hp@redhat.com (Havoc Pennington) Date: Sun, 09 Nov 2003 20:57:55 -0500 Subject: Proposed API Change ( was delayed authentication ) In-Reply-To: <1068397303.3236.28.camel@wodan.dobs.nl> References: <1067772061.2482.9.camel@wodan.dobs.nl> <1068373037.2094.32.camel@wodan.dobs.nl> <1068390323.3449.70.camel@dhcppc3> <1068397303.3236.28.camel@wodan.dobs.nl> Message-ID: <1068429475.4531.12.camel@localhost.localdomain> On Sun, 2003-11-09 at 12:01, Willem Dantuma wrote: > This is the way i was doing it, it only didn't work in my test with > dbus_monitor ( which is calling dbus_bus_get ). Right, dbus_bus_get() does some round trip messages to register with the bus and blocks for that reason. > Actually i'am using sasl callbacks internally allready for username and > password, i only think the need to provide callback functions doesn't > simplify the API and that's exactly what youre trying to do with the > dbus_bus_get wrapper. > > But i'am happy to implement it that way I'm all for simplifying the API, but the API still has to do the job, right? Havoc From hp@redhat.com Tue Nov 11 01:06:44 2003 From: hp@redhat.com (Havoc Pennington) Date: Mon, 10 Nov 2003 20:06:44 -0500 Subject: AFL 2.0 license change In-Reply-To: <1068484223.2689.315.camel@chili.home.hallendal.net> References: <1064087000.604.37.camel@dhcppc3> <1068484223.2689.315.camel@chili.home.hallendal.net> Message-ID: <1068512804.5225.5.camel@localhost.localdomain> On Mon, 2003-11-10 at 12:10, Mikael Hallendal wrote: > What happened to this. The COPYING files says version 2.0 but all source > files still says 1.2. Someone we are still waiting for to reply? No, I just forgot to do the sed job yet. Havoc From david@fubar.dk Tue Nov 11 20:12:09 2003 From: david@fubar.dk (David Zeuthen) Date: Tue, 11 Nov 2003 21:12:09 +0100 Subject: Python signals Message-ID: <1068581528.2972.3.camel@laptop.fubar.dk> Hi, Below very small patch to let D-BUS signal handlers in python chew on the message and extract the parameters, since we allow signals to carry parameters, yes? Ok to commit? Thanks, David Index: dbus.py =================================================================== RCS file: /cvs/dbus/dbus/python/dbus.py,v retrieving revision 1.2 diff -u -r1.2 dbus.py --- dbus.py 30 Sep 2003 02:40:49 -0000 1.2 +++ dbus.py 11 Nov 2003 20:07:43 -0000 @@ -103,7 +103,7 @@ if (self._match_rule_to_receivers.has_key(match_rule)): receivers = self._match_rule_to_receivers[match_rule] - args = [interface, member, service, path] + args = [interface, member, service, path, message] for receiver in receivers: receiver(*args) From solca@guug.org Thu Nov 13 22:18:09 2003 From: solca@guug.org (Otto Solares) Date: Thu, 13 Nov 2003 16:18:09 -0600 Subject: dbus basic question Message-ID: <20031113221809.GB6200@guug.org> Hi! I want to use dbus to implement messaging in my gpl desktop project. I don't use X in any way but i would like to support Keith Packard's kdrive server if i am able to compile it without input, nor fonts, just server and dri/glx extensions. I have read dbus's specs and the (unfinished) tutorial and have no clue where to begin, someone could point me to a simple example? i want to integrate dbus in the main loop. This is my server organization: -Input using input layer from 2.6 on a separate thread. -Sound using openal via alsa on a separate thread. -Graphics using fbdev/dri standalone mesa on separates threads each different thread for different gl capable card. -Network using separate thread for listening to remote clients. -System bus thread. As you can see my server is heavily threaded and my objective is async subsystem handling, threads allow me to simplify my code a lot and i don't note any slowdown at all, it's pretty fast. Currently, threads communication are handled via pointers to shared memory and posix locking. I think that the proper use of dbus will allow me to simplify the subsystem's comm routines. The question is: does dbus will be overkill for thread communication? I don't want systemwide comm, just comm in the same process. Another point is that the last threads are precisely for system notifications and client comm, obviously that is the primary task for dbus (i suppose), does hotplug and init rc.d scripts will talk to dbus so projects like mine will benefit for listening to system events? Is any project out there with this objective in mind? One last thing: i am currently using epoll sets for listening to network and system devices nodes, does dbus uses epoll sets for eficient polling of file descriptors in the current implementation? I know i ask too many questions but i am really impressed with dbus objectives and i am pretty confident that it will help me in my needs if i just manage to get started with it. TIA, -solca From lutchann-dbuslist@litech.org Sat Nov 15 21:09:54 2003 From: lutchann-dbuslist@litech.org (Nathan Lutchansky) Date: Sat, 15 Nov 2003 16:09:54 -0500 Subject: Using debug-pipe connections in real apps Message-ID: <20031115210954.GB18377@litech.org> --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi all, I'm writing a server app that uses DBus for IPC, and I need to be able to create DBus connections between the supervisor process and the forked worker processes. Right now I'm doing this by creating a DBusServer with a UNIX socket for the supervisor and having each worker open a DBusConnection to it, but it would make more sense and be more secure to create "connection pairs" with sockets that are only created internally. I see that DBus uses "debug-pipe" connetions for build tests, which are created using socketpair. This is exactly what I'd like to use in my app, but it seems limited to DBus internal debugging. Could this type of connection be promoted to a fully-supported DBus feature? -Nathan --=20 *** Help filter spam! PGP-sign your email. *** Expand your PGP Web of Trust with http://www.biglumber.com/ --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/tpYiTviDkW8mhycRAiAhAJ9orbdQyf42bD0kgAZvUdRvXsl6LwCggGTs IYShdr/ROQafKUEdMexJyh8= =Z3Mr -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4-- From hp@redhat.com Mon Nov 17 23:18:06 2003 From: hp@redhat.com (Havoc Pennington) Date: Mon, 17 Nov 2003 18:18:06 -0500 Subject: Using debug-pipe connections in real apps In-Reply-To: <20031115210954.GB18377@litech.org> References: <20031115210954.GB18377@litech.org> Message-ID: <1069111086.7144.1.camel@localhost.localdomain> On Sat, 2003-11-15 at 16:09, Nathan Lutchansky wrote: > I see that DBus uses "debug-pipe" connetions for build tests, which are > created using socketpair. This is exactly what I'd like to use in my app, > but it seems limited to DBus internal debugging. Could this type of > connection be promoted to a fully-supported DBus feature? -Nathan I don't see why not; seems pretty straightforward. Maybe just rename the method to "pipe" instead of "debug-pipe" and build it even with tests disabled? Havoc From lutchann-dbuslist@litech.org Mon Nov 17 23:37:56 2003 From: lutchann-dbuslist@litech.org (Nathan Lutchansky) Date: Mon, 17 Nov 2003 18:37:56 -0500 Subject: Using debug-pipe connections in real apps In-Reply-To: <1069111086.7144.1.camel@localhost.localdomain> References: <20031115210954.GB18377@litech.org> <1069111086.7144.1.camel@localhost.localdomain> Message-ID: <20031117233755.GC18377@litech.org> --tjCHc7DPkfUGtrlw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 17, 2003 at 06:18:06PM -0500, Havoc Pennington wrote: > On Sat, 2003-11-15 at 16:09, Nathan Lutchansky wrote: > > I see that DBus uses "debug-pipe" connetions for build tests, which are > > created using socketpair. This is exactly what I'd like to use in my a= pp, > > but it seems limited to DBus internal debugging. Could this type of > > connection be promoted to a fully-supported DBus feature? -Nathan >=20 > I don't see why not; seems pretty straightforward. Maybe just rename the > method to "pipe" instead of "debug-pipe" and build it even with tests > disabled? OK then, if it sounds acceptable to you, I'll make a patch as soon as I=20 move from dbus-0.13 to current CVS. Thanks! -Nathan --=20 *** Help filter spam! PGP-sign your email. *** Expand your PGP Web of Trust with http://www.biglumber.com/ --tjCHc7DPkfUGtrlw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE/uVvTTviDkW8mhycRAsYUAJ9w1Spi4/LstpXKoI7/pt0B9ZQ81gCfZ7vJ q3pWo2qpARayHCtKK4zWNqM= =2Mi3 -----END PGP SIGNATURE----- --tjCHc7DPkfUGtrlw-- From hp@redhat.com Wed Nov 19 21:56:07 2003 From: hp@redhat.com (Havoc Pennington) Date: Wed, 19 Nov 2003 16:56:07 -0500 Subject: 0.20 released Message-ID: <1069278967.17309.40.camel@localhost.localdomain> Hi, I made a release of the current cvs D-BUS. http://pdx.freedesktop.org/Software/dbus Havoc From willem.dantuma@dobs.nl Thu Nov 20 00:52:17 2003 From: willem.dantuma@dobs.nl (Willem Dantuma) Date: 20 Nov 2003 01:52:17 +0100 Subject: SASL implementation Message-ID: <1069289536.3166.14.camel@wodan.dobs.nl> --=-CztVctplTNL1o+sia54b Content-Type: multipart/alternative; boundary="=-w1yXIDF+g/FS3SYYLr3u" --=-w1yXIDF+g/FS3SYYLr3u Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Well here it is my first shot at the sasl implementation of DBusAuth, i only tested it with the sasl PLAIN method so far. It still needs a major cleanup and some function reshuffeling. This implementation merges the existing two authentication methods with all possible sasl methods, the dbus_connection_set_get_password_function and dbus_connection_set_get_username_function where added to the api to set the callback funtions used to promt for the username and password ( if needed ). dbus-monitor and dbus-send still needs to be modified to support this but these are waiting for the change of dbus_bus_get which i have not done yet. Willem Dantuma --=-w1yXIDF+g/FS3SYYLr3u Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi,

Well here it is my first shot at the sasl implementation of DBusAuth, i only tested it with the sasl PLAIN method so far.

It still needs a major cleanup and some function reshuffeling.

This implementation merges the existing two authentication methods with all possible sasl methods, the dbus_connection_set_get_password_function and dbus_connection_set_get_username_function where added to the api to set the callback funtions used to promt for the username and password ( if needed ).

dbus-monitor and dbus-send still needs to be modified to support this but these are waiting for the change of dbus_bus_get which i have not done yet.


Willem Dantuma --=-w1yXIDF+g/FS3SYYLr3u-- --=-CztVctplTNL1o+sia54b Content-Disposition: attachment; filename=dbus-sasl.diff Content-Type: text/x-patch; name=dbus-sasl.diff; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.438 diff -u -p -r1.438 ChangeLog --- ChangeLog 19 Nov 2003 21:51:09 -0000 1.438 +++ ChangeLog 19 Nov 2003 23:36:28 -0000 @@ -1,3 +1,43 @@ +2003-11-19 Willem Dantuma + + * configure.in: add option and cheks for sasl + + * dbus/Makefile.am: add sasl libraries + + * dbus/dbus-auth.h: prototypes for the new functions + _dbus_auth_set_remote_ip, dbus_auth_set_local_ip, + _dbus_auth_set_host, _dbus_auth_set_get_username_function + and _dbus_auth_set_get_password_function + + * dbus/dbus-auth.c: fairly large change implementing the sasl stuff, + the two existing authentication mechanims are merged with the available + sasl mecanisms. Several new and modififications to existing functions + also added fields to the DBusAuth, DBusAuthClient and DBusAuthServer + structures facilitate all this. + + * dbus/dbus-connection.h: new functions + dbus_connection_set_get_username_function and + dbus_connection_set_get_password_function + + * dbus/dbus-connection.c: implementations + + * dbus/dbus-sysdeps.h: new functions + _dbus_transport_is_inet + _dbus_transport_get_local_ip and + _dbus_transport_get_remote_ip + + * dbus/dbus-sysdeps.c: implementations + + * dbus/dbus-transport-unix.c: modifications to + _dbus_transport_new_for_fd to add the remote_ip, local_ip and host + information to the DBusAuth class + + * dbus/dbus-transport.h: new functions + _dbus_transport_set_get_username_function and + _dbus_transport_set_get_password_function + + * dbus/dbus-transport.c: implementations + 2003-11-19 Havoc Pennington * NEWS: update Index: configure.in =================================================================== RCS file: /cvs/dbus/dbus/configure.in,v retrieving revision 1.76 diff -u -p -r1.76 configure.in --- configure.in 19 Nov 2003 21:51:09 -0000 1.76 +++ configure.in 19 Nov 2003 22:40:56 -0000 @@ -37,7 +37,7 @@ AC_ARG_ENABLE(abstract-sockets, [ --ena AC_ARG_ENABLE(gcj, [ --enable-gcj build gcj bindings],enable_gcj=$enableval,enable_gcj=no) AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings],enable_mono=$enableval,enable_mono=no) AC_ARG_ENABLE(python, [ --enable-python build python bindings],enable_python=$enableval,enable_python=auto) - +AC_ARG_ENABLE(sasl, [ --enable-sasl enable sasl authentication],enable_sasl=$enableval,enable_sasl=no) AC_ARG_WITH(xml, [ --with-xml=[libxml/expat] XML library to use]) AC_ARG_WITH(init-scripts, [ --with-init-scripts=[redhat] Style of init scripts to install]) @@ -670,6 +670,34 @@ dnl Qt flags AC_SUBST(DBUS_QT_CXXFLAGS) AC_SUBST(DBUS_QT_LIBS) + +### SASL detection +have_sasl=no + +AC_CHECK_HEADERS(sasl/sasl.h) + +if test $ac_cv_header_sasl_sasl_h = yes ; then + have_sasl=yes + AC_CHECK_LIB(sasl2, sasl_client_init, + [DBUS_SASL_LIBS="-lsasl2"],[have_sasl=no]) +fi + +if test x$enable_sasl = xyes; then + if test x$have_sasl = xno; then + AC_MSG_ERROR([SASL explicitly required, and SASL libraries not found]) + else + AC_DEFINE(HAVE_SASL,1,[define if you have sasl]) + fi +fi + +if test x$enable_sasl = xno; then + have_sasl=no; +fi + +AC_SUBST(DBUS_SASL_LIBS) + + + ### X11 detection AC_PATH_XTRA @@ -1019,6 +1047,7 @@ echo " Using XML parser: ${with_xml} Init scripts style: ${with_init_scripts} Abstract socket names: ${have_abstract_sockets} + SASL Authentication: ${enable_sasl} System bus socket: ${DBUS_SYSTEM_SOCKET} System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} System bus PID file: ${DBUS_SYSTEM_PID_FILE} Index: dbus/Makefile.am =================================================================== RCS file: /cvs/dbus/dbus/dbus/Makefile.am,v retrieving revision 1.58 diff -u -p -r1.58 Makefile.am --- dbus/Makefile.am 15 Oct 2003 21:09:40 -0000 1.58 +++ dbus/Makefile.am 19 Nov 2003 22:41:34 -0000 @@ -124,7 +124,9 @@ EXTRA_DIST=dbus-arch-deps.h.in ## and is only used for static linking within the dbus package. noinst_LTLIBRARIES=libdbus-convenience.la -libdbus_1_la_LIBADD= $(DBUS_CLIENT_LIBS) +libdbus_convenience_la_LIBADD= $(DBUS_SASL_LIBS) + +libdbus_1_la_LIBADD= $(DBUS_CLIENT_LIBS) ${DBUS_SASL_LIBS} ## don't export symbols that start with "_" (we use this ## convention for internal symbols) libdbus_1_la_LDFLAGS= -export-symbols-regex "^[^_].*" Index: dbus/dbus-auth.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.h,v retrieving revision 1.6 diff -u -p -r1.6 dbus-auth.h --- dbus/dbus-auth.h 1 Apr 2003 05:33:01 -0000 1.6 +++ dbus/dbus-auth.h 19 Nov 2003 22:41:52 -0000 @@ -2,6 +2,7 @@ /* dbus-auth.h Authentication * * Copyright (C) 2002 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -27,6 +28,7 @@ #include #include #include +#include DBUS_BEGIN_DECLS; @@ -42,39 +44,53 @@ typedef enum DBUS_AUTH_STATE_AUTHENTICATED } DBusAuthState; -DBusAuth* _dbus_auth_server_new (void); -DBusAuth* _dbus_auth_client_new (void); -void _dbus_auth_ref (DBusAuth *auth); -void _dbus_auth_unref (DBusAuth *auth); -dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, - const char **mechanisms); -DBusAuthState _dbus_auth_do_work (DBusAuth *auth); -dbus_bool_t _dbus_auth_get_bytes_to_send (DBusAuth *auth, - const DBusString **str); -void _dbus_auth_bytes_sent (DBusAuth *auth, - int bytes_sent); -void _dbus_auth_get_buffer (DBusAuth *auth, - DBusString **buffer); -void _dbus_auth_return_buffer (DBusAuth *auth, - DBusString *buffer, - int bytes_read); -void _dbus_auth_get_unused_bytes (DBusAuth *auth, - const DBusString **str); -void _dbus_auth_delete_unused_bytes (DBusAuth *auth); -dbus_bool_t _dbus_auth_needs_encoding (DBusAuth *auth); -dbus_bool_t _dbus_auth_encode_data (DBusAuth *auth, - const DBusString *plaintext, - DBusString *encoded); -dbus_bool_t _dbus_auth_needs_decoding (DBusAuth *auth); -dbus_bool_t _dbus_auth_decode_data (DBusAuth *auth, - const DBusString *encoded, - DBusString *plaintext); -void _dbus_auth_set_credentials (DBusAuth *auth, - const DBusCredentials *credentials); -void _dbus_auth_get_identity (DBusAuth *auth, - DBusCredentials *credentials); -dbus_bool_t _dbus_auth_set_context (DBusAuth *auth, - const DBusString *context); + +DBusAuth* _dbus_auth_server_new (void); +DBusAuth* _dbus_auth_client_new (void); +dbus_bool_t _dbus_auth_start (DBusAuth *auth); +void _dbus_auth_ref (DBusAuth *auth); +void _dbus_auth_unref (DBusAuth *auth); +dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, + const char **mechanisms); +DBusAuthState _dbus_auth_do_work (DBusAuth *auth); +dbus_bool_t _dbus_auth_get_bytes_to_send (DBusAuth *auth, + const DBusString **str); +void _dbus_auth_bytes_sent (DBusAuth *auth, + int bytes_sent); +void _dbus_auth_get_buffer (DBusAuth *auth, + DBusString **buffer); +void _dbus_auth_return_buffer (DBusAuth *auth, + DBusString *buffer, + int bytes_read); +void _dbus_auth_get_unused_bytes (DBusAuth *auth, + const DBusString **str); +void _dbus_auth_delete_unused_bytes (DBusAuth *auth); +dbus_bool_t _dbus_auth_needs_encoding (DBusAuth *auth); +dbus_bool_t _dbus_auth_encode_data (DBusAuth *auth, + const DBusString *plaintext, + DBusString *encoded); +dbus_bool_t _dbus_auth_needs_decoding (DBusAuth *auth); +dbus_bool_t _dbus_auth_decode_data (DBusAuth *auth, + const DBusString *encoded, + DBusString *plaintext); +void _dbus_auth_set_credentials (DBusAuth *auth, + const DBusCredentials *credentials); +void _dbus_auth_get_identity (DBusAuth *auth, + DBusCredentials *credentials); +dbus_bool_t _dbus_auth_set_context (DBusAuth *auth, + const DBusString *context); +dbus_bool_t _dbus_auth_set_remote_ip (DBusAuth *auth, + DBusString *remote_ip); +dbus_bool_t _dbus_auth_set_local_ip (DBusAuth *auth, + DBusString *local_ip); +dbus_bool_t _dbus_auth_set_host (DBusAuth *auth, + const char *host); +void _dbus_auth_set_get_username_function (DBusAuth *auth, + DBusGetUsernameFunction function); +void _dbus_auth_set_get_password_function (DBusAuth *auth, + DBusGetPasswordFunction function); + + DBUS_END_DECLS; Index: dbus/dbus-auth.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.c,v retrieving revision 1.29 diff -u -p -r1.29 dbus-auth.c --- dbus/dbus-auth.c 30 Sep 2003 02:32:52 -0000 1.29 +++ dbus/dbus-auth.c 19 Nov 2003 22:42:05 -0000 @@ -2,6 +2,7 @@ /* dbus-auth.c Authentication * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -27,6 +28,9 @@ #include "dbus-keyring.h" #include "dbus-sha.h" #include "dbus-userdb.h" +#ifdef HAVE_SASL +#include +#endif /* HAVE_SASL */ /** * @defgroup DBusAuth Authentication @@ -82,6 +86,7 @@ typedef struct DBusProcessAuthCommandFunction func; /**< Function to handle the command */ } DBusAuthCommandHandler; + /** * This function appends an initial client response to the given string */ @@ -89,7 +94,7 @@ typedef dbus_bool_t (* DBusInitialRespon DBusString *response); /** - * This function processes a block of data received from the peer. + * This function processes a block of data received from the peer * i.e. handles a DATA command. */ typedef dbus_bool_t (* DBusAuthDataFunction) (DBusAuth *auth, @@ -112,14 +117,30 @@ typedef dbus_bool_t (* DBusAuthDecodeFun /** * This function is called when the mechanism is abandoned. */ -typedef void (* DBusAuthShutdownFunction) (DBusAuth *auth); +typedef void (* DBusAuthShutdownFunction) (DBusAuth *auth); + +#ifdef HAVE_SASL + +int _dbus_sasl_log (void *context, + int priority, + const char *message); +int _dbus_sasl_get_username_callback (void *context, + int id, + const char **result, + unsigned *len); +int _dbus_sasl_get_password_callback (sasl_conn_t *conn, + void *context, + int id, + sasl_secret_t **psecret); + +#endif /** * Virtual table representing a particular auth mechanism. */ typedef struct { - const char *mechanism; /**< Name of the mechanism */ + DBusString mechanism; /**< Name of the mechanism */ DBusAuthDataFunction server_data_func; /**< Function on server side for DATA */ DBusAuthEncodeFunction server_encode_func; /**< Function on server side to encode */ DBusAuthDecodeFunction server_decode_func; /**< Function on server side to decode */ @@ -131,6 +152,7 @@ typedef struct DBusAuthShutdownFunction client_shutdown_func; /**< Function on client side for shutdown */ } DBusAuthMechanismHandler; + /** * Internal members of DBusAuth. */ @@ -176,6 +198,11 @@ struct DBusAuth unsigned int already_got_mechanisms : 1; /**< Client already got mech list */ unsigned int already_asked_for_initial_response : 1; /**< Already sent a blank challenge to get an initial response */ unsigned int buffer_outstanding : 1; /**< Buffer is "checked out" for reading data into */ + DBusAuthMechanismHandler *all_mechanisms; /**< All possible auth mechanisms */ + DBusString local_ip; /**< Local IP address in case of a tcp domain socket */ + DBusString remote_ip; /**< Remote IP address in case of a tcp domain socket */ + void *sasl_context; /**< SASL context or NULL when SASL isn't enabled */ + void *sasl_callbacks; /**< pointer to a sasl_callback_t */ }; /** @@ -186,21 +213,33 @@ typedef struct DBusAuth base; /**< Parent class */ DBusList *mechs_to_try; /**< Mechanisms we got from the server that we're going to try using */ - + DBusString host; /**< FQDN of host connecting to */ + DBusString username; /** username */ + DBusGetUsernameFunction get_username_function; /** function to call when a username is needed */ + DBusString password; /** password */ + DBusGetPasswordFunction get_password_function; /** function to call when a password is needed */ + void *sasl_secret; /** pointer to a sasl_secret_t */ } DBusAuthClient; -/** +/** if(!_dbus_string_init(& DBUS_AUTH_CLIENT(auth)->host)) + goto nomem; + * "Subclass" of DBusAuth for server side. */ typedef struct { - DBusAuth base; /**< Parent class */ + DBusAuth base; /**< Parent class */ - int failures; /**< Number of times client has been rejected */ - int max_failures; /**< Number of times we reject before disconnect */ + int failures; /**< Number of times client has been rejected */ + int max_failures; /**< Number of times we reject before disconnect */ + dbus_bool_t allready_replyed; /**< TRUE if we allready replyed to a first response */ } DBusAuthServer; +static dbus_bool_t get_word (const DBusString *str, + int *start, + DBusString *word); +static dbus_bool_t init_all_mechanisms (DBusAuth *auth); static dbus_bool_t process_auth (DBusAuth *auth, const DBusString *command, const DBusString *args); @@ -232,6 +271,8 @@ static dbus_bool_t process_error_client static dbus_bool_t client_try_next_mechanism (DBusAuth *auth); static dbus_bool_t send_rejected (DBusAuth *auth); +static dbus_bool_t dbus_auth_sasl_client_new (DBusAuth *auth); +static dbus_bool_t dbus_auth_sasl_server_new (DBusAuth *auth); static DBusAuthCommandHandler server_handlers[] = { @@ -280,6 +321,13 @@ client_handlers[] = { */ #define DBUS_AUTH_NAME(auth) (DBUS_AUTH_IS_SERVER(auth) ? "server" : "client") + +#ifdef HAVE_SASL +static dbus_bool_t sasl_client_initialized = FALSE; +static dbus_bool_t sasl_server_initialized = FALSE; +#endif /* HAVE_SASL */ + + static DBusAuth* _dbus_auth_new (int size) { @@ -324,9 +372,16 @@ _dbus_auth_new (int size) /* default context if none is specified */ if (!_dbus_string_append (&auth->context, "org_freedesktop_general")) goto enomem_5; - - return auth; + if (!_dbus_string_init (&auth->remote_ip)) + goto enomem_5; + + if (!_dbus_string_init (&auth->local_ip)) + goto enomem_6; + + return auth; + enomem_6: + _dbus_string_free (&auth->remote_ip); enomem_5: _dbus_string_free (&auth->challenge); enomem_4: @@ -357,7 +412,7 @@ shutdown_mech (DBusAuth *auth) if (auth->mech != NULL) { _dbus_verbose ("%s: Shutting down mechanism %s\n", - DBUS_AUTH_NAME (auth), auth->mech->mechanism); + DBUS_AUTH_NAME (auth), _dbus_string_get_const_data(&auth->mech->mechanism)); if (DBUS_AUTH_IS_CLIENT (auth)) (* auth->mech->client_shutdown_func) (auth); @@ -388,7 +443,8 @@ sha1_compute_hash (DBusAuth *aut retval = FALSE; if (!_dbus_string_init (&cookie)) - return FALSE; + return FALSE; + if (!_dbus_keyring_get_hex_key (auth->keyring, cookie_id, &cookie)) @@ -612,7 +668,7 @@ sha1_handle_second_client_response (DBus { /* We are expecting a response which is the hex-encoded client * challenge, space, then SHA-1 hash of the concatenation of our - * challenge, ":", client challenge, ":", secret key, all + * challenge, ":", client challenge, "s:", secret key, all * hex-encoded. */ int i; @@ -869,7 +925,6 @@ handle_client_data_cookie_sha1_mech (DBu _dbus_assert (!dbus_error_is_set (&error)); } } - _dbus_assert (auth->keyring != NULL); if (!_dbus_string_init (&tmp)) @@ -1119,54 +1174,534 @@ handle_client_shutdown_external_mech (DB } -/* Put mechanisms here in order of preference. - * What I eventually want to have is: - * - * - a mechanism that checks UNIX domain socket credentials - * - a simple magic cookie mechanism like X11 or ICE - * - mechanisms that chain to Cyrus SASL, so we can use anything it - * offers such as Kerberos, X509, whatever. - * - */ -static const DBusAuthMechanismHandler -all_mechanisms[] = { - { "EXTERNAL", - handle_server_data_external_mech, - NULL, NULL, - handle_server_shutdown_external_mech, - handle_client_initial_response_external_mech, - handle_client_data_external_mech, - NULL, NULL, - handle_client_shutdown_external_mech }, - { "DBUS_COOKIE_SHA1", - handle_server_data_cookie_sha1_mech, - NULL, NULL, - handle_server_shutdown_cookie_sha1_mech, - handle_client_initial_response_cookie_sha1_mech, - handle_client_data_cookie_sha1_mech, - NULL, NULL, - handle_client_shutdown_cookie_sha1_mech }, - { NULL, NULL } -}; + +#ifdef HAVE_SASL + +static dbus_bool_t +handle_server_data_sasl_mech (DBusAuth *auth, + const DBusString *data) +{ + int result,outlen; + const char *out; + DBusString server_response; + dbus_bool_t retval = FALSE; + + if(!_dbus_string_init(&server_response)) + return retval; + + if(! DBUS_AUTH_SERVER(auth)->allready_replyed) + { + result=sasl_server_start((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(&auth->mech->mechanism), + _dbus_string_get_const_data(data), + _dbus_string_get_length(data), + &out, + &outlen); + } + else + { + result=sasl_server_step((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(data), + _dbus_string_get_length(data), + &out, + &outlen); + } + if(result != SASL_OK && result != SASL_CONTINUE ) + { + _dbus_string_free(&server_response); + return send_rejected(auth); + } + + DBUS_AUTH_SERVER(auth)->allready_replyed = TRUE; + + if(result == SASL_CONTINUE) + { + if(!_dbus_string_append_len(&server_response,out,outlen)) + goto out_1; + + if(!_dbus_string_append(&auth->outgoing,"DATA ")) + goto out_1; + + if (!_dbus_string_base64_encode (&server_response, 0, + &auth->outgoing, + _dbus_string_get_length (&auth->outgoing))) + goto out_1; + retval=TRUE; + } + else + { + DBusString username; + const char *sasl_username=NULL; + + if(sasl_getprop((sasl_conn_t *) auth->sasl_context,SASL_USERNAME,(const void **) &sasl_username) == SASL_OK + && sasl_username != NULL ) + { + _dbus_string_init_const(&username,sasl_username); + if(!_dbus_credentials_from_username (&username, &auth->authorized_identity)) + goto out_1; + } + + if(!_dbus_string_append(&auth->outgoing,"OK\r\n")) + goto out_1; + + auth->authenticated_pending_begin = TRUE; + retval=TRUE; + } + +out_1: + _dbus_string_free(&server_response); + + return retval; + +} + + +static void +handle_server_shutdown_sasl_mech (DBusAuth *auth) +{ +} + + +static dbus_bool_t +handle_client_initial_response_sasl_mech (DBusAuth *auth, + DBusString *response) +{ + int result,outlen; + const char *out,*mech_using=NULL; + DBusString client_response; + dbus_bool_t retval = FALSE; + + + if(!_dbus_string_init(&client_response)) + return retval; + + result=sasl_client_start((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(&auth->mech->mechanism), + NULL, + &out, + &outlen, + &mech_using); + + if(result == SASL_OK || result == SASL_CONTINUE) + { + if(!_dbus_string_append_len(&client_response,out,outlen)) + goto out_1; + if (!_dbus_string_base64_encode (&client_response, 0, + response, + _dbus_string_get_length (response))) + goto out_1; + retval=TRUE; + } + +out_1: + _dbus_string_free(&client_response); + + return retval; +} + + +static dbus_bool_t +handle_client_data_sasl_mech (DBusAuth *auth, + const DBusString *data) +{ + int result,outlen; + const char *out; + DBusString client_response; + dbus_bool_t retval = FALSE; + + if(!_dbus_string_init(&client_response)) + return retval; + + result=sasl_client_step((sasl_conn_t * ) auth->sasl_context, + _dbus_string_get_const_data(data), + _dbus_string_get_length(data), + NULL, + &out, + &outlen); + + + if(result == SASL_CONTINUE) + { + if(!_dbus_string_append_len(&client_response,out,outlen)) + goto out_1; + if(!_dbus_string_append(&auth->outgoing,"DATA ")) + goto out_1; + if (!_dbus_string_base64_encode (&client_response, 0, + &auth->outgoing, + _dbus_string_get_length (&auth->outgoing))) + goto out_1; + retval=TRUE; + } + + if(result == SASL_OK) + retval =TRUE; + +out_1: + _dbus_string_free(&client_response); + + return retval; + +} + +static void +handle_client_shutdown_sasl_mech (DBusAuth *auth) +{ +} + + +int +_dbus_sasl_log(void *context, + int priority, + const char *message) +{ + if(priority == SASL_LOG_ERR || priority == SASL_LOG_WARN ) + _dbus_verbose("SASL :%s\n",message); + + return SASL_OK; +} + +int +_dbus_sasl_get_username_callback(void *context, + int id, + const char **result, + unsigned *len) +{ + char const *username=NULL; + + if(! DBUS_AUTH_IS_CLIENT((DBusAuth *) context)) + return SASL_BADPARAM; + if(!result) + return SASL_BADPARAM; + + DBusAuthClient *auth = DBUS_AUTH_CLIENT(context); + + switch(id) + { + case SASL_CB_AUTHNAME: + case SASL_CB_USER: + if(auth->get_username_function) + { + if((*auth->get_username_function) (&username) && username) + { + if(! _dbus_string_set_length(&auth->username,0)) + goto out_1; + if(! _dbus_string_append(&auth->username,username)) + goto out_1; + } + } + *result=_dbus_string_get_const_data(&auth->username); + if(len) + *len=_dbus_string_get_length(&auth->username); + break; + default: + return SASL_BADPARAM; + } + + return SASL_OK; +out_1: + return SASL_FAIL; +} + + +int +_dbus_sasl_get_password_callback(sasl_conn_t *conn, + void *context, + int id, + sasl_secret_t **psecret) +{ + char const *password; + + if(!conn || !psecret || id != SASL_CB_PASS) + return SASL_BADPARAM; + + DBusAuthClient *auth = DBUS_AUTH_CLIENT(context); + + if(auth->sasl_secret) + dbus_free(auth->sasl_secret); + + if(auth->get_username_function) + { + if((*auth->get_password_function) (&password) && password) + { + if(! _dbus_string_set_length(&auth->password,0)) + goto out_1; + if(! _dbus_string_append(&auth->password,password)) + goto out_1; + } + } + + auth->sasl_secret=(void *) dbus_malloc0(sizeof(sasl_secret_t)+ _dbus_string_get_length(&auth->password)); + if(!auth->sasl_secret) + return SASL_NOMEM; + + *psecret=(sasl_secret_t *) auth->sasl_secret; + + strcpy((char *) (*psecret)->data, _dbus_string_get_data(&auth->password)); + (*psecret)->len=_dbus_string_get_length(&auth->password); + + return SASL_OK; + out_1: + return SASL_FAIL; +} + + +static dbus_bool_t +dbus_auth_sasl_server_new(DBusAuth *auth) +{ + int result; + sasl_conn_t *context; + const char *local_ip=NULL; + const char *remote_ip=NULL; + + /* TODO locking */ + if(!sasl_server_initialized) { + static sasl_callback_t server_callbacks[] = { + { SASL_CB_LOG, &_dbus_sasl_log, NULL }, + { SASL_CB_LIST_END, NULL, NULL } + }; + + result=sasl_server_init(server_callbacks,"dbus"); + if(result != SASL_OK ) + return FALSE; + sasl_server_initialized = TRUE; + } + + if(_dbus_string_get_length(&auth->local_ip)) + local_ip=_dbus_string_get_const_data(&auth->local_ip); + if(_dbus_string_get_length(&auth->remote_ip)) + remote_ip=_dbus_string_get_const_data(&auth->remote_ip); + + result=sasl_server_new("dbus",NULL,NULL,local_ip,remote_ip,NULL,0,&context); + if( result != SASL_OK ) + return FALSE; + + auth->sasl_context=(void *) context; + + return TRUE; +} + + +static dbus_bool_t +dbus_auth_sasl_client_new(DBusAuth *auth) +{ + int result; + sasl_conn_t *context; + sasl_callback_t *callback=(sasl_callback_t *) auth->sasl_callbacks; + const char *local_ip=NULL; + const char *remote_ip=NULL; + const char *host=NULL; + + /* TODO locking ? */ + if(!sasl_client_initialized) { + callback->id = SASL_CB_USER; + callback->proc = &_dbus_sasl_get_username_callback; + callback->context = (void *) auth; + callback++; + callback->id = SASL_CB_AUTHNAME; + callback->proc = &_dbus_sasl_get_username_callback; + callback->context = (void *) auth; + callback++; + callback->id = SASL_CB_PASS; + callback->proc = &_dbus_sasl_get_password_callback; + callback->context = (void *) auth; + callback++; + callback->id = SASL_CB_LIST_END; + callback->proc = NULL; + callback->context = NULL; + + result=sasl_client_init((sasl_callback_t *) auth->sasl_callbacks); + if(result != SASL_OK ) + return FALSE; + sasl_client_initialized = TRUE; + } + + if(_dbus_string_get_length(& DBUS_AUTH_CLIENT(auth)->host)) + host=_dbus_string_get_const_data(& DBUS_AUTH_CLIENT(auth)->host); + if(_dbus_string_get_length(&auth->local_ip)) + local_ip=_dbus_string_get_const_data(&auth->local_ip); + if(_dbus_string_get_length(&auth->remote_ip)) + remote_ip=_dbus_string_get_const_data(&auth->remote_ip); + + result=sasl_client_new("dbus",host,local_ip,remote_ip,NULL,0,&context); + if( result != SASL_OK ) + return FALSE; + + auth->sasl_context=(void *) context; + + return TRUE; +} + +#endif /* HAVE_SASL */ + + + +/* Initialize all mechanisms we can handle */ + +dbus_bool_t static +init_all_mechanisms (DBusAuth *auth) +{ + DBusAuthMechanismHandler *mechanism; + int number_of_sasl_mechanisms = 0; + + if(auth->all_mechanisms) + return TRUE; + +#ifdef HAVE_SASL + int length; + const char *sasl_mechanisms; + int result; + dbus_bool_t sasl_initialized; + + auth->sasl_callbacks=dbus_new0(sasl_callback_t,4); + if(auth->sasl_callbacks) + { + if(DBUS_AUTH_IS_CLIENT(auth)) + { + sasl_initialized=dbus_auth_sasl_client_new(auth); + } + else + { + sasl_initialized=dbus_auth_sasl_server_new(auth); + } + + if(sasl_initialized) + { + result=sasl_listmech((sasl_conn_t * ) auth->sasl_context, + NULL, + "", + " ", + "", + &sasl_mechanisms, + &length, + &number_of_sasl_mechanisms); + if( result != SASL_OK ) + number_of_sasl_mechanisms=0; + } + } +#endif /* HAVE_SASL */ + mechanism=(DBusAuthMechanismHandler *) dbus_malloc0((3+number_of_sasl_mechanisms) * sizeof(DBusAuthMechanismHandler)); + if ( mechanism == NULL ) + return FALSE; + + auth->all_mechanisms=mechanism; + + _dbus_string_init_const (&mechanism->mechanism, "EXTERNAL"); + mechanism->server_data_func = handle_server_data_external_mech; + mechanism->server_encode_func = NULL; + mechanism->server_decode_func = NULL; + mechanism->server_shutdown_func = handle_server_shutdown_external_mech; + mechanism->client_initial_response_func = handle_client_initial_response_external_mech; + mechanism->client_data_func = handle_client_data_external_mech; + mechanism->client_encode_func = NULL; + mechanism->client_decode_func = NULL; + mechanism->client_shutdown_func = handle_client_shutdown_external_mech; + + mechanism++; + _dbus_string_init_const (&mechanism->mechanism, "DBUS_COOKIE_SHA1"); + mechanism->server_data_func = handle_server_data_cookie_sha1_mech; + mechanism->server_encode_func = NULL; + mechanism->server_decode_func = NULL; + mechanism->server_shutdown_func = handle_server_shutdown_cookie_sha1_mech; + mechanism->client_initial_response_func = handle_client_initial_response_cookie_sha1_mech; + mechanism->client_data_func = handle_client_data_cookie_sha1_mech; + mechanism->client_encode_func = NULL; + mechanism->client_decode_func = NULL; + mechanism->client_shutdown_func = handle_client_shutdown_cookie_sha1_mech; + +#ifdef HAVE_SASL + + if(number_of_sasl_mechanisms) + _dbus_verbose("%s: Merge SASL mechanisms (%s)\n",DBUS_AUTH_NAME (auth),sasl_mechanisms); + + int i; + int next = 0; + DBusString sasl_mechanisms_copy; + + + if(!_dbus_string_init(&sasl_mechanisms_copy)) + goto out_1; + if(!_dbus_string_append(&sasl_mechanisms_copy,sasl_mechanisms)) + goto out_2; + + for(i=0;imechanism)) + goto out_3; + if(!get_word (&sasl_mechanisms_copy,&next, &mechanism->mechanism)) + goto out_4; + mechanism->server_data_func = handle_server_data_sasl_mech; + mechanism->server_encode_func = NULL; + mechanism->server_decode_func = NULL; + mechanism->server_shutdown_func = handle_server_shutdown_sasl_mech; + mechanism->client_initial_response_func = handle_client_initial_response_sasl_mech; + mechanism->client_data_func = handle_client_data_sasl_mech; + mechanism->client_encode_func = NULL; + mechanism->client_decode_func = NULL; + mechanism->client_shutdown_func = handle_client_shutdown_sasl_mech; + } + + goto out_2; + + out_4: + _dbus_string_free(&mechanism->mechanism); + out_3: + mechanism--; + out_2: + _dbus_string_free(&sasl_mechanisms_copy); + out_1: +#endif /* HAVE_SASL */ + + mechanism++; + _dbus_string_init_const(&mechanism->mechanism,""); + mechanism->server_data_func = NULL; + + return TRUE; +} + + +static void +free_all_mechanisms (DBusAuth *auth) +{ + int i; + + if( auth->all_mechanisms ) + { + i = 0; + while (auth->all_mechanisms[i].server_data_func != NULL) + { + _dbus_string_free( &auth->all_mechanisms[i].mechanism ); + i++; + } + /* and the last one */ + _dbus_string_free( &auth->all_mechanisms[i].mechanism ); + + dbus_free(auth->all_mechanisms); + + auth->all_mechanisms = NULL; + } +} + static const DBusAuthMechanismHandler* -find_mech (const DBusString *name, - char **allowed_mechs) +find_mech (DBusAuth *auth, + const DBusString *name, + char **allowed_mechs) { int i; - + if (allowed_mechs != NULL && !_dbus_string_array_contains ((const char**) allowed_mechs, _dbus_string_get_const_data (name))) return NULL; i = 0; - while (all_mechanisms[i].mechanism != NULL) + while (auth->all_mechanisms[i].server_data_func != NULL) { - if (_dbus_string_equal_c_str (name, - all_mechanisms[i].mechanism)) + if (_dbus_string_equal (name, + &auth->all_mechanisms[i].mechanism)) - return &all_mechanisms[i]; + return &auth->all_mechanisms[i]; ++i; } @@ -1174,6 +1709,7 @@ find_mech (const DBusString *name, return NULL; } + static dbus_bool_t send_rejected (DBusAuth *auth) { @@ -1188,20 +1724,37 @@ send_rejected (DBusAuth *auth) "REJECTED")) goto nomem; - i = 0; - while (all_mechanisms[i].mechanism != NULL) - { - if (!_dbus_string_append (&command, + if (auth->allowed_mechs != NULL ) + { + i = 0; + while(auth->allowed_mechs[i] != NULL ) + { + if (!_dbus_string_append (&command, " ")) - goto nomem; + goto nomem; - if (!_dbus_string_append (&command, - all_mechanisms[i].mechanism)) - goto nomem; + if (!_dbus_string_append (&command,auth->allowed_mechs[i])) + goto nomem; + + i++; + } + } + else + { + i = 0; + while (auth->all_mechanisms[i].server_data_func != NULL) + { + if (!_dbus_string_append (&command, + " ")) + goto nomem; + + if (!_dbus_string_append (&command, + _dbus_string_get_const_data(&auth->all_mechanisms[i].mechanism))) + goto nomem; - ++i; - } - + ++i; + } + } if (!_dbus_string_append (&command, "\r\n")) goto nomem; @@ -1229,6 +1782,9 @@ process_auth (DBusAuth *auth, const DBusString *command, const DBusString *args) { + + if(!init_all_mechanisms(auth)) + return FALSE; if (auth->mech) { /* We are already using a mechanism, client is on crack */ @@ -1280,13 +1836,13 @@ process_auth (DBusAuth *auth, if (!_dbus_string_base64_decode (&base64_response, 0, &decoded_response, 0)) goto failed; - - auth->mech = find_mech (&mech, auth->allowed_mechs); + + auth->mech = find_mech (auth, &mech, auth->allowed_mechs); if (auth->mech != NULL) { _dbus_verbose ("%s: Trying mechanism %s with initial response of %d bytes\n", DBUS_AUTH_NAME (auth), - auth->mech->mechanism, + _dbus_string_get_const_data(&auth->mech->mechanism), _dbus_string_get_length (&decoded_response)); if (!(* auth->mech->server_data_func) (auth, @@ -1445,14 +2001,14 @@ record_mechanisms (DBusAuth *aut if (!_dbus_string_init (&m)) goto nomem; - + if (!get_word (args, &next, &m)) { _dbus_string_free (&m); goto nomem; } - mech = find_mech (&m, auth->allowed_mechs); + mech = find_mech (auth, &m, auth->allowed_mechs); if (mech != NULL) { @@ -1466,7 +2022,7 @@ record_mechanisms (DBusAuth *aut */ _dbus_verbose ("%s: Adding mechanism %s to list we will try\n", - DBUS_AUTH_NAME (auth), mech->mechanism); + DBUS_AUTH_NAME (auth), _dbus_string_get_const_data(&mech->mechanism)); if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, (void*) mech)) @@ -1512,11 +2068,11 @@ client_try_next_mechanism (DBusAuth *aut if (auth->allowed_mechs != NULL && !_dbus_string_array_contains ((const char**) auth->allowed_mechs, - mech->mechanism)) + _dbus_string_get_const_data(&mech->mechanism))) { /* don't try this one after all */ _dbus_verbose ("%s: Mechanism %s isn't in the list of allowed mechanisms\n", - DBUS_AUTH_NAME (auth), mech->mechanism); + DBUS_AUTH_NAME (auth), _dbus_string_get_const_data(&mech->mechanism)); mech = NULL; _dbus_list_pop_first (& client->mechs_to_try); } @@ -1538,12 +2094,14 @@ client_try_next_mechanism (DBusAuth *aut } if (!_dbus_string_append (&auth_command, - mech->mechanism)) + _dbus_string_get_const_data(&mech->mechanism))) { _dbus_string_free (&auth_command); return FALSE; } + auth->mech = mech; + if (mech->client_initial_response_func != NULL) { if (!_dbus_string_append (&auth_command, " ")) @@ -1554,6 +2112,8 @@ client_try_next_mechanism (DBusAuth *aut if (!(* mech->client_initial_response_func) (auth, &auth_command)) { + /* pop this one to avoid looping */ + _dbus_list_pop_first (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); _dbus_string_free (&auth_command); return FALSE; } @@ -1574,12 +2134,11 @@ client_try_next_mechanism (DBusAuth *aut return FALSE; } - auth->mech = mech; _dbus_list_pop_first (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); _dbus_verbose ("%s: Trying mechanism %s\n", DBUS_AUTH_NAME (auth), - auth->mech->mechanism); + _dbus_string_get_const_data(&auth->mech->mechanism)); _dbus_string_free (&auth_command); @@ -1669,7 +2228,7 @@ process_data_client (DBusAuth *a "ERROR \"Got DATA when not in an auth exchange\"\r\n")) return FALSE; } - + return TRUE; } @@ -1850,10 +2409,11 @@ _dbus_auth_server_new (void) */ server_auth->failures = 0; server_auth->max_failures = 6; - + return auth; } + /** * Creates a new auth conversation object for the client side. * See doc/dbus-sasl-profile.txt for full details on what @@ -1865,6 +2425,7 @@ DBusAuth* _dbus_auth_client_new (void) { DBusAuth *auth; + DBusAuthClient *client_auth; auth = _dbus_auth_new (sizeof (DBusAuthClient)); if (auth == NULL) @@ -1872,24 +2433,50 @@ _dbus_auth_client_new (void) auth->handlers = client_handlers; - /* Add a default mechanism to try */ - if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, - (void*) &all_mechanisms[0])) - { - _dbus_auth_unref (auth); - return NULL; - } + client_auth = DBUS_AUTH_CLIENT (auth); - /* Now try the mechanism we just added */ - if (!client_try_next_mechanism (auth)) - { - _dbus_auth_unref (auth); - return NULL; - } - + if(!_dbus_string_init(& client_auth->host)) + goto nomem; + + if(!_dbus_string_init(& client_auth->username)) + goto nomem; + if(!_dbus_string_init(& client_auth->password)) + goto nomem; + return auth; +nomem: + _dbus_auth_unref(auth); + + return NULL; } + +/** + * Starts the client side authentication process + * + * @param auth the auth conversation + * @returns #TRUE if successfull + */ +dbus_bool_t +_dbus_auth_start (DBusAuth *auth) + { + if(DBUS_AUTH_IS_CLIENT(auth)) + { + if (!init_all_mechanisms(auth)) + return FALSE; + /* Add a default mechanism to try */ + if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, + (void*) &auth->all_mechanisms[0])) + return FALSE; + if (!client_try_next_mechanism (auth)) + return FALSE; + + return TRUE; + } + return FALSE; + } + + /** * Increments the refcount of an auth object. * @@ -1922,6 +2509,11 @@ _dbus_auth_unref (DBusAuth *auth) if (DBUS_AUTH_IS_CLIENT (auth)) { _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); + _dbus_string_free(& DBUS_AUTH_CLIENT (auth)->host); + _dbus_string_free(& DBUS_AUTH_CLIENT (auth)->username); + _dbus_string_free(& DBUS_AUTH_CLIENT (auth)->password); + if(DBUS_AUTH_CLIENT (auth)->sasl_secret) + dbus_free(DBUS_AUTH_CLIENT (auth)->sasl_secret); } if (auth->keyring) @@ -1932,13 +2524,126 @@ _dbus_auth_unref (DBusAuth *auth) _dbus_string_free (&auth->identity); _dbus_string_free (&auth->incoming); _dbus_string_free (&auth->outgoing); + _dbus_string_free (&auth->local_ip); + _dbus_string_free (&auth->remote_ip); dbus_free_string_array (auth->allowed_mechs); + + free_all_mechanisms(auth); + +#ifdef HAVE_SASL + if(auth->sasl_context) + sasl_dispose((sasl_conn_t **) &auth->sasl_context); + if(auth->sasl_callbacks) + dbus_free(auth->sasl_callbacks); +#endif /* HAVE_SASL */ dbus_free (auth); } } + +/** + * Sets the remote ip + * + * @param auth the auth conversation + * @param remote_ip the remote ip adress + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_auth_set_remote_ip(DBusAuth *auth, + DBusString *remote_ip) +{ + int p; + + if(!_dbus_string_copy(remote_ip,0,&auth->remote_ip,0)) + return FALSE; + if(!_dbus_string_find(&auth->remote_ip,0,":",&p)) + return FALSE; + _dbus_string_set_byte(&auth->remote_ip,p,';'); + + return TRUE; +} + + +/** + * Sets the local ip + * + * @param auth the auth conversation + * @param local_ip the local ip adress + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_auth_set_local_ip(DBusAuth *auth, + DBusString *local_ip) +{ + int p; + + if(!_dbus_string_copy(local_ip,0,&auth->local_ip,0)) + return FALSE; + if(!_dbus_string_find(&auth->local_ip,0,":",&p)) + return FALSE; + _dbus_string_set_byte(&auth->local_ip,p,';'); + + return TRUE; +} + + +/** + * Sets the host name + * + * @param auth the auth conversation + * @param host host connecting to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_auth_set_host(DBusAuth *auth, + const char *host) +{ + if(DBUS_AUTH_IS_CLIENT(auth)) + { + if(!_dbus_string_set_length(& DBUS_AUTH_CLIENT(auth)->host,0)) + return FALSE; + if(!_dbus_string_append(& DBUS_AUTH_CLIENT(auth)->host,host)) + return FALSE; + return TRUE; + } + return FALSE; +} + +/** + * see dbus_connection_set_get_username_function() + * + * @param auth the auth conversation + * @param function to call when a username is needed + */ +void +_dbus_auth_set_get_username_function (DBusAuth *auth, + DBusGetUsernameFunction function) +{ + if(DBUS_AUTH_IS_CLIENT(auth)) + { + DBUS_AUTH_CLIENT (auth)->get_username_function=function; + } +} + +/** + * see dbus_connection_set_get_password_function() + * + * @param auth the auth conversation + * @param function to call when a password is needed + */ +void +_dbus_auth_set_get_password_function (DBusAuth *auth, + DBusGetPasswordFunction function) +{ + if(DBUS_AUTH_IS_CLIENT(auth)) + { + DBUS_AUTH_CLIENT (auth)->get_password_function=function; + } +} + + /** * Sets an array of authentication mechanism names * that we are willing to use. @@ -1969,6 +2674,7 @@ _dbus_auth_set_mechanisms (DBusAuth * return TRUE; } + /** * @param auth the auth conversation object * @returns #TRUE if we're in a final state Index: dbus/dbus-connection.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v retrieving revision 1.25 diff -u -p -r1.25 dbus-connection.h --- dbus/dbus-connection.h 30 Sep 2003 02:32:52 -0000 1.25 +++ dbus/dbus-connection.h 19 Nov 2003 22:42:20 -0000 @@ -2,6 +2,7 @@ /* dbus-connection.h DBusConnection object * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -84,6 +85,8 @@ typedef void (* DBusWakeupMainFun typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection, unsigned long uid, void *data); +typedef dbus_bool_t (* DBusGetPasswordFunction) (const char **password); +typedef dbus_bool_t (* DBusGetUsernameFunction) (const char **username); typedef void (* DBusPendingCallNotifyFunction) (DBusPendingCall *pending, void *user_data); @@ -148,6 +151,11 @@ void dbus_connection_set_u DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function); +void dbus_connection_set_get_username_function (DBusConnection *connection, + DBusGetUsernameFunction function); +void dbus_connection_set_get_password_function (DBusConnection *connection, + DBusGetPasswordFunction function); + int dbus_watch_get_fd (DBusWatch *watch); Index: dbus/dbus-connection.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v retrieving revision 1.73 diff -u -p -r1.73 dbus-connection.c --- dbus/dbus-connection.c 26 Oct 2003 15:36:15 -0000 1.73 +++ dbus/dbus-connection.c 19 Nov 2003 22:42:35 -0000 @@ -2,6 +2,7 @@ /* dbus-connection.c DBusConnection object * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -3015,6 +3016,42 @@ dbus_connection_set_unix_user_function ( } /** + * Set the function to call when a username is needed for authentication + * + * @param connection the connection + * @param function to call when username is needed + */ +void +dbus_connection_set_get_username_function (DBusConnection *connection, + DBusGetUsernameFunction function) +{ + + _dbus_return_if_fail (connection != NULL); + CONNECTION_LOCK (connection); + _dbus_transport_set_get_username_function (connection->transport, + function); + CONNECTION_UNLOCK (connection); + +} + +/** + * Set the function to call when a password is needed for authentication + * + * @param connection the connection + * @param function to call when password is needed + */ +void +dbus_connection_set_get_password_function (DBusConnection *connection, + DBusGetPasswordFunction function) +{ + _dbus_return_if_fail (connection != NULL); + CONNECTION_LOCK (connection); + _dbus_transport_set_get_password_function (connection->transport, + function); + CONNECTION_UNLOCK (connection); +} + +/** * Adds a message filter. Filters are handlers that are run on all * incoming messages, prior to the objects registered with * dbus_connection_register_object_path(). Filters are run in the Index: dbus/dbus-sysdeps.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v retrieving revision 1.36 diff -u -p -r1.36 dbus-sysdeps.h --- dbus/dbus-sysdeps.h 30 Sep 2003 02:32:53 -0000 1.36 +++ dbus/dbus-sysdeps.h 19 Nov 2003 22:42:47 -0000 @@ -3,6 +3,7 @@ * * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -120,6 +121,12 @@ int _dbus_listen_tcp_socket (const cha dbus_uint32_t port, DBusError *error); int _dbus_accept (int listen_fd); +dbus_bool_t _dbus_transport_is_inet (int transport_fd); +dbus_bool_t _dbus_transport_get_remote_ip (int transport_fd, + DBusString *address); +dbus_bool_t _dbus_transport_get_local_ip (int transport_fd, + DBusString *address); + dbus_bool_t _dbus_read_credentials_unix_socket (int client_fd, DBusCredentials *credentials, Index: dbus/dbus-sysdeps.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v retrieving revision 1.67 diff -u -p -r1.67 dbus-sysdeps.c --- dbus/dbus-sysdeps.c 16 Oct 2003 06:34:51 -0000 1.67 +++ dbus/dbus-sysdeps.c 19 Nov 2003 22:42:59 -0000 @@ -3,6 +3,7 @@ * * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -44,6 +45,7 @@ #include #include #include +#include #include #include @@ -583,7 +585,7 @@ _dbus_listen_unix_socket (const char * nonblocking. * * @param host the host name to connect to - * @param port the prot to connect to + * @param port the port to connect to * @param error return location for error code * @returns connection file descriptor or -1 on error */ @@ -752,6 +754,7 @@ write_credentials_byte (int if (bytes_written < 0) { + _dbus_verbose("Errno=%d",errno); dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to write credentials byte: %s", _dbus_strerror (errno)); @@ -968,6 +971,104 @@ _dbus_accept (int listen_fd) return client_fd; } + +static dbus_bool_t +get_address (DBusString *address, + struct sockaddr_storage *sa) + +{ + char buffer[INET6_ADDRSTRLEN + 1]; + + if(sa->ss_family == AF_INET ) + { + if(inet_ntop(sa->ss_family,&((struct sockaddr_in *)sa)->sin_addr,(char *) buffer,INET6_ADDRSTRLEN)== NULL ) + return FALSE; + if(!_dbus_string_append(address,buffer)) + return FALSE; + if(!_dbus_string_append(address,":")) + return FALSE; + if(!_dbus_string_append_printf(address,"%hu",ntohs(((struct sockaddr_in *)sa)->sin_port))) + return FALSE; + } + else if(sa->ss_family == AF_INET6 ) + { + if(inet_ntop(sa->ss_family,&((struct sockaddr_in6 *)sa)->sin6_addr,(char *) buffer,INET6_ADDRSTRLEN)== NULL ) + return FALSE; + if(!_dbus_string_append(address,":")) + return FALSE; + if(!_dbus_string_append_printf(address,"%hu",ntohs(((struct sockaddr_in6 *)sa)->sin6_port))) + return FALSE; + } + else + return FALSE; + + return TRUE; +} + +/** + * Returns true if the address type of the transport_fd is INET + * + * @param transport_fd the transport file descriptor + * @returns #TRUE when address type is AF_INET or AF_INET6 + */ +dbus_bool_t +_dbus_transport_is_inet(int transport_fd) +{ + struct sockaddr_storage sa; + int len=sizeof(sa); + + if(getsockname(transport_fd,(struct sockaddr *) &sa, &len) == -1 ) + return FALSE; + + if(sa.ss_family == AF_INET || sa.ss_family == AF_INET6 ) + return TRUE; + + return FALSE; +} + + +/** + * Get the remote IP address from a transport fd. + * + * @param transport_fd the transport file descriptor + * @param ip_address filled with the remote IP address + * @returns #TRUE when successfull + */ +dbus_bool_t +_dbus_transport_get_remote_ip (int transport_fd, + DBusString *address) +{ + struct sockaddr_storage sa; + int len=sizeof(sa); + + if(getpeername(transport_fd,(struct sockaddr *) &sa,&len) == -1 ) + return FALSE; + + return get_address(address,&sa); +} + + +/** + * Get the local IP address from a transport fd. + * + * @param transport_fd the transport file descriptor + * @param ip_address filled with the local IP address + * @returns #TRUE when successfull + */ +dbus_bool_t +_dbus_transport_get_local_ip (int transport_fd, + DBusString *address) +{ + struct sockaddr_storage sa; + int len=sizeof(sa); + + if(getsockname(transport_fd,(struct sockaddr *) &sa,&len) == -1 ) + return FALSE; + + return get_address(address,&sa); +} + + /** @} */ /** Index: dbus/dbus-transport-unix.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport-unix.c,v retrieving revision 1.33 diff -u -p -r1.33 dbus-transport-unix.c --- dbus/dbus-transport-unix.c 21 Jun 2003 07:51:39 -0000 1.33 +++ dbus/dbus-transport-unix.c 19 Nov 2003 22:43:24 -0000 @@ -2,6 +2,7 @@ /* dbus-transport-unix.c UNIX socket subclasses of DBusTransport * * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2003 Dobs * * Licensed under the Academic Free License version 1.2 * @@ -1024,6 +1025,7 @@ _dbus_transport_new_for_fd (int const DBusString *address) { DBusTransportUnix *unix_transport; + DBusString ip; unix_transport = dbus_new0 (DBusTransportUnix, 1); if (unix_transport == NULL) @@ -1056,6 +1058,23 @@ _dbus_transport_new_for_fd (int unix_transport->fd = fd; unix_transport->message_bytes_written = 0; + + /* if this is a tcp socket set the local and remote address on the auth object */ + if(_dbus_transport_is_inet(fd)) { + if(!_dbus_string_init(&ip)) + goto failed_5; + if(!_dbus_transport_get_remote_ip(fd,&ip)) + goto failed_6; + if(!_dbus_auth_set_remote_ip( ((DBusTransport *) unix_transport)->auth,&ip)) + goto failed_6; + if(!_dbus_string_set_length(&ip,0)) + goto failed_6; + if(!_dbus_transport_get_local_ip(fd,&ip)) + goto failed_6; + if(!_dbus_auth_set_local_ip(((DBusTransport *) unix_transport)->auth,&ip)) + goto failed_6; + _dbus_string_free(&ip); + } /* These values should probably be tunable or something. */ unix_transport->max_bytes_read_per_iteration = 2048; @@ -1063,6 +1082,10 @@ _dbus_transport_new_for_fd (int return (DBusTransport*) unix_transport; + failed_6: + _dbus_string_free(&ip); + failed_5: + _dbus_transport_finalize_base ((DBusTransport *) unix_transport); failed_4: _dbus_watch_unref (unix_transport->read_watch); failed_3: @@ -1205,8 +1228,17 @@ _dbus_transport_new_for_tcp_socket (cons } _dbus_string_free (&address); + + if(!_dbus_auth_set_host(transport->auth,host)) + goto nomem; return transport; + +nomem: + _dbus_close(fd,NULL); + unix_finalize(transport); + + return NULL; } /** @} */ Index: dbus/dbus-transport.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.h,v retrieving revision 1.11 diff -u -p -r1.11 dbus-transport.h --- dbus/dbus-transport.h 16 Apr 2003 23:01:33 -0000 1.11 +++ dbus/dbus-transport.h 19 Nov 2003 22:43:39 -0000 @@ -30,43 +30,46 @@ DBUS_BEGIN_DECLS; typedef struct DBusTransport DBusTransport; -DBusTransport* _dbus_transport_open (const char *address, - DBusError *error); -void _dbus_transport_ref (DBusTransport *transport); -void _dbus_transport_unref (DBusTransport *transport); -void _dbus_transport_disconnect (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); -const char* _dbus_transport_get_address (DBusTransport *transport); -dbus_bool_t _dbus_transport_handle_watch (DBusTransport *transport, - DBusWatch *watch, - unsigned int condition); -dbus_bool_t _dbus_transport_set_connection (DBusTransport *transport, - DBusConnection *connection); -void _dbus_transport_messages_pending (DBusTransport *transport, - int queue_length); -void _dbus_transport_do_iteration (DBusTransport *transport, - unsigned int flags, - int timeout_milliseconds); -DBusDispatchStatus _dbus_transport_get_dispatch_status (DBusTransport *transport); -dbus_bool_t _dbus_transport_queue_messages (DBusTransport *transport); -void _dbus_transport_set_max_message_size (DBusTransport *transport, - long size); -long _dbus_transport_get_max_message_size (DBusTransport *transport); -void _dbus_transport_set_max_received_size (DBusTransport *transport, - long size); -long _dbus_transport_get_max_received_size (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_unix_user (DBusTransport *transport, - unsigned long *uid); -void _dbus_transport_set_unix_user_function (DBusTransport *transport, - DBusAllowUnixUserFunction function, - void *data, - DBusFreeFunction free_data_function, - void **old_data, - DBusFreeFunction *old_free_data_function); -dbus_bool_t _dbus_transport_set_auth_mechanisms (DBusTransport *transport, - const char **mechanisms); - +DBusTransport* _dbus_transport_open (const char *address, + DBusError *error); +void _dbus_transport_ref (DBusTransport *transport); +void _dbus_transport_unref (DBusTransport *transport); +void _dbus_transport_disconnect (DBusTransport *transport); +dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); +dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); +const char* _dbus_transport_get_address (DBusTransport *transport); +dbus_bool_t _dbus_transport_handle_watch (DBusTransport *transport, + DBusWatch *watch, + unsigned int condition); +dbus_bool_t _dbus_transport_set_connection (DBusTransport *transport, + DBusConnection *connection); +void _dbus_transport_messages_pending (DBusTransport *transport, + int queue_length); +void _dbus_transport_do_iteration (DBusTransport *transport, + unsigned int flags, + int timeout_milliseconds); +DBusDispatchStatus _dbus_transport_get_dispatch_status (DBusTransport *transport); +dbus_bool_t _dbus_transport_queue_messages (DBusTransport *transport); +void _dbus_transport_set_max_message_size (DBusTransport *transport, + long size); +long _dbus_transport_get_max_message_size (DBusTransport *transport); +void _dbus_transport_set_max_received_size (DBusTransport *transport, + long size); +long _dbus_transport_get_max_received_size (DBusTransport *transport); +dbus_bool_t _dbus_transport_get_unix_user (DBusTransport *transport, + unsigned long *uid); +void _dbus_transport_set_unix_user_function (DBusTransport *transport, + DBusAllowUnixUserFunction function, + void *data, + DBusFreeFunction free_data_function, + void **old_data, + DBusFreeFunction *old_free_data_function); +dbus_bool_t _dbus_transport_set_auth_mechanisms (DBusTransport *transport, + const char **mechanisms); +void _dbus_transport_set_get_username_function (DBusTransport *transport, + DBusGetUsernameFunction function); +void _dbus_transport_set_get_password_function (DBusTransport *transport, + DBusGetPasswordFunction function) Index: dbus/dbus-transport.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v retrieving revision 1.35 diff -u -p -r1.35 dbus-transport.c --- dbus/dbus-transport.c 26 Oct 2003 15:36:15 -0000 1.35 +++ dbus/dbus-transport.c 19 Nov 2003 22:43:49 -0000 @@ -116,7 +116,7 @@ _dbus_transport_init_base (DBusTransport _dbus_message_loader_unref (loader); return FALSE; } - + if (server) { _dbus_assert (address == NULL); @@ -340,10 +340,13 @@ _dbus_transport_open (const char *ad } else { + _dbus_auth_start(transport->auth); dbus_error_free (&first_error); } dbus_address_entries_free (entries); + + return transport; bad_address: @@ -979,5 +982,31 @@ _dbus_transport_set_auth_mechanisms (DBu return _dbus_auth_set_mechanisms (transport->auth, mechanisms); } +/** + * see dbus_connection_set_get_username_function() + * + * @param transport the transport + * @param function the function to call when a username is needed + */ +void +_dbus_transport_set_get_username_function (DBusTransport *transport, + DBusGetUsernameFunction function) +{ + _dbus_auth_set_get_username_function (transport->auth,function); +} + +/** + * see dbus_connection_set_get_password_function() + * + * @param transport the transport + * @param function the function to call when a password is needed + */ +void +_dbus_transport_set_get_password_function (DBusTransport *transport, + DBusGetPasswordFunction function) +{ + _dbus_auth_set_get_password_function (transport->auth,function); +} + /** @} */ Index: doc/TODO =================================================================== RCS file: /cvs/dbus/dbus/doc/TODO,v retrieving revision 1.34 diff -u -p -r1.34 TODO --- doc/TODO 1 Nov 2003 18:24:32 -0000 1.34 +++ doc/TODO 19 Nov 2003 23:35:02 -0000 @@ -128,3 +128,15 @@ - rename HEADER_FIELD_SERVICE -> HEADER_FIELD_DESTINATION and HEADER_FIELD_SENDER_SERVICE -> HEADER_FIELD_SENDER for both dbus-protocol.h and in the spec + + - cleanup sasl stuff, maybe move most of it to dbus-sysdeps + in one go with implement the state machine :-) + ( see above ) + + - maybe don't compile sasl as an option so we can use the + sasl base64 en/decoding implementations + + - modify the dbus-monitor and dbus-send utilities to support + the username and password callbacks. + + - remove the implicit call to dbus_bus_register in dbus_bus_get --=-CztVctplTNL1o+sia54b-- From micke@imendio.com Fri Nov 21 11:45:40 2003 From: micke@imendio.com (Mikael Hallendal) Date: Fri, 21 Nov 2003 12:45:40 +0100 Subject: Bug in the boxing of DBusMessage in Glib layer Message-ID: <1069415140.20885.8.camel@chili.home.hallendal.net> Hi! Playing around with the gproxy signals yesterday and stumbled over a bug. Seems that when boxing DBusMessage dbus_message_ref() was used for copy-function. Took me a time to realize that this wouldn't work since unlike for example g_object_ref() in glib this function doesn't return the pointer it just reffed. So I started on a patch that would make the dbus_*_ref() functions return the reffed pointer but then I thought I should ask first if it doesn't return the reffed pointer for a reason. The other solution would be to make a wrapped copy-function (that just call dbus_message_ref() and then returns the pointer in the GLib layer. Let me know which way is the preferred and I'll send a patch for it. Regards, Mikael Hallendal -- Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 From hp@redhat.com Sat Nov 22 17:38:37 2003 From: hp@redhat.com (Havoc Pennington) Date: Sat, 22 Nov 2003 12:38:37 -0500 Subject: Bug in the boxing of DBusMessage in Glib layer In-Reply-To: <1069415140.20885.8.camel@chili.home.hallendal.net> References: <1069415140.20885.8.camel@chili.home.hallendal.net> Message-ID: <1069522717.24752.21.camel@localhost.localdomain> On Fri, 2003-11-21 at 06:45, Mikael Hallendal wrote: > So I started on a patch that would make the dbus_*_ref() functions > return the reffed pointer but then I thought I should ask first if it > doesn't return the reffed pointer for a reason. No reason, just ignorance. I'd say make _ref() return a pointer. Havoc From zack@kde.org Mon Nov 24 06:08:40 2003 From: zack@kde.org (Zack Rusin) Date: Mon, 24 Nov 2003 01:08:40 -0500 Subject: Qt bindings Message-ID: <200311240108.40088.zack@kde.org> Ave, I started working on getting Qt bindings up to speed. I'm starting the thanksgiving break on Wednesday and I hope to get it done over that break. Wednesday me and Ian will have a small hackfest so hopefully we'll get code generation working. Currently a sample usage looks as follows: using DBusQt; Connection *connection = new Connection( "unix:/var/whatever" ); ... Message msg( service, path, interface, method ); msg << "Hello World"; msg << 13.54; connection->sendMessage( msg ); So yeah. The api is going to probably totally change as I work on it this week, making it a little bit more DCOP like. Either way, feel free to be changing anything you want, especially that currently I'm lot more concerned with getting the whole thing nicely integrated into Qt then having super fancy, DCOP resembling api. Zack -- "There is hope... but not for us." -Kafka From david@fubar.dk Mon Nov 24 20:27:19 2003 From: david@fubar.dk (David Zeuthen) Date: Mon, 24 Nov 2003 21:27:19 +0100 Subject: dbus python signals Message-ID: <1069705639.4936.3.camel@laptop.fubar.dk> Hi Seth, below is a small patch for the python bindings such that the payload of a signal can be examined. There's also a function for removing a signal handler. Ok to commit? Thanks, David Index: dbus.py =================================================================== RCS file: /cvs/dbus/dbus/python/dbus.py,v retrieving revision 1.2 diff -u -r1.2 dbus.py --- dbus.py 30 Sep 2003 02:40:49 -0000 1.2 +++ dbus.py 24 Nov 2003 20:20:35 -0000 @@ -75,7 +75,15 @@ self._match_rule_to_receivers[match_rule].append(receiver) dbus_bindings.bus_add_match(self._connection, match_rule) - + + def remove_signal_receiver(self, receiver, interface=None, service=None, path=None): + match_rule = self._get_match_rule(interface, service, path) + + if self._match_rule_to_receivers.has_key(match_rule): + if self._match_rule_to_receivers[match_rule].__contains__(receiver): + self._match_rule_to_receivers[match_rule].remove(receiver) + dbus_bindings.bus_remove_match(self._connection, match_rule) + def get_connection(self): """Get the dbus_bindings.Connection object associated with this Bus""" return self._connection @@ -103,7 +111,7 @@ if (self._match_rule_to_receivers.has_key(match_rule)): receivers = self._match_rule_to_receivers[match_rule] - args = [interface, member, service, path] + args = [interface, member, service, path, message] for receiver in receivers: receiver(*args) From micke@imendio.com Tue Nov 25 23:50:28 2003 From: micke@imendio.com (Mikael Hallendal) Date: Wed, 26 Nov 2003 00:50:28 +0100 Subject: Objectpath argument for register_object_path and unregister_object_path Message-ID: <1069804228.14302.1.camel@chili.home.hallendal.net> Hi! Is there a special reason why you have to build a string array yourself to pass to dbus_connection_register_object_path and dbus_connection_unregister_object_path? Wouldn't it be simpler to use if you could just pass a string "/org/myproject/Object" instead of having to build {"org", "myproject", "Object" } before passing? Cheers, Mikael Hallendal -- Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 From hp@redhat.com Wed Nov 26 05:20:46 2003 From: hp@redhat.com (Havoc Pennington) Date: Wed, 26 Nov 2003 00:20:46 -0500 Subject: Objectpath argument for register_object_path and unregister_object_path In-Reply-To: <1069804228.14302.1.camel@chili.home.hallendal.net> References: <1069804228.14302.1.camel@chili.home.hallendal.net> Message-ID: <1069824046.5754.73.camel@localhost.localdomain> On Tue, 2003-11-25 at 18:50, Mikael Hallendal wrote: > > Is there a special reason why you have to build a string array yourself > to pass to dbus_connection_register_object_path and > dbus_connection_unregister_object_path? > > Wouldn't it be simpler to use if you could just pass a string > "/org/myproject/Object" instead of having to build {"org", "myproject", > "Object" } before passing? > Yes, probably. There are a couple other places with weirdness like this, too, I think. Havoc From micke@imendio.com Wed Nov 26 10:35:10 2003 From: micke@imendio.com (Mikael Hallendal) Date: Wed, 26 Nov 2003 11:35:10 +0100 Subject: Bug in the boxing of DBusMessage in Glib layer In-Reply-To: <1069522717.24752.21.camel@localhost.localdomain> References: <1069415140.20885.8.camel@chili.home.hallendal.net> <1069522717.24752.21.camel@localhost.localdomain> Message-ID: <1069842910.14302.16.camel@chili.home.hallendal.net> --=-WnuRFg0Sci+c8D6sLmHI Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable l=F6r 2003-11-22 klockan 18.38 skrev Havoc Pennington: > On Fri, 2003-11-21 at 06:45, Mikael Hallendal wrote: > > So I started on a patch that would make the dbus_*_ref() functions > > return the reffed pointer but then I thought I should ask first if it > > doesn't return the reffed pointer for a reason. >=20 > No reason, just ignorance. I'd say make _ref() return a pointer. Patch that make all (I hope) _ref() functions return the pointer. Not sure if I still have a cvs account there (how would I apply for one?) Regards, Mikael Hallendal --=20 Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 --=-WnuRFg0Sci+c8D6sLmHI Content-Disposition: attachment; filename=ref-return-pointer.patch Content-Type: text/x-patch; name=ref-return-pointer.patch; charset=iso-8859-15 Content-Transfer-Encoding: 7bit ? Doxyfile ? Makefile ? Makefile.in ? aclocal.m4 ? autom4te.cache ? config.guess ? config.h ? config.h.in ? config.log ? config.status ? config.sub ? configure ? dbus-1.pc ? dbus-glib-1.pc ? libtool ? ltmain.sh ? stamp-h1 ? python/.deps ? python/.libs ? python/Makefile ? python/Makefile.in ? python/dbus_bindings.c ? python/dbus_bindings.la ? python/dbus_bindings.lo ? python/dbus_bindings.pyx ? test/glib/.deps ? test/glib/.libs ? test/glib/Makefile ? test/glib/Makefile.in ? test/glib/test-dbus-glib ? test/glib/test-profile ? test/glib/test-service-glib ? test/glib/test-thread-client ? test/glib/test-thread-server ? tools/dbus-viewer Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.442 diff -u -b -B -p -r1.442 ChangeLog --- ChangeLog 25 Nov 2003 15:30:03 -0000 1.442 +++ ChangeLog 26 Nov 2003 10:20:13 -0000 @@ -1,3 +1,9 @@ +2003-11-26 Mikael Hallendal + + * bus/*.[ch]: + * dbus/*.[ch]: + * glib/*.[ch]: Made ref functions return the pointer + 2003-11-25 Zack Rusin * qt/integrator.h, qt/integrator.cpp: Adding handling of DBusServer, Index: bus/activation.c =================================================================== RCS file: /cvs/dbus/dbus/bus/activation.c,v retrieving revision 1.29 diff -u -b -B -p -r1.29 activation.c --- bus/activation.c 16 Oct 2003 06:34:51 -0000 1.29 +++ bus/activation.c 26 Nov 2003 10:20:13 -0000 @@ -99,11 +99,13 @@ handle_timeout_callback (DBusTimeout * _dbus_wait_for_memory (); } -static void +static BusPendingActivation * bus_pending_activation_ref (BusPendingActivation *pending_activation) { _dbus_assert (pending_activation->refcount > 0); pending_activation->refcount += 1; + + return pending_activation; } static void @@ -445,12 +447,14 @@ bus_activation_new (BusContext *c return NULL; } -void +BusActivation * bus_activation_ref (BusActivation *activation) { _dbus_assert (activation->refcount > 0); activation->refcount += 1; + + return activation; } void Index: bus/activation.h =================================================================== RCS file: /cvs/dbus/dbus/bus/activation.h,v retrieving revision 1.9 diff -u -b -B -p -r1.9 activation.h --- bus/activation.h 2 Apr 2003 20:14:52 -0000 1.9 +++ bus/activation.h 26 Nov 2003 10:20:13 -0000 @@ -32,7 +32,7 @@ BusActivation* bus_activation_new const DBusString *address, DBusList **directories, DBusError *error); -void bus_activation_ref (BusActivation *activation); +BusActivation* bus_activation_ref (BusActivation *activation); void bus_activation_unref (BusActivation *activation); dbus_bool_t bus_activation_activate_service (BusActivation *activation, DBusConnection *connection, Index: bus/bus.c =================================================================== RCS file: /cvs/dbus/dbus/bus/bus.c,v retrieving revision 1.46 diff -u -b -B -p -r1.46 bus.c --- bus/bus.c 22 Oct 2003 16:01:08 -0000 1.46 +++ bus/bus.c 26 Nov 2003 10:20:13 -0000 @@ -670,11 +670,13 @@ bus_context_shutdown (BusContext *conte } } -void +BusContext * bus_context_ref (BusContext *context) { _dbus_assert (context->refcount > 0); context->refcount += 1; + + return context; } void Index: bus/bus.h =================================================================== RCS file: /cvs/dbus/dbus/bus/bus.h,v retrieving revision 1.20 diff -u -b -B -p -r1.20 bus.h --- bus/bus.h 14 Oct 2003 05:16:56 -0000 1.20 +++ bus/bus.h 26 Nov 2003 10:20:13 -0000 @@ -66,7 +66,7 @@ BusContext* bus_context_new int print_pid_fd, DBusError *error); void bus_context_shutdown (BusContext *context); -void bus_context_ref (BusContext *context); +BusContext* bus_context_ref (BusContext *context); void bus_context_unref (BusContext *context); const char* bus_context_get_type (BusContext *context); const char* bus_context_get_address (BusContext *context); Index: bus/config-parser.c =================================================================== RCS file: /cvs/dbus/dbus/bus/config-parser.c,v retrieving revision 1.25 diff -u -b -B -p -r1.25 config-parser.c --- bus/config-parser.c 14 Oct 2003 22:16:03 -0000 1.25 +++ bus/config-parser.c 26 Nov 2003 10:20:14 -0000 @@ -345,12 +345,14 @@ bus_config_parser_new (const DBusString return parser; } -void +BusConfigParser * bus_config_parser_ref (BusConfigParser *parser) { _dbus_assert (parser->refcount > 0); parser->refcount += 1; + + return parser; } void Index: bus/config-parser.h =================================================================== RCS file: /cvs/dbus/dbus/bus/config-parser.h,v retrieving revision 1.11 diff -u -b -B -p -r1.11 config-parser.h --- bus/config-parser.h 28 Apr 2003 19:29:41 -0000 1.11 +++ bus/config-parser.h 26 Nov 2003 10:20:14 -0000 @@ -37,7 +37,7 @@ typedef struct BusConfigParser BusConfig BusConfigParser* bus_config_parser_new (const DBusString *basedir, dbus_bool_t is_toplevel); -void bus_config_parser_ref (BusConfigParser *parser); +BusConfigParser* bus_config_parser_ref (BusConfigParser *parser); void bus_config_parser_unref (BusConfigParser *parser); dbus_bool_t bus_config_parser_check_doctype (BusConfigParser *parser, const char *doctype, Index: bus/connection.c =================================================================== RCS file: /cvs/dbus/dbus/bus/connection.c,v retrieving revision 1.51 diff -u -b -B -p -r1.51 connection.c --- bus/connection.c 28 Oct 2003 23:51:24 -0000 1.51 +++ bus/connection.c 26 Nov 2003 10:20:14 -0000 @@ -471,11 +471,13 @@ bus_connections_new (BusContext *context return NULL; } -void +BusConnections * bus_connections_ref (BusConnections *connections) { _dbus_assert (connections->refcount > 0); connections->refcount += 1; + + return connections; } void Index: bus/connection.h =================================================================== RCS file: /cvs/dbus/dbus/bus/connection.h,v retrieving revision 1.17 diff -u -b -B -p -r1.17 connection.h --- bus/connection.h 14 Oct 2003 05:16:56 -0000 1.17 +++ bus/connection.h 26 Nov 2003 10:20:14 -0000 @@ -33,7 +33,7 @@ typedef dbus_bool_t (* BusConnectionFore BusConnections* bus_connections_new (BusContext *context); -void bus_connections_ref (BusConnections *connections); +BusConnections* bus_connections_ref (BusConnections *connections); void bus_connections_unref (BusConnections *connections); dbus_bool_t bus_connections_setup_connection (BusConnections *connections, DBusConnection *connection); Index: bus/policy.c =================================================================== RCS file: /cvs/dbus/dbus/bus/policy.c,v retrieving revision 1.16 diff -u -b -B -p -r1.16 policy.c --- bus/policy.c 14 Oct 2003 22:16:03 -0000 1.16 +++ bus/policy.c 26 Nov 2003 10:20:14 -0000 @@ -68,12 +68,14 @@ bus_policy_rule_new (BusPolicyRuleType t return rule; } -void +BusPolicyRule * bus_policy_rule_ref (BusPolicyRule *rule) { _dbus_assert (rule->refcount > 0); rule->refcount += 1; + + return rule; } void @@ -178,12 +180,14 @@ bus_policy_new (void) return NULL; } -void +BusPolicy * bus_policy_ref (BusPolicy *policy) { _dbus_assert (policy->refcount > 0); policy->refcount += 1; + + return policy; } void @@ -628,12 +632,14 @@ bus_client_policy_new (void) return policy; } -void +BusClientPolicy * bus_client_policy_ref (BusClientPolicy *policy) { _dbus_assert (policy->refcount > 0); policy->refcount += 1; + + return policy; } static void Index: bus/policy.h =================================================================== RCS file: /cvs/dbus/dbus/bus/policy.h,v retrieving revision 1.11 diff -u -b -B -p -r1.11 policy.h --- bus/policy.h 14 Oct 2003 22:16:03 -0000 1.11 +++ bus/policy.h 26 Nov 2003 10:20:14 -0000 @@ -101,11 +101,11 @@ struct BusPolicyRule BusPolicyRule* bus_policy_rule_new (BusPolicyRuleType type, dbus_bool_t allow); -void bus_policy_rule_ref (BusPolicyRule *rule); +BusPolicyRule* bus_policy_rule_ref (BusPolicyRule *rule); void bus_policy_rule_unref (BusPolicyRule *rule); BusPolicy* bus_policy_new (void); -void bus_policy_ref (BusPolicy *policy); +BusPolicy* bus_policy_ref (BusPolicy *policy); void bus_policy_unref (BusPolicy *policy); BusClientPolicy* bus_policy_create_client_policy (BusPolicy *policy, DBusConnection *connection, @@ -127,7 +127,7 @@ dbus_bool_t bus_policy_merge BusPolicy *to_absorb); BusClientPolicy* bus_client_policy_new (void); -void bus_client_policy_ref (BusClientPolicy *policy); +BusClientPolicy* bus_client_policy_ref (BusClientPolicy *policy); void bus_client_policy_unref (BusClientPolicy *policy); dbus_bool_t bus_client_policy_check_can_send (BusClientPolicy *policy, BusRegistry *registry, Index: bus/services.c =================================================================== RCS file: /cvs/dbus/dbus/bus/services.c,v retrieving revision 1.16 diff -u -b -B -p -r1.16 services.c --- bus/services.c 30 Sep 2003 02:32:50 -0000 1.16 +++ bus/services.c 26 Nov 2003 10:20:14 -0000 @@ -82,11 +82,13 @@ bus_registry_new (BusContext *context) return NULL; } -void +BusRegistry * bus_registry_ref (BusRegistry *registry) { _dbus_assert (registry->refcount > 0); registry->refcount += 1; + + return registry; } void @@ -713,12 +715,14 @@ bus_service_remove_owner (BusService return TRUE; } -void +BusService * bus_service_ref (BusService *service) { _dbus_assert (service->refcount > 0); service->refcount += 1; + + return service; } void Index: bus/services.h =================================================================== RCS file: /cvs/dbus/dbus/bus/services.h,v retrieving revision 1.8 diff -u -b -B -p -r1.8 services.h --- bus/services.h 11 Apr 2003 00:03:06 -0000 1.8 +++ bus/services.h 26 Nov 2003 10:20:14 -0000 @@ -33,7 +33,7 @@ typedef void (* BusServiceForeachFunctio void *data); BusRegistry* bus_registry_new (BusContext *context); -void bus_registry_ref (BusRegistry *registry); +BusRegistry* bus_registry_ref (BusRegistry *registry); void bus_registry_unref (BusRegistry *registry); BusService* bus_registry_lookup (BusRegistry *registry, const DBusString *service_name); @@ -56,7 +56,7 @@ dbus_bool_t bus_registry_acquire_servic BusTransaction *transaction, DBusError *error); -void bus_service_ref (BusService *service); +BusService* bus_service_ref (BusService *service); void bus_service_unref (BusService *service); dbus_bool_t bus_service_add_owner (BusService *service, DBusConnection *owner, Index: bus/signals.c =================================================================== RCS file: /cvs/dbus/dbus/bus/signals.c,v retrieving revision 1.5 diff -u -b -B -p -r1.5 signals.c --- bus/signals.c 16 Oct 2003 06:34:51 -0000 1.5 +++ bus/signals.c 26 Nov 2003 10:20:15 -0000 @@ -59,12 +59,14 @@ bus_match_rule_new (DBusConnection *matc return rule; } -void +BusMatchRule * bus_match_rule_ref (BusMatchRule *rule) { _dbus_assert (rule->refcount > 0); rule->refcount += 1; + + return rule; } void @@ -765,12 +767,14 @@ bus_matchmaker_new (void) return matchmaker; } -void +BusMatchmaker * bus_matchmaker_ref (BusMatchmaker *matchmaker) { _dbus_assert (matchmaker->refcount > 0); matchmaker->refcount += 1; + + return matchmaker; } void Index: bus/signals.h =================================================================== RCS file: /cvs/dbus/dbus/bus/signals.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 signals.h --- bus/signals.h 30 Sep 2003 02:32:50 -0000 1.2 +++ bus/signals.h 26 Nov 2003 10:20:15 -0000 @@ -40,7 +40,7 @@ typedef enum } BusMatchFlags; BusMatchRule* bus_match_rule_new (DBusConnection *matches_go_to); -void bus_match_rule_ref (BusMatchRule *rule); +BusMatchRule* bus_match_rule_ref (BusMatchRule *rule); void bus_match_rule_unref (BusMatchRule *rule); dbus_bool_t bus_match_rule_set_message_type (BusMatchRule *rule, @@ -61,7 +61,7 @@ BusMatchRule* bus_match_rule_parse (DBus DBusError *error); BusMatchmaker* bus_matchmaker_new (void); -void bus_matchmaker_ref (BusMatchmaker *matchmaker); +BusMatchmaker* bus_matchmaker_ref (BusMatchmaker *matchmaker); void bus_matchmaker_unref (BusMatchmaker *matchmaker); dbus_bool_t bus_matchmaker_add_rule (BusMatchmaker *matchmaker, Index: dbus/dbus-auth.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.c,v retrieving revision 1.29 diff -u -b -B -p -r1.29 dbus-auth.c --- dbus/dbus-auth.c 30 Sep 2003 02:32:52 -0000 1.29 +++ dbus/dbus-auth.c 26 Nov 2003 10:20:15 -0000 @@ -1894,13 +1894,16 @@ _dbus_auth_client_new (void) * Increments the refcount of an auth object. * * @param auth the auth conversation + * @returns the auth conversation */ -void +DBusAuth * _dbus_auth_ref (DBusAuth *auth) { _dbus_assert (auth != NULL); auth->refcount += 1; + + return auth; } /** Index: dbus/dbus-auth.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-auth.h,v retrieving revision 1.6 diff -u -b -B -p -r1.6 dbus-auth.h --- dbus/dbus-auth.h 1 Apr 2003 05:33:01 -0000 1.6 +++ dbus/dbus-auth.h 26 Nov 2003 10:20:15 -0000 @@ -44,7 +44,7 @@ typedef enum DBusAuth* _dbus_auth_server_new (void); DBusAuth* _dbus_auth_client_new (void); -void _dbus_auth_ref (DBusAuth *auth); +DBusAuth* _dbus_auth_ref (DBusAuth *auth); void _dbus_auth_unref (DBusAuth *auth); dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, const char **mechanisms); Index: dbus/dbus-connection-internal.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection-internal.h,v retrieving revision 1.14 diff -u -b -B -p -r1.14 dbus-connection-internal.h --- dbus/dbus-connection-internal.h 26 Oct 2003 15:36:15 -0000 1.14 +++ dbus/dbus-connection-internal.h 26 Nov 2003 10:20:15 -0000 @@ -46,7 +46,7 @@ typedef enum void _dbus_connection_lock (DBusConnection *connection); void _dbus_connection_unlock (DBusConnection *connection); -void _dbus_connection_ref_unlocked (DBusConnection *connection); +DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection); void _dbus_connection_unref_unlocked (DBusConnection *connection); dbus_bool_t _dbus_connection_queue_received_message (DBusConnection *connection, DBusMessage *message); Index: dbus/dbus-connection.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v retrieving revision 1.73 diff -u -b -B -p -r1.73 dbus-connection.c --- dbus/dbus-connection.c 26 Oct 2003 15:36:15 -0000 1.73 +++ dbus/dbus-connection.c 26 Nov 2003 10:20:16 -0000 @@ -219,11 +219,13 @@ static void _dbus_connecti DBusDispatchStatus new_status); static void _dbus_connection_last_unref (DBusConnection *connection); -static void +static DBusMessageFilter * _dbus_message_filter_ref (DBusMessageFilter *filter) { _dbus_assert (filter->refcount.value > 0); _dbus_atomic_inc (&filter->refcount); + + return filter; } static void @@ -963,8 +965,9 @@ _dbus_connection_new_for_transport (DBus * Requires that the caller already holds the connection lock. * * @param connection the connection. + * @returns the connection. */ -void +DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection) { #ifdef DBUS_HAVE_ATOMIC_INT @@ -973,6 +976,8 @@ _dbus_connection_ref_unlocked (DBusConne _dbus_assert (connection->refcount.value > 0); connection->refcount.value += 1; #endif + + return connection; } /** @@ -1117,11 +1122,12 @@ dbus_connection_open (const char *ad * Increments the reference count of a DBusConnection. * * @param connection the connection. + * @returns the connection. */ -void +DBusConnection * dbus_connection_ref (DBusConnection *connection) { - _dbus_return_if_fail (connection != NULL); + _dbus_return_val_if_fail (connection != NULL, NULL); /* The connection lock is better than the global * lock in the atomic increment fallback @@ -1136,6 +1142,8 @@ dbus_connection_ref (DBusConnection *con connection->refcount.value += 1; CONNECTION_UNLOCK (connection); #endif + + return connection; } static void Index: dbus/dbus-connection.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v retrieving revision 1.25 diff -u -b -B -p -r1.25 dbus-connection.h --- dbus/dbus-connection.h 30 Sep 2003 02:32:52 -0000 1.25 +++ dbus/dbus-connection.h 26 Nov 2003 10:20:16 -0000 @@ -95,7 +95,7 @@ typedef DBusHandlerResult (* DBusHandleM DBusConnection* dbus_connection_open (const char *address, DBusError *error); -void dbus_connection_ref (DBusConnection *connection); +DBusConnection* dbus_connection_ref (DBusConnection *connection); void dbus_connection_unref (DBusConnection *connection); void dbus_connection_disconnect (DBusConnection *connection); dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); Index: dbus/dbus-hash.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-hash.c,v retrieving revision 1.15 diff -u -b -B -p -r1.15 dbus-hash.c --- dbus/dbus-hash.c 30 Sep 2003 02:32:52 -0000 1.15 +++ dbus/dbus-hash.c 26 Nov 2003 10:20:16 -0000 @@ -348,11 +348,14 @@ _dbus_hash_table_new (DBusHashType t * Increments the reference count for a hash table. * * @param table the hash table to add a reference to. + * @returns the hash table. */ -void +DBusHashTable * _dbus_hash_table_ref (DBusHashTable *table) { table->refcount += 1; + + return table; } /** Index: dbus/dbus-hash.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-hash.h,v retrieving revision 1.10 diff -u -b -B -p -r1.10 dbus-hash.h --- dbus/dbus-hash.h 30 Sep 2003 02:32:52 -0000 1.10 +++ dbus/dbus-hash.h 26 Nov 2003 10:20:16 -0000 @@ -61,7 +61,7 @@ typedef enum DBusHashTable* _dbus_hash_table_new (DBusHashType type, DBusFreeFunction key_free_function, DBusFreeFunction value_free_function); -void _dbus_hash_table_ref (DBusHashTable *table); +DBusHashTable* _dbus_hash_table_ref (DBusHashTable *table); void _dbus_hash_table_unref (DBusHashTable *table); void _dbus_hash_iter_init (DBusHashTable *table, DBusHashIter *iter); Index: dbus/dbus-keyring.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-keyring.c,v retrieving revision 1.19 diff -u -b -B -p -r1.19 dbus-keyring.c --- dbus/dbus-keyring.c 30 Sep 2003 02:32:52 -0000 1.19 +++ dbus/dbus-keyring.c 26 Nov 2003 10:20:16 -0000 @@ -657,11 +657,14 @@ _dbus_keyring_reload (DBusKeyring *keyri * Increments reference count of the keyring * * @param keyring the keyring + * @returns the keyring */ -void +DBusKeyring * _dbus_keyring_ref (DBusKeyring *keyring) { keyring->refcount += 1; + + return keyring; } /** Index: dbus/dbus-keyring.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-keyring.h,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-keyring.h --- dbus/dbus-keyring.h 5 Mar 2003 02:01:34 -0000 1.4 +++ dbus/dbus-keyring.h 26 Nov 2003 10:20:16 -0000 @@ -34,7 +34,7 @@ typedef struct DBusKeyring DBusKeyring; DBusKeyring* _dbus_keyring_new_homedir (const DBusString *username, const DBusString *context, DBusError *error); -void _dbus_keyring_ref (DBusKeyring *keyring); +DBusKeyring* _dbus_keyring_ref (DBusKeyring *keyring); void _dbus_keyring_unref (DBusKeyring *keyring); dbus_bool_t _dbus_keyring_validate_context (const DBusString *context); int _dbus_keyring_get_best_key (DBusKeyring *keyring, Index: dbus/dbus-mainloop.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-mainloop.c,v retrieving revision 1.13 diff -u -b -B -p -r1.13 dbus-mainloop.c --- dbus/dbus-mainloop.c 30 Sep 2003 02:32:52 -0000 1.13 +++ dbus/dbus-mainloop.c 26 Nov 2003 10:20:16 -0000 @@ -123,12 +123,14 @@ timeout_callback_new (DBusTimeout return cb; } -static void +static Callback * callback_ref (Callback *cb) { _dbus_assert (cb->refcount > 0); cb->refcount += 1; + + return cb; } static void @@ -204,13 +206,15 @@ _dbus_loop_new (void) return loop; } -void +DBusLoop * _dbus_loop_ref (DBusLoop *loop) { _dbus_assert (loop != NULL); _dbus_assert (loop->refcount > 0); loop->refcount += 1; + + return loop; } void Index: dbus/dbus-mainloop.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-mainloop.h,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-mainloop.h --- dbus/dbus-mainloop.h 30 Sep 2003 02:32:52 -0000 1.4 +++ dbus/dbus-mainloop.h 26 Nov 2003 10:20:16 -0000 @@ -37,7 +37,7 @@ typedef void (* DBusTimeoutFuncti void *data); DBusLoop* _dbus_loop_new (void); -void _dbus_loop_ref (DBusLoop *loop); +DBusLoop* _dbus_loop_ref (DBusLoop *loop); void _dbus_loop_unref (DBusLoop *loop); dbus_bool_t _dbus_loop_add_watch (DBusLoop *loop, DBusWatch *watch, Index: dbus/dbus-message-handler.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message-handler.c,v retrieving revision 1.9 diff -u -b -B -p -r1.9 dbus-message-handler.c --- dbus/dbus-message-handler.c 12 May 2003 02:44:44 -0000 1.9 +++ dbus/dbus-message-handler.c 26 Nov 2003 10:20:17 -0000 @@ -189,13 +189,16 @@ dbus_message_handler_new (DBusHandleMess * Increments the reference count on a message handler. * * @param handler the handler + * @returns the handler */ -void +DBusMessageHandler * dbus_message_handler_ref (DBusMessageHandler *handler) { _dbus_return_if_fail (handler != NULL); _dbus_atomic_inc (&handler->refcount); + + return handler; } /** Index: dbus/dbus-message-handler.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message-handler.h,v retrieving revision 1.1 diff -u -b -B -p -r1.1 dbus-message-handler.h --- dbus/dbus-message-handler.h 24 Dec 2002 06:37:32 -0000 1.1 +++ dbus/dbus-message-handler.h 26 Nov 2003 10:20:17 -0000 @@ -43,7 +43,7 @@ DBusMessageHandler* dbus_message_handler DBusFreeFunction free_user_data); -void dbus_message_handler_ref (DBusMessageHandler *handler); +DBusMessageHandler* dbus_message_handler_ref (DBusMessageHandler *handler); void dbus_message_handler_unref (DBusMessageHandler *handler); Index: dbus/dbus-message-internal.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message-internal.h,v retrieving revision 1.14 diff -u -b -B -p -r1.14 dbus-message-internal.h --- dbus/dbus-message-internal.h 12 May 2003 02:44:44 -0000 1.14 +++ dbus/dbus-message-internal.h 26 Nov 2003 10:20:17 -0000 @@ -48,7 +48,7 @@ void _dbus_message_remove_size_co DBusList **link_return); DBusMessageLoader* _dbus_message_loader_new (void); -void _dbus_message_loader_ref (DBusMessageLoader *loader); +DBusMessageLoader* _dbus_message_loader_ref (DBusMessageLoader *loader); void _dbus_message_loader_unref (DBusMessageLoader *loader); void _dbus_message_loader_get_buffer (DBusMessageLoader *loader, Index: dbus/dbus-message.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v retrieving revision 1.114 diff -u -b -B -p -r1.114 dbus-message.c --- dbus/dbus-message.c 29 Oct 2003 00:29:52 -0000 1.114 +++ dbus/dbus-message.c 26 Nov 2003 10:20:18 -0000 @@ -1504,17 +1504,20 @@ dbus_message_copy (const DBusMessage *me * Increments the reference count of a DBusMessage. * * @param message The message + * @returns the message * @see dbus_message_unref */ -void +DBusMessage * dbus_message_ref (DBusMessage *message) { dbus_int32_t old_refcount; - _dbus_return_if_fail (message != NULL); + _dbus_return_val_if_fail (message != NULL, NULL); old_refcount = _dbus_atomic_inc (&message->refcount); _dbus_assert (old_refcount >= 1); + + return message; } static void @@ -4781,11 +4784,14 @@ _dbus_message_loader_new (void) * Increments the reference count of the loader. * * @param loader the loader. + * @returns the loader */ -void +DBusMessageLoader * _dbus_message_loader_ref (DBusMessageLoader *loader) { loader->refcount += 1; + + return loader; } /** Index: dbus/dbus-message.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message.h,v retrieving revision 1.47 diff -u -b -B -p -r1.47 dbus-message.h --- dbus/dbus-message.h 21 Oct 2003 05:46:51 -0000 1.47 +++ dbus/dbus-message.h 26 Nov 2003 10:20:18 -0000 @@ -73,9 +73,9 @@ DBusMessage* dbus_message_new_error const char *error_name, const char *error_message); -DBusMessage *dbus_message_copy (const DBusMessage *message); +DBusMessage* dbus_message_copy (const DBusMessage *message); -void dbus_message_ref (DBusMessage *message); +DBusMessage* dbus_message_ref (DBusMessage *message); void dbus_message_unref (DBusMessage *message); int dbus_message_get_type (DBusMessage *message); dbus_bool_t dbus_message_set_path (DBusMessage *message, Index: dbus/dbus-object-tree.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-object-tree.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-object-tree.c --- dbus/dbus-object-tree.c 30 Sep 2003 02:32:53 -0000 1.2 +++ dbus/dbus-object-tree.c 26 Nov 2003 10:20:18 -0000 @@ -46,7 +46,7 @@ typedef struct DBusObjectSubtree DBusObj static DBusObjectSubtree* _dbus_object_subtree_new (const char *name, const DBusObjectPathVTable *vtable, void *user_data); -static void _dbus_object_subtree_ref (DBusObjectSubtree *subtree); +static DBusObjectSubtree* _dbus_object_subtree_ref (DBusObjectSubtree *subtree); static void _dbus_object_subtree_unref (DBusObjectSubtree *subtree); /** @@ -121,13 +121,16 @@ _dbus_object_tree_new (DBusConnection *c /** * Increment the reference count * @param tree the object tree + * @returns the object tree */ -void +DBusObjectTree * _dbus_object_tree_ref (DBusObjectTree *tree) { _dbus_assert (tree->refcount > 0); tree->refcount += 1; + + return tree; } /** @@ -859,11 +862,13 @@ _dbus_object_subtree_new (const char return NULL; } -static void +static DBusObjectSubtree * _dbus_object_subtree_ref (DBusObjectSubtree *subtree) { _dbus_assert (subtree->refcount.value > 0); _dbus_atomic_inc (&subtree->refcount); + + return subtree; } static void Index: dbus/dbus-object-tree.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-object-tree.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-object-tree.h --- dbus/dbus-object-tree.h 30 Sep 2003 02:32:53 -0000 1.2 +++ dbus/dbus-object-tree.h 26 Nov 2003 10:20:18 -0000 @@ -30,7 +30,7 @@ DBUS_BEGIN_DECLS; typedef struct DBusObjectTree DBusObjectTree; DBusObjectTree* _dbus_object_tree_new (DBusConnection *connection); -void _dbus_object_tree_ref (DBusObjectTree *tree); +DBusObjectTree* _dbus_object_tree_ref (DBusObjectTree *tree); void _dbus_object_tree_unref (DBusObjectTree *tree); dbus_bool_t _dbus_object_tree_register (DBusObjectTree *tree, Index: dbus/dbus-pending-call.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-pending-call.c,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-pending-call.c --- dbus/dbus-pending-call.c 16 Oct 2003 06:34:51 -0000 1.4 +++ dbus/dbus-pending-call.c 26 Nov 2003 10:20:18 -0000 @@ -138,13 +138,16 @@ _dbus_pending_call_notify (DBusPendingCa * Increments the reference count on a pending call. * * @param pending the pending call object + * @returns the pending call object */ -void +DBusPendingCall * dbus_pending_call_ref (DBusPendingCall *pending) { _dbus_return_if_fail (pending != NULL); _dbus_atomic_inc (&pending->refcount); + + return pending; } /** Index: dbus/dbus-pending-call.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-pending-call.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-pending-call.h --- dbus/dbus-pending-call.h 30 Sep 2003 02:32:53 -0000 1.2 +++ dbus/dbus-pending-call.h 26 Nov 2003 10:20:18 -0000 @@ -33,7 +33,7 @@ DBUS_BEGIN_DECLS; -void dbus_pending_call_ref (DBusPendingCall *pending); +DBusPendingCall* dbus_pending_call_ref (DBusPendingCall *pending); void dbus_pending_call_unref (DBusPendingCall *pending); dbus_bool_t dbus_pending_call_set_notify (DBusPendingCall *pending, DBusPendingCallNotifyFunction function, Index: dbus/dbus-resources.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-resources.c,v retrieving revision 1.1 diff -u -b -B -p -r1.1 dbus-resources.c --- dbus/dbus-resources.c 19 Jan 2003 03:33:35 -0000 1.1 +++ dbus/dbus-resources.c 26 Nov 2003 10:20:18 -0000 @@ -96,13 +96,16 @@ _dbus_counter_new (void) * Increments refcount of the counter * * @param counter the counter + * @returns the counter */ -void +DBusCounter * _dbus_counter_ref (DBusCounter *counter) { _dbus_assert (counter->refcount > 0); counter->refcount += 1; + + return counter; } /** Index: dbus/dbus-resources.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-resources.h,v retrieving revision 1.1 diff -u -b -B -p -r1.1 dbus-resources.h --- dbus/dbus-resources.h 19 Jan 2003 03:33:35 -0000 1.1 +++ dbus/dbus-resources.h 26 Nov 2003 10:20:18 -0000 @@ -35,7 +35,7 @@ typedef void (* DBusCounterNotifyFunctio void *user_data); DBusCounter* _dbus_counter_new (void); -void _dbus_counter_ref (DBusCounter *counter); +DBusCounter* _dbus_counter_ref (DBusCounter *counter); void _dbus_counter_unref (DBusCounter *counter); void _dbus_counter_adjust (DBusCounter *counter, long delta); Index: dbus/dbus-server.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-server.c,v retrieving revision 1.30 diff -u -b -B -p -r1.30 dbus-server.c --- dbus/dbus-server.c 30 Sep 2003 02:32:53 -0000 1.30 +++ dbus/dbus-server.c 26 Nov 2003 10:20:18 -0000 @@ -450,13 +450,16 @@ dbus_server_listen (const char *addr * Increments the reference count of a DBusServer. * * @param server the server. + * @returns the server */ -void +DBusServer * dbus_server_ref (DBusServer *server) { _dbus_return_if_fail (server != NULL); server->refcount += 1; + + return server; } /** Index: dbus/dbus-server.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-server.h,v retrieving revision 1.13 diff -u -b -B -p -r1.13 dbus-server.h --- dbus/dbus-server.h 22 Jun 2003 19:39:47 -0000 1.13 +++ dbus/dbus-server.h 26 Nov 2003 10:20:18 -0000 @@ -41,7 +41,7 @@ typedef void (* DBusNewConnectionFunctio DBusServer* dbus_server_listen (const char *address, DBusError *error); -void dbus_server_ref (DBusServer *server); +DBusServer* dbus_server_ref (DBusServer *server); void dbus_server_unref (DBusServer *server); void dbus_server_disconnect (DBusServer *server); dbus_bool_t dbus_server_get_is_connected (DBusServer *server); Index: dbus/dbus-spawn.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-spawn.c,v retrieving revision 1.13 diff -u -b -B -p -r1.13 dbus-spawn.c --- dbus/dbus-spawn.c 30 Sep 2003 02:32:53 -0000 1.13 +++ dbus/dbus-spawn.c 26 Nov 2003 10:20:18 -0000 @@ -235,14 +235,17 @@ _dbus_babysitter_new (void) * Increment the reference count on the babysitter object. * * @param sitter the babysitter + * @returns the babysitter */ -void +DBusBabysitter * _dbus_babysitter_ref (DBusBabysitter *sitter) { _dbus_assert (sitter != NULL); _dbus_assert (sitter->refcount > 0); sitter->refcount += 1; + + return sitter; } /** Index: dbus/dbus-spawn.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-spawn.h,v retrieving revision 1.3 diff -u -b -B -p -r1.3 dbus-spawn.h --- dbus/dbus-spawn.h 18 Apr 2003 04:18:57 -0000 1.3 +++ dbus/dbus-spawn.h 26 Nov 2003 10:20:18 -0000 @@ -40,7 +40,7 @@ dbus_bool_t _dbus_spawn_async_with_babys DBusSpawnChildSetupFunc child_setup, void *user_data, DBusError *error); -void _dbus_babysitter_ref (DBusBabysitter *sitter); +DBusBabysitter* _dbus_babysitter_ref (DBusBabysitter *sitter); void _dbus_babysitter_unref (DBusBabysitter *sitter); void _dbus_babysitter_kill_child (DBusBabysitter *sitter); dbus_bool_t _dbus_babysitter_get_child_exited (DBusBabysitter *sitter); Index: dbus/dbus-timeout.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-timeout.c,v retrieving revision 1.11 diff -u -b -B -p -r1.11 dbus-timeout.c --- dbus/dbus-timeout.c 30 Sep 2003 02:32:53 -0000 1.11 +++ dbus/dbus-timeout.c 26 Nov 2003 10:20:18 -0000 @@ -86,11 +86,14 @@ _dbus_timeout_new (int i * Increments the reference count of a DBusTimeout object. * * @param timeout the timeout object. + * @returns the timeout object. */ -void +DBusTimeout * _dbus_timeout_ref (DBusTimeout *timeout) { timeout->refcount += 1; + + return timeout; } /** Index: dbus/dbus-timeout.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-timeout.h,v retrieving revision 1.6 diff -u -b -B -p -r1.6 dbus-timeout.h --- dbus/dbus-timeout.h 24 Apr 2003 21:26:25 -0000 1.6 +++ dbus/dbus-timeout.h 26 Nov 2003 10:20:18 -0000 @@ -38,7 +38,7 @@ DBusTimeout* _dbus_timeout_new DBusTimeoutHandler handler, void *data, DBusFreeFunction free_data_function); -void _dbus_timeout_ref (DBusTimeout *timeout); +DBusTimeout* _dbus_timeout_ref (DBusTimeout *timeout); void _dbus_timeout_unref (DBusTimeout *timeout); void _dbus_timeout_set_interval (DBusTimeout *timeout, int interval); Index: dbus/dbus-transport.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v retrieving revision 1.35 diff -u -b -B -p -r1.35 dbus-transport.c --- dbus/dbus-transport.c 26 Oct 2003 15:36:15 -0000 1.35 +++ dbus/dbus-transport.c 26 Nov 2003 10:20:19 -0000 @@ -365,13 +365,16 @@ _dbus_transport_open (const char *ad * Increments the reference count for the transport. * * @param transport the transport. + * @returns the transport. */ -void +DBusTransport * _dbus_transport_ref (DBusTransport *transport) { _dbus_assert (transport->refcount > 0); transport->refcount += 1; + + return transport; } /** Index: dbus/dbus-transport.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.h,v retrieving revision 1.11 diff -u -b -B -p -r1.11 dbus-transport.h --- dbus/dbus-transport.h 16 Apr 2003 23:01:33 -0000 1.11 +++ dbus/dbus-transport.h 26 Nov 2003 10:20:19 -0000 @@ -32,7 +32,7 @@ typedef struct DBusTransport DBusTranspo DBusTransport* _dbus_transport_open (const char *address, DBusError *error); -void _dbus_transport_ref (DBusTransport *transport); +DBusTransport* _dbus_transport_ref (DBusTransport *transport); void _dbus_transport_unref (DBusTransport *transport); void _dbus_transport_disconnect (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); Index: dbus/dbus-userdb.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.c,v retrieving revision 1.5 diff -u -b -B -p -r1.5 dbus-userdb.c --- dbus/dbus-userdb.c 30 Sep 2003 02:32:53 -0000 1.5 +++ dbus/dbus-userdb.c 26 Nov 2003 10:20:19 -0000 @@ -635,13 +635,16 @@ _dbus_user_database_new (void) /** * Increments refcount of user database. * @param db the database + * @returns the database */ -void +DBusUserDatabase * _dbus_user_database_ref (DBusUserDatabase *db) { _dbus_assert (db->refcount > 0); db->refcount += 1; + + return db; } /** Index: dbus/dbus-userdb.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-userdb.h --- dbus/dbus-userdb.h 17 Apr 2003 23:17:04 -0000 1.2 +++ dbus/dbus-userdb.h 26 Nov 2003 10:20:19 -0000 @@ -31,7 +31,7 @@ DBUS_BEGIN_DECLS; typedef struct DBusUserDatabase DBusUserDatabase; DBusUserDatabase* _dbus_user_database_new (void); -void _dbus_user_database_ref (DBusUserDatabase *db); +DBusUserDatabase* _dbus_user_database_ref (DBusUserDatabase *db); void _dbus_user_database_unref (DBusUserDatabase *db); dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db, dbus_uid_t uid, Index: dbus/dbus-watch.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-watch.c,v retrieving revision 1.14 diff -u -b -B -p -r1.14 dbus-watch.c --- dbus/dbus-watch.c 30 Sep 2003 02:32:53 -0000 1.14 +++ dbus/dbus-watch.c 26 Nov 2003 10:20:19 -0000 @@ -97,11 +97,14 @@ _dbus_watch_new (int fd, * Increments the reference count of a DBusWatch object. * * @param watch the watch object. + * @returns the watch object. */ -void +DBusWatch * _dbus_watch_ref (DBusWatch *watch) { watch->refcount += 1; + + return watch; } /** Index: dbus/dbus-watch.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-watch.h,v retrieving revision 1.4 diff -u -b -B -p -r1.4 dbus-watch.h --- dbus/dbus-watch.h 18 Apr 2003 04:18:57 -0000 1.4 +++ dbus/dbus-watch.h 26 Nov 2003 10:20:19 -0000 @@ -42,7 +42,7 @@ DBusWatch* _dbus_watch_new DBusWatchHandler handler, void *data, DBusFreeFunction free_data_function); -void _dbus_watch_ref (DBusWatch *watch); +DBusWatch* _dbus_watch_ref (DBusWatch *watch); void _dbus_watch_unref (DBusWatch *watch); void _dbus_watch_invalidate (DBusWatch *watch); void _dbus_watch_sanitize_condition (DBusWatch *watch, Index: glib/dbus-gidl.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gidl.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gidl.c --- glib/dbus-gidl.c 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gidl.c 26 Nov 2003 10:20:19 -0000 @@ -67,13 +67,15 @@ struct ArgInfo ArgDirection direction; }; -void +BaseInfo * base_info_ref (BaseInfo *info) { g_return_if_fail (info != NULL); g_return_if_fail (info->refcount > 0); info->refcount += 1; + + return info; } static void @@ -222,10 +224,12 @@ node_info_new (const char *name) return info; } -void +NodeInfo * node_info_ref (NodeInfo *info) { info->base.refcount += 1; + + return info; } void @@ -287,10 +291,12 @@ interface_info_new (const char *name) return info; } -void +InterfaceInfo * interface_info_ref (InterfaceInfo *info) { info->base.refcount += 1; + + return info; } void @@ -366,10 +372,12 @@ method_info_new (const char *name) return info; } -void +MethodInfo * method_info_ref (MethodInfo *info) { info->base.refcount += 1; + + return info; } void @@ -416,10 +425,12 @@ signal_info_new (const char *name) return info; } -void +SignalInfo * signal_info_ref (SignalInfo *info) { info->base.refcount += 1; + + return info; } void @@ -472,10 +483,12 @@ arg_info_new (const char *name, return info; } -void +ArgInfo * arg_info_ref (ArgInfo *info) { info->base.refcount += 1; + + return info; } void Index: glib/dbus-gidl.h =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gidl.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gidl.h --- glib/dbus-gidl.h 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gidl.h 26 Nov 2003 10:20:19 -0000 @@ -54,7 +54,7 @@ typedef enum } InfoType; -void base_info_ref (BaseInfo *info); +BaseInfo* base_info_ref (BaseInfo *info); void base_info_unref (BaseInfo *info); InfoType base_info_get_type (BaseInfo *info); const char* base_info_get_name (BaseInfo *info); @@ -65,7 +65,7 @@ GType base_info_get_gtype NodeInfo* node_info_new (const char *name); -void node_info_ref (NodeInfo *info); +NodeInfo* node_info_ref (NodeInfo *info); void node_info_unref (NodeInfo *info); const char* node_info_get_name (NodeInfo *info); GSList* node_info_get_interfaces (NodeInfo *info); @@ -76,7 +76,7 @@ void node_info_add_node NodeInfo *child); InterfaceInfo* interface_info_new (const char *name); -void interface_info_ref (InterfaceInfo *info); +InterfaceInfo* interface_info_ref (InterfaceInfo *info); void interface_info_unref (InterfaceInfo *info); const char* interface_info_get_name (InterfaceInfo *info); GSList* interface_info_get_methods (InterfaceInfo *info); @@ -87,7 +87,7 @@ void interface_info_add_signal SignalInfo *signal); MethodInfo* method_info_new (const char *name); -void method_info_ref (MethodInfo *info); +MethodInfo* method_info_ref (MethodInfo *info); void method_info_unref (MethodInfo *info); const char* method_info_get_name (MethodInfo *info); @@ -96,7 +96,7 @@ void method_info_add_arg ArgInfo *arg); SignalInfo* signal_info_new (const char *name); -void signal_info_ref (SignalInfo *info); +SignalInfo* signal_info_ref (SignalInfo *info); void signal_info_unref (SignalInfo *info); const char* signal_info_get_name (SignalInfo *info); @@ -107,7 +107,7 @@ void signal_info_add_arg ArgInfo* arg_info_new (const char *name, ArgDirection direction, int type); -void arg_info_ref (ArgInfo *info); +ArgInfo* arg_info_ref (ArgInfo *info); void arg_info_unref (ArgInfo *info); const char* arg_info_get_name (ArgInfo *info); int arg_info_get_type (ArgInfo *info); Index: glib/dbus-gmain.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gmain.c,v retrieving revision 1.25 diff -u -b -B -p -r1.25 dbus-gmain.c --- glib/dbus-gmain.c 12 Oct 2003 05:59:39 -0000 1.25 +++ glib/dbus-gmain.c 26 Nov 2003 10:20:19 -0000 @@ -88,10 +88,12 @@ watch_fd_new (void) return watch_fd; } -static void +static WatchFD * watch_fd_ref (WatchFD *watch_fd) { watch_fd->refcount += 1; + + return watch_fd; } static void Index: glib/dbus-gparser.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gparser.c,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gparser.c --- glib/dbus-gparser.c 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gparser.c 26 Nov 2003 10:20:19 -0000 @@ -184,10 +184,12 @@ parser_new (void) return parser; } -void +Parser * parser_ref (Parser *parser) { parser->refcount += 1; + + return parser; } void Index: glib/dbus-gparser.h =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gparser.h,v retrieving revision 1.2 diff -u -b -B -p -r1.2 dbus-gparser.h --- glib/dbus-gparser.h 30 Sep 2003 02:32:57 -0000 1.2 +++ glib/dbus-gparser.h 26 Nov 2003 10:20:19 -0000 @@ -32,7 +32,7 @@ G_BEGIN_DECLS typedef struct Parser Parser; Parser* parser_new (void); -void parser_ref (Parser *parser); +Parser* parser_ref (Parser *parser); void parser_unref (Parser *parser); gboolean parser_check_doctype (Parser *parser, const char *doctype, Index: glib/dbus-gproxy.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gproxy.c,v retrieving revision 1.6 diff -u -b -B -p -r1.6 dbus-gproxy.c --- glib/dbus-gproxy.c 21 Oct 2003 05:46:52 -0000 1.6 +++ glib/dbus-gproxy.c 26 Nov 2003 10:20:19 -0000 @@ -93,7 +93,7 @@ struct DBusGProxyManager }; -static void dbus_gproxy_manager_ref (DBusGProxyManager *manager); +static DBusGProxyManager *dbus_gproxy_manager_ref (DBusGProxyManager *manager); static DBusHandlerResult dbus_gproxy_manager_filter (DBusConnection *connection, DBusMessage *message, void *user_data); @@ -152,7 +152,7 @@ dbus_gproxy_manager_get (DBusConnection return manager; } -static void +static DBusGProxyManager * dbus_gproxy_manager_ref (DBusGProxyManager *manager) { g_assert (manager != NULL); @@ -163,6 +163,8 @@ dbus_gproxy_manager_ref (DBusGProxyManag manager->refcount += 1; UNLOCK_MANAGER (manager); + + return manager; } static void --=-WnuRFg0Sci+c8D6sLmHI-- From micke@imendio.com Thu Nov 27 01:29:48 2003 From: micke@imendio.com (Mikael Hallendal) Date: Thu, 27 Nov 2003 02:29:48 +0100 Subject: Bug in the boxing of DBusMessage in Glib layer In-Reply-To: <1069842910.14302.16.camel@chili.home.hallendal.net> References: <1069415140.20885.8.camel@chili.home.hallendal.net> <1069522717.24752.21.camel@localhost.localdomain> <1069842910.14302.16.camel@chili.home.hallendal.net> Message-ID: <1069896588.2365.51.camel@chili.home.hallendal.net> ons 2003-11-26 klockan 11.35 skrev Mikael Hallendal: > Patch that make all (I hope) _ref() functions return the pointer. Commited after approval from Havoc. Cheers, Mikael Hallendal -- Mikael Hallendal micke@imendio.com Imendio HB http://www.imendio.com Phone: +46 (0)709 718 918 From richard@imendio.com Sun Nov 30 15:58:22 2003 From: richard@imendio.com (Richard Hult) Date: Sun, 30 Nov 2003 16:58:22 +0100 Subject: Dict in dict bug Message-ID: <1070207901.7273.20.camel@carrot> --=-637lgiX7YncIj0Pb8DMo Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Currently, you can't put a dict inside a dict, since iter->wrote_dict_key isn't reset like when appending other types to a dict. The attached patch fixes that, and adds a test case for the bug. Does it look OK? /Richard --=-637lgiX7YncIj0Pb8DMo Content-Disposition: attachment; filename=dict-in-dict.patch Content-Type: text/x-patch; name=dict-in-dict.patch; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.443 diff -u -b -B -p -r1.443 ChangeLog --- ChangeLog 27 Nov 2003 01:25:49 -0000 1.443 +++ ChangeLog 30 Nov 2003 15:57:42 -0000 @@ -1,3 +1,13 @@ +2003-11-30 Richard Hult + + * dbus/dbus-message.c (dbus_message_iter_append_dict): Set + wrote_dict_key to FALSE on the iter that the dict is appended to, + just like when appending other types. Fixes a bug where a dict + couldn't be put inside a dict. + (dbus_message_iter_append_dict_key): Fix typo in warning message. + (message_iter_test, _dbus_message_test): Add test case for dict + inside dict. + 2003-11-26 Mikael Hallendal * bus/*.[ch]: Index: dbus/dbus-message.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v retrieving revision 1.115 diff -u -b -B -p -r1.115 dbus-message.c --- dbus/dbus-message.c 27 Nov 2003 01:25:49 -0000 1.115 +++ dbus/dbus-message.c 30 Nov 2003 15:57:42 -0000 @@ -3874,7 +3874,7 @@ dbus_message_iter_append_dict_key (DBusM if (real->wrote_dict_key) { - _dbus_warn ("Appendinging multiple dict key names\n"); + _dbus_warn ("Appending multiple dict key names\n"); return FALSE; } @@ -4082,6 +4082,8 @@ dbus_message_iter_append_dict (DBusMessa dbus_message_iter_append_done (dict_real); + real->wrote_dict_key = FALSE; + return TRUE; } @@ -5800,7 +5802,7 @@ dbus_message_type_from_string (const cha static void message_iter_test (DBusMessage *message) { - DBusMessageIter iter, dict, array, array2; + DBusMessageIter iter, dict, dict2, array, array2; char *str; unsigned char *data; dbus_int32_t *our_int_array; @@ -5899,6 +5900,32 @@ message_iter_test (DBusMessage *message) if (dbus_message_iter_get_uint32 (&dict) != 0xDEADBEEF) _dbus_assert_not_reached ("wrong dict entry value"); + /* dict (in dict) */ + + if (!dbus_message_iter_next (&dict)) + _dbus_assert_not_reached ("reached end of dict"); + + if (dbus_message_iter_get_arg_type (&dict) != DBUS_TYPE_DICT) + _dbus_assert_not_reached ("not dict type"); + + dbus_message_iter_init_dict_iterator (&dict, &dict2); + + str = dbus_message_iter_get_dict_key (&dict2); + if (str == NULL || strcmp (str, "dictkey") != 0) + _dbus_assert_not_reached ("wrong dict key"); + dbus_free (str); + + if (dbus_message_iter_get_arg_type (&dict2) != DBUS_TYPE_STRING) + _dbus_assert_not_reached ("wrong dict entry type"); + + str = dbus_message_iter_get_string (&dict2); + if (str == NULL || strcmp (str, "dictvalue") != 0) + _dbus_assert_not_reached ("wrong dict entry value"); + dbus_free (str); + + if (dbus_message_iter_next (&dict2)) + _dbus_assert_not_reached ("didn't reach end of dict"); + if (!dbus_message_iter_next (&dict)) _dbus_assert_not_reached ("reached end of dict"); @@ -7107,6 +7135,13 @@ _dbus_message_test (const char *test_dat dbus_message_iter_append_dict_key (&child_iter, "test"); dbus_message_iter_append_uint32 (&child_iter, 0xDEADBEEF); + /* dict (in dict) */ + dbus_message_iter_append_dict_key (&child_iter, "testdict"); + dbus_message_iter_append_dict (&child_iter, &child_iter2); + + dbus_message_iter_append_dict_key (&child_iter2, "dictkey"); + dbus_message_iter_append_string (&child_iter2, "dictvalue"); + /* array of array of int32 (in dict) */ dbus_message_iter_append_dict_key (&child_iter, "array"); dbus_message_iter_append_array (&child_iter, &child_iter2, DBUS_TYPE_ARRAY); --=-637lgiX7YncIj0Pb8DMo-- From hp@redhat.com Sun Nov 30 18:32:31 2003 From: hp@redhat.com (Havoc Pennington) Date: Sun, 30 Nov 2003 13:32:31 -0500 Subject: Dict in dict bug In-Reply-To: <1070207901.7273.20.camel@carrot> References: <1070207901.7273.20.camel@carrot> Message-ID: <1070217151.4479.50.camel@localhost.localdomain> On Sun, 2003-11-30 at 10:58, Richard Hult wrote: > Hi, > > Currently, you can't put a dict inside a dict, since > iter->wrote_dict_key isn't reset like when appending other types to a > dict. The attached patch fixes that, and adds a test case for the bug. > > Does it look OK? > Looks sane, thanks. Havoc