summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorRadoslaw Pajak <r.pajak@samsung.com>2013-11-04 08:39:36 +0100
committerLubomir Rintel <lkundrak@v3.sk>2015-02-11 11:53:33 +0100
commit6db0414bdadc370c11c622006bd310021e899c8e (patch)
treedcfcdfd661409927f87c21f94f641aa8050d19fc /dbus
parent3825fd70fc5f0e7be933626ee239ff764f661351 (diff)
[doc][daemon-fix][daemon-opt] Known limitations updated, code fixes, clean-ups, optimizations, formatting
- org.freedesktop.DBus.GetNameOwner fixed - added policy checking when acquiring well-known name - dbus_connection_get_unix_user rewritten for kdbus - dbus_connection_get_unix_process_id rewritten for kdbus - bus_service_get_primary_owners_connection extended with kdbus support - (kdbus_get_connection_unix_) user and process_id refactored for more universal usage - kdbus_list_services optimized Change-Id: I90896df7bebafe05869778da1aef2a22a24722fe Signed-off-by: Radoslaw Pajak <r.pajak@samsung.com>
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-connection.c3
-rw-r--r--dbus/dbus-transport-kdbus.c4
-rw-r--r--dbus/kdbus-common.c78
-rw-r--r--dbus/kdbus-common.h4
4 files changed, 5 insertions, 84 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index b891b173..cb6421cf 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -5259,7 +5259,7 @@ dbus_connection_get_socket(DBusConnection *connection,
return retval;
}
-
+#ifndef ENABLE_KDBUS_TRANSPORT
/**
* Gets the UNIX user ID of the connection if known. Returns #TRUE if
* the uid is filled in. Always returns #FALSE on non-UNIX platforms
@@ -5339,6 +5339,7 @@ dbus_connection_get_unix_process_id (DBusConnection *connection,
return result;
}
+#endif
/**
* Gets the ADT audit data of the connection if any.
diff --git a/dbus/dbus-transport-kdbus.c b/dbus/dbus-transport-kdbus.c
index 0e77f158..cc226a37 100644
--- a/dbus/dbus-transport-kdbus.c
+++ b/dbus/dbus-transport-kdbus.c
@@ -475,9 +475,9 @@ int kdbus_NameQuery(const char* name, DBusTransport* transport, struct nameInfo*
pInfo->sec_label_len = 0;
pInfo->sec_label = NULL;
- item_size = KDBUS_PART_HEADER_SIZE + strlen(name) + 1;
+ item_size = KDBUS_PART_HEADER_SIZE + strlen(name) + 1;
item_size = (item_size < 56) ? 56 : item_size; //at least 56 bytes are needed by kernel to place info about name, otherwise error
- size = sizeof(struct kdbus_cmd_name_info) + item_size;
+ size = sizeof(struct kdbus_cmd_name_info) + item_size;
msg = malloc(size);
if (!msg)
diff --git a/dbus/kdbus-common.c b/dbus/kdbus-common.c
index 90eb2c26..4a5d7f2e 100644
--- a/dbus/kdbus-common.c
+++ b/dbus/kdbus-common.c
@@ -25,6 +25,7 @@
*/
#include "kdbus.h"
#include "kdbus-common.h"
+#include "dbus-transport-kdbus.h"
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
@@ -130,83 +131,6 @@ dbus_bool_t register_kdbus_policy(const char* name, int fd)
return TRUE;
}
-/*
- * Asks kdbus for well-known names registered on the bus
- */
-dbus_bool_t list_kdbus_names(int fd, char ***listp, int *array_len)
-{
- struct kdbus_cmd_names* pCmd;
- __u64 cmd_size;
- dbus_bool_t ret_val = FALSE;
- char** list;
- int list_len = 0;
- int i = 0;
- int j;
-
- cmd_size = sizeof(struct kdbus_cmd_names) + KDBUS_ITEM_SIZE(1);
- pCmd = malloc(cmd_size);
- if(pCmd == NULL)
- goto out;
- pCmd->size = cmd_size;
-
-again:
- cmd_size = 0;
- if(ioctl(fd, KDBUS_CMD_NAME_LIST, pCmd))
- {
- if(errno == EINTR)
- goto again;
- if(errno == ENOBUFS) //buffer to small to put all names into it
- cmd_size = pCmd->size; //here kernel tells how much memory it needs
- else
- {
- _dbus_verbose("kdbus error asking for name list: err %d (%m)\n",errno);
- goto out;
- }
- }
- if(cmd_size) //kernel needs more memory
- {
- pCmd = realloc(pCmd, cmd_size); //prepare memory
- if(pCmd == NULL)
- return FALSE;
- goto again; //and try again
- }
- else
- {
- struct kdbus_cmd_name* pCmd_name;
-
- for (pCmd_name = pCmd->names; (uint8_t *)(pCmd_name) < (uint8_t *)(pCmd) + pCmd->size; pCmd_name = KDBUS_PART_NEXT(pCmd_name))
- list_len++;
-
- list = malloc(sizeof(char*) * (list_len + 1));
- if(list == NULL)
- goto out;
-
- for (pCmd_name = pCmd->names; (uint8_t *)(pCmd_name) < (uint8_t *)(pCmd) + pCmd->size; pCmd_name = KDBUS_PART_NEXT(pCmd_name))
- {
- list[i] = strdup(pCmd_name->name);
- if(list[i] == NULL)
- {
- for(j=0; j<i; j++)
- free(list[j]);
- free(list);
- goto out;
- }
- _dbus_verbose ("Name %d: %s\n", i, list[i]);
- ++i;
- }
- list[i] = NULL;
- }
-
- *array_len = list_len;
- *listp = list;
- ret_val = TRUE;
-
-out:
- if(pCmd)
- free(pCmd);
- return ret_val;
-}
-
/**
*
* Asks the bus to assign the given name to the connection.
diff --git a/dbus/kdbus-common.h b/dbus/kdbus-common.h
index 4a50ed08..7fbe77a0 100644
--- a/dbus/kdbus-common.h
+++ b/dbus/kdbus-common.h
@@ -35,11 +35,7 @@
(typeof(part))(((uint8_t *)part) + KDBUS_ALIGN8((part)->size))
#define KDBUS_ITEM_SIZE(s) KDBUS_ALIGN8((s) + KDBUS_PART_HEADER_SIZE)
-/*struct kdbus_policy *make_policy_name(const char *name);
-struct kdbus_policy *make_policy_access(__u64 type, __u64 bits, __u64 id);
-void append_policy(struct kdbus_cmd_policy *cmd_policy, struct kdbus_policy *policy, __u64 max_size);*/
dbus_bool_t register_kdbus_policy(const char* name, int fd);
-dbus_bool_t list_kdbus_names(int fd, char ***listp, int *array_len);
int request_kdbus_name(int fd, const char *name, const __u64 flags, __u64 id);
int release_kdbus_name(int fd, const char *name, __u64 id);