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

Dasshio script failing when pressing Dash button - IndexError: Layer [ARP] not found #44

Open
theastropath opened this issue Jul 31, 2018 · 10 comments

Comments

@theastropath
Copy link

I set up Dasshio version 0.3.0 in Hass.io supervisor version 121 on an Ubuntu 16.04 host. When I configure a button and then press it, I get the results below:

2018-07-31 18:52:35,229 | INFO | Reading config file: /data/options.json
2018-07-31 18:52:35,230 | INFO | Starting sniffing...
Traceback (most recent call last):
  File "/dasshio.py", line 27, in arp_display
    mac = pkt[ARP].hwsrc.lower()
  File "/usr/lib/python3.6/site-packages/scapy/packet.py", line 966, in __getitem__
    raise IndexError("Layer [%s] not found" % lname)
IndexError: Layer [ARP] not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/dasshio.py", line 149, in <module>
    count=0)
  File "/usr/lib/python3.6/site-packages/scapy/sendrecv.py", line 783, in sniff
    if stop_filter and stop_filter(p):
  File "/dasshio.py", line 29, in arp_display
    mac = pkt[Ether].src.lower()
  File "/usr/lib/python3.6/site-packages/scapy/packet.py", line 966, in __getitem__
    raise IndexError("Layer [%s] not found" % lname)
IndexError: Layer [Ether] not found
@SmightyCrown
Copy link

I have the same Problem, with nearly the same setup: Dasshio 0.3.1 in Hass.io supervisor 125 on an Ubuntu 16.04.
Is there a solution for it ?
Or is it possible to downgrade to 0.21 because that version worked without problems?

@theastropath
Copy link
Author

For what it's worth, I have since upgraded to Dasshio 0.3.1 and Hassio supervisor 125 as well, and it still doesn't work for me.

I had previously set up another Hassio instance (Which had DNS issues) on Ubuntu 17.10, and Dasshio is working in that setup. My current workaround is to keep Dasshio running on that host, but sending commands to the Ubuntu 16.04 instance (Which works perfectly otherwise)

@IvoryAguado
Copy link

IvoryAguado commented Aug 15, 2018 via email

@theastropath
Copy link
Author

I've determined the cause of the problem and half determined a work-around, but not entirely sure how to get it actually working. Let me outline everything that I've determined:

By entering the Dasshio container and manually executing the dasshio.py, I was able to determine that the "sniff" function was picking up every packet that was hitting the network interface and not filtering out packets that don't match the specified filter.

I was able to find this issue:
secdev/scapy#393
Which mentions that the filter gets installed by tcpdump. Trying to manually run tcpdump gave me the following output:

bash-4.4# tcpdump
Error loading shared library libcrypto.so.43: Permission denied (needed by /usr/sbin/tcpdump)
Error loading shared library libpcap.so.1: Permission denied (needed by /usr/sbin/tcpdump)
Error relocating /usr/sbin/tcpdump: EVP_CIPHER_CTX_new: symbol not found
Error relocating /usr/sbin/tcpdump: EVP_CIPHER_iv_length: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_create: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_dump_ftell: symbol not found
Error relocating /usr/sbin/tcpdump: bpf_dump: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_compile: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_dump_close: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_datalink_name_to_val: symbol not found
Error relocating /usr/sbin/tcpdump: MD5_Update: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_tstamp_type_val_to_description: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_snaplen: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_snapshot: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_list_tstamp_types: symbol not found
Error relocating /usr/sbin/tcpdump: MD5_Final: symbol not found
Error relocating /usr/sbin/tcpdump: EVP_get_cipherbyname: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_list_datalinks: symbol not found
Error relocating /usr/sbin/tcpdump: EVP_CIPHER_CTX_free: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_stats: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_breakloop: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_open_offline: symbol not found
Error relocating /usr/sbin/tcpdump: OPENSSL_add_all_algorithms_noconf: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_close: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_dump_open: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_datalink_val_to_name: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_dump: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_tstamp_type_val_to_name: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_open_offline_with_tstamp_precision: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_lookupnet: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_immediate_mode: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_lib_version: symbol not found
Error relocating /usr/sbin/tcpdump: SSLeay_version: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_statustostr: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_geterr: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_setfilter: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_setdirection: symbol not found
Error relocating /usr/sbin/tcpdump: EVP_Cipher: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_buffer_size: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_rfmon: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_freealldevs: symbol not found
Error relocating /usr/sbin/tcpdump: EVP_CipherInit_ex: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_can_set_rfmon: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_tstamp_type_name_to_val: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_findalldevs: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_free_tstamp_types: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_timeout: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_freecode: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_loop: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_strerror: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_tstamp_type: symbol not found
Error relocating /usr/sbin/tcpdump: EVP_CIPHER_CTX_block_size: symbol not found
Error relocating /usr/sbin/tcpdump: OBJ_NAME_add: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_datalink: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_dump_flush: symbol not found
Error relocating /usr/sbin/tcpdump: MD5_Init: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_datalink_val_to_description: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_free_datalinks: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_tstamp_precision: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_activate: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_promisc: symbol not found
Error relocating /usr/sbin/tcpdump: pcap_set_datalink: symbol not found

Which obviously seems bad (And yes, I verified that I was root, so the lack of permission seemed odd)

Further searching to determine why tcpdump might not be working lead me to the following issue:
moby/moby#14140
In which this is mentioned as "likely an AppArmor issue" (A ha! That sort of makes sense!). A temporary workaround is described in the discussion to try moving tcpdump to "/usr/local/bin" (and then run "hash -r" to rehash your path). I did so, and manually ran the dasshio script. It worked! The button press was detected, but since the script that was run during the container creation crashed, the container died.

So there's some sort of privilege issue being caused by AppArmor that is preventing tcpdump from being executed in /usr/sbin/ but not in /usr/local/bin/.

What I'm not sure about (being a Docker noob) is how to move the tcpdump binary in the container and make that permanent until the issue gets resolved properly. Ideas?

@theastropath
Copy link
Author

It took a bit of fiddling, but I've forked the Dasshio repository and gotten things working for me. The only real differences between 0.3.1 and my version is that the add-on generates the Docker image on the fly (instead of using a published image) and moves the tcpdump binary to /usr/bin during creation. I changed some of the add-on text as well just to make it explicitly clear that this is a work-around version, and isn't really a permanent solution.

If you're encountering the issue described here, you should be able to add my repository to your Hass.io add-on store, and install the add-on that way. My repository is:
https://github.com/theastropath/dasshio

I would love to not have to keep my fork up to date, so hopefully a proper fix gets added to the main repository eventually!

@danimtb
Copy link
Owner

danimtb commented Oct 31, 2018

So, looking at the @theastropath workaround it seems easy to add it. I have been running this version in RPI for a long time and now I run it inside an Ubuntu 18 an it working without issue.

I am willing to make the workaround suggested but would like to know if any of you found another way of making it work without the IndexError: Layer [ARP] not found

Thanks!

@cryptooth
Copy link

It took a bit of fiddling, but I've forked the Dasshio repository and gotten things working for me. The only real differences between 0.3.1 and my version is that the add-on generates the Docker image on the fly (instead of using a published image) and moves the tcpdump binary to /usr/bin during creation. I changed some of the add-on text as well just to make it explicitly clear that this is a work-around version, and isn't really a permanent solution.

If you're encountering the issue described here, you should be able to add my repository to your Hass.io add-on store, and install the add-on that way. My repository is:
https://github.com/theastropath/dasshio

I would love to not have to keep my fork up to date, so hopefully a proper fix gets added to the main repository eventually!

It's working on Ubunut 16.04 and latest hassio without crash.

Thank you.

@theastropath
Copy link
Author

@danimtb I believe the other (proper) solution would be to figure out how AppArmor needs to be configured to allow tcpdump to run in its current location. That being said, I have absolutely no understanding of how AppArmor really works, so I can't provide much insight. I think just moving tcpdump is the easy/good enough solution.

@smartsoldier
Copy link

I have been experiencing the crashing issue as well so please implement this workaround. Or did you already? I checked the releases page of your github and the other guys fork and they both say Aug was latest but your posts are only 25 days old. Where is your latest code lol am I missing it?

@theastropath
Copy link
Author

There were some minor changes (documentation, IIRC) to the base version around when I made the workarounds in my fork. If you are experiencing the "Layer [ARP] not found" crash, I would recommend using my fork for the time being, then switch back to the original version once the workaround has been implemented there. You should be able to just copy the configuration from my version and just dump it into the base version once you need to make the switch.

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

6 participants