-
-
Notifications
You must be signed in to change notification settings - Fork 266
Allow NetworkService to be used without an explicit SSH username
#1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -118,8 +118,10 @@ def _start_own_master_once(self, timeout): | |||||
| "-o", "ControlPersist=300", "-o", | ||||||
| "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no", | ||||||
| "-o", "ServerAliveInterval=15", "-MN", "-S", control.replace('%', '%%'), "-p", | ||||||
| str(self.networkservice.port), "-l", self._get_username(), | ||||||
| self.networkservice.address] | ||||||
| str(self.networkservice.port)] | ||||||
| if self._get_username(): | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| args += ["-l", self._get_username()] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| args += [self.networkservice.address] | ||||||
|
|
||||||
| # proxy via the exporter if we have an ifname suffix | ||||||
| address = self.networkservice.address | ||||||
|
|
@@ -214,9 +216,10 @@ def _run(self, cmd, codec="utf-8", decodeerrors="strict", timeout=None): | |||||
| raise ExecutionError("Keepalive no longer running") | ||||||
|
|
||||||
| complete_cmd = [self._ssh, "-x", *self.ssh_prefix, | ||||||
| "-p", str(self.networkservice.port), "-l", self._get_username(), | ||||||
| self.networkservice.address | ||||||
| ] + cmd.split(" ") | ||||||
| "-p", str(self.networkservice.port)] | ||||||
| if self._get_username(): | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||||||
| complete_cmd += ["-l", self._get_username()] | ||||||
| complete_cmd += [self.networkservice.address] + cmd.split(" ") | ||||||
| self.logger.debug("Sending command: %s", complete_cmd) | ||||||
| if self.stderr_merge: | ||||||
| stderr_pipe = subprocess.STDOUT | ||||||
|
|
@@ -482,14 +485,18 @@ def _scp_supports_explicit_scp_mode(self): | |||||
| @Driver.check_active | ||||||
| @step(args=['filename', 'remotepath']) | ||||||
| def put(self, filename, remotepath=''): | ||||||
| destination = f"{self.networkservice.address}:{remotepath}" | ||||||
| if self._get_username(): | ||||||
| destination = f"{self._get_username()}@{destination}" | ||||||
|
|
||||||
| transfer_cmd = [ | ||||||
| self._scp, | ||||||
| "-S", self._ssh, | ||||||
| *self.ssh_prefix, | ||||||
| "-P", str(self.networkservice.port), | ||||||
| "-r", | ||||||
| filename, | ||||||
| f"{self._get_username()}@{self.networkservice.address}:{remotepath}" | ||||||
| destination | ||||||
| ] | ||||||
|
|
||||||
| if self.explicit_sftp_mode and self._scp_supports_explicit_sftp_mode(): | ||||||
|
|
@@ -513,13 +520,17 @@ def put(self, filename, remotepath=''): | |||||
| @Driver.check_active | ||||||
| @step(args=['filename', 'destination']) | ||||||
| def get(self, filename, destination="."): | ||||||
| source = f"{self.networkservice.address}:{filename}" | ||||||
| if self._get_username(): | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||||||
| source = f"{self._get_username()}@{source}" | ||||||
|
|
||||||
| transfer_cmd = [ | ||||||
| self._scp, | ||||||
| "-S", self._ssh, | ||||||
| *self.ssh_prefix, | ||||||
| "-P", str(self.networkservice.port), | ||||||
| "-r", | ||||||
| f"{self._get_username()}@{self.networkservice.address}:{filename}", | ||||||
| source, | ||||||
| destination | ||||||
| ] | ||||||
|
|
||||||
|
|
@@ -543,7 +554,10 @@ def get(self, filename, destination="."): | |||||
|
|
||||||
| def _cleanup_own_master(self): | ||||||
| """Exit the controlmaster and delete the tmpdir""" | ||||||
| complete_cmd = f"{self._ssh} -x -o ControlPath={self.control.replace('%', '%%')} -O exit -p {self.networkservice.port} -l {self._get_username()} {self.networkservice.address}".split(' ') # pylint: disable=line-too-long | ||||||
| complete_cmd = [self._ssh, "-x", "-o", f"ControlPath={self.control.replace('%', '%%')}", "-O", "exit", "-p", str(self.networkservice.port)] # pylint: disable=line-too-long | ||||||
| if self._get_username(): | ||||||
| complete_cmd += ["-l", self._get_username()] | ||||||
| complete_cmd += [self.networkservice.address] | ||||||
| res = subprocess.call( | ||||||
| complete_cmd, | ||||||
| stdin=subprocess.DEVNULL, | ||||||
|
|
@@ -560,7 +574,10 @@ def _cleanup_own_master(self): | |||||
|
|
||||||
| def _start_keepalive(self): | ||||||
| """Starts a keepalive connection via the own or external master.""" | ||||||
| args = [self._ssh, *self.ssh_prefix, self.networkservice.address, "cat"] | ||||||
| args = [self._ssh, *self.ssh_prefix] | ||||||
| if self._get_username(): | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||||||
| args += ["-l", self._get_username()] | ||||||
| args += [self.networkservice.address, "cat"] | ||||||
|
|
||||||
| assert self._keepalive is None | ||||||
| self._keepalive = subprocess.Popen( | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default should be
None, not the empty string.