Prevent repmgr/repmgrd running as root

This commit is contained in:
Ian Barwick
2016-02-22 14:58:17 +09:00
parent dc542a1b7d
commit 05b47cb2a8
3 changed files with 29 additions and 1 deletions

View File

@@ -142,6 +142,20 @@ main(int argc, char **argv)
set_progname(argv[0]);
/* Disallow running as root to prevent directory ownership problems */
if (geteuid() == 0)
{
fprintf(stderr,
_("%s: cannot be run as root\n"
"Please log in (using, e.g., \"su\") as the "
"(unprivileged) user that owns "
"the data directory.\n"
),
progname());
exit(1);
}
while ((c = getopt_long(argc, argv, "?Vf:vmdp:", long_options, &optindex)) != -1)
{
switch (c)