pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refactor dir/file permissions
Date: Sat, 07 Apr 2018 21:46:20 +0000
Message-ID: <E1f4vfA-0006cB-2l@gemulon.postgresql.org> (raw)

Refactor dir/file permissions

Consolidate directory and file create permissions for tools which work
with the PG data directory by adding a new module (common/file_perm.c)
that contains variables (pg_file_create_mode, pg_dir_create_mode) and
constants to initialize them (0600 for files and 0700 for directories).

Convert mkdir() calls in the backend to MakePGDirectory() if the
original call used default permissions (always the case for regular PG
directories).

Add tests to make sure permissions in PGDATA are set correctly by the
tools which modify the PG data directory.

Authors: David Steele <david@pgmasters.net>,
         Adam Brightwell <adam.brightwell@crunchydata.com>
Reviewed-By: Michael Paquier, with discussion amongst many others.
Discussion: https://postgr.es/m/ad346fe6-b23e-59f1-ecb7-0e08390ad629%40pgmasters.net

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/da9b580d89903fee871cf54845ffa2b26bda2e11

Modified Files
--------------
src/backend/access/transam/xlog.c            |  2 +-
src/backend/commands/tablespace.c            | 18 ++++---
src/backend/postmaster/postmaster.c          |  7 +--
src/backend/postmaster/syslogger.c           |  5 +-
src/backend/replication/basebackup.c         |  5 +-
src/backend/replication/slot.c               |  5 +-
src/backend/storage/file/copydir.c           |  2 +-
src/backend/storage/file/fd.c                | 51 +++++++++++++------
src/backend/storage/ipc/dsm_impl.c           |  3 +-
src/backend/storage/ipc/ipc.c                |  4 ++
src/backend/utils/init/miscinit.c            |  5 +-
src/bin/initdb/initdb.c                      | 24 ++++-----
src/bin/initdb/t/001_initdb.pl               | 11 ++++-
src/bin/pg_basebackup/pg_basebackup.c        |  9 ++--
src/bin/pg_basebackup/t/010_pg_basebackup.pl | 14 +++++-
src/bin/pg_basebackup/t/020_pg_receivewal.pl | 14 +++++-
src/bin/pg_basebackup/walmethods.c           |  6 ++-
src/bin/pg_ctl/pg_ctl.c                      |  4 +-
src/bin/pg_ctl/t/001_start_stop.pl           | 18 ++++++-
src/bin/pg_resetwal/pg_resetwal.c            |  5 +-
src/bin/pg_resetwal/t/001_basic.pl           | 12 ++++-
src/bin/pg_rewind/RewindTest.pm              |  4 ++
src/bin/pg_rewind/file_ops.c                 |  7 +--
src/bin/pg_rewind/t/001_basic.pl             | 11 ++++-
src/bin/pg_upgrade/file.c                    |  5 +-
src/bin/pg_upgrade/pg_upgrade.c              |  3 +-
src/bin/pg_upgrade/test.sh                   | 11 +++++
src/common/Makefile                          |  4 +-
src/common/file_perm.c                       | 19 ++++++++
src/include/common/file_perm.h               | 34 +++++++++++++
src/include/storage/fd.h                     |  3 ++
src/test/perl/PostgresNode.pm                |  3 ++
src/test/perl/TestLib.pm                     | 73 ++++++++++++++++++++++++++++
src/tools/msvc/Mkvcbuild.pm                  |  4 +-
34 files changed, 330 insertions(+), 75 deletions(-)



Message-ID: <E1f4vfA-0006cB-2l@gemulon.postgresql.org>
Permalink:  ../E1f4vfA-0006cB-2l@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1f4vfA-0006cB-2l@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: sfrost@snowman.net
  Subject: Re: pgsql: Refactor dir/file permissions
  In-Reply-To: <E1f4vfA-0006cB-2l@gemulon.postgresql.org>
  References: <E1f4vfA-0006cB-2l@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox