From 5e3966c99180abdcd1e21774a882f1c14c47aae8 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Mon, 2 Mar 2009 09:35:06 -0500 Subject: Implement GetUserAttributes in the InfoPipe This patch adds support for requesting user data in the sysdb via the InfoPipe. It currently has support for reading defined entries of integral, floating-point or string types. Tasks remaining: 1) Implement call to the provider when cache is out of date 2) Support byte arrays for userpic and similar I modified sysdb_search_ctx in sysdb_search.c to accept an array of attributes to pass into the LDB search. I also made one additional related fix: the btreemap now sorts in the correct order. Previously I had accidentally transposed the two values for sorting, so the map would always have been in exact reverse order. --- server/infopipe/sysbus.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'server/infopipe/sysbus.c') diff --git a/server/infopipe/sysbus.c b/server/infopipe/sysbus.c index 6ba1bb72d..a90f92d5f 100644 --- a/server/infopipe/sysbus.c +++ b/server/infopipe/sysbus.c @@ -165,3 +165,32 @@ struct sbus_conn_ctx *sysbus_get_sbus_conn(struct sysbus_ctx *sysbus) { return sysbus->sconn; } + +char *sysbus_get_caller(TALLOC_CTX *mem_ctx, DBusMessage *message, struct sbus_conn_ctx *sconn) +{ + char *caller; + const char *conn_name; + DBusError error; + uid_t uid; + + /* Get the connection UID */ + conn_name = dbus_message_get_sender(message); + if (conn_name == NULL) { + DEBUG(0, ("Critical error: D-BUS client has no unique name\n")); + return NULL; + } + dbus_error_init(&error); + uid = dbus_bus_get_unix_user(sbus_get_connection(sconn), conn_name, &error); + if (uid == -1) { + DEBUG(0, ("Could not identify unix user. Error message was '%s:%s'\n", error.name, error.message)); + dbus_error_free(&error); + return NULL; + } + caller = get_username_from_uid(mem_ctx, uid); + if (caller == NULL) { + DEBUG(0, ("No username matched the connected UID\n")); + return NULL; + } + + return caller; +} -- cgit