1 /***************************************************************************
3 * adt_data.c : Provides Audit functionalities
5 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms.
8 * Licensed under the Academic Free License version 2.1
10 ***************************************************************************/
12 #pragma ident "%Z%%M% %I% %E% SMI"
19 #include <dbus/dbus-glib-lowlevel.h>
20 #include <dbus/dbus-glib.h>
21 #include "../hald/logger.h"
25 get_audit_export_data(DBusConnection
*bus
, const char *invoked_by_syscon_name
, size_t *data_size
)
29 DBusMessageIter iter
, subiter
;
35 message
= dbus_message_new_method_call ("org.freedesktop.DBus",
36 "/org/freedesktop/DBus",
37 "org.freedesktop.DBus",
38 "GetAdtAuditSessionData");
39 if (message
== NULL
) {
40 printf ("cannot get GetAdtAuditSessionData message\n");
44 if (!dbus_message_append_args(message
, DBUS_TYPE_STRING
, &invoked_by_syscon_name
,
46 dbus_message_unref(message
);
50 dbus_error_init (&error
);
51 reply
= dbus_connection_send_with_reply_and_block (bus
,
54 if (dbus_error_is_set (&error
)) {
55 printf ("send failed %s\n", error
.message
);
56 dbus_error_free (&error
);
57 dbus_message_unref (message
);
61 dbus_message_unref (message
);
65 dbus_message_iter_init (reply
, &iter
);
67 if (dbus_message_iter_get_arg_type (&iter
) != DBUS_TYPE_ARRAY
||
68 dbus_message_iter_get_element_type (&iter
) != DBUS_TYPE_BYTE
) {
69 printf ("expecting an array of byte entries\n");
70 dbus_message_unref (message
);
71 dbus_message_unref (reply
);
74 dbus_message_iter_recurse (&iter
, &subiter
);
78 buf
= (uchar_t
*)malloc (bufsize
);
80 while (dbus_message_iter_get_arg_type (&subiter
) == DBUS_TYPE_BYTE
) {
81 if (count
== bufsize
) {
83 buf
= realloc (buf
, bufsize
);
85 dbus_message_unref (message
);
86 dbus_message_unref (reply
);
91 dbus_message_iter_get_basic (&subiter
, &value
);
93 dbus_message_iter_next(&subiter
);
96 dbus_message_unref (message
);
97 dbus_message_unref (reply
);
105 return (adt_export_data_t
*)buf
;