Dealing with SUID helper processes. More...
Typedefs | |
typedef void(* | GNUNET_HELPER_ExceptionCallback) (void *cls) |
Callback that will be called when the helper process dies. More... | |
typedef void(* | GNUNET_HELPER_Continuation) (void *cls, enum GNUNET_GenericReturnValue result) |
Continuation function. More... | |
Functions | |
struct GNUNET_HELPER_Handle * | GNUNET_HELPER_start (const struct GNUNET_OS_ProjectData *pd, int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls) |
Starts a helper and begins reading from it. More... | |
enum GNUNET_GenericReturnValue | GNUNET_HELPER_kill (struct GNUNET_HELPER_Handle *h, int soft_kill) |
Sends termination signal to the helper process. More... | |
enum GNUNET_GenericReturnValue | GNUNET_HELPER_wait (struct GNUNET_HELPER_Handle *h) |
Reap the helper process. More... | |
void | GNUNET_HELPER_destroy (struct GNUNET_HELPER_Handle *h) |
Free's the resources occupied by the helper handle. More... | |
void | GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h, int soft_kill) |
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process. More... | |
struct GNUNET_HELPER_SendHandle * | GNUNET_HELPER_send (struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, bool can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls) |
Send an message to the helper. More... | |
void | GNUNET_HELPER_send_cancel (struct GNUNET_HELPER_SendHandle *sh) |
Cancel a GNUNET_HELPER_send operation. More... | |
Dealing with SUID helper processes.
Provides an API for dealing with (SUID) helper processes that communicate via GNUNET_MessageHeaders on STDIN/STDOUT.
typedef void(* GNUNET_HELPER_ExceptionCallback) (void *cls) |
Callback that will be called when the helper process dies.
This is not called when the helper process is stopped using GNUNET_HELPER_stop()
cls | the closure from GNUNET_HELPER_start() |
Definition at line 64 of file gnunet_helper_lib.h.
typedef void(* GNUNET_HELPER_Continuation) (void *cls, enum GNUNET_GenericReturnValue result) |
Continuation function.
cls | closure |
result | GNUNET_OK on success, GNUNET_NO if helper process died GNUNET_SYSERR during GNUNET_HELPER_destroy |
Definition at line 150 of file gnunet_helper_lib.h.
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start | ( | const struct GNUNET_OS_ProjectData * | pd, |
int | with_control_pipe, | ||
const char * | binary_name, | ||
char *const | binary_argv[], | ||
GNUNET_MessageTokenizerCallback | cb, | ||
GNUNET_HELPER_ExceptionCallback | exp_cb, | ||
void * | cb_cls | ||
) |
Starts a helper and begins reading from it.
The helper process is restarted when it dies except when it is stopped using GNUNET_HELPER_stop() or when the exp_cb callback is not NULL.
pd | project data to use to determine paths |
with_control_pipe | does the helper support the use of a control pipe for signalling? |
binary_name | name of the binary to run |
binary_argv | NULL-terminated list of arguments to give when starting the binary (this argument must not be modified by the client for the lifetime of the helper handle) |
cb | function to call if we get messages from the helper |
exp_cb | the exception callback to call. Set this to NULL if the helper process has to be restarted automatically when it dies/crashes |
cb_cls | closure for the above callbacks |
Definition at line 460 of file helper.c.
References GNUNET_HELPER_Handle::binary_argv, GNUNET_HELPER_Handle::binary_name, GNUNET_HELPER_Handle::cb_cls, exp_cb(), GNUNET_malloc, GNUNET_MST_create(), GNUNET_new, GNUNET_OS_get_libexec_binary_path(), GNUNET_strdup, h, start_helper(), and GNUNET_HELPER_Handle::with_control_pipe.
Referenced by enable(), GNUNET_FS_directory_scan_start(), run(), and start_helper().
enum GNUNET_GenericReturnValue GNUNET_HELPER_kill | ( | struct GNUNET_HELPER_Handle * | h, |
int | soft_kill | ||
) |
Sends termination signal to the helper process.
The helper process is not reaped; call GNUNET_HELPER_wait() for reaping the dead helper process.
h | the helper handle |
soft_kill | if GNUNET_YES, signals termination by closing the helper's stdin; GNUNET_NO to signal termination by sending SIGTERM to helper |
Definition at line 166 of file helper.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_OS_process_kill(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TERM_SIG, GNUNET_YES, h, ret, and sh.
Referenced by cleanup(), disable(), and stop_helper().
enum GNUNET_GenericReturnValue GNUNET_HELPER_wait | ( | struct GNUNET_HELPER_Handle * | h | ) |
Reap the helper process.
This call is blocking (!). The helper process should either be sent a termination signal before or should be dead before calling this function
h | the helper handle |
Definition at line 206 of file helper.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_MST_from_buffer(), GNUNET_NO, GNUNET_OS_process_destroy(), GNUNET_OS_process_wait(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_YES, h, ret, and sh.
Referenced by cleanup(), and stop_helper().
void GNUNET_HELPER_destroy | ( | struct GNUNET_HELPER_Handle * | h | ) |
Free's the resources occupied by the helper handle.
h | the helper handle to free |
Definition at line 501 of file helper.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MST_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, h, and sh.
Referenced by disable(), and GNUNET_HELPER_stop().
void GNUNET_HELPER_stop | ( | struct GNUNET_HELPER_Handle * | h, |
int | soft_kill | ||
) |
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
h | handle to helper to stop |
soft_kill | if GNUNET_YES, signals termination by closing the helper's stdin; GNUNET_NO to signal termination by sending SIGTERM to helper |
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
h | handle to helper to stop |
soft_kill | if GNUNET_YES, signals termination by closing the helper's stdin; GNUNET_NO to signal termination by sending SIGTERM to helper |
Definition at line 538 of file helper.c.
References GNUNET_HELPER_destroy(), h, and stop_helper().
Referenced by cleanup(), cleanup_task(), finish_scan(), GNUNET_FS_directory_scan_abort(), handle_helper_local_finished(), helper_read(), helper_write(), and netjail_exec_cleanup().
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send | ( | struct GNUNET_HELPER_Handle * | h, |
const struct GNUNET_MessageHeader * | msg, | ||
bool | can_drop, | ||
GNUNET_HELPER_Continuation | cont, | ||
void * | cont_cls | ||
) |
Send an message to the helper.
h | helper to send message to |
msg | message to send |
can_drop | can the message be dropped if there is already one in the queue? |
cont | continuation to run once the message is out (GNUNET_OK on success, GNUNET_NO if the helper process died, GNUNET_SYSERR during GNUNET_HELPER_destroy). |
cont_cls | closure for cont |
Definition at line 615 of file helper.c.
References GNUNET_CONTAINER_DLL_insert_tail, GNUNET_malloc, GNUNET_memcpy, GNUNET_SCHEDULER_add_write_file(), GNUNET_TIME_UNIT_FOREVER_REL, h, helper_write(), msg, sh, and GNUNET_MessageHeader::size.
Referenced by GNUNET_TESTING_loop_notify_children_(), handle_icmp_back(), handle_tcp_back(), handle_udp_back(), play(), request_done(), send_icmp_packet_via_tun(), send_start_messages(), send_tcp_packet_via_tun(), and send_udp_packet_via_tun().
void GNUNET_HELPER_send_cancel | ( | struct GNUNET_HELPER_SendHandle * | sh | ) |
Cancel a GNUNET_HELPER_send operation.
If possible, transmitting the message is also aborted, but at least 'cont' won't be called.
sh | operation to cancel |
Definition at line 655 of file helper.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), h, and sh.
Referenced by finish_test().