diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-11-21 04:16:17 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-11-21 04:16:17 +0000 |
commit | d8ba3dfb0b3385350d512fd6d56c83c244c98016 (patch) | |
tree | edc2b511d07e6f02c8f23b0b6faa561bebd7d1db /src/backend/commands/copy.c | |
parent | 76ccf73f2bd3c8af621c24fd3ebddcc2ff21d807 (diff) |
Change backend-side COPY to write files with permissions 644 not 666
(whoever thought world-writable files were a good default????). Modify
the pg_pwd code so that pg_pwd is created with 600 permissions. Modify
initdb so that permissions on a pre-existing PGDATA directory are not
blindly accepted: if the dir is already there, it does chmod go-rwx
to be sure that the permissions are OK and the dir actually is owned
by postgres.
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r-- | src/backend/commands/copy.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index ada751c37fa..cac94cebad2 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.89 1999/09/27 20:00:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.90 1999/11/21 04:16:17 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -214,12 +214,12 @@ CopyDonePeek(FILE *fp, int c, int pickup) /* - * DoCopy executes a the SQL COPY statement. + * DoCopy executes the SQL COPY statement. */ void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, - char *filename, char *delim) + char *filename, char *delim, int fileumask) { /*---------------------------------------------------------------------------- Either unload or reload contents of class <relname>, depending on <from>. @@ -234,6 +234,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, If in the text format, delimit columns with delimiter <delim>. + <fileumask> is the umask(2) setting to use while creating an output file. + This should usually be more liberal than the backend's normal 077 umask, + but not always (in particular, "pg_pwd" should be written with 077!). + Up through version 6.5, <fileumask> was always 000, which was foolhardy. + When loading in the text format from an input stream (as opposed to a file), recognize a "." on a line by itself as EOF. Also recognize a stream EOF. When unloading in the text format to an output stream, @@ -316,7 +321,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, { mode_t oumask; /* Pre-existing umask value */ - oumask = umask((mode_t) 0); + oumask = umask((mode_t) fileumask); #ifndef __CYGWIN32__ fp = AllocateFile(filename, "w"); #else |