summaryrefslogtreecommitdiffstats
path: root/network/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'network/server.c')
-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);