Skip to content

Commit a74d9a0

Browse files
timofey-barminjamesl33
authored andcommitted
MB-53547 [BP] Pass password to erlang in env
Change-Id: Ib08598ebe8f1fdf8238630c15f9499710ccb04bd Reviewed-on: http://review.couchbase.org/c/couchbase-cli/+/163420 Reviewed-by: James Lee <james.lee@couchbase.com> Tested-by: Build Bot <build@couchbase.com> Reviewed-on: https://review.couchbase.org/c/couchbase-cli/+/182194 Well-Formed: Restriction Checker Reviewed-by: Maksimiljans Januska <maks.januska@couchbase.com> Reviewed-by: Steve Watanabe <steve.watanabe@couchbase.com>
1 parent 87caeda commit a74d9a0

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

cbmgr.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,15 +1502,18 @@ def prompt_for_master_pwd(self, node, cookie, password, cb_cfg_path):
15021502
if password == '':
15031503
password = getpass.getpass("\nEnter master password:")
15041504

1505-
name = f'executioner@cb.local'
1506-
args = ['-pa', ns_server_ebin_path, babystr_ebin_path, '-noinput', '-name', name, \
1507-
'-proto_dist', 'cb', '-epmd_module', 'cb_epmd', \
1508-
'-kernel', 'inetrc', f'"{inetrc_file}"', 'dist_config_file', f'"{dist_cfg_file}"', \
1509-
'-setcookie', cookie, \
1510-
'-run', 'encryption_service', 'remote_set_password', node, password]
1511-
1512-
rc, out, err = self.run_process("erl", args)
1513-
1505+
args = [
1506+
'-pa', ns_server_ebin_path, babystr_ebin_path,
1507+
'-noinput',
1508+
'-name', 'executioner@cb.local',
1509+
'-proto_dist', 'cb',
1510+
'-epmd_module', 'cb_epmd',
1511+
'-kernel', 'inetrc', f'"{inetrc_file}"', 'dist_config_file', f'"{dist_cfg_file}"',
1512+
'-setcookie', cookie,
1513+
'-run', 'encryption_service', 'remote_set_password', node,
1514+
]
1515+
1516+
rc, out, err = self.run_process("erl", args, extra_env={'SETPASSWORD': password})
15141517
if rc == 0:
15151518
print("SUCCESS: Password accepted. Node started booting.")
15161519
elif rc == 101:
@@ -1525,13 +1528,17 @@ def prompt_for_master_pwd(self, node, cookie, password, cb_cfg_path):
15251528
else:
15261529
_exitIfErrors([f'Unknown error: {rc} {out}, {err}'])
15271530

1528-
def run_process(self, name, args):
1531+
def run_process(self, name, args, extra_env=None):
15291532
try:
15301533
if os.name == "nt":
15311534
name = name + ".exe"
15321535

1536+
env = None
1537+
if extra_env is not None:
1538+
env = os.environ.copy()
1539+
env.update(extra_env)
15331540
args.insert(0, name)
1534-
p = subprocess.Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
1541+
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
15351542
output = p.stdout.read()
15361543
error = p.stderr.read()
15371544
p.wait()

0 commit comments

Comments
 (0)