git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: add8044)
Split apart pg_upgrade user lookup and root check so '--help' shows
2010年5月24日 16:34:35 +0000 (16:34 +0000)
2010年5月24日 16:34:35 +0000 (16:34 +0000)
proper default username.


diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
index 4d97da05aba693f264457a6d1e6d2aa5ff7bc46f..83e0ea6c151af337c1a26bf58d9d53740fd9342e 100644 (file)
--- a/contrib/pg_upgrade/option.c
+++ b/contrib/pg_upgrade/option.c
@@ -48,7 +48,8 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
};
char option; /* Command line option */
int optindex = 0; /* used by getopt_long */
-
+ int user_id;
+
if (getenv("PGUSER"))
{
pg_free(ctx->user);
@@ -62,6 +63,9 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
ctx->transfer_mode = TRANSFER_MODE_COPY;
+ /* user lookup and 'root' test must be split because of usage() */
+ user_id = get_user_info(ctx, &ctx->user);
+
if (argc > 1)
{
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
@@ -77,7 +81,7 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
}
}
- if ((get_user_info(ctx, &ctx->user)) == 0)
+ if (user_id == 0)
pg_log(ctx, PG_FATAL, "%s: cannot be run as root\n", ctx->progname);
#ifndef WIN32
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /