" <arg type='i' name='client_pid' direction='in'/>"
" <arg type='i' name='return_value' direction='out'/>"
" </method>"
- " <method name='update_key_pair'>"
- " <arg type='s' name='id' direction='in'/>"
- " <arg type='s' name='key' direction='in'/>"
- " <arg type='i' name='client_pid' direction='in'/>"
- " <arg type='i' name='return_value' direction='out'/>"
- " </method>"
+ " <method name='update_key_pair'>"
+ " <arg type='s' name='id' direction='in'/>"
+ " <arg type='s' name='key' direction='in'/>"
+ " <arg type='i' name='client_pid' direction='in'/>"
+ " <arg type='i' name='return_value' direction='out'/>"
+ " </method>"
" </interface>"
" </node>";
/* ---------------------------------------------------------------------------------------------------- */
g_variant_get(parameters, "(ssi)", &id, &key, &client_pid);
DEBUG("[orchestration dbus_interface] _update_key_pair\n");
- DEBUG("\t id = %s\n", id);
- DEBUG("\t key = %s\n", key);
- DEBUG("\t client_pid = %d\n", client_pid);
- if (g_strcmp0(id, "") == 0 || g_strcmp0(key, "") == 0) {
+ if (id == NULL || key == NULL) {
return ORCH_ERROR_INVALID_PARAMETER;
}
+ DEBUG("\t id = %s\n", id);
+ DEBUG("\t key = %s\n", key);
+ DEBUG("\t client_pid = %d\n", client_pid);
+
if (origin_client_pid != client_pid) {
DEBUG("not matched clinet_pid from client and dbus, origin_client_pid(%d), client_pid(%d)\n", origin_client_pid, client_pid);
}
char process_name[128] = {0, };
- const char unknown[] = "Unknown";
- if (get_process_name_by_pid(process_name, origin_client_pid) != 0) {
- DEBUG("could not get Process name");
- strncpy(process_name, unknown, strlen(unknown));
- }
+ const char unknown[] = "Unknown";
+ if (get_process_name_by_pid(process_name, origin_client_pid) != 0) {
+ DEBUG("could not get Process name");
+ strncpy(process_name, unknown, strlen(unknown));
+ }
- result = _update_key_pair_cb(id, key, process_name);
+ result = _update_key_pair_cb(id, key, process_name);
return result;
}
-
static int get_process_name_by_pid(char* process_name, int pid) {
- char fname[1024] = {0, };
- char line[1024] = {0, };
- ssize_t fname_len = snprintf(NULL, 0, "/proc/%d/status", pid);
-
- snprintf(fname, fname_len + 1, "/proc/%d/status", pid);
- FILE *fp = fopen(fname, "r");
- if (fp == NULL) {
- DEBUG("%d Process not found!!!\n", pid);
- return -1;
- }
- while (!feof(fp)) {
- fgets(line, 1024, fp);
- if (strstr(line, "Name:") != NULL) {
- int index = 0;
- char *ptr = strchr(line, ':');
- while (1) {
- ptr++;
- if (*ptr == '\n' || *ptr == '\0')
- break;
- if (*ptr != ' ' && *ptr != '\t')
- process_name[index++] = *ptr;
- }
- process_name[index] = '\0';
- printf("process_name = %s\n", process_name);
- fclose(fp);
- return 0;
- }
- }
- printf("%d Process status have no Process name!!\n", pid);
- fclose(fp);
- return -1;
+ char fname[1024] = {0, };
+ char line[1024] = {0, };
+ ssize_t fname_len = snprintf(NULL, 0, "/proc/%d/status", pid);
+
+ snprintf(fname, fname_len + 1, "/proc/%d/status", pid);
+ FILE *fp = fopen(fname, "r");
+ if (fp == NULL) {
+ DEBUG("%d Process not found!!!\n", pid);
+ return -1;
+ }
+ while (!feof(fp)) {
+ fgets(line, 1024, fp);
+ if (strstr(line, "Name:") != NULL) {
+ int index = 0;
+ char *ptr = strchr(line, ':');
+ while (1) {
+ ptr++;
+ if (*ptr == '\n' || *ptr == '\0')
+ break;
+ if (*ptr != ' ' && *ptr != '\t')
+ process_name[index++] = *ptr;
+ }
+ process_name[index] = '\0';
+ printf("process_name = %s\n", process_name);
+ fclose(fp);
+ return 0;
+ }
+ }
+ printf("%d Process status have no Process name!!\n", pid);
+ fclose(fp);
+ return -1;
}
static int get_pid_with_connection(const gchar* sender) {
#include "orchestration_type.h"
-#define MAX_KEY_SIZE 256
+#define MAX_KEY_SIZE 2048
static char id[MAX_KEY_SIZE];
static char key[MAX_KEY_SIZE];
int updateKeyPair(char* _id,char* _key) {
- if (strlen(_id) > MAX_KEY_SIZE) {
- DEBUG("invalid id size: %u/n", strlen(_id));
- return -1;
- }
- else if (strlen(_key) > MAX_KEY_SIZE) {
- DEBUG("invalid key size: %u/n", strlen(_key));
- return -1;
- }
- strncpy(id, _id, strlen(_id));
- strncpy(key, _key, strlen(_key));
-
- return 0;
+ if (strlen(_id) > MAX_KEY_SIZE) {
+ DEBUG("invalid id size: %u/n", strlen(_id));
+ return -1;
+ }
+ else if (strlen(_key) > MAX_KEY_SIZE) {
+ DEBUG("invalid key size: %u/n", strlen(_key));
+ return -1;
+ }
+
+ strncpy(id, _id, strlen(_id));
+ id[strlen(_id)] = '\0';
+ strncpy(key, _key, strlen(_key));
+ key[strlen(_key)] = '\0';
+
+ return 0;
}
char* identityGetter() {
- return id;
+ return id;
}
char* keyGetter(char* id) {
- return key;
+ return key;
}