diff --git a/doc/sudo.conf.man.in b/doc/sudo.conf.man.in index 3326fab31..6f142e98f 100644 --- a/doc/sudo.conf.man.in +++ b/doc/sudo.conf.man.in @@ -769,10 +769,10 @@ front end configuration # Sudo command interception: # Path intercept /path/to/sudo_intercept.so # -# Path to a shared library containing replacements for the execv(), -# execve() and fexecve() library functions that perform a policy check -# to verify the command is allowed and simply return an error if not. -# This is used to implement the "intercept" functionality on systems that +# Path to a shared library containing replacements for the execv() +# and execve() library functions that perform a policy check to verify +# the command is allowed and simply return an error if not. This is +# used to implement the "intercept" functionality on systems that # support LD_PRELOAD or its equivalent. # # The compiled-in value is usually sufficient and should only be changed @@ -784,10 +784,10 @@ front end configuration # Sudo noexec: # Path noexec /path/to/sudo_noexec.so # -# Path to a shared library containing replacements for the execv(), -# execve() and fexecve() library functions that just return an error. -# This is used to implement the "noexec" functionality on systems that -# support LD_PRELOAD or its equivalent. +# Path to a shared library containing replacements for the execv() +# family of library functions that just return an error. This is +# used to implement the "noexec" functionality on systems that support +# LD_PRELOAD or its equivalent. # # The compiled-in value is usually sufficient and should only be changed # if you rename or move the sudo_noexec.so file. diff --git a/doc/sudo.conf.mdoc.in b/doc/sudo.conf.mdoc.in index 80f1780a3..46e7ccc6b 100644 --- a/doc/sudo.conf.mdoc.in +++ b/doc/sudo.conf.mdoc.in @@ -699,10 +699,10 @@ front end configuration # Sudo command interception: # Path intercept /path/to/sudo_intercept.so # -# Path to a shared library containing replacements for the execv(), -# execve() and fexecve() library functions that perform a policy check -# to verify the command is allowed and simply return an error if not. -# This is used to implement the "intercept" functionality on systems that +# Path to a shared library containing replacements for the execv() +# and execve() library functions that perform a policy check to verify +# the command is allowed and simply return an error if not. This is +# used to implement the "intercept" functionality on systems that # support LD_PRELOAD or its equivalent. # # The compiled-in value is usually sufficient and should only be changed @@ -714,10 +714,10 @@ front end configuration # Sudo noexec: # Path noexec /path/to/sudo_noexec.so # -# Path to a shared library containing replacements for the execv(), -# execve() and fexecve() library functions that just return an error. -# This is used to implement the "noexec" functionality on systems that -# support LD_PRELOAD or its equivalent. +# Path to a shared library containing replacements for the execv() +# family of library functions that just return an error. This is +# used to implement the "noexec" functionality on systems that support +# LD_PRELOAD or its equivalent. # # The compiled-in value is usually sufficient and should only be changed # if you rename or move the sudo_noexec.so file. diff --git a/doc/sudoers.man.in b/doc/sudoers.man.in index 3fc43ac38..a4015f40a 100644 --- a/doc/sudoers.man.in +++ b/doc/sudoers.man.in @@ -2763,8 +2763,10 @@ If set, \fBsudoers\fR will log when a command spawns a child process and executes a program using the +\fBexecv\fR() +or \fBexecve\fR() -system call. +library functions. For example, if a shell is run by \fBsudo\fR, the individual commands run via the shell will be logged. diff --git a/doc/sudoers.mdoc.in b/doc/sudoers.mdoc.in index 870b0daf3..0cc11b237 100644 --- a/doc/sudoers.mdoc.in +++ b/doc/sudoers.mdoc.in @@ -2603,8 +2603,10 @@ If set, .Nm will log when a command spawns a child process and executes a program using the +.Fn execv +or .Fn execve -system call. +library functions. For example, if a shell is run by .Nm sudo , the individual commands run via the shell will be logged. diff --git a/src/intercept.exp b/src/intercept.exp index cc7f00786..7c09b837c 100644 --- a/src/intercept.exp +++ b/src/intercept.exp @@ -1 +1,2 @@ +execv execve diff --git a/src/sudo_intercept.c b/src/sudo_intercept.c index a620c5ebf..1e4cbf80d 100644 --- a/src/sudo_intercept.c +++ b/src/sudo_intercept.c @@ -48,6 +48,7 @@ #include "sudo_util.h" #include "pathnames.h" +extern char **environ; extern bool command_allowed(const char *cmnd, char * const argv[], char * const envp[], char **ncmnd, char ***nargv, char ***nenvp); #ifdef HAVE___INTERPOSE @@ -81,10 +82,17 @@ my_execve(const char *cmnd, char * const argv[], char * const envp[]) return -1; } +static int +my_execv(const char *cmnd, char * const argv[]) +{ + return my_execve(cmnd, argv, environ); +} + /* Magic to tell dyld to do symbol interposition. */ __attribute__((__used__)) static const interpose_t interposers[] __attribute__((__section__("__DATA,__interpose"))) = { { (void *)my_execve, (void *)execve } + { (void *)my_execv, (void *)execv } }; #else /* HAVE___INTERPOSE */ @@ -148,4 +156,10 @@ execve(const char *cmnd, char * const argv[], char * const envp[]) return -1; } + +sudo_dso_public int +execv(const char *cmnd, char * const argv[]) +{ + return execve(cmnd, argv, environ); +} #endif /* HAVE___INTERPOSE) */