Skip to content

changes to agentwrapper to make it user LG_USERNAME #1641

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions labgrid/util/agentwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import logging

from .ssh import get_ssh_connect_timeout
from getpass import getuser

def get_user():
return os.environ.get("LG_USERNAME", getuser())

def b2s(b):
return base64.b85encode(b).decode('ascii')
Expand Down Expand Up @@ -47,6 +51,7 @@ def __init__(self, host=None):
os.path.abspath(os.path.dirname(__file__)),
'agent.py')
if host:
user = get_user()
# copy agent.py and run via ssh
with open(agent, 'rb') as agent_fd:
agent_data = agent_fd.read()
Expand All @@ -56,10 +61,10 @@ def __init__(self, host=None):
ssh_opts = f'ssh -x -o ConnectTimeout={connect_timeout} -o PasswordAuthentication=no'.split()
subprocess.check_call(
['rsync', '-e', ' '.join(ssh_opts), '-tq', agent,
f'{host}:{agent_remote}'],
f'{user}@{host}:{agent_remote}'],
)
self.agent = subprocess.Popen(
ssh_opts + [host, '--', 'python3', agent_remote],
ssh_opts + [f'{user}@{host}', '--', 'python3', agent_remote],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
start_new_session=True,
Expand Down