Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mms-engine] Added org.nemomobile.MmsEngine.exit D-Bus method. JB#50406
Allows sufficiently privileged client to stop the service in case if
mms-engine needs to be restarted under a different user account.
  • Loading branch information
monich committed Jul 8, 2020
1 parent e1c516c commit 599d6f1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mms-engine/main.c
Expand Up @@ -57,6 +57,7 @@ typedef struct mms_app_dbus_policy {
#define MMS_ENGINE_DBUS_METHOD_SET_LOG_TYPE "setLogType"
#define MMS_ENGINE_DBUS_METHOD_GET_VERSION "getVersion"
#define MMS_ENGINE_DBUS_METHOD_MIGRATE_SETTINGS "migrateSettings"
#define MMS_ENGINE_DBUS_METHOD_EXIT "exit"

static const DA_ACTION mms_engine_dbus_actions[] = {
#define INIT_DA_ACTION(id) \
Expand All @@ -74,7 +75,8 @@ static const MMSAppDBusPolicy mms_engine_default_dbus_policy = {
MMS_ENGINE_DBUS_METHOD_SEND_MESSAGE"()|"
MMS_ENGINE_DBUS_METHOD_SET_LOG_LEVEL"()|"
MMS_ENGINE_DBUS_METHOD_SET_LOG_TYPE"()|"
MMS_ENGINE_DBUS_METHOD_MIGRATE_SETTINGS"()))|"
MMS_ENGINE_DBUS_METHOD_MIGRATE_SETTINGS"()|"
MMS_ENGINE_DBUS_METHOD_EXIT"()))|"
"((!(user("RADIO_USER")&group("RADIO_GROUP")))&("
MMS_ENGINE_DBUS_METHOD_PUSH"()|"
MMS_ENGINE_DBUS_METHOD_PUSH_NOTIFY "()))=deny",
Expand Down
20 changes: 20 additions & 0 deletions mms-engine/mms_engine.c
Expand Up @@ -547,6 +547,23 @@ mms_engine_handle_migrate_settings(
return TRUE;
}

/* org.nemomobile.MmsEngine.exit */
static
gboolean
mms_engine_handle_exit(
OrgNemomobileMmsEngine* proxy,
GDBusMethodInvocation* call,
MMSEngine* engine)
{
/* mms_engine_dbus_access_allowed completes the call if access is denied */
if (mms_engine_dbus_access_allowed(engine, call, MMS_ENGINE_ACTION_EXIT)) {
GDEBUG("Exit requested over D-Bus");
mms_engine_stop(engine);
org_nemomobile_mms_engine_complete_exit(proxy, call);
}
return TRUE;
}

MMSEngine*
mms_engine_new(
const MMSConfig* config,
Expand Down Expand Up @@ -636,6 +653,9 @@ mms_engine_new(
mms->proxy_signal_id[MMS_ENGINE_METHOD_MIGRATE_SETTINGS] =
g_signal_connect(mms->proxy, "handle-migrate-settings",
G_CALLBACK(mms_engine_handle_migrate_settings), mms);
mms->proxy_signal_id[MMS_ENGINE_METHOD_EXIT] =
g_signal_connect(mms->proxy, "handle-exit",
G_CALLBACK(mms_engine_handle_exit), mms);

return mms;
}
Expand Down
3 changes: 2 additions & 1 deletion mms-engine/mms_engine.h
Expand Up @@ -49,7 +49,8 @@
m(SET_LOG_LEVEL) \
m(SET_LOG_TYPE) \
m(GET_VERSION) \
m(MIGRATE_SETTINGS)
m(MIGRATE_SETTINGS) \
m(EXIT)

typedef enum mms_engine_action {
/* Action ids must be non-zero, shift those by one */
Expand Down
3 changes: 3 additions & 0 deletions mms-engine/org.nemomobile.MmsEngine.xml
Expand Up @@ -211,5 +211,8 @@
<arg type="s" name="imsi" direction="in"/>
</method>

<!-- Since 1.0.70 -->
<method name="exit"/>

</interface>
</node>

0 comments on commit 599d6f1

Please sign in to comment.