Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
4dde1f08
Commit
4dde1f08
authored
Jun 21, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dhcpd: deduplicate domain keys; closes #1023
parent
ae6b495e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
25 deletions
+19
-25
services.inc
src/etc/inc/services.inc
+19
-25
No files found.
src/etc/inc/services.inc
View file @
4dde1f08
...
@@ -957,7 +957,6 @@ EOD;
...
@@ -957,7 +957,6 @@ EOD;
$newzone
[
'dns-servers'
]
=
array
(
$dhcpifconf
[
'ddnsdomainprimary'
]);
$newzone
[
'dns-servers'
]
=
array
(
$dhcpifconf
[
'ddnsdomainprimary'
]);
$newzone
[
'ddnsdomainkeyname'
]
=
$dhcpifconf
[
'ddnsdomainkeyname'
];
$newzone
[
'ddnsdomainkeyname'
]
=
$dhcpifconf
[
'ddnsdomainkeyname'
];
$newzone
[
'ddnsdomainkey'
]
=
$dhcpifconf
[
'ddnsdomainkey'
];
$newzone
[
'ddnsdomainkey'
]
=
$dhcpifconf
[
'ddnsdomainkey'
];
$dhcpdconf
.=
dhcpdkey
(
$newzone
);
$ddns_zones
[]
=
$newzone
;
$ddns_zones
[]
=
$newzone
;
}
}
}
}
...
@@ -966,7 +965,7 @@ EOD;
...
@@ -966,7 +965,7 @@ EOD;
if
(
$need_ddns_updates
)
{
if
(
$need_ddns_updates
)
{
$dhcpdconf
.=
"ddns-update-style interim;
\n
"
;
$dhcpdconf
.=
"ddns-update-style interim;
\n
"
;
$dhcpdconf
.=
"update-static-leases on;
\n
"
;
$dhcpdconf
.=
"update-static-leases on;
\n
"
;
$dhcpdconf
.=
dhcpd
zones
(
$ddns_zones
);
$dhcpdconf
.=
services_dhcpd_
zones
(
$ddns_zones
);
}
}
/* write dhcpd.conf */
/* write dhcpd.conf */
...
@@ -996,30 +995,18 @@ EOD;
...
@@ -996,30 +995,18 @@ EOD;
return
0
;
return
0
;
}
}
function
dhcpdkey
(
$ddns_zone
)
function
services_dhcpd_zones
(
$ddns_zones
)
{
{
$dhcpdconf
=
''
;
$dhcpdconf
=
''
;
if
(
!
empty
(
$ddns_zone
[
'ddnsdomainkeyname'
])
&&
!
empty
(
$ddns_zone
[
'ddnsdomainkey'
]))
{
$dhcpdconf
.=
"key
{
$ddns_zone
[
'ddnsdomainkeyname'
]
}
{\n"
;
$dhcpdconf
.=
" algorithm hmac-md5;
\n
"
;
$dhcpdconf
.=
" secret
{
$ddns_zone
[
'ddnsdomainkey'
]
}
;
\n
"
;
$dhcpdconf
.=
"}
\n
"
;
}
return
$dhcpdconf
;
}
function
dhcpdzones
(
$ddns_zones
)
{
$dhcpdconf
=
""
;
if
(
is_array
(
$ddns_zones
))
{
if
(
is_array
(
$ddns_zones
))
{
$added_zones
=
array
();
$added_zones
=
array
();
$added_keys
=
array
();
foreach
(
$ddns_zones
as
$zone
)
{
foreach
(
$ddns_zones
as
$zone
)
{
if
(
!
is_array
(
$zone
)
||
empty
(
$zone
)
||
!
is_array
(
$zone
[
'dns-servers'
]))
{
if
(
!
is_array
(
$zone
)
||
empty
(
$zone
)
||
!
is_array
(
$zone
[
'dns-servers'
]))
{
continue
;
continue
;
}
}
$primary
=
$zone
[
'dns-servers'
][
0
];
$primary
=
$zone
[
'dns-servers'
][
0
];
$secondary
=
empty
(
$zone
[
'dns-servers'
][
1
])
?
""
:
$zone
[
'dns-servers'
][
1
];
$secondary
=
empty
(
$zone
[
'dns-servers'
][
1
])
?
""
:
$zone
[
'dns-servers'
][
1
];
...
@@ -1036,15 +1023,23 @@ function dhcpdzones($ddns_zones)
...
@@ -1036,15 +1023,23 @@ function dhcpdzones($ddns_zones)
// We don't need to add zones multiple times.
// We don't need to add zones multiple times.
foreach
(
array
(
$zone
[
'domain-name'
],
$zone
[
'ptr-domain'
])
as
$domain
)
{
foreach
(
array
(
$zone
[
'domain-name'
],
$zone
[
'ptr-domain'
])
as
$domain
)
{
if
(
!
empty
(
$domain
)
&&
!
in_array
(
$domain
,
$added_zones
))
{
if
(
!
empty
(
$domain
)
&&
!
in_array
(
$domain
,
$added_zones
))
{
$dhcpdconf
.=
"zone
{
$domain
}
. {\n"
;
/* dhcpdconf2 is injected *after* the key */
$dhcpdconf
.=
" primary
{
$primary
}
;
\n
"
;
$dhcpdconf2
=
"zone
{
$domain
}
. {\n"
;
$dhcpdconf2
.=
" primary
{
$primary
}
;
\n
"
;
if
(
is_ipaddrv4
(
$secondary
))
{
if
(
is_ipaddrv4
(
$secondary
))
{
$dhcpdconf
.=
" secondary
{
$secondary
}
;
\n
"
;
$dhcpdconf
2
.=
" secondary
{
$secondary
}
;
\n
"
;
}
}
if
(
!
empty
(
$zone
[
'ddnsdomainkeyname'
])
&&
!
empty
(
$zone
[
'ddnsdomainkey'
]))
{
if
(
!
empty
(
$zone
[
'ddnsdomainkeyname'
])
&&
!
empty
(
$zone
[
'ddnsdomainkey'
])
&&
$dhcpdconf
.=
" key
{
$zone
[
'ddnsdomainkeyname'
]
}
;
\n
"
;
!
in_array
(
$zone
[
'ddnsdomainkeyname'
],
$added_keys
))
{
$dhcpdconf2
.=
" key
{
$zone
[
'ddnsdomainkeyname'
]
}
;
\n
"
;
$dhcpdconf
.=
"key
{
$zone
[
'ddnsdomainkeyname'
]
}
{\n"
;
$dhcpdconf
.=
" algorithm hmac-md5;
\n
"
;
$dhcpdconf
.=
" secret
{
$zone
[
'ddnsdomainkey'
]
}
;
\n
"
;
$dhcpdconf
.=
"}
\n
"
;
$added_keys
[]
=
$zone
[
'ddnsdomainkeyname'
];
}
}
$dhcpdconf
.=
"}
\n
"
;
$dhcpdconf2
.=
"}
\n
"
;
$dhcpdconf
.=
$dhcpdconf2
;
$added_zones
[]
=
$domain
;
$added_zones
[]
=
$domain
;
}
}
}
}
...
@@ -1343,7 +1338,6 @@ EOD;
...
@@ -1343,7 +1338,6 @@ EOD;
$newzone
[
'dns-servers'
]
=
array
(
$dhcpv6ifconf
[
'ddnsdomainprimary'
]);
$newzone
[
'dns-servers'
]
=
array
(
$dhcpv6ifconf
[
'ddnsdomainprimary'
]);
$newzone
[
'ddnsdomainkeyname'
]
=
$dhcpv6ifconf
[
'ddnsdomainkeyname'
];
$newzone
[
'ddnsdomainkeyname'
]
=
$dhcpv6ifconf
[
'ddnsdomainkeyname'
];
$newzone
[
'ddnsdomainkey'
]
=
$dhcpv6ifconf
[
'ddnsdomainkey'
];
$newzone
[
'ddnsdomainkey'
]
=
$dhcpv6ifconf
[
'ddnsdomainkey'
];
$dhcpdv6conf
.=
dhcpdkey
(
$dhcpv6ifconf
);
$ddns_zones
[]
=
$newzone
;
$ddns_zones
[]
=
$newzone
;
}
}
}
}
...
@@ -1368,7 +1362,7 @@ EOD;
...
@@ -1368,7 +1362,7 @@ EOD;
if
(
$nsupdate
)
{
if
(
$nsupdate
)
{
$dhcpdv6conf
.=
"ddns-update-style interim;
\n
"
;
$dhcpdv6conf
.=
"ddns-update-style interim;
\n
"
;
$dhcpdv6conf
.=
dhcpd
zones
(
$ddns_zones
);
$dhcpdv6conf
.=
services_dhcpd_
zones
(
$ddns_zones
);
}
else
{
}
else
{
$dhcpdv6conf
.=
"ddns-update-style none;
\n
"
;
$dhcpdv6conf
.=
"ddns-update-style none;
\n
"
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment