Skip to content

Commit 7a246e7

Browse files
authored
fix #2044 (#2045)
Specify the distro name when pop up a debugging window in wsl
1 parent c04dbdb commit 7a246e7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pwnlib/util/misc.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,14 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
340340
with open('/proc/sys/kernel/osrelease', 'rb') as f:
341341
is_wsl = b'icrosoft' in f.read()
342342
if is_wsl and which('cmd.exe') and which('wsl.exe') and which('bash.exe'):
343-
terminal = 'cmd.exe'
344-
args = ['/c', 'start', 'bash.exe', '-c']
343+
terminal = 'cmd.exe'
344+
args = ['/c', 'start']
345+
distro_name = os.getenv('WSL_DISTRO_NAME')
346+
if distro_name:
347+
args.extend(['wsl.exe', '-d', distro_name, 'bash', '-c'])
348+
else:
349+
args.extend(['bash.exe', '-c'])
350+
345351

346352
if not terminal:
347353
log.error('Could not find a terminal binary to use. Set context.terminal to your terminal.')

0 commit comments

Comments
 (0)