diff --git a/ofono/include/dbus-access.h b/ofono/include/dbus-access.h index ace340ce..c62ce6de 100644 --- a/ofono/include/dbus-access.h +++ b/ofono/include/dbus-access.h @@ -41,6 +41,8 @@ enum ofono_dbus_access_intf { OFONO_DBUS_ACCESS_INTF_RADIOSETTINGS, /* org.ofono.RadioSettings */ OFONO_DBUS_ACCESS_INTF_STK, /* org.ofono.SimToolkit */ OFONO_DBUS_ACCESS_INTF_OEMRAW, /* org.ofono.OemRaw */ + /* Since 1.29+git3 */ + OFONO_DBUS_ACCESS_INTF_IMS, /* org.ofono.IpMultimediaSystem */ OFONO_DBUS_ACCESS_INTF_COUNT }; @@ -132,6 +134,15 @@ enum ofono_dbus_access_oemraw_method { OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT }; +/* OFONO_DBUS_ACCESS_INTF_IMS */ +enum ofono_dbus_access_ims_method { + /* Since 1.29+git3 */ + OFONO_DBUS_ACCESS_IMS_SET_PROPERTY, + OFONO_DBUS_ACCESS_IMS_REGISTER, + OFONO_DBUS_ACCESS_IMS_UNREGISTER, + OFONO_DBUS_ACCESS_IMS_METHOD_COUNT +}; + #define OFONO_DBUS_ACCESS_PRIORITY_LOW (-100) #define OFONO_DBUS_ACCESS_PRIORITY_DEFAULT (0) #define OFONO_DBUS_ACCESS_PRIORITY_HIGH (100) @@ -159,7 +170,7 @@ const char *ofono_dbus_access_intf_name(enum ofono_dbus_access_intf intf); const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf, int method); -/* Since mer/1.24+git2 */ +/* Since 1.24+git2 */ ofono_bool_t ofono_dbus_access_method_allowed(const char *sender, enum ofono_dbus_access_intf iface, int method, const char *arg); diff --git a/ofono/src/dbus-access.c b/ofono/src/dbus-access.c index 480dbd20..11769734 100644 --- a/ofono/src/dbus-access.c +++ b/ofono/src/dbus-access.c @@ -46,6 +46,8 @@ const char *ofono_dbus_access_intf_name(enum ofono_dbus_access_intf intf) return OFONO_STK_INTERFACE; case OFONO_DBUS_ACCESS_INTF_OEMRAW: return "org.ofono.OemRaw"; + case OFONO_DBUS_ACCESS_INTF_IMS: + return OFONO_IMS_INTERFACE; case OFONO_DBUS_ACCESS_INTF_COUNT: break; } @@ -188,6 +190,18 @@ const char *ofono_dbus_access_method_name(enum ofono_dbus_access_intf intf, break; } break; + case OFONO_DBUS_ACCESS_INTF_IMS: + switch ((enum ofono_dbus_access_ims_method)method) { + case OFONO_DBUS_ACCESS_IMS_SET_PROPERTY: + return "SetProperty"; + case OFONO_DBUS_ACCESS_IMS_REGISTER: + return "Register"; + case OFONO_DBUS_ACCESS_IMS_UNREGISTER: + return "Unregister"; + case OFONO_DBUS_ACCESS_IMS_METHOD_COUNT: + break; + } + break; case OFONO_DBUS_ACCESS_INTF_COUNT: break; } diff --git a/ofono/src/ims.c b/ofono/src/ims.c index 6f79cecc..1c33fa2b 100644 --- a/ofono/src/ims.c +++ b/ofono/src/ims.c @@ -51,6 +51,13 @@ struct ofono_ims { static GSList *g_drivers = NULL; +static inline gboolean ims_dbus_access_allowed(DBusMessage *msg, + enum ofono_dbus_access_ims_method method) +{ + return ofono_dbus_access_method_allowed(dbus_message_get_sender(msg), + OFONO_DBUS_ACCESS_INTF_IMS, method, NULL); +} + static DBusMessage *ims_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -209,6 +216,9 @@ static DBusMessage *ofono_ims_send_register(DBusConnection *conn, { struct ofono_ims *ims = data; + if (!ims_dbus_access_allowed(msg, OFONO_DBUS_ACCESS_IMS_REGISTER)) + return __ofono_error_access_denied(msg); + if (ims->pending) return __ofono_error_busy(msg); @@ -227,6 +237,9 @@ static DBusMessage *ofono_ims_unregister(DBusConnection *conn, { struct ofono_ims *ims = data; + if (!ims_dbus_access_allowed(msg, OFONO_DBUS_ACCESS_IMS_UNREGISTER)) + return __ofono_error_access_denied(msg); + if (ims->pending) return __ofono_error_busy(msg); diff --git a/ofono/unit/test-dbus-access.c b/ofono/unit/test-dbus-access.c index 0f044fd1..b214c5f4 100644 --- a/ofono/unit/test-dbus-access.c +++ b/ofono/unit/test-dbus-access.c @@ -1,7 +1,7 @@ /* * oFono - Open Source Telephony * - * Copyright (C) 2019-2021 Jolla Ltd. + * Copyright (C) 2019-2022 Jolla Ltd. * Copyright (C) 2020 Open Mobile Platform LLC. * * This program is free software; you can redistribute it and/or modify @@ -122,6 +122,9 @@ static const struct test_method_name_data method_name_tests[] = { },{ OFONO_DBUS_ACCESS_INTF_OEMRAW, OFONO_DBUS_ACCESS_OEMRAW_METHOD_COUNT + },{ + OFONO_DBUS_ACCESS_INTF_IMS, + OFONO_DBUS_ACCESS_IMS_METHOD_COUNT } };