AC_CHECK_FUNCS([eaccess euidaccess mmap])
+AC_CHECK_FUNCS([secure_getenv __secure_getenv])
+AS_IF([test "x$ac_cv_func_secure_getenv" = xno -a \
+ "x$ac_cv_func___secure_getenv" = xno], [
+ AC_MSG_WARN([C library does not support secure_getenv, using getenv instead])
+])
+
# Some tests use Linux-specific headers
AC_CHECK_HEADER([linux/input.h])
AM_CONDITIONAL(BUILD_LINUX_TESTS, [test "x$ac_cv_header_linux_input_h" = xyes])
const char *env = NULL;
if (ctx->use_environment_names)
- env = getenv("XKB_DEFAULT_RULES");
+ env = secure_getenv("XKB_DEFAULT_RULES");
return env ? env : DEFAULT_XKB_RULES;
}
const char *env = NULL;
if (ctx->use_environment_names)
- env = getenv("XKB_DEFAULT_MODEL");
+ env = secure_getenv("XKB_DEFAULT_MODEL");
return env ? env : DEFAULT_XKB_MODEL;
}
const char *env = NULL;
if (ctx->use_environment_names)
- env = getenv("XKB_DEFAULT_LAYOUT");
+ env = secure_getenv("XKB_DEFAULT_LAYOUT");
return env ? env : DEFAULT_XKB_LAYOUT;
}
xkb_context_get_default_variant(struct xkb_context *ctx)
{
const char *env = NULL;
- const char *layout = getenv("XKB_DEFAULT_VARIANT");
+ const char *layout = secure_getenv("XKB_DEFAULT_VARIANT");
/* We don't want to inherit the variant if they haven't also set a
* layout, since they're so closely paired. */
if (layout && ctx->use_environment_names)
- env = getenv("XKB_DEFAULT_VARIANT");
+ env = secure_getenv("XKB_DEFAULT_VARIANT");
return env ? env : DEFAULT_XKB_VARIANT;
}
const char *env = NULL;
if (ctx->use_environment_names)
- env = getenv("XKB_DEFAULT_OPTIONS");
+ env = secure_getenv("XKB_DEFAULT_OPTIONS");
return env ? env : DEFAULT_XKB_OPTIONS;
}
ret |= xkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_ROOT);
- home = getenv("HOME");
+ home = secure_getenv("HOME");
if (!home)
return ret;
err = asprintf(&user_path, "%s/.xkb", home);
ctx->log_verbosity = 0;
/* Environment overwrites defaults. */
- env = getenv("XKB_LOG_LEVEL");
+ env = secure_getenv("XKB_LOG_LEVEL");
if (env)
xkb_context_set_log_level(ctx, log_level(env));
- env = getenv("XKB_LOG_VERBOSITY");
+ env = secure_getenv("XKB_LOG_VERBOSITY");
if (env)
xkb_context_set_log_verbosity(ctx, log_verbosity(env));
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MAX3(a, b, c) MAX(MAX((a), (b)), (c))
+#if defined(HAVE_SECURE_GETENV)
+# define secure_getenv secure_getenv
+#elif defined(HAVE___SECURE_GETENV)
+# define secure_getenv __secure_getenv
+#else
+# define secure_getenv getenv
+#endif
+
/* Compiler Attributes */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)