Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory: '/etc/services' #671

Closed
gssantana opened this issue Jun 21, 2022 · 3 comments
Closed

No such file or directory: '/etc/services' #671

gssantana opened this issue Jun 21, 2022 · 3 comments

Comments

@gssantana
Copy link

Describe the bug

Include the following information:

  • OpenSnitch version. v1.6.0-rc.1
  • OS: openSUSE Tumbleweed 20220607
  • Version openSUSE Tumbleweed 20220607
  • Window Manager: GNOME Shell
  • Kernel version: Linux brain 5.18.1-1-default TypeError: pkt_callback() takes exactly 2 arguments (3 given) #1 SMP PREEMPT_DYNAMIC Mon May 30 07:49:01 UTC 2022 (d00e88d) x86_64 x86_64 x86_64 GNU/Linux

To Reproduce

After install opensnitch server and gui v1.6.0-rc.1, when I try to open opensnitch-ui, I get the error No such file or directory: '/etc/services'

Post error logs:

Themes not available. Install qt-material if you want to change GUI's appearance: pip3 install qt-material.
Loading translations: /usr/lib/python3/dist-packages/opensnitch/i18n locale: en_US
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
is new file, or IN MEMORY, setting initial schema version
setting schema version to: 1
setting schema version to: 1
schema version: 1
db schema is up to date
exception loading ipasn db: No module named 'pyasn'
Install python3-pyasn to display IP's network name.
Traceback (most recent call last):
File "/usr/bin/opensnitch-ui", line 74, in
service = UIService(app, on_exit)
File "/usr/lib/python3/dist-packages/opensnitch/service.py", line 92, in init
self._stats_dialog = StatsDialog(dbname="general", db=self._db, appicon=self.white_icon)
File "/usr/lib/python3/dist-packages/opensnitch/dialogs/stats.py", line 397, in init
self._fw_dialog = FirewallDialog(appicon=appicon)
File "/usr/lib/python3/dist-packages/opensnitch/dialogs/firewall.py", line 47, in init
self._fwrule_dialog = FwRuleDialog(appicon=self.appicon)
File "/usr/lib/python3/dist-packages/opensnitch/dialogs/firewall_rule.py", line 55, in init
self.net_srv = NetworkServices()
File "/usr/lib/python3/dist-packages/opensnitch/utils.py", line 323, in init
etcServices = open("/etc/services")
FileNotFoundError: [Errno 2] No such file or directory: '/etc/services'

@gustavo-iniguez-goya
Copy link
Collaborator

gustavo-iniguez-goya commented Jun 21, 2022

damn! thank you @gssantana

I'll generate a new release + GUI packages. Meanwhile you can just copy the file https://raw.githubusercontent.com/evilsocket/opensnitch/master/ui/opensnitch/utils.py to your installation directory (/usr/lib/python3/dist-packages/opensnitch/)

Or install setup on Fedora or netcfg on OpenSuse

gustavo-iniguez-goya added a commit that referenced this issue Jun 21, 2022
Added netbase (debian based distros) or setup (fedora) or netcfg
(opensuse) as dependency, to allow to read the file /etc/services.

 #671
@munix9
Copy link
Contributor

munix9 commented Jun 21, 2022

@gustavo-iniguez-goya FYI:

According to the information in https://kubic.opensuse.org/blog/2019-12-05-usr-etc/, a possible solution could look like this:

--- a/ui/opensnitch/utils.py
+++ b/ui/opensnitch/utils.py
@@ -320,8 +320,12 @@ class NetworkServices():
     ports_list = []
 
     def __init__(self):
+        etcServicesPath = "/etc/services"
+        if not os.path.isfile(etcServicesPath) and os.path.isfile("/usr/etc/services"):
+            etcServicesPath = "/usr/etc/services"
+
         try:
-            etcServices = open("/etc/services")
+            etcServices = open(etcServicesPath)
             for line in etcServices:
                 if line[0] == "#":
                     continue
@@ -339,7 +343,7 @@ class NetworkServices():
             self.srv_array.append("wireguard/51820 WireGuard VPN")
             self.ports_list.append("51820")
         except Exception as e:
-            print("Error loading /etc/services:", e)
+            print("Error loading " + etcServicesPath + ":", e)
 
     def to_array(self):
         return self.srv_array

It first looks to see if an /etc/services exists. If not and a /usr/etc/services exists, this is used.

@gustavo-iniguez-goya
Copy link
Collaborator

Oh, I see, thank you!

gustavo-iniguez-goya added a commit that referenced this issue Jun 21, 2022
Thanks @munix9! for spotting this problem, and providing a solution:
 #671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants