mirror of
https://github.com/beard7n/bsdports.git
synced 2026-04-10 02:21:15 +02:00
105 lines
3.6 KiB
Diff
105 lines
3.6 KiB
Diff
--- a/src/bin/pg_basebackup/pg_receivewal.c
|
|
+++ src/bin/pg_basebackup/pg_receivewal.c
|
|
@@ -91,6 +91,7 @@ usage(void)
|
|
printf(_(" -d, --dbname=CONNSTR connection string\n"));
|
|
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
|
|
printf(_(" -p, --port=PORT database server port number\n"));
|
|
+ printf(_(" -u, --umask set files mode according to umask (might breaks security!)\n"));
|
|
printf(_(" -U, --username=NAME connect as specified database user\n"));
|
|
printf(_(" -w, --no-password never prompt for password\n"));
|
|
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
|
|
@@ -461,6 +462,7 @@ main(int argc, char **argv)
|
|
{"dbname", required_argument, NULL, 'd'},
|
|
{"host", required_argument, NULL, 'h'},
|
|
{"port", required_argument, NULL, 'p'},
|
|
+ {"umask", no_argument, NULL, 'u'},
|
|
{"username", required_argument, NULL, 'U'},
|
|
{"no-loop", no_argument, NULL, 'n'},
|
|
{"no-password", no_argument, NULL, 'w'},
|
|
@@ -522,6 +524,9 @@ main(int argc, char **argv)
|
|
}
|
|
dbport = pg_strdup(optarg);
|
|
break;
|
|
+ case 'u':
|
|
+ useumask = 1;
|
|
+ break;
|
|
case 'U':
|
|
dbuser = pg_strdup(optarg);
|
|
break;
|
|
--- a/src/bin/pg_basebackup/pg_recvlogical.c
|
|
+++ src/bin/pg_basebackup/pg_recvlogical.c
|
|
@@ -335,11 +335,14 @@ StreamLogicalLog(void)
|
|
{
|
|
struct stat statbuf;
|
|
|
|
+ mode_t mode = (useumask == 1) ?
|
|
+ (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) : (S_IRUSR | S_IWUSR);
|
|
+
|
|
if (strcmp(outfile, "-") == 0)
|
|
outfd = fileno(stdout);
|
|
else
|
|
outfd = open(outfile, O_CREAT | O_APPEND | O_WRONLY | PG_BINARY,
|
|
- S_IRUSR | S_IWUSR);
|
|
+ mode);
|
|
if (outfd == -1)
|
|
{
|
|
fprintf(stderr,
|
|
--- a/src/bin/pg_basebackup/streamutil.c
|
|
+++ src/bin/pg_basebackup/streamutil.c
|
|
@@ -38,6 +38,7 @@ char *dbhost = NULL;
|
|
char *dbuser = NULL;
|
|
char *dbport = NULL;
|
|
char *dbname = NULL;
|
|
+int useumask = 0; /* 0=auto, -1=never, 1=always */
|
|
int dbgetpassword = 0; /* 0=auto, -1=never, 1=always */
|
|
static bool have_password = false;
|
|
static char password[100];
|
|
--- a/src/bin/pg_basebackup/streamutil.h
|
|
+++ src/bin/pg_basebackup/streamutil.h
|
|
@@ -23,6 +23,7 @@ extern char *dbhost;
|
|
extern char *dbuser;
|
|
extern char *dbport;
|
|
extern char *dbname;
|
|
+extern int useumask;
|
|
extern int dbgetpassword;
|
|
|
|
/* Connection kept global so we can disconnect easily */
|
|
--- a/src/bin/pg_basebackup/walmethods.c
|
|
+++ src/bin/pg_basebackup/walmethods.c
|
|
@@ -77,6 +77,8 @@ dir_open_for_write(const char *pathname,
|
|
#ifdef HAVE_LIBZ
|
|
gzFile gzfp = NULL;
|
|
#endif
|
|
+ mode_t mode = (useumask == 1) ?
|
|
+ (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) : (S_IRUSR | S_IWUSR);
|
|
|
|
snprintf(tmppath, sizeof(tmppath), "%s/%s%s%s",
|
|
dir_data->basedir, pathname,
|
|
@@ -89,7 +91,7 @@ dir_open_for_write(const char *pathname,
|
|
* does not do any system calls to fsync() to make changes permanent on
|
|
* disk.
|
|
*/
|
|
- fd = open(tmppath, O_WRONLY | O_CREAT | PG_BINARY, S_IRUSR | S_IWUSR);
|
|
+ fd = open(tmppath, O_WRONLY | O_CREAT | PG_BINARY, mode);
|
|
if (fd < 0)
|
|
return NULL;
|
|
|
|
@@ -525,6 +527,8 @@ tar_open_for_write(const char *pathname,
|
|
{
|
|
int save_errno;
|
|
static char tmppath[MAXPGPATH];
|
|
+ mode_t mode = (useumask == 1) ?
|
|
+ (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) : (S_IRUSR | S_IWUSR);
|
|
|
|
tar_clear_error();
|
|
|
|
@@ -534,7 +538,7 @@ tar_open_for_write(const char *pathname,
|
|
* We open the tar file only when we first try to write to it.
|
|
*/
|
|
tar_data->fd = open(tar_data->tarfilename,
|
|
- O_WRONLY | O_CREAT | PG_BINARY, S_IRUSR | S_IWUSR);
|
|
+ O_WRONLY | O_CREAT | PG_BINARY, mode);
|
|
if (tar_data->fd < 0)
|
|
return NULL;
|
|
|