Project

General

Profile

Bug #23353

Issues with default directory for included DHCP files

Added by Sven Lueder about 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DHCP
Target version:
-
Difficulty:
Triaged:
Yes
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

In case of ISC DHCP integration enabled:
If DHCP config file is read during proxy startup, all files referenced in dhcpd.conf using include statement are loaded for inspection.
This is leading to issues, if those are not specified with an absolute path, but just with a simple filename.

Example:
[root@foreman dns]# cat /etc/dhcp/dhcpd.conf
include "omapi.key";
(--- remaining part of file snipped ---)

It seems as if those files are searched in the root directory instead of the directory where the dhcp config file itself is located.

The following code fixed the issue for me:

  patch -p0 /usr/share/foreman-proxy/modules/dhcp_common/isc/configuration_parser.rb << '@EOF'
*** dada        2018-04-10 04:35:16.461982185 +0200
--- configuration_parser.rb     2018-04-10 04:30:57.872176905 +0200
***************
*** 382,392 ****
--- 382,394 ----
          end

          def parse_file(a_path)
+           a_path = @@config_path + '/' + a_path if File.dirname(a_path) == '.'
            File.open(a_path, 'r') {|f| conf.parse!(f.read, a_path)}
          end

          # returns all_subnets, all_hosts, root_group
          def subnets_hosts_and_leases(conf_as_string, filename)
+           @@config_path = File.dirname(filename)
            parsed = conf.parse!(conf_as_string, filename)
            start_visiting_parse_tree_nodes(parsed)
          end
@EOF

Associated revisions

Revision ce744b8b (diff)
Added by Sven Lueder 5 months ago

Fixes #23353 - included DHCP files default directory

History

#1 Updated by Lukas Zapletal about 1 year ago

Thanks for analysis and fix. Are you planning filing it in

https://github.com/theforeman/smart-proxy/pulls

If not, I can do this on your behalf, but we appreciate patches. A unit test might be required tho.

#2 Updated by Sven Lueder about 1 year ago

Hi Lukas,

will do so.

Best regards
Sven

#3 Updated by The Foreman Bot 10 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/smart-proxy/pull/593 added

#4 Updated by The Foreman Bot 10 months ago

  • Pull request https://github.com/theforeman/smart-proxy/pull/600 added

#5 Updated by The Foreman Bot 5 months ago

  • Assignee set to Michael Moll
  • Pull request https://github.com/theforeman/smart-proxy/pull/627 added

#6 Updated by Lukas Zapletal 5 months ago

  • Triaged changed from No to Yes
  • Fixed in Releases 1.21.0 added

#7 Updated by Lukas Zapletal 5 months ago

  • Status changed from Ready For Testing to Closed
  • Pull request deleted (https://github.com/theforeman/smart-proxy/pull/593, https://github.com/theforeman/smart-proxy/pull/600)

Also available in: Atom PDF