Commit 2d530034 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Complain if too many options are passed to pg_controldata or pg_resetxlog.

parent 22b743b2
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment