+#include <unistd.h>
#include "common.h"
#include "../fota/fota-manager.h"
#include "update-manager-dbus.h"
static guint owner_id;
+static pid_t dbus_get_sender_pid(GDBusMethodInvocation *invocation)
+{
+ const gchar *sender = g_dbus_method_invocation_get_sender(invocation);
+ GDBusConnection *conn = g_dbus_method_invocation_get_connection(invocation);
+ if (sender == NULL || conn == NULL) {
+ _FLOGW("Failed to get invocation data");
+ return 0;
+ }
+ GError *error = NULL;
+ GVariant *result = g_dbus_connection_call_sync(conn,
+ "org.freedesktop.DBus",
+ "/",
+ "org.freedesktop.DBus",
+ "GetConnectionUnixProcessID",
+ g_variant_new("(s)", sender),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (!result || error) {
+ _FLOGW("Failed to get sender PID: %s", error ? error->message : "");
+ g_error_free(error);
+ return 0;
+ }
+
+ pid_t pid;
+ g_variant_get(result, "(u)", &pid);
+ g_variant_unref(result);
+ return pid;
+}
+
gboolean dbus_manager_result(OrgTizenUpdateManager *skeleton, GDBusMethodInvocation *invocation, gpointer user_data)
{
int ret = 0;
int ret = 0;
_FLOGD("Dbus status : install called");
- ret = fota_installer_execute();
+ pid_t pid = dbus_get_sender_pid(invocation);
+ ret = fota_installer_execute(pid);
if (ret < 0)
_FLOGW("Failed to install delta with fota : %d", ret);
org_tizen_update_manager_complete_install(skeleton, invocation, ret);
+#include <linux/limits.h>
#include "../common/common.h"
#include "fota-manager.h"
#define FOTA_INSTALL_REBOOT_REASON "fota"
+static char *get_sender_or_client_appid(pid_t pid)
+{
+ char *result = NULL;
+ if (pid > 0) {
+ char tmp_appid[PATH_MAX];
+ int res = aul_app_get_appid_bypid(pid, tmp_appid, sizeof(tmp_appid));
+ if (res == AUL_R_OK) {
+ result = strdup(tmp_appid);
+ if (result == NULL) {
+ _FLOGE("Out of memory");
+ return NULL;
+ }
+ } else {
+ _FLOGE("Failed to get sender app id: %d", res);
+ }
+ }
+
+ // Fallback to appid retrieval based on application metadata if the
+ // caller appid cannot be determined
+ if (result == NULL) {
+ result = fota_client_info_get_appid();
+ if (result == NULL)
+ _FLOGE("Failed to get client app id");
+ }
+ return result;
+}
-int fota_installer_execute()
+int fota_installer_execute(pid_t sender_pid)
{
int ret = 0, status = 0, exec_status = 0;
char buf[MAX_BUFFER_SIZE] = {0, };
pid_t pid;
/* 1. Check client have delta.tar */
- appid = fota_client_info_get_appid();
+ appid = get_sender_or_client_appid(sender_pid);
if (appid == NULL) {
- _FLOGE("Failed to get client app id");
status = -1;
goto execute_destroy;
}
#include <device/power.h>
#include <dlog.h>
#include <system_info.h>
+#include <unistd.h>
/* Log */
#define FOTA_LOG_TAG "FOTA_MANAGER"
int fota_info_checker_fini(void);
char *fota_info_get_build_string(void);
-int fota_installer_execute(void);
+int fota_installer_execute(pid_t pid);
int fota_result_sender_execute(void);
int fota_status_checker_init(void);