AlexGustafsson / homebridge-wol

A Wake on Lan plugin for Homebridge
MIT License
301 stars 30 forks source link

Raw Socket initializing error #8

Closed iDevo closed 8 years ago

iDevo commented 8 years ago

Hi there! I've installed the homebridge-wol plugin like described in the instructions. I've also added the entry to the config.json like this:

{
    "accessory": "Computer",
    "name": "Boston2",
    "mac": "MY_MAC_ADDRESS",
    "ip": "192.168.178.12",
    "pingInterval": 20, 
    "wakeGraceTime": 60,
    "shutdownGraceTime": 15
},

Unfortunately I'm getting this error, when starting homebridge with: hombridge

[Tue May 10 2016 19:05:19 GMT+0000 (UTC)] [Boston2] Initializing Computer accessory...
/usr/local/lib/node_modules/homebridge-wol/node_modules/net-ping/node_modules/raw-socket/index.js:47
    this.wrap = new raw.SocketWrap (
                ^

Error: Operation not permitted
    at Error (native)
    at new Socket (/usr/local/lib/node_modules/homebridge-wol/node_modules/net-ping/node_modules/raw-socket/index.js:47:14)
    at Object.exports.createSocket (/usr/local/lib/node_modules/homebridge-wol/node_modules/net-ping/node_modules/raw-socket/index.js:202:9)
    at Session.getSocket (/usr/local/lib/node_modules/homebridge-wol/node_modules/net-ping/index.js:147:20)
    at new Session (/usr/local/lib/node_modules/homebridge-wol/node_modules/net-ping/index.js:101:7)
    at Object.exports.createSession (/usr/local/lib/node_modules/homebridge-wol/node_modules/net-ping/index.js:545:9)
    at new Pinger (/usr/local/lib/node_modules/homebridge-wol/index.js:114:24)
    at new Computer (/usr/local/lib/node_modules/homebridge-wol/index.js:28:16)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:244:29)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:72:38)

All my other plugins are setting up correctly except the wol alias Computer plugin. It seems for me like an issue in the raw-socket module but I just want to make sure I didn't misconfigured anything.

Thanks in advance!

blubber commented 8 years ago

Unfortunately using raw sockets requires root privileges. As far as I can tell you have to options, either you run homebridge as root or you give the user that is running homebridge the CAP_NET_RAW (see $ man 7 capabilities.) I don't personally have experience with the CAP_NET_RAW, I run homebridge as root on a dedicated Pi.

iDevo commented 8 years ago

Aaaah good to know I'll check it! Okay maybe I'd just run homebridge as root, I don't think that this would have any disadvantages. But please correct me if there are things I should keep an eye, when running hombridge as root. Thanks a lot @blubber !

blubber commented 8 years ago

Well, running it as root implies trust, the root user can do literally everything on the computer. You are downloading and installing software from the internet, it's up to you to decide whether or not you trust the homebridge and plugin developers.

This is not just homebridge specific by the way, it goes or anything you run as root.

AAShepAA commented 6 years ago

I have the same issue with the homebridge-people-plus plugin on a raspberry pi. I got it to run by copying the config.json file to root/.homebridge and running sudo homebridge. But how do I get this to run from the default /home/pi folder the way it should? How can I give user pi the permission it needs? - thanks

AlexGustafsson commented 6 years ago

@AAShepAA I think there’s a note about it in the readme about “capabilities”. Please try that solution and come back whether it works or not.

AAShepAA commented 6 years ago

I see nothing here: https://github.com/Glavin001/homebridge-people-plus#readme

Shep Owner/Operator | Stratoliner.Me M: 1-602-451-1728 E: shep@stratoliner.me 11942 W. Monte Lindo Ln. Sun City, AZ. 85373 www.stratoliner.me On Jun 7, 2018, 12:46 AM -0700, Alex Gustafsson notifications@github.com, wrote:

@AAShepAA I think there’s a note about it in the readme about “capabilities”. Please try that solution and come back whether it works or not. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

AlexGustafsson commented 6 years ago

@AAShepAA I meant in the readme for this package.

AAShepAA commented 6 years ago

I’m sorry I guess I do not know where to find that readme.  But, thank you for your help anyway :)

Shep Owner/Operator | Stratoliner.Me M: 1-602-451-1728 E: shep@stratoliner.me 11942 W. Monte Lindo Ln. Sun City, AZ. 85373 www.stratoliner.me On Jun 8, 2018, 10:24 AM -0700, Alex Gustafsson notifications@github.com, wrote:

@AAShepAA I meant in the readme for this package. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

AlexGustafsson commented 6 years ago

@AAShepAA here you go, the commit that added the note: https://github.com/AlexGustafsson/homebridge-wol/commit/6e1ef148a9ac7c21d9fbddcfaef461c7bce235bd

I hope it solves your issue.