Nekmo / amazon-dash

Hack your Amazon Dash to run what you want.
MIT License
826 stars 69 forks source link

FreeNAS iocage Plugin #120

Closed gt2416 closed 5 years ago

gt2416 commented 5 years ago

Using the plugin, amazon-dash service does not start. It results in this error :

File "/usr/local/lib/python3.6/site-packages/scapy/arch/__init__.py", line 63, in <module>
    conf.use_bpf = True
  File "/usr/local/lib/python3.6/site-packages/scapy/config.py", line 75, in __set__
    self.hook(self.name, val, *self.args, **self.kargs)
  File "/usr/local/lib/python3.6/site-packages/scapy/config.py", line 491, in _socket_changer
    _set_conf_sockets()
  File "/usr/local/lib/python3.6/site-packages/scapy/config.py", line 436, in _set_conf_sockets
    raise ScapyInvalidPlatformException("Darwin (OSX) only !")
scapy.error.ScapyInvalidPlatformException: Darwin (OSX) only !

It also spits out the same error if installed manually.

I think only the last few lines are relevant, I have not touched anything, just installed the plugin and added 1 Homeassistant command in the xml file.

Another question, In the config file, where it says legacy-api for HomeAssistant, is that where you put the newer access token ? Thanks

tprelog commented 5 years ago

@gt2416 I think the error is related to this issue with scapy

I have done a test install of the plugin and got it running by replacing /usr/local/lib/python3.6/site-packages/scapy/config.py with this version from github

I found the easiest approach to install wget and download the file directly using the plugin console

root@amazon-dash:~ #

pkg install wget ca_root_nss
wget -O /usr/local/lib/python3.6/site-packages/scapy/config.py https://raw.githubusercontent.com/secdev/scapy/master/scapy/config.py
service amazon-dash start

service amazon-dash status
amazondash is running as pid 10803.

For a long live access token replace that line with access_token: (obviously include your token)

Note: I also suggest you install ca_root_nss > This is not related to your error but I have just discovered this is required for amazon-dash --version to work correctly

gt2416 commented 5 years ago

Thanks for the fast response. After getting the new scapy.py file, it now errors out with this:

File "/usr/local/lib/python3.6/site-packages/scapy/arch/bpf/supersocket.py", line 58, in __init__
    (self.ins, self.dev_bpf) = get_dev_bpf()
  File "/usr/local/lib/python3.6/site-packages/scapy/arch/bpf/core.py", line 98, in get_dev_bpf
    raise Scapy_Exception("No /dev/bpf handle is available !")
scapy.error.Scapy_Exception: No /dev/bpf handle is available !

I have tried setting the option --ignore-perms --root-allowed to see if this was a permission issue, but it didnt fix it. The device /dev/bpf does not exits in my file system, even though I double checked that bpf was ticked in the iocage jail settings. This is on FreeNAS 11.2-RELEASE U1

Edit: I just recreated the plugin and it works. (after using the wget to get the new scapy file) Not sure why my original jail is spitting out errors. The only difference was that instead of dhcp I assigned it a ipv4 address.

tprelog commented 5 years ago

I just recreated the plugin and it works. (after using the wget to get the new scapy file) Not sure why my original jail is spitting out errors. The only difference was that instead of dhcp I assigned it a ipv4 address

I'm pretty sure this a FreeNAS (iocage) issue. In general I've seen others report issues when trying to set an assigned IP address during creation. It seems like this works just fine for some people but for others it does not. I've always had good luck using the dhcp=on vnet=on bpf=yes options. Also I've seen others suggest these options when setting an IP manually fails to work. Besides I find (in my opinion) it much easier to manage IP address in one place, on my router, rather than multiple computers, VMs, and(or) jails

tprelog commented 5 years ago

After further testing the original error exist in scapy 2.4.1 and 2.4.2.

The last working version was scapy 2.4.0 as alternative to using the wget workaround mentioned above downgrading to scapy 2.4.0 inside the jail will also work.

root@amazon-dash:~ #

pip install scapy==2.4.0
service amazon-dash start

EDIT: I have updated the plugin script to (hopefully) handle this auto-magically.

tprelog commented 5 years ago

@Nekmo I think you can close this now.

Nekmo commented 5 years ago

Thanks for the notice! it may be a bug in Scapy. I'll wait for a patched version.