Navigation Menu

Skip to content

Commit

Permalink
convert errors to btd_error_not_authorized()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo F. Padovan authored and Jaikumar Ganesh committed Mar 11, 2011
1 parent 46cc3ef commit 96e50d1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions audio/gateway.c
Expand Up @@ -514,8 +514,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
goto done;

if (strcmp(gw->agent->name, dbus_message_get_sender(msg)) != 0)
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
"Permission denied");
return btd_error_not_authorized(msg);

if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_OBJECT_PATH, &path,
Expand Down
8 changes: 4 additions & 4 deletions audio/transport.c
Expand Up @@ -443,10 +443,10 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,

owner = media_transport_find_owner(transport, sender);
if (owner != NULL)
return error_failed(msg, strerror(EPERM));
return btd_error_not_authorized(msg);

if (media_transport_acquire(transport, accesstype) == FALSE)
return error_failed(msg, strerror(EPERM));
return btd_error_not_authorized(msg);

owner = media_owner_create(transport, msg, accesstype);
req = g_new0(struct acquire_request, 1);
Expand Down Expand Up @@ -476,15 +476,15 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,

owner = media_transport_find_owner(transport, sender);
if (owner == NULL)
return error_failed(msg, strerror(EPERM));
return btd_error_not_authorized(msg);

if (g_strcmp0(owner->accesstype, accesstype) == 0)
media_owner_remove(owner);
else if (g_strstr_len(owner->accesstype, -1, accesstype) != NULL) {
media_transport_release(transport, accesstype);
g_strdelimit(owner->accesstype, accesstype, ' ');
} else
return error_failed(msg, strerror(EPERM));
return btd_error_not_authorized(msg);

return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
Expand Down
2 changes: 1 addition & 1 deletion network/connection.c
Expand Up @@ -438,7 +438,7 @@ static DBusMessage *connection_cancel(DBusConnection *conn,
const char *caller = dbus_message_get_sender(msg);

if (!g_str_equal(owner, caller))
return not_permited(msg);
return btd_error_not_authorized(msg);

connection_destroy(conn, nc);

Expand Down
2 changes: 1 addition & 1 deletion serial/port.c
Expand Up @@ -538,7 +538,7 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
owner = dbus_message_get_sender(port->msg);
caller = dbus_message_get_sender(msg);
if (!g_str_equal(owner, caller))
return failed(msg, "Operation not permited");
return btd_error_not_authorized(msg);

port_release(port);

Expand Down
4 changes: 2 additions & 2 deletions serial/proxy.c
Expand Up @@ -728,7 +728,7 @@ static DBusMessage *proxy_set_serial_params(DBusConnection *conn,

/* Don't allow change TTY settings if it is open */
if (prx->local)
return failed(msg, "Not allowed");
return btd_error_not_authorized(msg);

if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &ratestr,
Expand Down Expand Up @@ -1112,7 +1112,7 @@ static DBusMessage *remove_proxy(DBusConnection *conn,

sender = dbus_message_get_sender(msg);
if (g_strcmp0(prx->owner, sender) != 0)
return failed(msg, "Permission denied");
return btd_error_not_authorized(msg);

unregister_proxy(prx);

Expand Down

0 comments on commit 96e50d1

Please sign in to comment.