mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Complain if too many options are passed to pg_controldata or pg_resetxlog.
This commit is contained in:
parent
22b743b2ca
commit
2d53003432
@ -142,6 +142,16 @@ main(int argc, char *argv[])
|
||||
DataDir = getenv("PGDATA");
|
||||
}
|
||||
|
||||
/* Complain if any arguments remain */
|
||||
if (optind < argc)
|
||||
{
|
||||
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
|
||||
progname, argv[optind]);
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (DataDir == NULL)
|
||||
{
|
||||
fprintf(stderr, _("%s: no data directory specified\n"), progname);
|
||||
|
@ -237,14 +237,25 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (DataDir == NULL && optind == argc)
|
||||
if (DataDir == NULL && optind < argc)
|
||||
DataDir = argv[optind++];
|
||||
|
||||
/* Complain if any arguments remain */
|
||||
if (optind < argc)
|
||||
{
|
||||
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
|
||||
progname, argv[optind]);
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (DataDir == NULL)
|
||||
{
|
||||
fprintf(stderr, _("%s: no data directory specified\n"), progname);
|
||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||
exit(1);
|
||||
}
|
||||
if (DataDir == NULL)
|
||||
DataDir = argv[optind];
|
||||
|
||||
/*
|
||||
* Don't allow pg_resetxlog to be run as root, to avoid overwriting the
|
||||
|
Loading…
x
Reference in New Issue
Block a user