Mmutouyuguoinit commit
d0bea0d8创建于 2025年4月29日历史提交
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index f8f7ebbd445..49c15ef47a3 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -62,7 +62,7 @@ static void check_root(const char *progname);
 int
 main(int argc, char *argv[])
 {
-	bool		do_check_root = true;
+	bool		do_check_root = false;
 
 	/*
 	 * If supported on the current platform, set up a handler to be called if
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 429844fdd35..e7582e1ebb8 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -592,15 +592,6 @@ get_id(void)
 {
 	const char *username;
 
-#ifndef WIN32
-	if (geteuid() == 0)			/* 0 is root's uid */
-	{
-		pg_log_error("cannot be run as root");
-		pg_log_error_hint("Please log in (using, e.g., \"su\") as the (unprivileged) user that will own the server process.");
-		exit(1);
-	}
-#endif
-
 	username = get_user_name_or_exit(progname);
 
 	return pg_strdup(username);
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index dd78e5bc660..d2a37958808 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -2336,21 +2336,6 @@ main(int argc, char **argv)
 		}
 	}
 
-	/*
-	 * Disallow running as root, to forestall any possible security holes.
-	 */
-#ifndef WIN32
-	if (geteuid() == 0)
-	{
-		write_stderr(_("%s: cannot be run as root\n"
-					   "Please log in (using, e.g., \"su\") as the "
-					   "(unprivileged) user that will\n"
-					   "own the server process.\n"),
-					 progname);
-		exit(1);
-	}
-#endif
-
 	env_wait = getenv("PGCTLTIMEOUT");
 	if (env_wait != NULL)
 		wait_seconds = atoi(env_wait);