<div dir="ltr"><br><br><div class="gmail_quote">Hi,<div link="blue" vlink="purple" lang="EN-US"><div>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I am using DBUS over TCP for communication between two
remote machines.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I am not using dbus-daemon and have a custom dbus
server and client instead.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">The issue I am facing is when I use
dbus_connection_set_allow_anonymous(conn,TRUE) for enabling anonymous only
access mode, the client is not able to send data and the connection is lost
during dbus_connection_flush.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">If I comment out this line, DBUS_COOKIE_SHA1 takes place and
from the same machine and as the same user I am able to communicate between the
client and server.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">When I enable verbose, the following message is shown at the
server.</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">13972: server: Sent 46 bytes of: REJECTED EXTERNAL
DBUS_COOKIE_SHA1 ANONYMOUS</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">When the DBUS_COOKIE_SHA1 authentication takes place the
corresponding message is :</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">13958: server: Sent 141 bytes of: DATA
6f72675f667265656465736b746f705f67656e6572616c2031323631363231303438203164363166373463633338626134636330623963623730353966346235353463</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Why am I not able to get an anonymous access to the server
even if that is enabled?</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">My code looks like:</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#define DBUS_API_SUBJECT_TO_CHANGE</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#include <stdio.h></span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#include <stdlib.h></span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#include <dbus/dbus.h></span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#include <glib.h></span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#include <dbus/dbus-glib-lowlevel.h></span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#define USAGE "usage %s client|server addr (f)\n"</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">#define BUFSIZE 10</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">int client(char * addr) {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> char * buffer;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> int i=0;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> DBusConnection*
con;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> DBusError error;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> buffer =
malloc(BUFSIZE);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> dbus_error_init
(&error);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> con =
dbus_connection_open(addr, &error);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> if (con == NULL)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
fprintf (stderr, "could not open connection: %s\n", error.message);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_error_free (&error);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
return 1;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> }</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> for(;;) {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
DBusMessage *message;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
message =
dbus_message_new_signal("/p","my.i","n");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
size_t blen = fread (buffer, 1, BUFSIZE, stdin);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
if (blen==0) break;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_message_append_args(message,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
DBUS_TYPE_INT32, &i, DBUS_TYPE_ARRAY,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
DBUS_TYPE_BYTE,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
&buffer, blen,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
DBUS_TYPE_INVALID</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
if (!dbus_connection_send (con,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
message,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
NULL))</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
fprintf(stderr, "mes %d: send message failed\n", i);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_message_unref (message);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_connection_flush(con) ;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
if (!dbus_connection_get_is_connected(con))</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
fprintf(stderr, "connection not connected!\n");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
exit(1);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
i++;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> }</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> dbus_connection_close(con);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> fprintf(stderr,
"finished=%d\n", i);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">static void</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">new_connection_callback (DBusServer
*server,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
DBusConnection *new_connection,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
void *user_data)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> char * buffer;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> int len;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> fprintf (stderr,
"new_connection_callback\n");</span></font></p>
<p><b><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; font-weight: bold;">
dbus_connection_set_allow_anonymous (new_connection, TRUE);</span></font></b></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_connection_ref (new_connection);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> while (dbus_connection_read_write_dispatch
(new_connection, -1))</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
/* use dbus_connection_read_write(new_connection, -1)) instead? */</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
DBusMessage* m;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
while (m=dbus_connection_pop_message(new_connection)) {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
int ival;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
if (!dbus_message_get_args(m, NULL, DBUS_TYPE_INT32, &ival,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &buffer, &len, DBUS_TYPE_INVALID))</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
fprintf(stderr, "message error name=%s\n",
dbus_message_get_error_name(m));</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
else</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
fwrite (buffer, 1, len, stdout);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_message_unref
(m);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> }</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> fflush(stdout);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> fprintf (stderr,
"end connection\n");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> exit(0);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">static int</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">get_port(DBusServer *server)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> char *address;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> DBusAddressEntry **entries;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> int n_entries;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> const char *port_str;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> int port;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> address =
dbus_server_get_address(server);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> if (!dbus_parse_address (address,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
&entries,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
&n_entries,</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
NULL) ||</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> n_entries < 1)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
g_error("libdbus could not parse its own address '%s'", address);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> /* libdbus doesn't really guarantee this
but it should be ok to assume */</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
g_assert(strcmp(dbus_address_entry_get_method(entries[0]), "tcp") ==
0);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> port_str = dbus_address_entry_get_value
(entries[0], "port");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> if (port_str == NULL)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
g_error("libdbus returned no port in tcp address entry");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> port = atoi (port_str);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> g_assert (port > 0);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> dbus_address_entries_free (entries);
</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> dbus_free(address);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> return port;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">int server(char * addr) {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> GMainLoop *loop;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> DBusServer
*server;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> GMainContext
*context;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> DBusError error;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
int listening_on_port;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
const char *auth_mechanisms[] = { "ANONYMOUS" };</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> printf("In
server\n");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> dbus_error_init
(&error);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
server = dbus_server_listen(addr, &error);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
if (server == NULL) {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
g_printerr("Error listening on TCP: %s\n",
error.message);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
return FALSE;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
g_assert(dbus_server_get_is_connected(server));</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> <b><span style="font-weight: bold;">dbus_server_set_auth_mechanisms(server,
auth_mechanisms);</span></b></span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> dbus_server_setup_with_g_main(server,
NULL);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> /* Allow only anonymous auth, don't even attempt
user auth</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> */</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
dbus_server_set_new_connection_function(server, new_connection_callback, NULL,
NULL);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> listening_on_port = get_port(server);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> printf("server is listening on port
%d\n",listening_on_port);
</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> loop = g_main_loop_new (NULL, FALSE);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> g_main_run (loop);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">int main(int argc, char** argv)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">{</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> if (argc < 3)</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> {</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
printf("args error\n");</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
//fprintf (stderr, USAGE, argv[0]);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">
return 1;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> }</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> if (strcmp(argv[1],
"server")==0) return server(argv[2]);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> if
(strcmp(argv[1], "client")==0) return client(argv[2]);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> //printf (stderr,
USAGE, argv[0]);</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> return 1;</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">}</span></font></p>
<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"></span></font></p>
</div>
</div>
<table><tbody><tr><td bgcolor="#ffffff"></td></tr></tbody></table></div>Regards,<br>Remya<br></div>