gustavo-iniguez-goya / opensnitch

OpenSnitch is a GNU/Linux application firewall
GNU General Public License v3.0
394 stars 20 forks source link

Does not work anymore on Arch after python 3.9 upgrade #98

Closed squalou closed 3 years ago

squalou commented 3 years ago

Hi,

Describe the bug

Maybe you've noticed it yourself, anyway : Arch has updated python to 3.9.

As a result, as it sometimes happens, a dependency broke, and UI does not work. See error below

To Reproduce

opensnitch-ui

ImportError: /usr/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-x86_64-linux-gnu.so: undefined symbol: RunningOnValgrind 

I made sure to reinstall grpcio and grpcio-tools (but the package itself is marked deprecated on arch, maybe next will fix things ?)

Also, rebuilsing the package fails :

~/.cache/yay/opensnitch-git/src/opensnitch
~/.cache/yay/opensnitch-git/src/opensnitch/proto ~/.cache/yay/opensnitch-git/src/opensnitch
python3 -m grpc_tools.protoc -I. --python_out=../ui/opensnitch/ --grpc_python_out=../ui/opensnitch/ ui.proto
/usr/bin/python3: Error while finding module specification for 'grpc_tools.protoc' (ModuleNotFoundError: No module named 'grpc_tools')
make: *** [Makefile:7: ../ui/ui_pb2.py] Error 1
==> ERROR: A failure occurred in build().
    Aborting...
error making: opensnitch-git

OS (please complete the following information):

Additional context Add any other context about the problem here.

squalou commented 3 years ago

UPDATE

I manually updated grpcio-tools from 1.33-2 to 1.34

gustavo-iniguez-goya commented 3 years ago

_cython/cygrpc.cpython-39-x86_64-linux-gnu.so: undefined symbol: RunningOnValgrind

It looks like you have a broken dependency somewhere. Execute ldd /usr/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-x86_64-linux-gnu.so and check that all the libs dynamically linked are properly installed.

I'm using the GUI with python3.9 and works fine, grpcio 1.30.2, grpcio-tools 1.14.1.

squalou commented 3 years ago

here's the output. It's good to hear you can run with 3.9 ... but then the problem is well hidden, gonna be fun to track it :)

$ ldd /usr/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-x86_64-linux-gnu.so
    linux-vdso.so.1 (0x00007fff59309000)
    libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x00007f48a6383000)
    libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007f48a60a5000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007f48a608b000)
    libcares.so.2 => /usr/lib/libcares.so.2 (0x00007f48a6072000)
    libre2.so.8 => /usr/lib/libre2.so.8 (0x00007f48a6009000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f48a5fe7000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f48a5e08000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f48a5cc2000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f48a5af9000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f48a6883000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f48a5af3000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f48a5ad9000)

sent too quickly sorry

(typo in previsous edit : all files are there)

squalou commented 3 years ago

If I want to run the ui from source (so that I can play with a local virtualenv and any local python installation), how would I do this ?

I created a virtualenv, actovated it, installed deps ... but now I don't know how to properly run local opensnitch-ui (the one from bin complains ModuleNotFoundError: No module named 'opensnitch' )

Thah's a fairly usual python newbe error and I must admit I don't remember how to solve this.

squalou commented 3 years ago

(edit again : moved from bin/ to one level up, worked from there, ugly workaroud but starts)

gustavo-iniguez-goya commented 3 years ago

I would uninstall any reference to grpcio libs, well installed via pacman well installed via pip: locate grpc|less

pip3 uninstall grpcio, etc..

I've also upgraded to grpcio-1.34.0 and works as expected.

If you have other versions of python, you can copy opensnitch package to /usr/lib/python3.Y/site-packages/ and change /usr/bin/opensnitch shebang to #!/usr/bin/python3.Y

squalou commented 3 years ago

Quick test

=> closing, the issue is somewhere on my system !

thanks for your help

user747 commented 3 years ago

noticed this on my Arch today as well after updating. i know not much help lol, but just wanting to confirm issue is not isolated to one user. ill try some of the suggestions above and see.

opensnitch-ui 
Traceback (most recent call last):
  File "/usr/bin/opensnitch-ui", line 16, in <module>
    import grpc
  File "/usr/lib/python3.9/site-packages/grpc/__init__.py", line 23, in <module>
    from grpc._cython import cygrpc as _cygrpc
ImportError: /usr/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-x86_64-linux-gnu.so: undefined symbol: RunningOnValgrind
ldd /usr/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-x86_64-linux-gnu.so
    linux-vdso.so.1 (0x00007ffe3f7f5000)
    libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x00007f297469e000)
    libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007f29743c0000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007f29743a6000)
    libcares.so.2 => /usr/lib/libcares.so.2 (0x00007f297438d000)
    libre2.so.8 => /usr/lib/libre2.so.8 (0x00007f2974324000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f2974302000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f2974123000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f2973fdd000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f2973e14000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f2974b90000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f2973e0e000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f2973df4000)
gustavo-iniguez-goya commented 3 years ago

Thank you @user747 , can you create a file user747.py and execute it, with this content?

#!/usr/bin/python3

import grpc

print("grpc")

It should output the same error.

squalou commented 3 years ago

exact same error indeed.

I opened his : https://bbs.archlinux.org/viewtopic.php?pid=1941639#p1941639

What I did as an ugly fix :

Ugly workaround but easier to deal with that virtualenv things

user747 commented 3 years ago

yup same error. so this is likely upstream issue ?

squalou commented 3 years ago

for the records : package is fixed on arch :-) -python-grpcio 1.34.0-3

binarytrails commented 3 years ago

same issue here with 1.34.0-3

mr tmp $ pacman -Si python-grpcio
Repository      : community
Name            : python-grpcio
Version         : 1.34.0-3
...
mr tmp $ cat test.py
#!/usr/bin/python3

import grpc

print("grpc")
mr tmp $ python /tmp/test.py
grpc
mr tmp $ python --version
Python 3.9.0
mr tmp $ pacman -Qi opensnitch-git
Name            : opensnitch-git
Version         : 1.3.0.rc.1.r0.cdea3b5-1
...
mr tmp $ opensnitch-ui 
Traceback (most recent call last):
  File "/bin/opensnitch-ui", line 22, in <module>
    from opensnitch.service import UIService
ModuleNotFoundError: No module named 'opensnitch'
binarytrails commented 3 years ago

My solution as downgrading python is an incredible pain since it break pip etc. is to fallback to another aur package:

==> Making package: opensnitch 1.3.0_rc2-1 (Tue 08 Dec 2020 02:11:50 PM EST)
...
Packages (2) opensnitch-git-1.3.0.rc.1.r0.cdea3b5-1 [removal]  opensnitch-1.3.0_rc2-1
....
$ pacman -Qi opensnitch
Name            : opensnitch
Version         : 1.3.0_rc2-1

then, it works: new node connected, listening for client responses... /tmp/osui.sock