public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: Murtuza Zabuawala <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgadmin4][Patch]: RM #3122 - Backup not working on certificate (SSL) protected servers
Date: Wed, 14 Mar 2018 20:25:37 +0530
Message-ID: <CAFOhELezjboyr3SHAdazh1mmcTmNhH8XA6nig97CVpjCuNvEMw@mail.gmail.com> (raw)
In-Reply-To: <CAFOhELcXj-XwwdNz33c5jF8u1AL70hTbEVquTHcc6g-kXcgtHg@mail.gmail.com>
References: <CAFOhELd49WZXE1DRNJuSo-Xfkvg7kXf7JUuAcNti=7BbO3sCwQ@mail.gmail.com>
<CAKKotZTm9+oH_mqkXviidB0-kUfRfXzM90Se0ymjyekdQdfzHQ@mail.gmail.com>
<CAKKotZT5R4knox3zH0E5A5gMn6TZ7qSR=c2-a1Qqc8cdj7+2Gg@mail.gmail.com>
<CAFOhELcXj-XwwdNz33c5jF8u1AL70hTbEVquTHcc6g-kXcgtHg@mail.gmail.com>
Hi,
Please find the attached updated patch.
Thanks,
Khushboo
On Wed, Mar 14, 2018 at 1:07 PM, Khushboo Vashi <
[email protected]> wrote:
>
>
> On Wed, Mar 14, 2018 at 12:48 PM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> ../pgadmin4/web/pgadmin/tools/import_export/__init__.py +310 without
>> your patch applied.
>>
>> Yes, good point. Will update and send the patch.
>
>>
>> On Wed, Mar 14, 2018 at 12:39 PM, Murtuza Zabuawala <
>> [email protected]> wrote:
>>
>>> Hi Khushboo,
>>>
>>> We can simplify this, we don't need to create any extra column,
>>>
>>> Check: ../pgadmin4/web/pgadmin/tools/import_export/__init__.py +322
>>> where we are setting ENV variable we can create common utility function
>>> (let say in ../tools/utils/__init__.py) which will set all required the
>>> environment variables and then we will pass that function in p.start(..)
>>> method.
>>>
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>>> On Wed, Mar 14, 2018 at 11:03 AM, Khushboo Vashi <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find the attached patch to fix RM #3122 : Backup not working on
>>>> certificate (SSL) protected servers.
>>>>
>>>> The attached patch fixes the issue in the following modules:
>>>>
>>>> 1. Backup
>>>> 2. Restore
>>>> 3. Import/Export
>>>> 4. Maintenance
>>>>
>>>> Thanks,
>>>> Khushboo
>>>>
>>>>
>>>>
>>>
>>
>
Attachments:
[text/x-patch] RM_3122_ver1.patch (4.6K, 3-RM_3122_ver1.patch)
download | inline diff:
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index c456b4f..cefb51a 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -19,7 +19,8 @@ from datetime import datetime
from pickle import dumps, loads
from subprocess import Popen
-from pgadmin.utils import IS_PY2, u, file_quote, fs_encoding
+from pgadmin.utils import IS_PY2, u, file_quote, fs_encoding, \
+ get_complete_file_path
import pytz
from dateutil import parser
@@ -62,6 +63,7 @@ class BatchProcess(object):
self.id = self.desc = self.cmd = self.args = self.log_dir = \
self.stdout = self.stderr = self.stime = self.etime = \
self.ecode = None
+ self.env = dict()
if 'id' in kwargs:
self._retrieve_process(kwargs['id'])
@@ -330,6 +332,9 @@ class BatchProcess(object):
env['OUTDIR'] = self.log_dir
env['PGA_BGP_FOREGROUND'] = "1"
+ if self.env:
+ env.update(self.env)
+
if cb is not None:
cb(env)
@@ -622,3 +627,18 @@ class BatchProcess(object):
p.acknowledge = get_current_time()
db.session.commit()
+
+ def set_env_variables(self, server, **kwargs):
+ """Set environment variables"""
+ if server and server.sslcert is not None and \
+ server.sslkey is not None and \
+ server.sslrootcert is not None:
+ # SSL environment variables
+ self.env['PGSSLMODE'] = server.ssl_mode
+ self.env['PGSSLCERT'] = get_complete_file_path(server.sslcert)
+ self.env['PGSSLKEY'] = get_complete_file_path(server.sslkey)
+ self.env['PGSSLROOTCERT'] = \
+ get_complete_file_path(server.sslrootcert)
+
+ if 'env' in kwargs:
+ self.env.update(kwargs['env'])
diff --git a/web/pgadmin/tools/backup/__init__.py b/web/pgadmin/tools/backup/__init__.py
index 940ef5b..8936e53 100644
--- a/web/pgadmin/tools/backup/__init__.py
+++ b/web/pgadmin/tools/backup/__init__.py
@@ -300,6 +300,7 @@ def create_backup_job(sid):
'--database',
server.maintenance_db
]
+
if 'role' in data and data['role']:
args.append('--role')
args.append(data['role'])
@@ -323,6 +324,7 @@ def create_backup_job(sid):
cmd=utility, args=args
)
manager.export_password_env(p.id)
+ p.set_env_variables(server)
p.start()
jid = p.id
except Exception as e:
@@ -486,6 +488,7 @@ def create_backup_objects_job(sid):
cmd=utility, args=args
)
manager.export_password_env(p.id)
+ p.set_env_variables(server)
p.start()
jid = p.id
except Exception as e:
diff --git a/web/pgadmin/tools/import_export/__init__.py b/web/pgadmin/tools/import_export/__init__.py
index 3f83fd4..9690475 100644
--- a/web/pgadmin/tools/import_export/__init__.py
+++ b/web/pgadmin/tools/import_export/__init__.py
@@ -307,13 +307,13 @@ def create_import_export_job(sid):
)
manager.export_password_env(p.id)
- def export_pg_env(env):
- env['PGHOST'] = server.host
- env['PGPORT'] = str(server.port)
- env['PGUSER'] = server.username
- env['PGDATABASE'] = data['database']
-
- p.start(export_pg_env)
+ env = dict()
+ env['PGHOST'] = server.host
+ env['PGPORT'] = str(server.port)
+ env['PGUSER'] = server.username
+ env['PGDATABASE'] = data['database']
+ p.set_env_variables(server, env=env)
+ p.start()
jid = p.id
except Exception as e:
current_app.logger.exception(e)
diff --git a/web/pgadmin/tools/maintenance/__init__.py b/web/pgadmin/tools/maintenance/__init__.py
index 8416a20..088922b 100644
--- a/web/pgadmin/tools/maintenance/__init__.py
+++ b/web/pgadmin/tools/maintenance/__init__.py
@@ -236,6 +236,7 @@ def create_maintenance_job(sid, did):
cmd=utility, args=args
)
manager.export_password_env(p.id)
+ p.set_env_variables(server)
p.start()
jid = p.id
except Exception as e:
diff --git a/web/pgadmin/tools/restore/__init__.py b/web/pgadmin/tools/restore/__init__.py
index 6afa7b4..db1d522 100644
--- a/web/pgadmin/tools/restore/__init__.py
+++ b/web/pgadmin/tools/restore/__init__.py
@@ -329,6 +329,7 @@ def create_restore_job(sid):
cmd=utility, args=args
)
manager.export_password_env(p.id)
+ p.set_env_variables(server)
p.start()
jid = p.id
except Exception as e:
view thread (8+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgadmin4][Patch]: RM #3122 - Backup not working on certificate (SSL) protected servers
In-Reply-To: <CAFOhELezjboyr3SHAdazh1mmcTmNhH8XA6nig97CVpjCuNvEMw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox