1 |
#!/bin/bash |
2 |
# |
3 |
# Wizard |
4 |
# |
5 |
# Copyright (C) 2000 Mandrakesoft. |
6 |
# |
7 |
# This program is free software; you can redistribute it and/or |
8 |
# modify it under the terms of the GNU General Public License |
9 |
# as published by the Free Software Foundation; either version 2 |
10 |
# of the License, or (at your option) any later version. |
11 |
# See file LICENSE for further informations on licensing terms. |
12 |
# |
13 |
# This program is distributed in the hope that it will be useful, |
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
# GNU General Public License for more details. |
17 |
# |
18 |
# You should have received a copy of the GNU General Public License |
19 |
# along with this program; if not, write to the Free Software |
20 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
# |
22 |
# Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi |
23 |
# icons: Helene Durosini <ln@mandrakesoft.com> |
24 |
# <corporate@mandrakesoft.com> http://www.mandrakesoft.com |
25 |
|
26 |
echo_debug "in $0" |
27 |
|
28 |
wiz_ip_net=`get_var wiz_ip_net` |
29 |
wiz_ip_server=`get_var wiz_ip_server` |
30 |
wiz_domain_name=`get_var wiz_domain_name` |
31 |
s_trunc=${wiz_ip_net%.*} |
32 |
ds=${wiz_ip_server##*.} |
33 |
sc_trunc=${wiz_client_ip%.*} |
34 |
dc=${wiz_client_ip##*.} |
35 |
|
36 |
wiz_client_name=${wiz_client_name%%.*} |
37 |
|
38 |
if [ -z "${wiz_client_name}" ]; then |
39 |
echo_debug "incorrect name" |
40 |
exit 1 |
41 |
fi |
42 |
|
43 |
if [ -z "${wiz_client_ip}" ]; then |
44 |
echo_debug "incorrect address" |
45 |
exit 1 |
46 |
fi |
47 |
|
48 |
if [ -z "${sc_trunc}" ]; then |
49 |
echo_debug "incorrect address" |
50 |
exit 1 |
51 |
fi |
52 |
if [ -z "${dc}" ]; then |
53 |
echo_debug "incorrect address" |
54 |
exit 1 |
55 |
fi |
56 |
|
57 |
if [ "${s_trunc}" != "${sc_trunc}" ]; then |
58 |
echo_debug "range not in network" |
59 |
exit 1 |
60 |
fi |
61 |
|
62 |
if [ "${dc}" = "${ds}" -o ${dc} -le 0 -o ${dc} -gt 255 ]; then |
63 |
echo_debug "bad ip" |
64 |
exit 1 |
65 |
fi |
66 |
|
67 |
|
68 |
file="/var/named/${wiz_domain_name}.db" |
69 |
t=`grep -E "^${wiz_client_name}[[:space:]]*IN" ${file}` |
70 |
if [ -n "$t" ]; then |
71 |
echo_debug "${wiz_client_name} got in ${file}" |
72 |
exit 2 |
73 |
fi |
74 |
t=`grep -E "^[^;]*A[[:space:]]*${wiz_client_ip}" ${file}` |
75 |
if [ -n "$t" ]; then |
76 |
echo_debug "${wiz_client_ip} got in ${file}" |
77 |
exit 2 |
78 |
fi |
79 |
|
80 |
file="/var/named/${s_trunc}.rev" |
81 |
t=`grep -E "^${dc}[[:space:]]*IN" ${file}` |
82 |
if [ -n "$t" ]; then |
83 |
echo_debug "${dc} got in ${file}" |
84 |
exit 2 |
85 |
fi |
86 |
t=`grep -E "^[^;]*PTR[[:space:]]*${wiz_client_name}" ${file}` |
87 |
if [ -n "$t" ]; then |
88 |
echo_debug "${wiz_client_name} got in ${file}" |
89 |
exit 2 |
90 |
fi |
91 |
|
92 |
# all seems to be ok |
93 |
exit 10 |