ufw

Comment 19 for bug 2015645

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Note that autopkg tests for ufw test various aspects of normal ufw usage, including ufw enable. I also performed the testing for this issue on focal:

$ apt-cache policy ufw
ufw:
  Installed: 0.36-6ubuntu1
  Candidate: 0.36-6ubuntu1
  Version table:
 *** 0.36-6ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     0.36-6 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

# recreate the WSL2 scenario by having the parent shell contain 'Relay(NNN)'.
# This could be done various ways, but the easiest is to create a script named
# /tmp/Relay(230) to launch ufw:
$ cat <<EOM > "/tmp/Relay(230)"
#!/bin/bash
sudo ufw enable
EOM
$ chmod 755 "/tmp/Relay(230)"

# before the update
$ "/tmp/Relay(230)"
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/ufw/util.py", line 444, in under_ssh
    ppid = get_ppid(pid)
  File "/usr/lib/python3/dist-packages/ufw/util.py", line 434, in get_ppid
    ppid = open(name).readlines()[0].split(')')[1].split()[1]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/ufw", line 138, in <module>
    not ui.continue_under_ssh():
  File "/usr/lib/python3/dist-packages/ufw/frontend.py", line 900, in continue_under_ssh
    if self.backend.do_checks and ufw.util.under_ssh(): # pragma: no cover
  File "/usr/lib/python3/dist-packages/ufw/util.py", line 474, in under_ssh
    return under_ssh(ppid)
  File "/usr/lib/python3/dist-packages/ufw/util.py", line 474, in under_ssh
    return under_ssh(ppid)
  File "/usr/lib/python3/dist-packages/ufw/util.py", line 451, in under_ssh
    raise ValueError(err_msg)
ValueError: Couldn't find parent pid for '1782'

# after the update

$ cat <<EOF | sudo tee /etc/apt/sources.list.d/ubuntu-$(lsb_release -cs)-proposed.list
# Enable Ubuntu proposed archive
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-proposed restricted main multiverse universe
EOF
# Enable Ubuntu proposed archive
deb http://archive.ubuntu.com/ubuntu/ focal-proposed restricted main multiverse universe

$ sudo apt-get update && sudo apt-get install ufw/focal-proposed
...
Setting up ufw (0.36-6ubuntu1.1) ...

# it now doesn't traceback
$ "/tmp/Relay(230)"
Command may disrupt existing ssh connections. Proceed with operation (