Gufw problems and solution

Hi all!

Gufw is a firewall program with a simple GUI.

If you are having problems starting gufw (like I did), here’s a workaround.
Replace the following two files with the code show below.
The fix applies to gufw version 20.04.1-3.

For me this seems to work, but a standard warning: do this at your own risk!

/usr/bin/gufw:

#!/bin/bash
Main() {
    local whoami="$(whoami)"
    if [ "$(loginctl show-session "$(loginctl|grep $whoami|sort -n|tail -n 1 |awk '{print $1}')" -p Type)" = "Type=wayland" ]
    then
        xhost +si:localuser:root
    fi
    pkexec gufw-pkexec $whoami
}
Main "$@"

/usr/bin/gufw-pkexec:

#!/bin/bash
LOCATIONS=`ls -ld /usr/lib/python*/site-packages/gufw/gufw.py | awk '{print $NF}'` # from source
LOCATIONS=( "${LOCATIONS[@]}" "/usr/share/gufw/gufw/gufw.py" )                    # deb package

for ((i = 0; i < ${#LOCATIONS[@]}; i++))
do
    if [[ -e "${LOCATIONS[${i}]}" ]]; then
        python3 ${LOCATIONS[${i}]} $1
    fi
done
3 Likes