From 346ff6766eb44d8a37050e977db5b47cac9d54ab Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 22 Oct 2014 13:13:00 -0600 Subject: [PATCH] Pass plugin path in the settings array. --- doc/sudo_plugin.cat | 8 ++++++++ doc/sudo_plugin.man.in | 15 +++++++++++++++ doc/sudo_plugin.mdoc.in | 13 +++++++++++++ include/sudo_plugin.h | 4 ++-- src/load_plugins.c | 2 ++ src/sudo.c | 2 ++ src/sudo_plugin_int.h | 3 ++- 7 files changed, 44 insertions(+), 3 deletions(-) diff --git a/doc/sudo_plugin.cat b/doc/sudo_plugin.cat index 7276395a1..4943db833 100644 --- a/doc/sudo_plugin.cat +++ b/doc/sudo_plugin.cat @@ -178,6 +178,11 @@ DDEESSCCRRIIPPTTIIOONN plugin was loaded from. It may be used by a plugin to locate support files. + plugin_path=string + The path name of plugin loaded by the ssuuddoo front end. + The path name will be a fully-qualified unless the + plugin was statically compiled into ssuuddoo. + preserve_environment=bool Set to true if the user specified the --EE flag, indicating that the user wishes to preserve the @@ -1462,6 +1467,9 @@ PPLLUUGGIINN AAPPII CCHHAANNGGEELLOOGG Previously, output from the command would be displayed to the terminal even if an output logging function returned 0. + Version 1.7 (sudo 1.8.12) + The _p_l_u_g_i_n___p_a_t_h entry was added to the settings list. + SSEEEE AALLSSOO sudo.conf(4), sudoers(4), sudo(1m) diff --git a/doc/sudo_plugin.man.in b/doc/sudo_plugin.man.in index 343b23ad4..c34b5754a 100644 --- a/doc/sudo_plugin.man.in +++ b/doc/sudo_plugin.man.in @@ -304,6 +304,14 @@ This is the default directory set at compile time and may not correspond to the directory the running plugin was loaded from. It may be used by a plugin to locate support files. .TP 6n +plugin_path=string +The path name of plugin loaded by the +\fBsudo\fR +front end. +The path name will be a fully-qualified unless the plugin was +statically compiled into +\fBsudo\fR. +.TP 6n preserve_environment=bool Set to true if the user specified the \fB\-E\fR @@ -2608,6 +2616,13 @@ function returned an error. The behavior when an I/O logging plugin returns 0 has changed. Previously, output from the command would be displayed to the terminal even if an output logging function returned 0. +.TP 6n +Version 1.7 (sudo 1.8.12) +The +\fIplugin_path\fR +entry was added to the +\fRsettings\fR +list. .SH "SEE ALSO" sudo.conf(@mansectform@), sudoers(@mansectform@), diff --git a/doc/sudo_plugin.mdoc.in b/doc/sudo_plugin.mdoc.in index 0a8e20919..1641d5059 100644 --- a/doc/sudo_plugin.mdoc.in +++ b/doc/sudo_plugin.mdoc.in @@ -275,6 +275,13 @@ front end. This is the default directory set at compile time and may not correspond to the directory the running plugin was loaded from. It may be used by a plugin to locate support files. +.It plugin_path=string +The path name of plugin loaded by the +.Nm sudo +front end. +The path name will be a fully-qualified unless the plugin was +statically compiled into +.Nm sudo . .It preserve_environment=bool Set to true if the user specified the .Fl E @@ -2279,6 +2286,12 @@ function returned an error. The behavior when an I/O logging plugin returns 0 has changed. Previously, output from the command would be displayed to the terminal even if an output logging function returned 0. +.It Version 1.7 (sudo 1.8.12) +The +.Em plugin_path +entry was added to the +.Li settings +list. .El .Sh SEE ALSO .Xr sudo.conf @mansectform@ , diff --git a/include/sudo_plugin.h b/include/sudo_plugin.h index b4300222b..9d380c3c5 100644 --- a/include/sudo_plugin.h +++ b/include/sudo_plugin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2013 Todd C. Miller + * Copyright (c) 2009-2014 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -19,7 +19,7 @@ /* API version major/minor */ #define SUDO_API_VERSION_MAJOR 1 -#define SUDO_API_VERSION_MINOR 6 +#define SUDO_API_VERSION_MINOR 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) diff --git a/src/load_plugins.c b/src/load_plugins.c index f25f12830..f12cf8157 100644 --- a/src/load_plugins.c +++ b/src/load_plugins.c @@ -237,6 +237,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin, } if (handle != NULL) { policy_plugin->handle = handle; + policy_plugin->path = sudo_estrdup(path); policy_plugin->name = info->symbol_name; policy_plugin->options = info->options; policy_plugin->u.generic = plugin; @@ -255,6 +256,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin, if (handle != NULL) { container = sudo_ecalloc(1, sizeof(*container)); container->handle = handle; + container->path = sudo_estrdup(path); container->name = info->symbol_name; container->options = info->options; container->u.generic = plugin; diff --git a/src/sudo.c b/src/sudo.c index 85a889fd6..ee6b2c2d0 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -1091,6 +1091,8 @@ format_plugin_settings(struct plugin_container *plugin, debug_decl(format_plugin_settings, SUDO_DEBUG_PCOMM) plugin_settings = sudo_emallocarray(plugin_settings_size, sizeof(char *)); + plugin_settings[num_plugin_settings++] = + sudo_new_key_val("plugin_path", plugin->path); while (settings->name != NULL) { if (settings->value != NULL) { sudo_debug_printf(SUDO_DEBUG_INFO, "settings: %s=%s", diff --git a/src/sudo_plugin_int.h b/src/sudo_plugin_int.h index 2e0fb1709..fb82b204d 100644 --- a/src/sudo_plugin_int.h +++ b/src/sudo_plugin_int.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Todd C. Miller + * Copyright (c) 2010-2014 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -83,6 +83,7 @@ struct io_plugin_1_1 { struct plugin_container { TAILQ_ENTRY(plugin_container) entries; const char *name; + const char *path; char * const *options; void *handle; union { -- 2.40.0