summaryrefslogtreecommitdiffstats
path: root/network
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-03-28 15:33:31 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-03-28 15:33:31 +0000
commitea1a79ba431bd7aec17fe24084577443fb2a72d5 (patch)
tree25757551ae6e46c2f5cda5c5aebf5d449ddab621 /network
parentfdacbf3a77476dc525425ee060bbf5809383b885 (diff)
network: reply bnep "not allowed" if the bnep_connadd fails
Diffstat (limited to 'network')
-rw-r--r--network/server.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/network/server.c b/network/server.c
index e8dedf7b..e04d6de4 100644
--- a/network/server.c
+++ b/network/server.c
@@ -232,8 +232,10 @@ static void authorization_callback(DBusPendingCall *pcall, void *data)
{
struct network_server *ns = data;
DBusMessage *reply = dbus_pending_call_steal_reply(pcall);
+ char devname[16];
DBusError derr;
uint16_t response;
+ int sk;
if (!ns->pauth)
goto failed;
@@ -242,28 +244,28 @@ static void authorization_callback(DBusPendingCall *pcall, void *data)
if (dbus_set_error_from_message(&derr, reply)) {
error("Access denied: %s", derr.message);
response = BNEP_CONN_NOT_ALLOWED;
- } else {
- char devname[16];
- int sk;
-
- response = BNEP_SUCCESS;
-
- memset(devname, 0, 16);
- strncpy(devname, netdev, 16);
+ dbus_error_free(&derr);
+ goto reply;
+ }
- /* FIXME: Is it the correct order? */
- sk = g_io_channel_unix_get_fd(ns->pauth->io);
- bnep_connadd(sk, ns->id, devname);
+ memset(devname, 0, 16);
+ strncpy(devname, netdev, 16);
- /* FIXME: Reply not allowed if bnep connection add fails? */
+ /* FIXME: Is it the correct order? */
+ sk = g_io_channel_unix_get_fd(ns->pauth->io);
+ if (bnep_connadd(sk, ns->id, devname) < 0) {
+ response = BNEP_CONN_NOT_ALLOWED;
+ goto reply;
+ }
- info("Authorization succedded. New connection: %s", devname);
+ info("Authorization succedded. New connection: %s", devname);
+ response = BNEP_SUCCESS;
- /* Enable routing if applied */
+ /* FIXME: Enable routing if applied */
- /* FIXME: send the D-Bus message to notify the new bnep iface */
- }
+ /* FIXME: send the D-Bus message to notify the new bnep iface */
+reply:
send_bnep_ctrl_rsp(ns->pauth->io, response);
pending_auth_free(ns->pauth);