kdbus: modified to get label for signal 79/157579/1
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 24 Oct 2017 14:34:18 +0000 (23:34 +0900)
committersanghyeok oh <sanghyeok.oh@samsung.com>
Wed, 25 Oct 2017 07:36:06 +0000 (07:36 +0000)
Change-Id: Ia6fa61fe49084e25270b15387980299fe0b40b44
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/libdbuspolicy1.c

index 55d003c..0cd422b 100755 (executable)
@@ -58,6 +58,9 @@
 #define SESSION_BUS_CONF_FILE_PRIMARY "/usr/lib/dbus-tests/configs/libdbuspolicy-tests/session.conf"
 #endif
 
+#define POLICY_CONN_INFO_ALL (__u64)(KDBUS_ATTACH_CREDS | KDBUS_ATTACH_NAMES | KDBUS_ATTACH_SECLABEL)
+#define POLICY_CONN_INFO_NAME (__u64)(KDBUS_ATTACH_NAMES)
+
 /** A process ID */
 typedef unsigned long dbus_pid_t;
 /** A user ID */
@@ -292,7 +295,7 @@ struct kdbus_cmd_param {
        union kdbus_cmd_union cmd;
 };
 
-int kdbus_get_conn_info(bool bus_type, const char *destination, int message_type, struct kdbus_cmd_param *info)
+int kdbus_get_conn_info(bool bus_type, const char *destination, struct kdbus_cmd_param *info, __u64 flags)
 {
        char const *label = NULL;
        const char** k_names = info->k_names;
@@ -309,7 +312,7 @@ int kdbus_get_conn_info(bool bus_type, const char *destination, int message_type
        uintptr_t items_end;
 
        cmd->cmd_info.flags = 0;
-       cmd->cmd_info.attach_flags = (__u64)(KDBUS_ATTACH_CREDS | KDBUS_ATTACH_NAMES | (DBUSPOLICY_MESSAGE_TYPE_SIGNAL != message_type ? KDBUS_ATTACH_SECLABEL : 0));
+       cmd->cmd_info.attach_flags = flags;
 
        if (kdbus_is_unique_id(destination)) {
                cmd->cmd_info.size = sizeof(cmd->cmd_info);
@@ -409,7 +412,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
        /* check can send */
        /* if broadcasting, then pass - null destination */
        if (destination && *destination) {
-               r = kdbus_get_conn_info(bus_type, destination, message_type, &info);
+               r = kdbus_get_conn_info(bus_type, destination, &info, POLICY_CONN_INFO_ALL);
                if (r < 0)
                        goto end;
        }
@@ -443,7 +446,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
 
        /* check can recv */
        /* get sender information from kdbus */
-       r = kdbus_get_conn_info(bus_type, sender, message_type, &info);
+       r = kdbus_get_conn_info(bus_type, sender, &info, POLICY_CONN_INFO_NAME);
        if (r < 0) {
                fprintf(stderr, "failed to kdbus conn info:%d\n", r);
                goto end;
@@ -493,7 +496,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_in(void* configuration,
        __internal_enter();
 
        if (destination && *destination) {
-               r = kdbus_get_conn_info(bus_type, destination, message_type, &info);
+               r = kdbus_get_conn_info(bus_type, destination, &info, POLICY_CONN_INFO_NAME);
                if (r < 0)
                        goto end;
        }