Custom option types defined at a higher level (such as in a subnet) can be used in the Edit Options page at lower levels (such as in a host).
---- Changes since 1.440 ----
When a subnet or host is renamed, the user's ACL is updated to match.
+---- Changes since 1.470 ----
+Added a Module Config option to specify an alternate file to add new top-level objects (like subnets) to. This must be referenced by an include directive in the main dhcpd.conf though.
group_name=Show group names as,1,1-<tt>domain-name</tt> option,0-Name or member count,2-Description
desc_name=Show other object descriptions instead of names?,1,1-Yes,0-No
display_max=Maximum number of subnets and hosts to display,3,Unlimited
+add_file=Add new subnets, hosts and groups to file,3,Main configuration file
line2=System configuration,11
dhcpd_conf=DHCP server config file,0
dhcpd_path=DHCP server executable,0
use WebminCore;
&init_config();
-# get_parent_config()
+# get_parent_config([file])
# Returns a dummy parent structure for the DHCP config
sub get_parent_config
{
-return $get_parent_config_cache if ($get_parent_config_cache);
-return $get_parent_config_cache = {
- 'file' => $config{'dhcpd_conf'},
- 'members' => &get_config(),
+local ($file) = @_;
+$file ||= $config{'dhcpd_conf'};
+return $get_parent_config_cache{$file} if ($get_parent_config_cache{$file});
+return $get_parent_config_cache{$file} = {
+ 'file' => $file,
+ 'members' => &get_config($file),
'line' => -1,
'fline' => -1,
'eline' => $get_config_lines };
}
-# get_config()
+# get_config([file])
# Parses the DHCPD config file into a data structure
sub get_config
{
-return \@get_config_cache if (@get_config_cache);
-local @rv = &get_config_file($config{'dhcpd_conf'}, \$get_config_lines);
-@get_config_cache = @rv;
-return \@get_config_cache;
+local ($file) = @_;
+$file ||= $config{'dhcpd_conf'};
+return $get_config_cache{$file} if ($get_config_cache{$file});
+local @rv = &get_config_file($file, \$get_config_lines);
+$get_config_cache{$file} = \@rv;
+return $get_config_cache{$file};
}
# get_config_file(file, [&lines])
# hash that links objtypes shortcuts with object names
%obj_names2types = qw(host hst group grp subnet sub shared-network sha);
-# get_branch($objtype)
+# get_branch(objtype, [addmode])
# usefull for edit_*.cgi and save_*.cgi scripts
# $objtype = one of 'hst' 'grp' 'sub' 'sha'
sub get_branch
local %obj_types2names = reverse %obj_names2types;
local $name = $obj_types2names{$_[0]};
local ($parnode, $nparnode, $node, $indent, $nindent);
-$parnode = $nparnode = &get_parent_config();
+$parnode = $nparnode = &get_parent_config(
+ $_[1] && $in{'sidx'} eq '' && $in{'uidx'} eq '' && $in{'gidx'} eq '' &&
+ $in{'parent'} eq '' ? $config{'add_file'} : undef);
$indent = $nindent = 0;
foreach ($in{'sidx'}, $in{'uidx'}, $in{'gidx'}) {
if ($_ ne '') {
local ($perm, $acc, $node, $smode) = @_;
local @perm = split(//, $perm);
-if ($node ne get_parent_config()) {
+if ($node ne get_parent_config() &&
+ $node ne get_parent_config($config{'add_file'})) {
foreach (@perm) {
next if ($_ ne 'c') && ($_ ne 'r') && ($_ ne 'w');
return 0 unless $acc->{$_ . '_' . $obj_names2types{$node->{'name'}} };
require './params-lib.pl';
&ReadParse();
&lock_file($config{'dhcpd_conf'});
-($par, $group, $indent, $npar, $nindent) = get_branch('grp');
+($par, $group, $indent, $npar, $nindent) = get_branch('grp', $in{'new'});
$parconf = $par->{'members'};
# check acls
require './params-lib.pl';
&ReadParse();
&lock_file($config{'dhcpd_conf'});
-($par, $host, $indent, $npar, $nindent) = get_branch('hst');
+($par, $host, $indent, $npar, $nindent) = get_branch('hst', $in{'new'});
# check acls
%access = &get_module_acl();
require './params-lib.pl';
&ReadParse();
&lock_file($config{'dhcpd_conf'});
-($par, $sha, $indent) = &get_branch('sha');
+($par, $sha, $indent) = &get_branch('sha', $in{'new'});
$parconf = $par->{'members'};
# check acls
require './params-lib.pl';
&ReadParse();
&lock_file($config{'dhcpd_conf'});
-($par, $sub, $indent, $npar, $nindent) = get_branch('sub');
+($par, $sub, $indent, $npar, $nindent) = get_branch('sub', $in{'new'});
$parconf = $par->{'members'};
# check acls
$sub->{'comment'} = $in{'desc'};
&parse_params($sub, 0);
-# $npar = &get_parent_config();
-# $nindent = 0;
-# if ($in{'parent'} ne "") {
-# $nindent = 1;
-# if ($in{'parent'} < @{$npar->{'members'}}) {
-# $npar = $npar->{'members'}->[$in{'parent'}];
-# }
-# }
if (!npar || $in{'assign'} > 0 && $npar->{'name'} ne "shared-network") {
&error($text{'sgroup_echanged'});
}