This repository has been archived by the owner on Jun 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #274 Support cases where NetworkManager is running dnsmasq better
- Loading branch information
1 parent
e10f684
commit ad0622e
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Landrush | ||
module Util | ||
class Dnsmasq | ||
def self.nm_managed? | ||
nm_config = Pathname('/etc/NetworkManager/NetworkManager.conf') | ||
File.exist?(nm_config) && File.readlines(nm_config).grep(/^dns=dnsmasq$/).any? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require_relative '../../test_helper' | ||
|
||
module Landrush | ||
module Util | ||
describe Dnsmasq do | ||
MANAGED_DNSMASQ = '# Configuration file for NetworkManager. | ||
[main] | ||
dns=dnsmasq | ||
[logging] | ||
'.split('\n') | ||
|
||
UNMANAGED_DNSMASQ = '# Configuration file for NetworkManager. | ||
[main] | ||
#dns=dnsmasq | ||
[logging] | ||
'.split('\n') | ||
|
||
describe 'nm_managed?' do | ||
it 'No NetworkManager config exists' do | ||
File.expects(:exist?).returns(false) | ||
Dnsmasq.nm_managed?.must_equal false | ||
end | ||
|
||
it 'NetworkManager manages dnsmasq' do | ||
File.expects(:exist?).returns(true) | ||
File.expects(:readlines).returns(MANAGED_DNSMASQ) | ||
|
||
Dnsmasq.nm_managed?.must_equal true | ||
end | ||
|
||
it 'NetworkManager does not manage dnsmasq' do | ||
File.expects(:exist?).returns(true) | ||
File.expects(:readlines).returns(UNMANAGED_DNSMASQ) | ||
|
||
Dnsmasq.nm_managed?.must_equal false | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters