Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for the presence of secure_getenv #163

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kubernetes/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include(CheckFunctionExists)

check_function_exists(strndup HAVE_STRNDUP)
check_function_exists(strndup HAVE_STRNDUP)
check_function_exists(secure_getenv HAVE_SECURE_GETENV)
3 changes: 2 additions & 1 deletion kubernetes/config.h.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/* Define to 1 if you have the `strndup' function. */
#cmakedefine HAVE_STRNDUP 1
#cmakedefine HAVE_STRNDUP 1
#cmakedefine HAVE_SECURE_GETENV 1
4 changes: 2 additions & 2 deletions kubernetes/config/incluster_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static int setBasePathInCluster(char **pBasePath)
{
static char fname[] = "setBasePathInCluster()";

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__) || !defined(HAVE_SECURE_GETENV)
const char *service_host_env = getenv(SERVICE_HOST_ENV_NAME);
#elif __linux || defined(__EMSCRIPTEN__)
const char *service_host_env = secure_getenv(SERVICE_HOST_ENV_NAME);
Expand All @@ -54,7 +54,7 @@ static int setBasePathInCluster(char **pBasePath)
fprintf(stderr, "%s: Cannot retrieve the kubernetes service host inside a pod by the env %s.\n", fname, SERVICE_HOST_ENV_NAME);
return -1;
}
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__) || !defined(HAVE_SECURE_GETENV)
const char *service_port_env = getenv(SERVICE_PORT_ENV_NAME);
#elif __linux || defined(__EMSCRIPTEN__)
const char *service_port_env = secure_getenv(SERVICE_PORT_ENV_NAME);
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/config/kube_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ static char *getWorkingConfigFile(const char *configFileNamePassedIn)
configFileName = strdup(configFileNamePassedIn);
} else {

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__) || !defined(HAVE_SECURE_GETENV)
kubeconfig_env = getenv(ENV_KUBECONFIG);
#elif __linux || defined(__EMSCRIPTEN__)
kubeconfig_env = secure_getenv(ENV_KUBECONFIG);
#endif
if (kubeconfig_env) {
configFileName = strdup(kubeconfig_env);
} else {
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__APPLE__) || !defined(HAVE_SECURE_GETENV)
homedir_env = getenv(ENV_HOME);
#elif __linux || defined(__EMSCRIPTEN__)
homedir_env = secure_getenv(ENV_HOME);
Expand Down