diff --git a/include/sudo_plugin.h b/include/sudo_plugin.h index 4a68f46926..24a20d1903 100644 --- a/include/sudo_plugin.h +++ b/include/sudo_plugin.h @@ -96,7 +96,11 @@ typedef int (*sudo_printf_t)(int msg_type, const char * restrict fmt, ...); #endif /* Hook functions typedefs. */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +typedef int (*sudo_hook_fn_t)(...); +#else typedef int (*sudo_hook_fn_t)(); +#endif typedef int (*sudo_hook_fn_setenv_t)(const char *name, const char *value, int overwrite, void *closure); typedef int (*sudo_hook_fn_putenv_t)(char *string, void *closure); typedef int (*sudo_hook_fn_getenv_t)(const char *name, char **value, void *closure); diff --git a/plugins/sudoers/policy.c b/plugins/sudoers/policy.c index 20f67a1c64..e3fe259c7f 100644 --- a/plugins/sudoers/policy.c +++ b/plugins/sudoers/policy.c @@ -1358,10 +1358,10 @@ sudoers_policy_version(int verbose) } static struct sudo_hook sudoers_hooks[] = { - { SUDO_HOOK_VERSION, SUDO_HOOK_SETENV, sudoers_hook_setenv, NULL }, - { SUDO_HOOK_VERSION, SUDO_HOOK_UNSETENV, sudoers_hook_unsetenv, NULL }, - { SUDO_HOOK_VERSION, SUDO_HOOK_GETENV, sudoers_hook_getenv, NULL }, - { SUDO_HOOK_VERSION, SUDO_HOOK_PUTENV, sudoers_hook_putenv, NULL }, + { SUDO_HOOK_VERSION, SUDO_HOOK_SETENV, (sudo_hook_fn_t)sudoers_hook_setenv, NULL }, + { SUDO_HOOK_VERSION, SUDO_HOOK_UNSETENV, (sudo_hook_fn_t)sudoers_hook_unsetenv, NULL }, + { SUDO_HOOK_VERSION, SUDO_HOOK_GETENV, (sudo_hook_fn_t)sudoers_hook_getenv, NULL }, + { SUDO_HOOK_VERSION, SUDO_HOOK_PUTENV, (sudo_hook_fn_t)sudoers_hook_putenv, NULL }, { 0, 0, NULL, NULL } }; diff --git a/src/hooks.c b/src/hooks.c index 8ef3e935ef..a7befe3977 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -125,7 +125,7 @@ process_hooks_unsetenv(const char *name) /* Hook registration internals. */ static int register_hook_internal(struct sudo_hook_list *head, - int (*hook_fn)(), void *closure) + sudo_hook_fn_t hook_fn, void *closure) { struct sudo_hook_entry *hook; debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS); @@ -185,7 +185,7 @@ register_hook(struct sudo_hook *hook) /* Hook deregistration internals. */ static void deregister_hook_internal(struct sudo_hook_list *head, - int (*hook_fn)(), void *closure) + sudo_hook_fn_t hook_fn, void *closure) { struct sudo_hook_entry *hook, *prev = NULL; debug_decl(deregister_hook_internal, SUDO_DEBUG_HOOKS);