File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 23
23
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
24
24
* Portions Copyright (c) 1994, Regents of the University of California
25
25
*
26
- * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.25 2004/11/17 21:37:47 tgl Exp $
26
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.26 2004/12/14 01:59:41 neilc Exp $
27
27
*
28
28
*-------------------------------------------------------------------------
29
29
*/
@@ -176,6 +176,25 @@ main(int argc, char *argv[])
176
176
exit (1 );
177
177
}
178
178
179
+ /*
180
+ * Don't allow pg_resetxlog to be run as root, to avoid
181
+ * overwriting the ownership of files in the data directory. We
182
+ * need only check for root -- any other user won't have
183
+ * sufficient permissions to modify files in the data directory.
184
+ */
185
+ #ifndef WIN32
186
+ #ifndef __BEOS__ /* no root check on BeOS */
187
+ if (geteuid () == 0 )
188
+ {
189
+ fprintf (stderr , _ ("%s: cannot be executed by \"root\"\n" ),
190
+ progname );
191
+ fprintf (stderr , _ ("You must run %s as the PostgreSQL superuser.\n" ),
192
+ progname );
193
+ exit (1 );
194
+ }
195
+ #endif
196
+ #endif
197
+
179
198
DataDir = argv [optind ];
180
199
snprintf (XLogDir , MAXPGPATH , "%s/pg_xlog" , DataDir );
181
200
snprintf (ControlFilePath , MAXPGPATH , "%s/global/pg_control" , DataDir );
You can’t perform that action at this time.
0 commit comments