diff -Nru ufw-0.36.1/debian/changelog ufw-0.36.1/debian/changelog --- ufw-0.36.1/debian/changelog 2022-02-16 17:36:07.000000000 +0000 +++ ufw-0.36.1/debian/changelog 2023-07-17 13:55:25.000000000 +0000 @@ -1,3 +1,9 @@ +ufw (0.36.1-4ubuntu0.1) jammy; urgency=medium + + * 0005-lp2015645.patch: fix for LP: #2015645 (get_ppid() not working on WSL) + + -- Jamie Strandboge Mon, 17 Jul 2023 13:55:25 +0000 + ufw (0.36.1-4build1) jammy; urgency=medium * No-change rebuild to update maintainer scripts, see LP: 1959054 diff -Nru ufw-0.36.1/debian/patches/0005-lp2015645.patch ufw-0.36.1/debian/patches/0005-lp2015645.patch --- ufw-0.36.1/debian/patches/0005-lp2015645.patch 1970-01-01 00:00:00.000000000 +0000 +++ ufw-0.36.1/debian/patches/0005-lp2015645.patch 2023-07-17 13:55:25.000000000 +0000 @@ -0,0 +1,74 @@ +Origin: upstream, https://git.launchpad.net/ufw/commit/?id=55669b732255c224343605272b793ae3fd534557 +Author: Jamie Strandboge +Description: fix for LP: #2015645 (get_ppid() not working on WSL) +Bug-Ubuntu: https://bugs.launchpad.net/bugs/2015645 +diff --git a/src/util.py b/src/util.py +index b1b90b6..ac20c75 100644 +--- a/src/util.py ++++ b/src/util.py +@@ -1,6 +1,6 @@ + '''util.py: utility functions for ufw''' + # +-# Copyright 2008-2018 Canonical Ltd. ++# Copyright 2008-2023 Canonical Ltd. + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License version 3, +@@ -416,7 +416,9 @@ def get_ppid(mypid=os.getpid()): + # LP: #1101304 + # 9983 (cmd) S 923 ... + # 9983 (cmd with spaces) S 923 ... +- ppid = open(name).readlines()[0].split(')')[1].split()[1] ++ # LP: #2015645 ++ # 229 (cmd(withparen)) S 228 ... ++ ppid = open(name).readlines()[0].rsplit(")", 1)[1].split()[1] + + return int(ppid) + +diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py +index e1043ad..a83418e 100644 +--- a/tests/unit/test_util.py ++++ b/tests/unit/test_util.py +@@ -741,6 +741,42 @@ AAA + tests.unit.support.check_for_exception(self, IOError, \ + ufw.util.get_ppid, 0) + ++ def test_get_ppid_no_space(self): ++ """Test get_ppid() no space""" ++ if sys.version_info[0] < 3: ++ return tests.unit.support.skipped(self, "skipping with python2") ++ import unittest.mock ++ ++ m = unittest.mock.mock_open(read_data="9983 (cmd) S 923 9983 ...\n") ++ with unittest.mock.patch("builtins.open", m): ++ with unittest.mock.patch("os.path.isfile", return_value=True): ++ ppid = ufw.util.get_ppid(9983) ++ self.assertEquals(ppid, 923, "%d' != '923'" % ppid) ++ ++ def test_get_ppid_with_space(self): ++ """Test get_ppid() with space""" ++ if sys.version_info[0] < 3: ++ return tests.unit.support.skipped(self, "skipping with python2") ++ import unittest.mock ++ ++ m = unittest.mock.mock_open(read_data="9983 (cmd with space) S 923 9983 ...\n") ++ with unittest.mock.patch("builtins.open", m): ++ with unittest.mock.patch("os.path.isfile", return_value=True): ++ ppid = ufw.util.get_ppid(9983) ++ self.assertEquals(ppid, 923, "%d' != '923'" % ppid) ++ ++ def test_get_ppid_with_parens(self): ++ """Test get_ppid() with parens""" ++ if sys.version_info[0] < 3: ++ return tests.unit.support.skipped(self, "skipping with python2") ++ import unittest.mock ++ ++ m = unittest.mock.mock_open(read_data="9983 (cmd(paren)) S 923 9983 ...\n") ++ with unittest.mock.patch("builtins.open", m): ++ with unittest.mock.patch("os.path.isfile", return_value=True): ++ ppid = ufw.util.get_ppid(9983) ++ self.assertEquals(ppid, 923, "%d' != '923'" % ppid) ++ + def test_under_ssh(self): + '''Test under_ssh()''' + # this test could be running under ssh, so can't do anything more diff -Nru ufw-0.36.1/debian/patches/series ufw-0.36.1/debian/patches/series --- ufw-0.36.1/debian/patches/series 2021-10-13 19:02:20.000000000 +0000 +++ ufw-0.36.1/debian/patches/series 2023-07-17 13:55:25.000000000 +0000 @@ -2,3 +2,4 @@ 0002-fix-copyright.patch 0003-python3-versions.patch 0004-set-default-policy-after-load.patch +0005-lp2015645.patch