Permalink
Browse files

Locate epcap executable relative to the module directory.

  • Loading branch information...
1 parent 4324dcf commit 8c38b5945923f7ab72079c81118ad093d9ae548f @msantos committed Mar 9, 2010
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/epcap.erl
View
@@ -31,8 +31,8 @@
-module(epcap).
-export([start/0, start/1, start/2, stop/0]).
+-export([progname/0]).
--define(PROGNAME, "sudo priv/epcap").
start() ->
start(self(), []).
@@ -69,7 +69,7 @@ loop(Caller, Port) ->
end.
make_args(PL) ->
- proplists:get_value(progname, PL, ?PROGNAME) ++ " " ++
+ proplists:get_value(progname, PL, "sudo " ++ progname()) ++ " " ++
string:join([ get_switch(proplists:lookup(Arg, PL)) || Arg <- [
chroot,
group,
@@ -93,4 +93,12 @@ get_switch({user, Arg}) -> "-u " ++ Arg;
get_switch({verbose, _Arg}) -> "-v";
get_switch({filter, Arg}) -> "\"" ++ Arg ++ "\"".
+progname() ->
+ filename:join([
+ filename:dirname(code:which(?MODULE)),
+ "..",
+ "priv",
+ ?MODULE
+ ]).
+

0 comments on commit 8c38b59

Please sign in to comment.