aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/pg_config.h.in6
-rw-r--r--src/include/port.h8
-rw-r--r--src/port/setenv.c48
-rw-r--r--src/port/unsetenv.c65
-rw-r--r--src/tools/msvc/Solution.pm2
5 files changed, 0 insertions, 129 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index f3f132e2058..b6ee575681c 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -448,9 +448,6 @@
/* Define to 1 if you have the <security/pam_appl.h> header file. */
#undef HAVE_SECURITY_PAM_APPL_H
-/* Define to 1 if you have the `setenv' function. */
-#undef HAVE_SETENV
-
/* Define to 1 if you have the `setproctitle' function. */
#undef HAVE_SETPROCTITLE
@@ -625,9 +622,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
-/* Define to 1 if you have the `unsetenv' function. */
-#undef HAVE_UNSETENV
-
/* Define to 1 if you have the `uselocale' function. */
#undef HAVE_USELOCALE
diff --git a/src/include/port.h b/src/include/port.h
index cec785f8a5d..85c9b38f4ee 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -448,14 +448,6 @@ extern size_t strlcpy(char *dst, const char *src, size_t siz);
extern size_t strnlen(const char *str, size_t maxlen);
#endif
-#ifndef HAVE_SETENV
-extern int setenv(const char *name, const char *value, int overwrite);
-#endif
-
-#ifndef HAVE_UNSETENV
-extern int unsetenv(const char *name);
-#endif
-
/* thread.c */
#ifndef WIN32
extern bool pg_get_user_name(uid_t user_id, char *buffer, size_t buflen);
diff --git a/src/port/setenv.c b/src/port/setenv.c
deleted file mode 100644
index d13c8824671..00000000000
--- a/src/port/setenv.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * setenv.c
- * setenv() emulation for machines without it
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/setenv.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-
-int
-setenv(const char *name, const char *value, int overwrite)
-{
- char *envstr;
-
- /* Error conditions, per POSIX */
- if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL ||
- value == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- /* No work if variable exists and we're not to replace it */
- if (overwrite == 0 && getenv(name) != NULL)
- return 0;
-
- /*
- * Add or replace the value using putenv(). This will leak memory if the
- * same variable is repeatedly redefined, but there's little we can do
- * about that when sitting atop putenv().
- */
- envstr = (char *) malloc(strlen(name) + strlen(value) + 2);
- if (!envstr) /* not much we can do if no memory */
- return -1;
-
- sprintf(envstr, "%s=%s", name, value);
-
- return putenv(envstr);
-}
diff --git a/src/port/unsetenv.c b/src/port/unsetenv.c
deleted file mode 100644
index 62b806d796c..00000000000
--- a/src/port/unsetenv.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * unsetenv.c
- * unsetenv() emulation for machines without it
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/unsetenv.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-
-int
-unsetenv(const char *name)
-{
- char *envstr;
-
- /* Error conditions, per POSIX */
- if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- if (getenv(name) == NULL)
- return 0; /* no work */
-
- /*
- * The technique embodied here works if libc follows the Single Unix Spec
- * and actually uses the storage passed to putenv() to hold the environ
- * entry. When we clobber the entry in the second step we are ensuring
- * that we zap the actual environ member. However, there are some libc
- * implementations (notably recent BSDs) that do not obey SUS but copy the
- * presented string. This method fails on such platforms. Hopefully all
- * such platforms have unsetenv() and thus won't be using this hack. See:
- * http://www.greenend.org.uk/rjk/2008/putenv.html
- *
- * Note that repeatedly setting and unsetting a var using this code will
- * leak memory.
- */
-
- envstr = (char *) malloc(strlen(name) + 2);
- if (!envstr) /* not much we can do if no memory */
- return -1;
-
- /* Override the existing setting by forcibly defining the var */
- sprintf(envstr, "%s=", name);
- if (putenv(envstr))
- return -1;
-
- /* Now we can clobber the variable definition this way: */
- strcpy(envstr, "=");
-
- /*
- * This last putenv cleans up if we have multiple zero-length names as a
- * result of unsetting multiple things.
- */
- return putenv(envstr);
-}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 2a7d9f1f9ef..5301e01e833 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -343,7 +343,6 @@ sub GenerateFiles
HAVE_RL_RESET_SCREEN_SIZE => undef,
HAVE_RL_VARIABLE_BIND => undef,
HAVE_SECURITY_PAM_APPL_H => undef,
- HAVE_SETENV => undef,
HAVE_SETPROCTITLE => undef,
HAVE_SETPROCTITLE_FAST => undef,
HAVE_SOCKLEN_T => 1,
@@ -402,7 +401,6 @@ sub GenerateFiles
HAVE_UINT8 => undef,
HAVE_UNION_SEMUN => undef,
HAVE_UNISTD_H => 1,
- HAVE_UNSETENV => undef,
HAVE_USELOCALE => undef,
HAVE_UUID_BSD => undef,
HAVE_UUID_E2FS => undef,