We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentadd8044 commit00be754Copy full SHA for 00be754
contrib/pg_upgrade/option.c
@@ -48,7 +48,8 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
48
};
49
charoption;/* Command line option */
50
intoptindex=0;/* used by getopt_long */
51
-
+intuser_id;
52
+
53
if (getenv("PGUSER"))
54
{
55
pg_free(ctx->user);
@@ -62,6 +63,9 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
62
63
64
ctx->transfer_mode=TRANSFER_MODE_COPY;
65
66
+/* user lookup and 'root' test must be split because of usage() */
67
+user_id=get_user_info(ctx,&ctx->user);
68
69
if (argc>1)
70
71
if (strcmp(argv[1],"--help")==0||strcmp(argv[1],"-h")==0||
@@ -77,7 +81,7 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
77
81
}
78
82
79
83
80
-if ((get_user_info(ctx,&ctx->user))==0)
84
+if (user_id==0)
85
pg_log(ctx,PG_FATAL,"%s: cannot be run as root\n",ctx->progname);
86
87
#ifndefWIN32