+#include <sys/types.h>
+#include <db.h>
+#include <crt_externs.h>
+#include <errno.h>
+
+extern struct owned_ptr *__env_owned;
+
+#ifdef LEGACY_CRT1_ENVIRON
+extern char **_saved_environ;
+#endif /* LEGACY_CRT1_ENVIRON */
+
+__private_extern__ int __init__env_owned(int);
+__private_extern__ int __setenv(const char *, const char *, int, int, char ***, struct owned_ptr *);
+
+#ifndef BUILDING_VARIANT
+/*
+ * _putenvp -- SPI using an arbitrary pointer to string array (the array must
+ * have been created with malloc) and an env state, created by _allocenvstate().
+ * Returns ptr to value associated with name, if any, else NULL.
+ */
+int
+_putenvp(char *str, char ***envp, void *state)
+{
+ if (__init__env_owned(1)) return (-1);
+ return (__setenv(str, NULL, 1, 0, envp, (state ? (struct owned_ptr *)state : __env_owned)));
+}
+#endif /* BUILDING_VARIANT */