Validate sender information for every request from client 94/274794/1 submit/tizen/20220510.005443
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 9 May 2022 11:45:12 +0000 (20:45 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Mon, 9 May 2022 11:45:36 +0000 (20:45 +0900)
Change-Id: I3d3b51e8b70dec4f8a25eb2827c5f647f6cca273

inc/client_manager.h
inc/service_ipc_dbus_dispatcher.h
inc/service_main.h
src/client_manager.cpp
src/service_ipc_dbus_dispatcher.cpp
src/service_main.cpp

index 94712a1..0f98b34 100644 (file)
@@ -26,6 +26,7 @@
 typedef struct {
        pid_t pid;
        std::string appid;
+       std::string sender_info;
 } ma_client_s;
 
 class CClientManager {
@@ -34,7 +35,7 @@ public:
        virtual ~CClientManager() {}
 
        int set_application_manager(IApplicationManager* manager);
-       int create_client(pid_t pid, std::string appid);
+       int create_client(pid_t pid, std::string appid, std::string sender_info);
        int destroy_client_by_pid(pid_t pid);
        int destroy_client_by_appid(std::string appid);
 
@@ -43,8 +44,11 @@ public:
 
        pid_t find_client_pid_by_appid(std::string appid);
        std::string find_client_appid_by_pid(pid_t pid);
+       std::string find_sender_info_by_pid(pid_t pid);
 
        bool check_client_validity_by_appid(std::string appid);
+
+       bool check_sender_info_by_pid(pid_t pid, std::string sender_info);
 private:
        ma_client_s* find_client_by_appid(std::string appid);
        ma_client_s* find_client_by_pid(pid_t pid);
index 9d2250b..c7f3104 100644 (file)
@@ -25,25 +25,25 @@ class CServiceMain;
 
 class IServiceIpcObserver {
 public:
-       virtual int on_initialize(pid_t pid) = 0;
-       virtual int on_deinitialize(pid_t pid) = 0;
-       virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) = 0;
-       virtual int on_get_audio_source_type(pid_t pid, std::string& type) = 0;
-       virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result) = 0;
+       virtual int on_initialize(pid_t pid, std::string sender_info) = 0;
+       virtual int on_deinitialize(pid_t pid, std::string sender_info) = 0;
+       virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type, std::string sender_info) = 0;
+       virtual int on_get_audio_source_type(pid_t pid, std::string& type, std::string sender_info) = 0;
+       virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result, std::string sender_info) = 0;
        virtual int on_send_result(pid_t pid,
-               std::string display_text, std::string utterance_text, std::string result_json) = 0;
-       virtual int on_send_recognition_result(pid_t pid, int result) = 0;
-       virtual int on_start_streaming_audio_data(pid_t pid, int type) = 0;
-       virtual int on_stop_streaming_audio_data(pid_t pid, int type) = 0;
-       virtual int on_update_voice_feedback_state(pid_t pid, int state) = 0;
-       virtual int on_send_assistant_specific_command(pid_t pid, std::string command) = 0;
-       virtual int on_set_background_volume(pid_t pid, double ratio) = 0;
-       virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) = 0;
-       virtual int on_send_preprocessing_result(pid_t pid, int result) = 0;
-       virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require) = 0;
-       virtual int on_set_assistant_language(pid_t pid, std::string language) = 0;
-       virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) = 0;
-       virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) = 0;
+               std::string display_text, std::string utterance_text, std::string result_json, std::string sender_info) = 0;
+       virtual int on_send_recognition_result(pid_t pid, int result, std::string sender_info) = 0;
+       virtual int on_start_streaming_audio_data(pid_t pid, int type, std::string sender_info) = 0;
+       virtual int on_stop_streaming_audio_data(pid_t pid, int type, std::string sender_info) = 0;
+       virtual int on_update_voice_feedback_state(pid_t pid, int state, std::string sender_info) = 0;
+       virtual int on_send_assistant_specific_command(pid_t pid, std::string command, std::string sender_info) = 0;
+       virtual int on_set_background_volume(pid_t pid, double ratio, std::string sender_info) = 0;
+       virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id, std::string sender_info) = 0;
+       virtual int on_send_preprocessing_result(pid_t pid, int result, std::string sender_info) = 0;
+       virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require, std::string sender_info) = 0;
+       virtual int on_set_assistant_language(pid_t pid, std::string language, std::string sender_info) = 0;
+       virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) = 0;
+       virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) = 0;
 
        virtual int on_ui_initialize(pid_t pid) = 0;
        virtual int on_ui_deinitialize(pid_t pid) = 0;
index 168b59f..c3fc791 100644 (file)
@@ -123,25 +123,25 @@ public:
        int process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event);
        int update_voice_key_support_mode();
 
-       int on_initialize(pid_t pid) override;
-       int on_deinitialize(pid_t pid) override;
-       int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) override;
-       int on_get_audio_source_type(pid_t pid, std::string& type) override;
-       int on_send_asr_result(pid_t pid, int event, std::string asr_result) override;
+       int on_initialize(pid_t pid, std::string sender_info) override;
+       int on_deinitialize(pid_t pid, std::string sender_info) override;
+       int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type, std::string sender_info) override;
+       int on_get_audio_source_type(pid_t pid, std::string& type, std::string sender_info) override;
+       int on_send_asr_result(pid_t pid, int event, std::string asr_result, std::string sender_info) override;
        int on_send_result(pid_t pid, std::string display_text,
-               std::string utterance_text, std::string result_json) override;
-       int on_send_recognition_result(pid_t pid, int result) override;
-       int on_start_streaming_audio_data(pid_t pid, int type) override;
-       int on_stop_streaming_audio_data(pid_t pid, int type) override;
-       int on_update_voice_feedback_state(pid_t pid, int state) override;
-       int on_send_assistant_specific_command(pid_t pid, std::string command) override;
-       int on_set_background_volume(pid_t pid, double ratio) override;
-       int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) override;
-       int on_send_preprocessing_result(pid_t pid, int result) override;
-       int on_set_wake_word_audio_require_flag(pid_t pid, int require) override;
-       int on_set_assistant_language(pid_t pid, std::string language) override;
-       int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) override;
-       int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) override;
+               std::string utterance_text, std::string result_json, std::string sender_info) override;
+       int on_send_recognition_result(pid_t pid, int result, std::string sender_info) override;
+       int on_start_streaming_audio_data(pid_t pid, int type, std::string sender_info) override;
+       int on_stop_streaming_audio_data(pid_t pid, int type, std::string sender_info) override;
+       int on_update_voice_feedback_state(pid_t pid, int state, std::string sender_info) override;
+       int on_send_assistant_specific_command(pid_t pid, std::string command, std::string sender_info) override;
+       int on_set_background_volume(pid_t pid, double ratio, std::string sender_info) override;
+       int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id, std::string sender_info) override;
+       int on_send_preprocessing_result(pid_t pid, int result, std::string sender_info) override;
+       int on_set_wake_word_audio_require_flag(pid_t pid, int require, std::string sender_info) override;
+       int on_set_assistant_language(pid_t pid, std::string language, std::string sender_info) override;
+       int on_add_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) override;
+       int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) override;
 
        int on_ui_initialize(pid_t pid) override;
        int on_ui_deinitialize(pid_t pid) override;
index 2fd5b61..0225eb1 100644 (file)
@@ -23,7 +23,7 @@ int CClientManager::set_application_manager(IApplicationManager* manager)
        return 0;
 }
 
-int CClientManager::create_client(pid_t pid, std::string appid)
+int CClientManager::create_client(pid_t pid, std::string appid, std::string sender_info)
 {
        ma_client_s* data = NULL;
 
@@ -37,6 +37,7 @@ int CClientManager::create_client(pid_t pid, std::string appid)
        if (data) {
                data->pid = pid;
                data->appid = appid;
+               data->sender_info = sender_info;
                mClientList = g_slist_append(mClientList, data);
                MAS_LOGI("Create client : %s %d", appid.c_str(), pid);
        } else {
@@ -188,9 +189,35 @@ std::string CClientManager::find_client_appid_by_pid(pid_t pid)
        return appid;
 }
 
+std::string CClientManager::find_sender_info_by_pid(pid_t pid)
+{
+       std::string ret;
+       ma_client_s* client = find_client_by_pid(pid);
+       if (client) {
+               ret = client->sender_info;
+       }
+       return ret;
+}
+
 bool CClientManager::check_client_validity_by_appid(std::string appid)
 {
        pid_t pid = find_client_pid_by_appid(appid);
        if (0 < pid) return true;
        return false;
 }
+
+bool CClientManager::check_sender_info_by_pid(pid_t pid, std::string sender_info)
+{
+       bool ret = false;
+       ma_client_s* client = find_client_by_pid(pid);
+       if (client) {
+               if (client->sender_info.compare(sender_info) == 0) {
+                       ret = true;
+               }
+       }
+       if (!ret) {
+               MAS_LOGE("SENDER INFO does not match : [%s] [%s]",
+                       client->sender_info.c_str(), sender_info.c_str());
+       }
+       return ret;
+}
index 674c9e1..b2552af 100644 (file)
@@ -63,6 +63,7 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage*
                MAS_LOGE("[ERROR] Failed retrieving arguments");
        }
 
+
        MAS_LOGD("[DEBUG] MAS INITIALIZE");
 
        if (dbus_error_is_set(&err)) {
@@ -71,7 +72,8 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage*
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGD("[IN] mas initialize : pid(%d)", pid);
-               ret = mIpcObserver->on_initialize(pid);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_initialize(pid, (sender ? sender : ""));
        }
 
        DBusMessage* reply;
@@ -129,7 +131,8 @@ int CServiceIpcDbusDispatcher::on_deinitialize(DBusConnection* conn, DBusMessage
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGD("[IN] mas deinitialize : pid(%d)", pid);
-               ret = mIpcObserver->on_deinitialize(pid);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_deinitialize(pid, (sender ? sender : ""));
        }
 
        DBusMessage* reply;
@@ -188,7 +191,8 @@ int CServiceIpcDbusDispatcher::on_get_audio_format(DBusConnection* conn, DBusMes
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGD("[IN] mas get audio format");
-               ret = mIpcObserver->on_get_audio_format(pid, rate, channel, audio_type);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_get_audio_format(pid, rate, channel, audio_type, (sender ? sender : ""));
        }
 
        DBusMessage* reply;
@@ -249,7 +253,8 @@ int CServiceIpcDbusDispatcher::on_get_audio_source_type(DBusConnection* conn, DB
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGD("[IN] mas get audio source type");
-               ret = mIpcObserver->on_get_audio_source_type(pid, type);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_get_audio_source_type(pid, type, (sender ? sender : ""));
        }
 
        DBusMessage* reply;
@@ -320,8 +325,10 @@ int CServiceIpcDbusDispatcher::on_send_asr_result(DBusConnection* conn, DBusMess
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas send asr result : pid(%d), event(%d), asr_result(%s)", pid, event, asr_result);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_send_asr_result(pid, event,
-                       asr_result ? std::string{asr_result} : std::string{});
+                       asr_result ? std::string{asr_result} : std::string{},
+                       (sender ? sender : ""));
        }
 
        DBusMessage* reply;
@@ -387,10 +394,12 @@ int CServiceIpcDbusDispatcher::on_send_result(DBusConnection* conn, DBusMessage*
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas send result : pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_send_result(pid,
                        display_text ? std::string{display_text} : std::string{},
                        utterance_text ? std::string{utterance_text} : std::string{},
-                       result_json ? std::string{result_json} : std::string{});
+                       result_json ? std::string{result_json} : std::string{},
+                       (sender ? sender : ""));
        }
 
        DBusMessage* reply;
@@ -452,7 +461,8 @@ int CServiceIpcDbusDispatcher::on_send_recognition_result(DBusConnection* conn,
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas send recognition result : pid(%d), result(%d)", pid, result);
-               ret = mIpcObserver->on_send_recognition_result(pid, result);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_send_recognition_result(pid, result, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -490,7 +500,8 @@ int CServiceIpcDbusDispatcher::on_start_streaming_audio_data(DBusConnection* con
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas send start streaming : pid(%d), type(%d)", pid, type);
-               ret = mIpcObserver->on_start_streaming_audio_data(pid, type);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_start_streaming_audio_data(pid, type, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -528,7 +539,8 @@ int CServiceIpcDbusDispatcher::on_stop_streaming_audio_data(DBusConnection* conn
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas stop streaming : pid(%d), type(%d)", pid, type);
-               ret = mIpcObserver->on_stop_streaming_audio_data(pid, type);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_stop_streaming_audio_data(pid, type, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -566,7 +578,8 @@ int CServiceIpcDbusDispatcher::on_update_voice_feedback_state(DBusConnection* co
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas update voice feedback : pid(%d), state(%d)", pid, state);
-               ret = mIpcObserver->on_update_voice_feedback_state(pid, state);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_update_voice_feedback_state(pid, state, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -604,8 +617,10 @@ int CServiceIpcDbusDispatcher::on_send_assistant_specific_command(DBusConnection
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas send assistant specific command : pid(%d), command(%s)", pid, command);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_send_assistant_specific_command(pid,
-                       command ? std::string{command} : std::string{});
+                       command ? std::string{command} : std::string{},
+                       (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -643,7 +658,8 @@ int CServiceIpcDbusDispatcher::on_set_background_volume(DBusConnection* conn, DB
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas set background volume : pid(%d), ratio(%f)", pid, ratio);
-               ret = mIpcObserver->on_set_background_volume(pid, ratio);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_set_background_volume(pid, ratio, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -683,9 +699,11 @@ int CServiceIpcDbusDispatcher::on_set_preprocessing_allow_mode(DBusConnection* c
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas set preprocessing allow mode : pid(%d), mode(%d), app_id(%s)", pid, mode, app_id);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_set_preprocessing_allow_mode(pid,
                        static_cast<ma_preprocessing_allow_mode_e>(mode),
-                       app_id ? std::string{app_id} : std::string{});
+                       app_id ? std::string{app_id} : std::string{},
+                       (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -723,7 +741,8 @@ int CServiceIpcDbusDispatcher::on_send_preprocessing_result(DBusConnection* conn
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas send preprocessing result : pid(%d), result(%d)", pid, result);
-               ret = mIpcObserver->on_send_preprocessing_result(pid, result);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_send_preprocessing_result(pid, result, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -761,7 +780,8 @@ int CServiceIpcDbusDispatcher::on_set_wake_word_audio_require_flag(DBusConnectio
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas set wake word audio require flag : pid(%d), require(%d)", pid, require);
-               ret = mIpcObserver->on_set_wake_word_audio_require_flag(pid, require);
+               const char *sender = dbus_message_get_sender(msg);
+               ret = mIpcObserver->on_set_wake_word_audio_require_flag(pid, require, (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -799,8 +819,10 @@ int CServiceIpcDbusDispatcher::on_set_assistant_language(DBusConnection* conn, D
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas set assistant language : pid(%d), language(%s)", pid, language);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_set_assistant_language(pid,
-                       language ? std::string{language} : std::string{});
+                       language ? std::string{language} : std::string{},
+                       (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -840,9 +862,11 @@ int CServiceIpcDbusDispatcher::on_add_wake_word(DBusConnection* conn, DBusMessag
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas add wake word : pid(%d), wake_word(%s) language(%s)", pid, wake_word, language);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_add_wake_word(pid,
                        wake_word ? std::string{wake_word} : std::string{},
-                       language ? std::string{language} : std::string{});
+                       language ? std::string{language} : std::string{},
+                       (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
@@ -882,9 +906,11 @@ int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMes
                ret = -1; //MAS_ERROR_OPERATION_FAILED;
        } else {
                MAS_LOGI("[IN] mas remove wake word : pid(%d), wake_word(%s) language(%s)", pid, wake_word, language);
+               const char *sender = dbus_message_get_sender(msg);
                ret = mIpcObserver->on_remove_wake_word(pid,
                        wake_word ? std::string{wake_word} : std::string{},
-                       language ? std::string{language} : std::string{});
+                       language ? std::string{language} : std::string{},
+                       (sender ? sender : ""));
        }
 
        MAS_LOGD("<<<<<");
index e3482e6..635f895 100644 (file)
@@ -867,7 +867,7 @@ pid_t CServiceMain::get_client_pid_by_appid(const char *appid)
 
        if (-1 != ret && !mApplicationManager.is_application_running(appid)) {
                MAS_LOGE("The PID for %s was %d, but it seems to be terminated", appid, ret);
-               on_deinitialize(ret);
+               on_deinitialize(ret, mClientManager.find_sender_info_by_pid(ret));
                ret = -1;
        }
 
@@ -1389,14 +1389,14 @@ void CServiceMain::app_terminate(void *data)
        return;
 }
 
-int CServiceMain::on_initialize(pid_t pid) {
+int CServiceMain::on_initialize(pid_t pid, std::string sender_info) {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
        std::string pid_appid;
        boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
        if (appid_by_pid) {
                pid_appid = *appid_by_pid;
-               MAS_LOGD("appid for pid %d is : %s", pid, pid_appid.c_str());
+               MAS_LOGD("appid for pid %d is : %s (%s)", pid, pid_appid.c_str(), sender_info.c_str());
 
                /* Remove existing client that has same appid, if there's any */
                mClientManager.destroy_client_by_appid(pid_appid.c_str());
@@ -1404,7 +1404,7 @@ int CServiceMain::on_initialize(pid_t pid) {
                /* And remove a client that has same pid also */
                mClientManager.destroy_client_by_pid(pid);
 
-               mClientManager.create_client(pid, pid_appid.c_str());
+               mClientManager.create_client(pid, pid_appid, sender_info);
 
                const char *current_maclient_appid = NULL;
                if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) {
@@ -1439,8 +1439,11 @@ int CServiceMain::on_initialize(pid_t pid) {
        return 0;
 }
 
-int CServiceMain::on_deinitialize(pid_t pid) {
+int CServiceMain::on_deinitialize(pid_t pid, std::string sender_info) {
        MAS_LOGD("[Enter] pid(%d)", pid);
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        if (mLastDuckingRequester == pid) {
                MAS_LOGE("Last ducking requester has disconnected, resetting background volume");
                std::string pid_appid = mClientManager.find_client_appid_by_pid( pid);
@@ -1453,7 +1456,10 @@ int CServiceMain::on_deinitialize(pid_t pid) {
        return 0;
 }
 
-int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) {
+int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        int main_rate, main_channel, main_audio_type;
        int ret = client_get_audio_format(pid,
                &main_rate, &main_channel, &main_audio_type);
@@ -1463,7 +1469,10 @@ int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& a
        return ret;
 }
 
-int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) {
+int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        char *main_type = nullptr;
        int ret = client_get_audio_source_type(pid, &main_type);
        if (0 == ret && main_type) {
@@ -1472,62 +1481,104 @@ int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) {
        return ret;
 }
 
-int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result) {
+int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_send_asr_result(pid, event, asr_result.c_str());
 }
 
 int CServiceMain::on_send_result(pid_t pid, std::string display_text,
-       std::string utterance_text, std::string result_json) {
+       std::string utterance_text, std::string result_json, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_send_result(pid,
                display_text.c_str(), utterance_text.c_str(), result_json.c_str());
 }
 
-int CServiceMain::on_send_recognition_result(pid_t pid, int result) {
+int CServiceMain::on_send_recognition_result(pid_t pid, int result, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_send_recognition_result(pid, result);
 }
 
-int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type) {
+int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_start_streaming_audio_data(pid, type);
 }
 
-int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type) {
+int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_stop_streaming_audio_data(pid, type);
 }
 
-int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state) {
+int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_update_voice_feedback_state(pid, state);
 }
 
-int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command) {
+int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_set_assistant_specific_command(pid, command.c_str());
 }
 
-int CServiceMain::on_set_background_volume(pid_t pid, double ratio) {
+int CServiceMain::on_set_background_volume(pid_t pid, double ratio, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_set_background_volume(pid, ratio);
 }
 
-int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) {
+int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_set_preprocessing_allow_mode(pid,
                static_cast<ma_preprocessing_allow_mode_e>(mode), app_id.c_str());
 }
 
-int CServiceMain::on_send_preprocessing_result(pid_t pid, int result) {
+int CServiceMain::on_send_preprocessing_result(pid_t pid, int result, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_send_preprocessing_result(pid, result);
 }
 
-int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require) {
+int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_set_wake_word_audio_require_flag(pid, require);
 }
 
-int CServiceMain::on_set_assistant_language(pid_t pid, std::string language) {
+int CServiceMain::on_set_assistant_language(pid_t pid, std::string language, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_set_assistant_language(pid, language.c_str());
 }
 
-int CServiceMain::on_add_wake_word(pid_t pid, std::string wake_word, std::string language) {
+int CServiceMain::on_add_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_add_wake_word(pid, wake_word.c_str(), language.c_str());
 }
 
-int CServiceMain::on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) {
+int CServiceMain::on_remove_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) {
+       if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) {
+               return -1;
+       }
        return client_remove_wake_word(pid, wake_word.c_str(), language.c_str());
 }