Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
|
3 |
# $FreeBSD$ |
4 |
# |
5 |
# PROVIDE: p0f2 |
6 |
# REQUIRE: LOGIN |
7 |
# KEYWORD: shutdown |
8 |
# |
9 |
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf |
10 |
# to enable this service: |
11 |
# |
12 |
# p0f_enable (bool): Set to NO by default. |
13 |
# |
14 |
# p0f_user: User to drop privileges and change to |
15 |
# |
16 |
# p0f_int: Network interface to listen on |
17 |
# |
18 |
# p0f_sock (path): Path to socket used to communicate with p0f |
19 |
# |
20 |
# p0f_args: Additonal options passed to the p0f daemon |
21 |
# |
22 |
# p0f_log (path): File where p0f logs matches |
23 |
# |
24 |
# p0f_db (path): Location of fingerprint db. |
25 |
# Defaults to %%PREFIX%%/p0f/p0f.fp |
26 |
|
27 |
. /etc/rc.subr |
28 |
|
29 |
name="p0f" |
30 |
rcvar=p0f_enable |
31 |
|
32 |
load_rc_config ${name} |
33 |
|
34 |
: ${p0f_enable:="NO"} |
35 |
: ${p0f_user:="root"} |
36 |
: ${p0f_sock:="/var/run/${name}.sock"} |
37 |
: ${p0f_log:="/var/log/p0f.log"} |
38 |
: ${p0f_db:="%%PREFIX%%/etc/p0f/p0f.fp"} |
39 |
|
40 |
stop_cmd="${name}_stopcmd" |
41 |
status_cmd="${name}_statuscmd" |
42 |
|
43 |
pidfile=/var/run/${name}.pid |
44 |
p0f_command="%%PREFIX%%/bin/${name} -i ${p0f_int} -u ${p0f_user} -Q ${p0f_sock} -o ${p0f_log} -f ${p0f_db} ${p0f_args}" |
45 |
command="/usr/sbin/daemon" |
46 |
command_args="-f -p ${pidfile} ${p0f_command}" |
47 |
|
48 |
p0f_statuscmd() |
49 |
{ |
50 |
if [ ! -e $pidfile ]; |
51 |
then |
52 |
echo "pidfile does not exist. $name is not running?"; |
53 |
exit 1; |
54 |
fi |
55 |
|
56 |
if pgrep -F $pidfile >/dev/null; |
57 |
then |
58 |
echo "$name is running."; |
59 |
else |
60 |
echo "$name is not running."; |
61 |
exit 1; |
62 |
fi |
63 |
} |
64 |
|
65 |
p0f_stopcmd() |
66 |
{ |
67 |
if pgrep -F $pidfile >/dev/null; |
68 |
then |
69 |
p0fpid=`cat $pidfile`; |
70 |
kill $sig_stop ${p0fpid}; |
71 |
wait_for_pids ${p0fpid}; |
72 |
else |
73 |
echo "$name is not running."; |
74 |
exit 1; |
75 |
fi |
76 |
} |
77 |
|
78 |
run_rc_command "$1" |