You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2018/11/07 18:46:42 UTC
[couchdb] 01/01: Copy _security object in couchup; python3 fix
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 1604-couchup-security
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit cc2d4b9d3bf2606f1c7fe1ef309b94169cda97f2
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Wed Nov 7 13:46:21 2018 -0500
Copy _security object in couchup; python3 fix
---
rel/overlay/bin/couchup | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/rel/overlay/bin/couchup b/rel/overlay/bin/couchup
index 6532170..75b7d7e 100755
--- a/rel/overlay/bin/couchup
+++ b/rel/overlay/bin/couchup
@@ -172,6 +172,25 @@ def _put_filter(args, db=None):
print(exc.response.text)
exit(1)
+def _do_security(args, db=None):
+ """Copies the _security object from source to target DB."""
+ try:
+ req = requests.get(
+ 'http://127.0.0.1:{}/{}/_security'.format(
+ args['local_port'], db),
+ auth=args['creds'])
+ req.raise_for_status()
+ security_doc = _tojson(req)
+ req = requests.put(
+ 'http://127.0.0.1:{}/{}/_security'.format(
+ args['clustered_port'], db),
+ data=json.dumps(security_doc),
+ auth=args['creds'])
+ req.raise_for_status()
+ except requests.exceptions.HTTPError as exc:
+ print(exc.response.text)
+ exit(1)
+
def _replicate(args):
args = _args(args)
if args['all_dbs']:
@@ -229,6 +248,11 @@ def _replicate(args):
if req.get('no_changes'):
if not args['quiet']:
print("No changes, replication is caught up.")
+
+ if not args['quiet']:
+ print('Copying _security object for ' + db + '...')
+ _do_security(args, db)
+
if not args['quiet']:
print("Replication complete.")
@@ -474,7 +498,11 @@ def main(argv):
parser_delete.set_defaults(func=_delete)
args = parser.parse_args(argv[1:])
- args.func(args)
+ try:
+ args.func(args)
+ except AttributeError:
+ parser.print_help()
+ sys.exit(0)
if __name__ == '__main__':
main(sys.argv)