From f0f63262e3dc40bf8e7ad447d7a240304f5d7d62 Mon Sep 17 00:00:00 2001 From: Joshua Moody Date: Wed, 27 Jul 2016 12:23:36 +0200 Subject: [PATCH] Bin: restrict how and where bin/dnssd can be run --- bin/dnssd | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/dnssd b/bin/dnssd index 6f70f261..0aee232f 100755 --- a/bin/dnssd +++ b/bin/dnssd @@ -9,10 +9,23 @@ Thread.abort_on_exception = true trap 'INT' do exit end trap 'TERM' do exit end -if RUBY_PLATFORM[/darwin/] - require "dnssd" +if defined?(Bundler) + raise "This tool cannot be called in the context of bundle exec" +elsif RUBY_PLATFORM[/darwin/] + begin + require "dnssd" + rescue LoadError => _ + raise %Q[ + +This tool requires the dnssd gem which is not installed. Install it: + +gem install dnssd --version 2.0 + +and try again. +] + end else - raise "dnssd gem is not available on #{RUBY_PLATFORM}" + raise "This tool is not available on #{RUBY_PLATFORM}" end services = []