Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit00be754

Browse files
committed
Split apart pg_upgrade user lookup and root check so '--help' shows
proper default username.
1 parentadd8044 commit00be754

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎contrib/pg_upgrade/option.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
4848
};
4949
charoption;/* Command line option */
5050
intoptindex=0;/* used by getopt_long */
51-
51+
intuser_id;
52+
5253
if (getenv("PGUSER"))
5354
{
5455
pg_free(ctx->user);
@@ -62,6 +63,9 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
6263

6364
ctx->transfer_mode=TRANSFER_MODE_COPY;
6465

66+
/* user lookup and 'root' test must be split because of usage() */
67+
user_id=get_user_info(ctx,&ctx->user);
68+
6569
if (argc>1)
6670
{
6771
if (strcmp(argv[1],"--help")==0||strcmp(argv[1],"-h")==0||
@@ -77,7 +81,7 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
7781
}
7882
}
7983

80-
if ((get_user_info(ctx,&ctx->user))==0)
84+
if (user_id==0)
8185
pg_log(ctx,PG_FATAL,"%s: cannot be run as root\n",ctx->progname);
8286

8387
#ifndefWIN32

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp