Allow building without the exec() supported ...

.. to satisfy restricted environment or fuzzers

We are encountering weird issues in the oss-fuzz that the file disappears during
coverage build so I assume some corpus sneaked in, that contains some commands
that end up being executed as part of the coverage run causing it randomly
failing.

The solution I propose is to build fuzzers without ability to call arbitrary
commands on the filesystem (such as `rm -rf /`) as this is not the point the
fuzzers should be testing.

This is controlled by the WITH_EXEC CMake option (enabled by default).

https://github.com/google/oss-fuzz/issues/10136

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Jakub Jelen
2024-07-04 18:28:43 +02:00
committed by Sahana Prasad
parent 2fe9ed1764
commit bed4438695
12 changed files with 81 additions and 34 deletions

View File

@@ -881,7 +881,7 @@ int ssh_socket_connect(ssh_socket s,
return SSH_OK;
}
#ifndef _WIN32
#ifdef WITH_EXEC
/**
* @internal
* @brief executes a command and redirect input and outputs
@@ -910,7 +910,7 @@ ssh_execute_command(const char *command, socket_t in, socket_t out)
*/
shell = getenv("SHELL");
if (shell == NULL || shell[0] == '\0') {
/* Fall back to the /bin/sh only if the bash is not available. But there are
/* Fall back to the /bin/sh only if the bash is not available. But there are
* issues with dash or whatever people tend to link to /bin/sh */
rc = access("/bin/bash", 0);
if (rc != 0) {
@@ -947,7 +947,6 @@ ssh_execute_command(const char *command, socket_t in, socket_t out)
* @returns SSH_OK socket is being connected.
* @returns SSH_ERROR error while executing the command.
*/
int
ssh_socket_connect_proxycommand(ssh_socket s, const char *command)
{
@@ -987,6 +986,5 @@ ssh_socket_connect_proxycommand(ssh_socket s, const char *command)
return SSH_OK;
}
#endif /* _WIN32 */
#endif /* WITH_EXEC */
/** @} */