mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 01:49:11 +00:00
Cast hook functions to sudo_hook_fn_t to fix C23 compile error.
The sudo plugin API defines sudo_hook_fn_t as a function with unspecified arguments. This is no longer supported in C23 so use a variadic function for sudo_hook_fn_t instead. Moving to a union may be a better long-term fix. GitHub issue #420.
This commit is contained in:
parent
4c99e29bb3
commit
9613ef9445
@ -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);
|
||||
|
@ -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 }
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user