MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute

Method execute

keepercommander/commands/connect.py:510–547  ·  view source on GitHub ↗
(self, params, **kwargs)

Source from the content-addressed store, hash-verified

508 return rdp_parser
509
510 def execute(self, params, **kwargs):
511 record_name = kwargs.pop('record', None)
512 if not record_name:
513 ls = RecordListCommand()
514 return ls.execute(params, record_type=['serverCredentials'], verbose=True, **kwargs)
515
516 record = find_record(params, record_name, types=['serverCredentials'])
517
518 login = BaseConnectCommand.get_record_field(record, 'login')
519 if not login:
520 logging.warning('Record "%s" does not have user name.', record.title)
521 return
522
523 host = BaseConnectCommand.get_record_field(record, 'host')
524 if not host:
525 logging.warning('Record "%s" does not have host.', record.title)
526 return
527 host_name, _, port = host.partition(':')
528
529 password = BaseConnectCommand.get_record_field(record, 'password')
530 if password:
531 command = ['cmdkey', f'/generic:{host_name}', f'/user:{login}', f'/pass:{password}']
532 subprocess.run(command, stdout=subprocess.DEVNULL)
533 # os.system(f'cmdkey /generic:{host_name} /user:{login} /pass:{password} > NUL')
534
535 def clear_password():
536 subprocess.run(['cmdkey', f'/delete:{host_name}'], stdout=subprocess.DEVNULL)
537 # os.system(f'cmdkey /delete:{host_name} > NUL')
538 self.run_at_the_end.append(clear_password)
539
540 options = f'/v:{host_name}'
541 if port:
542 options += ':' + port
543 command = ['mstsc', options]
544 self.command = shlex.join(command)
545
546 logging.info('Connecting to "%s" ...', record.title)
547 self.execute_shell(record=record, stage='rdp')
548
549
550connect_command_description = '''

Callers

nothing calls this directly

Calls 8

executeMethod · 0.95
RecordListCommandClass · 0.85
find_recordFunction · 0.85
get_record_fieldMethod · 0.80
warningMethod · 0.80
execute_shellMethod · 0.80
runMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected