From: Todd C. Miller Date: Wed, 9 Sep 2015 20:56:52 +0000 (-0600) Subject: No need to have version macros for hooks, callbacks and the sudoers X-Git-Tag: SUDO_1_8_15^2~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=edfeee6a7a45c1299596177cc421567dedb14ba0;p=sudo No need to have version macros for hooks, callbacks and the sudoers group plugin. We can just use the main sudo API macros. The sudoers group plugin macros are preserved for source compatibility but are not documented. --- diff --git a/doc/sudo_plugin.cat b/doc/sudo_plugin.cat index daa3c6e86..164271a3c 100644 --- a/doc/sudo_plugin.cat +++ b/doc/sudo_plugin.cat @@ -799,7 +799,7 @@ DDEESSCCRRIIPPTTIIOONN #define SUDO_API_VERSION_SET_MAJOR(vp, n) do { \ *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \ } while(0) - #define SUDO_VERSION_SET_MINOR(vp, n) do { \ + #define SUDO_API_VERSION_SET_MINOR(vp, n) do { \ *(vp) = (*(vp) & 0xffff0000) | (n); \ } while(0) @@ -1232,19 +1232,10 @@ DDEESSCCRRIIPPTTIIOONN /* Hook API version major/minor */ #define SUDO_HOOK_VERSION_MAJOR 1 #define SUDO_HOOK_VERSION_MINOR 0 - #define SUDO_HOOK_MKVERSION(x, y) ((x << 16) | y) - #define SUDO_HOOK_VERSION SUDO_HOOK_MKVERSION(SUDO_HOOK_VERSION_MAJOR,\ + #define SUDO_HOOK_VERSION SUDO_API_MKVERSION(SUDO_HOOK_VERSION_MAJOR,\ SUDO_HOOK_VERSION_MINOR) - /* Getters and setters for hook API version */ - #define SUDO_HOOK_VERSION_GET_MAJOR(v) ((v) >> 16) - #define SUDO_HOOK_VERSION_GET_MINOR(v) ((v) & 0xffff) - #define SUDO_HOOK_VERSION_SET_MAJOR(vp, n) do { \ - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \ - } while(0) - #define SUDO_HOOK_VERSION_SET_MINOR(vp, n) do { \ - *(vp) = (*(vp) & 0xffff0000) | (n); \ - } while(0) + For getters and setters see the _P_o_l_i_c_y _p_l_u_g_i_n _A_P_I. RReemmoottee ccoommmmaanndd eexxeeccuuttiioonn The ssuuddoo front end does not have native support for running remote @@ -1279,6 +1270,11 @@ DDEESSCCRRIIPPTTIIOONN informational or error messages to the user, which is usually more convenient for simple messages where no use input is required. + _C_o_n_v_e_r_s_a_t_i_o_n _f_u_n_c_t_i_o_n _s_t_r_u_c_t_u_r_e_s + + The conversation function takes as arguments pointers to the following + structures: + struct sudo_conv_message { #define SUDO_CONV_PROMPT_ECHO_OFF 0x0001 /* do not echo user input */ #define SUDO_CONV_PROMPT_ECHO_ON 0x0002 /* echo user input */ @@ -1297,14 +1293,6 @@ DDEESSCCRRIIPPTTIIOONN char *reply; }; - /* Conversation callback API version major/minor */ - #define SUDO_CONV_CALLBACK_VERSION_MAJOR 1 - #define SUDO_CONV_CALLBACK_VERSION_MINOR 0 - #define SUDO_CONV_CALLBACK_MKVERSION(x, y) ((x << 16) | y) - #define SUDO_CONV_CALLBACK_VERSION \ - SUDO_CONV_CALLBACK_MKVERSION(SUDO_CONV_CALLBACK_VERSION_MAJOR, \ - SUDO_CONV_CALLBACK_VERSION_MINOR) - typedef int (*sudo_conv_callback_fn_t)(int signo, void *closure); struct sudo_conv_callback { unsigned int version; @@ -1313,6 +1301,11 @@ DDEESSCCRRIIPPTTIIOONN sudo_conv_callback_fn_t on_resume; }; + Pointers to the ccoonnvveerrssaattiioonn() and pprriinnttff()-style functions are passed in + to the plugin's ooppeenn() function when the plugin is initialized. The + following type definitions can be used in the declaration of the ooppeenn() + function: + typedef int (*sudo_conv_t)(int num_msgs, const struct sudo_conv_message msgs[], struct sudo_conv_reply replies[], @@ -1320,20 +1313,18 @@ DDEESSCCRRIIPPTTIIOONN typedef int (*sudo_printf_t)(int msg_type, const char *fmt, ...); - Pointers to the ccoonnvveerrssaattiioonn() and pprriinnttff()-style functions are passed in - to the plugin's ooppeenn() function when the plugin is initialized. - To use the ccoonnvveerrssaattiioonn() function, the plugin must pass an array of sudo_conv_message and sudo_conv_reply structures. There must be a struct sudo_conv_message and struct sudo_conv_reply for each message in the - conversation. The struct sudo_conv_callback pointer, if not NULL, - contains function pointers that are called when the ssuuddoo process is - suspended and/or resumed during conversation input. The functions are - passed the signal that caused ssuuddoo to be suspended and the _c_l_o_s_u_r_e - pointer. This allows the plugin to release resources such as locks that - should not be held indefinitely on suspend and reacquire them on resume. - Note that the functions are not actually invoked from within a signal - handler. + conversation. The struct sudo_conv_callback pointer, if not NULL, should + contain function pointers to be called when the ssuuddoo process is suspended + and/or resumed during conversation input. The _o_n___s_u_s_p_e_n_d and _o_n___r_e_s_u_m_e + functions are called with the signal that caused ssuuddoo to be suspended and + the _c_l_o_s_u_r_e pointer from the struct sudo_conv_callback. The intended use + is to allow the plugin to release resources, such as locks, that should + not be held indefinitely while suspended and then reacquire them when the + process is resumed. Note that the functions are not actually invoked + from within a signal handler. The plugin is responsible for freeing the reply buffer located in each struct sudo_conv_reply, if it is not NULL. SUDO_CONV_REPL_MAX represents @@ -1440,16 +1431,7 @@ DDEESSCCRRIIPPTTIIOONN #define GROUP_API_VERSION_MINOR 0 #define GROUP_API_VERSION ((GROUP_API_VERSION_MAJOR << 16) | \ GROUP_API_VERSION_MINOR) - - /* Getters and setters for group version */ - #define GROUP_API_VERSION_GET_MAJOR(v) ((v) >> 16) - #define GROUP_API_VERSION_GET_MINOR(v) ((v) & 0xffff) - #define GROUP_API_VERSION_SET_MAJOR(vp, n) do { \ - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \ - } while(0) - #define GROUP_API_VERSION_SET_MINOR(vp, n) do { \ - *(vp) = (*(vp) & 0xffff0000) | (n); \ - } while(0) + For getters and setters see the _P_o_l_i_c_y _p_l_u_g_i_n _A_P_I. PPLLUUGGIINN AAPPII CCHHAANNGGEELLOOGG The following revisions have been made to the Sudo Plugin API. diff --git a/doc/sudo_plugin.man.in b/doc/sudo_plugin.man.in index d7a44136c..c5bc35e37 100644 --- a/doc/sudo_plugin.man.in +++ b/doc/sudo_plugin.man.in @@ -1391,7 +1391,7 @@ will not be called. #define SUDO_API_VERSION_SET_MAJOR(vp, n) do { \e *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \e } while(0) -#define SUDO_VERSION_SET_MINOR(vp, n) do { \e +#define SUDO_API_VERSION_SET_MINOR(vp, n) do { \e *(vp) = (*(vp) & 0xffff0000) | (n); \e } while(0) .RE @@ -2201,21 +2201,13 @@ return SUDO_HOOK_RET_STOP; /* Hook API version major/minor */ #define SUDO_HOOK_VERSION_MAJOR 1 #define SUDO_HOOK_VERSION_MINOR 0 -#define SUDO_HOOK_MKVERSION(x, y) ((x << 16) | y) -#define SUDO_HOOK_VERSION SUDO_HOOK_MKVERSION(SUDO_HOOK_VERSION_MAJOR,\e +#define SUDO_HOOK_VERSION SUDO_API_MKVERSION(SUDO_HOOK_VERSION_MAJOR,\e SUDO_HOOK_VERSION_MINOR) - -/* Getters and setters for hook API version */ -#define SUDO_HOOK_VERSION_GET_MAJOR(v) ((v) >> 16) -#define SUDO_HOOK_VERSION_GET_MINOR(v) ((v) & 0xffff) -#define SUDO_HOOK_VERSION_SET_MAJOR(vp, n) do { \e - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \e -} while(0) -#define SUDO_HOOK_VERSION_SET_MINOR(vp, n) do { \e - *(vp) = (*(vp) & 0xffff0000) | (n); \e -} while(0) .RE .fi +.PP +For getters and setters see the +\fIPolicy plugin API\fR. .SS "Remote command execution" The \fBsudo\fR @@ -2272,6 +2264,11 @@ A function is also available that can be used to display informational or error messages to the user, which is usually more convenient for simple messages where no use input is required. +.PP +\fIConversation function structures\fR +.PP +The conversation function takes as arguments pointers to the following +structures: .nf .sp .RS 0n @@ -2293,14 +2290,6 @@ struct sudo_conv_reply { char *reply; }; -/* Conversation callback API version major/minor */ -#define SUDO_CONV_CALLBACK_VERSION_MAJOR 1 -#define SUDO_CONV_CALLBACK_VERSION_MINOR 0 -#define SUDO_CONV_CALLBACK_MKVERSION(x, y) ((x << 16) | y) -#define SUDO_CONV_CALLBACK_VERSION \e - SUDO_CONV_CALLBACK_MKVERSION(SUDO_CONV_CALLBACK_VERSION_MAJOR, \e - SUDO_CONV_CALLBACK_VERSION_MINOR) - typedef int (*sudo_conv_callback_fn_t)(int signo, void *closure); struct sudo_conv_callback { unsigned int version; @@ -2308,13 +2297,6 @@ struct sudo_conv_callback { sudo_conv_callback_fn_t on_suspend; sudo_conv_callback_fn_t on_resume; }; - -typedef int (*sudo_conv_t)(int num_msgs, - const struct sudo_conv_message msgs[], - struct sudo_conv_reply replies[], - struct sudo_conv_callback *callback); - -typedef int (*sudo_printf_t)(int msg_type, const char *fmt, ...); .RE .fi .PP @@ -2326,6 +2308,20 @@ functions are passed in to the plugin's \fBopen\fR() function when the plugin is initialized. +The following type definitions can be used in the declaration of the +\fBopen\fR() +function: +.nf +.sp +.RS 0n +typedef int (*sudo_conv_t)(int num_msgs, + const struct sudo_conv_message msgs[], + struct sudo_conv_reply replies[], + struct sudo_conv_callback *callback); + +typedef int (*sudo_printf_t)(int msg_type, const char *fmt, ...); +.RE +.fi .PP To use the \fBconversation\fR() @@ -2344,17 +2340,22 @@ The \fRstruct sudo_conv_callback\fR pointer, if not \fRNULL\fR, -contains function pointers that are called when the +should contain function pointers to be called when the \fBsudo\fR process is suspended and/or resumed during conversation input. -The functions are passed the signal that caused +The +\fIon_suspend\fR +and +\fIon_resume\fR +functions are called with the signal that caused \fBsudo\fR to be suspended and the \fIclosure\fR -pointer. -This allows the plugin to release resources such as locks that -should not be held indefinitely on suspend and reacquire them -on resume. +pointer from the +\fRstruct sudo_conv_callback\fR. +The intended use is to allow the plugin to release resources, such as locks, +that should not be held indefinitely while suspended and then reacquire them +when the process is resumed. Note that the functions are not actually invoked from within a signal handler. .PP The plugin is responsible for freeing the reply buffer located in each @@ -2563,18 +2564,10 @@ will be #define GROUP_API_VERSION_MINOR 0 #define GROUP_API_VERSION ((GROUP_API_VERSION_MAJOR << 16) | \e GROUP_API_VERSION_MINOR) - -/* Getters and setters for group version */ -#define GROUP_API_VERSION_GET_MAJOR(v) ((v) >> 16) -#define GROUP_API_VERSION_GET_MINOR(v) ((v) & 0xffff) -#define GROUP_API_VERSION_SET_MAJOR(vp, n) do { \e - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \e -} while(0) -#define GROUP_API_VERSION_SET_MINOR(vp, n) do { \e - *(vp) = (*(vp) & 0xffff0000) | (n); \e -} while(0) .RE .fi +For getters and setters see the +\fIPolicy plugin API\fR. .SH "PLUGIN API CHANGELOG" The following revisions have been made to the Sudo Plugin API. .TP 6n diff --git a/doc/sudo_plugin.mdoc.in b/doc/sudo_plugin.mdoc.in index b49699aad..d4a5f9ceb 100644 --- a/doc/sudo_plugin.mdoc.in +++ b/doc/sudo_plugin.mdoc.in @@ -1228,7 +1228,7 @@ will not be called. #define SUDO_API_VERSION_SET_MAJOR(vp, n) do { \e *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \e } while(0) -#define SUDO_VERSION_SET_MINOR(vp, n) do { \e +#define SUDO_API_VERSION_SET_MINOR(vp, n) do { \e *(vp) = (*(vp) & 0xffff0000) | (n); \e } while(0) .Ed @@ -1910,20 +1910,12 @@ return SUDO_HOOK_RET_STOP; /* Hook API version major/minor */ #define SUDO_HOOK_VERSION_MAJOR 1 #define SUDO_HOOK_VERSION_MINOR 0 -#define SUDO_HOOK_MKVERSION(x, y) ((x << 16) | y) -#define SUDO_HOOK_VERSION SUDO_HOOK_MKVERSION(SUDO_HOOK_VERSION_MAJOR,\e +#define SUDO_HOOK_VERSION SUDO_API_MKVERSION(SUDO_HOOK_VERSION_MAJOR,\e SUDO_HOOK_VERSION_MINOR) - -/* Getters and setters for hook API version */ -#define SUDO_HOOK_VERSION_GET_MAJOR(v) ((v) >> 16) -#define SUDO_HOOK_VERSION_GET_MINOR(v) ((v) & 0xffff) -#define SUDO_HOOK_VERSION_SET_MAJOR(vp, n) do { \e - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \e -} while(0) -#define SUDO_HOOK_VERSION_SET_MINOR(vp, n) do { \e - *(vp) = (*(vp) & 0xffff0000) | (n); \e -} while(0) .Ed +.Pp +For getters and setters see the +.Sx Policy plugin API . .Ss Remote command execution The .Nm sudo @@ -1980,6 +1972,11 @@ A function is also available that can be used to display informational or error messages to the user, which is usually more convenient for simple messages where no use input is required. +.Pp +.Em Conversation function structures +.Pp +The conversation function takes as arguments pointers to the following +structures: .Bd -literal struct sudo_conv_message { #define SUDO_CONV_PROMPT_ECHO_OFF 0x0001 /* do not echo user input */ @@ -1999,14 +1996,6 @@ struct sudo_conv_reply { char *reply; }; -/* Conversation callback API version major/minor */ -#define SUDO_CONV_CALLBACK_VERSION_MAJOR 1 -#define SUDO_CONV_CALLBACK_VERSION_MINOR 0 -#define SUDO_CONV_CALLBACK_MKVERSION(x, y) ((x << 16) | y) -#define SUDO_CONV_CALLBACK_VERSION \e - SUDO_CONV_CALLBACK_MKVERSION(SUDO_CONV_CALLBACK_VERSION_MAJOR, \e - SUDO_CONV_CALLBACK_VERSION_MINOR) - typedef int (*sudo_conv_callback_fn_t)(int signo, void *closure); struct sudo_conv_callback { unsigned int version; @@ -2014,13 +2003,6 @@ struct sudo_conv_callback { sudo_conv_callback_fn_t on_suspend; sudo_conv_callback_fn_t on_resume; }; - -typedef int (*sudo_conv_t)(int num_msgs, - const struct sudo_conv_message msgs[], - struct sudo_conv_reply replies[], - struct sudo_conv_callback *callback); - -typedef int (*sudo_printf_t)(int msg_type, const char *fmt, ...); .Ed .Pp Pointers to the @@ -2031,6 +2013,17 @@ functions are passed in to the plugin's .Fn open function when the plugin is initialized. +The following type definitions can be used in the declaration of the +.Fn open +function: +.Bd -literal +typedef int (*sudo_conv_t)(int num_msgs, + const struct sudo_conv_message msgs[], + struct sudo_conv_reply replies[], + struct sudo_conv_callback *callback); + +typedef int (*sudo_printf_t)(int msg_type, const char *fmt, ...); +.Ed .Pp To use the .Fn conversation @@ -2049,17 +2042,22 @@ The .Li struct sudo_conv_callback pointer, if not .Dv NULL , -contains function pointers that are called when the +should contain function pointers to be called when the .Nm sudo process is suspended and/or resumed during conversation input. -The functions are passed the signal that caused +The +.Fa on_suspend +and +.Fa on_resume +functions are called with the signal that caused .Nm sudo to be suspended and the .Fa closure -pointer. -This allows the plugin to release resources such as locks that -should not be held indefinitely on suspend and reacquire them -on resume. +pointer from the +.Li struct sudo_conv_callback . +The intended use is to allow the plugin to release resources, such as locks, +that should not be held indefinitely while suspended and then reacquire them +when the process is resumed. Note that the functions are not actually invoked from within a signal handler. .Pp The plugin is responsible for freeing the reply buffer located in each @@ -2239,17 +2237,9 @@ will be #define GROUP_API_VERSION_MINOR 0 #define GROUP_API_VERSION ((GROUP_API_VERSION_MAJOR << 16) | \e GROUP_API_VERSION_MINOR) - -/* Getters and setters for group version */ -#define GROUP_API_VERSION_GET_MAJOR(v) ((v) >> 16) -#define GROUP_API_VERSION_GET_MINOR(v) ((v) & 0xffff) -#define GROUP_API_VERSION_SET_MAJOR(vp, n) do { \e - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \e -} while(0) -#define GROUP_API_VERSION_SET_MINOR(vp, n) do { \e - *(vp) = (*(vp) & 0xffff0000) | (n); \e -} while(0) .Ed +For getters and setters see the +.Sx Policy plugin API . .Sh PLUGIN API CHANGELOG The following revisions have been made to the Sudo Plugin API. .Bl -tag -width 4n diff --git a/include/sudo_plugin.h b/include/sudo_plugin.h index b8fa44591..dd1df8d69 100644 --- a/include/sudo_plugin.h +++ b/include/sudo_plugin.h @@ -23,7 +23,7 @@ #define SUDO_API_MKVERSION(x, y) ((x << 16) | y) #define SUDO_API_VERSION SUDO_API_MKVERSION(SUDO_API_VERSION_MAJOR, SUDO_API_VERSION_MINOR) -/* Getters and setters for API version */ +/* Getters and setters for plugin API versions */ #define SUDO_API_VERSION_GET_MAJOR(v) ((v) >> 16) #define SUDO_API_VERSION_GET_MINOR(v) ((v) & 0xffff) #define SUDO_API_VERSION_SET_MAJOR(vp, n) do { \ @@ -64,8 +64,7 @@ struct sudo_conv_reply { /* Conversation callback API version major/minor */ #define SUDO_CONV_CALLBACK_VERSION_MAJOR 1 #define SUDO_CONV_CALLBACK_VERSION_MINOR 0 -#define SUDO_CONV_CALLBACK_MKVERSION(x, y) ((x << 16) | y) -#define SUDO_CONV_CALLBACK_VERSION SUDO_CONV_CALLBACK_MKVERSION(SUDO_CONV_CALLBACK_VERSION_MAJOR, SUDO_CONV_CALLBACK_VERSION_MINOR) +#define SUDO_CONV_CALLBACK_VERSION SUDO_API_MKVERSION(SUDO_CONV_CALLBACK_VERSION_MAJOR, SUDO_CONV_CALLBACK_VERSION_MINOR) /* * Callback struct to be passed to the conversation function. @@ -106,18 +105,7 @@ struct sudo_hook { /* Hook API version major/minor */ #define SUDO_HOOK_VERSION_MAJOR 1 #define SUDO_HOOK_VERSION_MINOR 0 -#define SUDO_HOOK_MKVERSION(x, y) ((x << 16) | y) -#define SUDO_HOOK_VERSION SUDO_HOOK_MKVERSION(SUDO_HOOK_VERSION_MAJOR, SUDO_HOOK_VERSION_MINOR) - -/* Getters and setters for hook API version */ -#define SUDO_HOOK_VERSION_GET_MAJOR(v) ((v) >> 16) -#define SUDO_HOOK_VERSION_GET_MINOR(v) ((v) & 0xffff) -#define SUDO_HOOK_VERSION_SET_MAJOR(vp, n) do { \ - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \ -} while(0) -#define SUDO_HOOK_VERSION_SET_MINOR(vp, n) do { \ - *(vp) = (*(vp) & 0xffff0000) | (n); \ -} while(0) +#define SUDO_HOOK_VERSION SUDO_API_MKVERSION(SUDO_HOOK_VERSION_MAJOR, SUDO_HOOK_VERSION_MINOR) /* * Hook function return values. @@ -185,17 +173,13 @@ struct io_plugin { /* Sudoers group plugin version major/minor */ #define GROUP_API_VERSION_MAJOR 1 #define GROUP_API_VERSION_MINOR 0 -#define GROUP_API_VERSION ((GROUP_API_VERSION_MAJOR << 16) | GROUP_API_VERSION_MINOR) +#define GROUP_API_VERSION SUDO_API_MKVERSION(GROUP_API_VERSION_MAJOR, GROUP_API_VERSION_MINOR) -/* Getters and setters for group version */ -#define GROUP_API_VERSION_GET_MAJOR(v) ((v) >> 16) -#define GROUP_API_VERSION_GET_MINOR(v) ((v) & 0xffff) -#define GROUP_API_VERSION_SET_MAJOR(vp, n) do { \ - *(vp) = (*(vp) & 0x0000ffff) | ((n) << 16); \ -} while(0) -#define GROUP_API_VERSION_SET_MINOR(vp, n) do { \ - *(vp) = (*(vp) & 0xffff0000) | (n); \ -} while(0) +/* Getters and setters for group version (for source compat only) */ +#define GROUP_API_VERSION_GET_MAJOR(v) SUDO_API_VERSION_GET_MAJOR(v) +#define GROUP_API_VERSION_GET_MINOR(v) SUDO_API_VERSION_GET_MINOR(v) +#define GROUP_API_VERSION_SET_MAJOR(vp, n) SUDO_API_VERSION_SET_MAJOR(vp, n) +#define GROUP_API_VERSION_SET_MINOR(vp, n) SUDO_API_VERSION_SET_MINOR(vp, n) /* * version: for compatibility checking diff --git a/plugins/group_file/group_file.c b/plugins/group_file/group_file.c index 788eb8d0c..f475b698f 100644 --- a/plugins/group_file/group_file.c +++ b/plugins/group_file/group_file.c @@ -62,10 +62,10 @@ sample_init(int version, sudo_printf_t sudo_printf, char *const argv[]) sudo_log = sudo_printf; - if (GROUP_API_VERSION_GET_MAJOR(version) != GROUP_API_VERSION_MAJOR) { + if (SUDO_API_VERSION_GET_MAJOR(version) != GROUP_API_VERSION_MAJOR) { sudo_log(SUDO_CONV_ERROR_MSG, "group_file: incompatible major version %d, expected %d\n", - GROUP_API_VERSION_GET_MAJOR(version), + SUDO_API_VERSION_GET_MAJOR(version), GROUP_API_VERSION_MAJOR); return -1; } diff --git a/plugins/group_file/plugin_test.c b/plugins/group_file/plugin_test.c index d16d86883..4914250f9 100644 --- a/plugins/group_file/plugin_test.c +++ b/plugins/group_file/plugin_test.c @@ -100,10 +100,10 @@ group_plugin_load(char *plugin_info) return -1; } - if (GROUP_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) { + if (SUDO_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) { fprintf(stderr, "%s: incompatible group plugin major version %d, expected %d\n", - path, GROUP_API_VERSION_GET_MAJOR(group_plugin->version), + path, SUDO_API_VERSION_GET_MAJOR(group_plugin->version), GROUP_API_VERSION_MAJOR); return -1; } diff --git a/plugins/sudoers/group_plugin.c b/plugins/sudoers/group_plugin.c index bbd7d5c29..b26a076a8 100644 --- a/plugins/sudoers/group_plugin.c +++ b/plugins/sudoers/group_plugin.c @@ -104,9 +104,9 @@ group_plugin_load(char *plugin_info) goto done; } - if (GROUP_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) { + if (SUDO_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) { sudo_warnx(U_("%s: incompatible group plugin major version %d, expected %d"), - path, GROUP_API_VERSION_GET_MAJOR(group_plugin->version), + path, SUDO_API_VERSION_GET_MAJOR(group_plugin->version), GROUP_API_VERSION_MAJOR); goto done; } diff --git a/plugins/sudoers/policy.c b/plugins/sudoers/policy.c index 3dafb7ebf..4b8e6539a 100644 --- a/plugins/sudoers/policy.c +++ b/plugins/sudoers/policy.c @@ -812,8 +812,8 @@ sudoers_policy_register_hooks(int version, int (*register_hook)(struct sudo_hook if (register_hook(hook) != 0) { sudo_warn_nodebug( U_("unable to register hook of type %d (version %d.%d)"), - hook->hook_type,SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version), - SUDO_HOOK_VERSION_GET_MINOR(hook->hook_version)); + hook->hook_type, SUDO_API_VERSION_GET_MAJOR(hook->hook_version), + SUDO_API_VERSION_GET_MINOR(hook->hook_version)); } } } diff --git a/plugins/system_group/system_group.c b/plugins/system_group/system_group.c index 6093fc324..1561ec0df 100644 --- a/plugins/system_group/system_group.c +++ b/plugins/system_group/system_group.c @@ -69,10 +69,10 @@ sysgroup_init(int version, sudo_printf_t sudo_printf, char *const argv[]) sudo_log = sudo_printf; - if (GROUP_API_VERSION_GET_MAJOR(version) != GROUP_API_VERSION_MAJOR) { + if (SUDO_API_VERSION_GET_MAJOR(version) != GROUP_API_VERSION_MAJOR) { sudo_log(SUDO_CONV_ERROR_MSG, "sysgroup_group: incompatible major version %d, expected %d\n", - GROUP_API_VERSION_GET_MAJOR(version), + SUDO_API_VERSION_GET_MAJOR(version), GROUP_API_VERSION_MAJOR); return -1; } diff --git a/src/hooks.c b/src/hooks.c index 6c867094c..d4e14c88f 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -150,7 +150,7 @@ register_hook(struct sudo_hook *hook) int rval; debug_decl(register_hook, SUDO_DEBUG_HOOKS) - if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) { + if (SUDO_API_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) { /* Major versions must match. */ errno = EINVAL; rval = -1; @@ -214,7 +214,7 @@ deregister_hook(struct sudo_hook *hook) int rval = 0; debug_decl(deregister_hook, SUDO_DEBUG_HOOKS) - if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) { + if (SUDO_API_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) { /* Major versions must match. */ rval = -1; } else {