Tom Lane writes:
> Um. Okay then, the alternatives are
>
> (1) move the handling of --version out of PostgresMain and friends, and
> put it into main.c before the are-we-root check;
>
> (2) move the are-we-root check out of main.c and duplicate it in
> PostgresMain and friends.
>
> Which choice do you like best?
Let them meet in the middle. ;-) If the option is --version or --help,
ignore the root test.
I would have opted for (1), but it would be nice to be able to see the
help as root, too, and I don't want to move that.
diff -U2 -r1.40 main.c
--- main.c 2001/01/24 19:42:56 1.40
+++ main.c 2001/02/05 20:58:50
@@ -110,5 +110,8 @@
*/
#ifndef __BEOS__
- if (geteuid() == 0)
+ if (!(argc > 1
+ && ( strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0
+ || strcmp(argv[1], "--version")==0 || strcmp(argv[1], "-V")==0 ))
+ && (geteuid() == 0) )
{
fprintf(stderr, "%s", NOROOTEXEC);
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/