forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlookup_host.cgi
executable file
·39 lines (34 loc) · 1.07 KB
/
lookup_host.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/local/bin/perl
# lookup_host.cgi
# Find a host with a certain name and re-direct to its editing form
require './dhcpd-lib.pl';
&ReadParse();
$in{'host'} || &error($text{'lookup_ehostname'});
# Recursively find hosts
$conf = &get_config();
@hosts = &find_recursive("host", $conf);
# Look for a match
%access = &get_module_acl();
foreach $h (@hosts) {
local $can_view = &can('r', \%access, $h);
next if !$can_view && $access{'hide'};
local $fixed = &find("fixed-address", $h->{'members'});
local $hard = &find("hardware", $h->{'members'});
if (&search_re($h->{'values'}->[0], $in{'host'}) ||
$fixed && &search_re($fixed->{'values'}->[0], $in{'host'}) ||
$hard && &search_re($hard->{'values'}->[1], $in{'host'})) {
$host = $h;
last;
}
}
# Go to the host or show an error
if ($host) {
($gidx, $uidx, $sidx) = &find_parents($host);
&redirect("edit_host.cgi?idx=$host->{'index'}".
(defined($gidx) ? "&gidx=$gidx" : "").
(defined($uidx) ? "&uidx=$uidx" : "").
(defined($sidx) ? "&sidx=$sidx" : ""));
}
else {
&error(&text('lookup_ehost', $in{'host'}));
}