Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf487e3d

Browse files
committed
Check that the data directory does not have group or world access; remove
a similar check on postgresql.conf.
1 parent46e2521 commitf487e3d

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

‎src/backend/utils/init/miscinit.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.73 2001/07/03 16:49:48 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.74 2001/08/06 13:45:15 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -120,6 +120,7 @@ void
120120
SetDataDir(constchar*dir)
121121
{
122122
char*new;
123+
structstatstat_buf;
123124

124125
AssertArg(dir);
125126

@@ -162,6 +163,21 @@ SetDataDir(const char *dir)
162163
if (!new)
163164
elog(FATAL,"out of memory");
164165
}
166+
167+
/*
168+
* Check if the directory has group or world access. If so, reject.
169+
*/
170+
if (stat(new,&stat_buf)==-1)
171+
{
172+
free(new);
173+
elog(FATAL,"could not read permissions of directory %s: %s",new,strerror(errno));
174+
}
175+
176+
if (stat_buf.st_mode& (S_IRWXG |S_IRWXO))
177+
{
178+
free(new);
179+
elog(FATAL,"data directory %s has group or world access; permissions should be u=rwx (0700)",new);
180+
}
165181

166182
if (DataDir)
167183
free(DataDir);

‎src/backend/utils/misc/guc-file.l

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright 2000 by PostgreSQL Global Development Group
66
*
7-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.8 2001/06/07 04:50:57 momjian Exp $
7+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc-file.l,v 1.9 2001/08/06 13:45:15 petere Exp $
88
*/
99

1010
%{
@@ -130,7 +130,6 @@ ProcessConfigFile(GucContext context)
130130
int token, parse_state;
131131
char *opt_name, *opt_value;
132132
char *filename;
133-
struct stat stat_buf;
134133
struct name_value_pair *item, *head, *tail;
135134
int elevel;
136135
FILE * fp;
@@ -161,25 +160,6 @@ ProcessConfigFile(GucContext context)
161160
return;
162161
}
163162
164-
/*
165-
* Check if the file is group or world writeable. If so, reject.
166-
*/
167-
if (fstat(fileno(fp), &stat_buf) == -1)
168-
{
169-
FreeFile(fp);
170-
free(filename);
171-
elog(elevel,"couldnot stat configuration file `" CONFIG_FILENAME"': %s", strerror(errno));
172-
return;
173-
}
174-
175-
if (stat_buf.st_mode & (S_IWGRP | S_IXGRP | S_IWOTH | S_IXOTH))
176-
{
177-
FreeFile(fp);
178-
free(filename);
179-
elog(elevel, "configuration file `" CONFIG_FILENAME "' has wrong permissions");
180-
return;
181-
}
182-
183163
/*
184164
* Parse
185165
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp