This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
177 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facter | ||
module Fedora | ||
class OsArchitecture | ||
FACT_NAME = 'os.architecture' | ||
|
||
def call_the_resolver | ||
fact_value = UnameResolver.resolve(:machine) | ||
|
||
Fact.new(FACT_NAME, fact_value) | ||
end | ||
end | ||
end | ||
end |
6 changes: 2 additions & 4 deletions
6
lib/facts/scientific/os/family.rb → lib/facts/fedora/os/family.rb
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
6 changes: 3 additions & 3 deletions
6
lib/facts/scientific/os/name.rb → lib/facts/fedora/os/hardware.rb
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facter | ||
module Fedora | ||
class OsName | ||
FACT_NAME = 'os.name' | ||
|
||
def call_the_resolver | ||
fact_value = OsReleaseResolver.resolve('NAME') | ||
|
||
Fact.new(FACT_NAME, fact_value) | ||
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facter | ||
module Fedora | ||
class OsRelease | ||
FACT_NAME = 'os.release' | ||
|
||
def call_the_resolver | ||
version = OsReleaseResolver.resolve('VERSION_ID') | ||
|
||
Fact.new(FACT_NAME, build_fact_list(version)) | ||
end | ||
|
||
def build_fact_list(version) | ||
{ | ||
full: version, | ||
major: version | ||
} | ||
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facter | ||
module Fedora | ||
class OsSelinux | ||
FACT_NAME = 'os.selinux' | ||
|
||
def call_the_resolver | ||
selinux = SELinuxResolver.resolve(:enabled) | ||
|
||
Fact.new(FACT_NAME, build_fact_list(selinux)) | ||
end | ||
|
||
def build_fact_list(selinux) | ||
{ | ||
enabled: selinux | ||
} | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
# frozen_string_literal: true | ||
|
||
class SELinuxResolver < BaseResolver | ||
# :name | ||
# :version | ||
# :codename | ||
|
||
class << self | ||
@@semaphore = Mutex.new | ||
@@fact_list ||= {} | ||
|
||
def resolve(fact_name) | ||
@@semaphore.synchronize do | ||
result ||= @@fact_list[fact_name] | ||
result || read_lsb_release_file(fact_name) | ||
end | ||
end | ||
|
||
def read_lsb_release_file(fact_name) | ||
output, _s = Open3.capture2('cat /proc/self/mounts') | ||
@@fact_list[:enabled] = false | ||
|
||
output.each_line do |line| | ||
next unless line.match(/selinuxfs/) | ||
|
||
@@fact_list[:enabled] = true | ||
@@fact_list[:mountpoint] = line | ||
break | ||
end | ||
|
||
@@fact_list[fact_name] | ||
end | ||
|
||
def invalidate_cache | ||
@@fact_list = {} | ||
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
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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
describe 'SELinuxResolver' do | ||
after(:each) do | ||
SELinuxResolver.invalidate_cache | ||
end | ||
it 'returns false when selinux is not enabled' do | ||
allow(Open3).to receive(:capture2) | ||
.with('cat /proc/self/mounts') | ||
.and_return(load_fixture('proc_self_mounts').read) | ||
result = SELinuxResolver.resolve(:enabled) | ||
|
||
expect(result).to be_falsey | ||
end | ||
|
||
it 'returns true when selinux is enabled' do | ||
allow(Open3).to receive(:capture2) | ||
.with('cat /proc/self/mounts') | ||
.and_return(load_fixture('proc_self_mounts_selinux').read) | ||
result = SELinuxResolver.resolve(:enabled) | ||
|
||
expect(result).to be_truthy | ||
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,12 @@ | ||
NAME="Ubuntu" | ||
VERSION="18.04.1 LTS (Bionic Beaver)" | ||
ID= | ||
ID_LIKE=debian | ||
PRETTY_NAME="Ubuntu 18.04.1 LTS" | ||
VERSION_ID="18.04" | ||
HOME_URL="https://www.ubuntu.com/" | ||
SUPPORT_URL="https://help.ubuntu.com/" | ||
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" | ||
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" | ||
VERSION_CODENAME=bionic | ||
UBUNTU_CODENAME=bionic |
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,6 @@ | ||
'sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 | ||
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 | ||
udev /dev devtmpfs rw,nosuid,relatime,size=3023708k,nr_inodes=755927,mode=755 0 0 | ||
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 | ||
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=610440k,mode=755 0 0 | ||
/dev/mapper/localhost--vg-root / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0' |
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,6 @@ | ||
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 | ||
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 | ||
udev /dev devtmpfs rw,nosuid,relatime,size=3023708k,nr_inodes=755927,mode=755 0 0 | ||
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 | ||
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0 | ||
/dev/mapper/localhost--vg-root / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0 |
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