fix comments
[src/app-framework-binder.git] / src / afb-hook.c
index 2e0255d..bc33c49 100644 (file)
@@ -32,6 +32,7 @@
 #include "afb-context.h"
 #include "afb-hook.h"
 #include "afb-session.h"
+#include "afb-cred.h"
 #include "afb-xreq.h"
 #include "afb-ditf.h"
 #include "verbose.h"
@@ -95,7 +96,17 @@ static void _hook_xreq_(const struct afb_xreq *xreq, const char *format, ...)
 
 static void hook_xreq_begin_default_cb(void * closure, const struct afb_xreq *xreq)
 {
-       _hook_xreq_(xreq, "BEGIN");
+       if (!xreq->cred)
+               _hook_xreq_(xreq, "BEGIN");
+       else
+               _hook_xreq_(xreq, "BEGIN uid=%d=%s gid=%d pid=%d label=%s id=%s",
+                       (int)xreq->cred->uid,
+                       xreq->cred->user,
+                       (int)xreq->cred->gid,
+                       (int)xreq->cred->pid,
+                       xreq->cred->label?:"(null)",
+                       xreq->cred->id?:"(null)"
+               );
 }
 
 static void hook_xreq_end_default_cb(void * closure, const struct afb_xreq *xreq)
@@ -123,16 +134,6 @@ static void hook_xreq_fail_default_cb(void * closure, const struct afb_xreq *xre
        _hook_xreq_(xreq, "fail(%s, %s)", status, info);
 }
 
-static void hook_xreq_raw_default_cb(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
-       _hook_xreq_(xreq, "raw() -> %.*s", (int)size, buffer);
-}
-
-static void hook_xreq_send_default_cb(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
-       _hook_xreq_(xreq, "send(%.*s)", (int)size, buffer);
-}
-
 static void hook_xreq_context_get_default_cb(void * closure, const struct afb_xreq *xreq, void *value)
 {
        _hook_xreq_(xreq, "context_get() -> %p", value);
@@ -200,8 +201,6 @@ static struct afb_hook_xreq_itf hook_xreq_default_itf = {
        .hook_xreq_get = hook_xreq_get_default_cb,
        .hook_xreq_success = hook_xreq_success_default_cb,
        .hook_xreq_fail = hook_xreq_fail_default_cb,
-       .hook_xreq_raw = hook_xreq_raw_default_cb,
-       .hook_xreq_send = hook_xreq_send_default_cb,
        .hook_xreq_context_get = hook_xreq_context_get_default_cb,
        .hook_xreq_context_set = hook_xreq_context_set_default_cb,
        .hook_xreq_addref = hook_xreq_addref_default_cb,
@@ -269,17 +268,6 @@ void afb_hook_xreq_fail(const struct afb_xreq *xreq, const char *status, const c
        _HOOK_XREQ_(fail, xreq, status, info);
 }
 
-const char *afb_hook_xreq_raw(const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
-       _HOOK_XREQ_(raw, xreq, buffer, size);
-       return buffer;
-}
-
-void afb_hook_xreq_send(const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
-       _HOOK_XREQ_(send, xreq, buffer, size);
-}
-
 void *afb_hook_xreq_context_get(const struct afb_xreq *xreq, void *value)
 {
        _HOOK_XREQ_(context_get, xreq, value);
@@ -346,7 +334,7 @@ int afb_hook_xreq_subcallsync_result(const struct afb_xreq *xreq, int status, st
 }
 
 /******************************************************************************
- * section: 
+ * section: hooking xreqs
  *****************************************************************************/
 
 void afb_hook_init_xreq(struct afb_xreq *xreq)
@@ -554,6 +542,10 @@ static void hook_ditf_rootdir_open_locale_cb(void *closure, const struct afb_dit
        }
 }
 
+static void hook_ditf_queue_job(void *closure, const struct afb_ditf *ditf, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout, int result)
+{
+       _hook_ditf_(ditf, "queue_job(%p, %p, %p, %d) -> %d", callback, argument, group, timeout, result);
+}
 
 static struct afb_hook_ditf_itf hook_ditf_default_itf = {
        .hook_ditf_event_broadcast_before = hook_ditf_event_broadcast_before_cb,
@@ -565,10 +557,11 @@ static struct afb_hook_ditf_itf hook_ditf_default_itf = {
        .hook_ditf_event_make = hook_ditf_event_make_cb,
        .hook_ditf_rootdir_get_fd = hook_ditf_rootdir_get_fd_cb,
        .hook_ditf_rootdir_open_locale = hook_ditf_rootdir_open_locale_cb,
+       .hook_ditf_queue_job = hook_ditf_queue_job
 };
 
 /******************************************************************************
- * section: hooks for tracing requests
+ * section: hooks for tracing daemon interface (ditf)
  *****************************************************************************/
 
 #define _HOOK_DITF_(what,...)   \
@@ -637,10 +630,14 @@ int afb_hook_ditf_rootdir_open_locale(const struct afb_ditf *ditf, const char *f
        return result;
 }
 
-
+int afb_hook_ditf_queue_job(const struct afb_ditf *ditf, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout, int result)
+{
+       _HOOK_DITF_(queue_job, ditf, callback, argument, group, timeout, result);
+       return result;
+}
 
 /******************************************************************************
- * section: 
+ * section: hooking ditf
  *****************************************************************************/
 
 int afb_hook_flags_ditf(const char *api)