Project

General

Profile

Actions

Bug #23353

closed

Issues with default directory for included DHCP files

Added by Sven Lueder about 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
DHCP
Target version:
-
Difficulty:
Triaged:
Yes
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

Actions #1

Updated by Lukas Zapletal about 6 years 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.

Actions #2

Updated by Sven Lueder about 6 years ago

Hi Lukas,

will do so.

Best regards
Sven

Actions #3

Updated by The Foreman Bot over 5 years ago

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

Updated by The Foreman Bot over 5 years ago

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

Updated by The Foreman Bot over 5 years ago

  • Assignee set to Anonymous
  • Pull request https://github.com/theforeman/smart-proxy/pull/627 added
Actions #6

Updated by Lukas Zapletal over 5 years ago

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

Updated by Lukas Zapletal over 5 years ago

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

Also available in: Atom PDF