* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.111 2006/02/24 00:55:49 adunstan Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.112 2006/02/24 02:02:41 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
static bool debug = false;
static bool noclean = false;
static bool show_setting = false;
-#ifdef WIN32
-static bool restricted_exec = false;
-#endif
/* internal vars */
{"lc-messages", required_argument, NULL, 7},
{"no-locale", no_argument, NULL, 8},
{"auth", required_argument, NULL, 'A'},
- {"pwprompt", no_argument, NULL, 'W'},
+ {"pwprompt", no_argument, NULL, 'W'},
{"pwfile", required_argument, NULL, 9},
-#ifdef WIN32
- {"restrictedexec", no_argument, NULL, 10},
-#endif
{"username", required_argument, NULL, 'U'},
{"help", no_argument, NULL, '?'},
{"version", no_argument, NULL, 'V'},
* environment */
char bin_dir[MAXPGPATH];
char *pg_data_native;
+#ifdef WIN32
+ char *restrict_env;
+#endif
static const char *subdirs[] = {
"global",
"pg_xlog",
case 9:
pwfilename = xstrdup(optarg);
break;
-#ifdef WIN32
- case 10:
- restricted_exec = true;
- break;
-#endif
case 's':
show_setting = true;
break;
}
}
+
/* Non-option argument specifies data directory */
if (optind < argc)
{
* Before we execute another program, make sure that we are running with a
* restricted token. If not, re-execute ourselves with one.
*/
- if (!restricted_exec)
+
+ if ((restrict_env = getenv("PG_RESTRICT_EXEC")) == NULL
+ || strcmp(restrict_env,"1") != 0)
{
PROCESS_INFORMATION pi;
char *cmdline;
ZeroMemory(&pi, sizeof(pi));
- cmdline = pg_malloc(strlen(GetCommandLine()) + 19);
- strcpy(cmdline, GetCommandLine());
- strcat(cmdline, " --restrictedexec");
+ cmdline = xstrdup(GetCommandLine());
+
+ putenv("PG_RESTRICT_EXEC=1");
if (!CreateRestrictedProcess(cmdline, &pi))
{