Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/facter/root_home.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class << self
def get_root_home
root_ent = Facter::Util::Resolution.exec("getent passwd root")
# The home directory is the sixth element in the passwd entry
root_ent.split(":")[5]
# If the platform doesn't have getent, root_ent will be nil and we should
# return it straight away.
root_ent && root_ent.split(":")[5]
end
end
end
Expand Down
12 changes: 5 additions & 7 deletions spec/unit/facter/root_home_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@
end
end
context "windows" do
let(:root_ent) { "FIXME TBD on Windows" }
let(:expected_root_home) { "FIXME TBD on Windows" }

it "should return FIXME TBD on windows" do
pending "FIXME: TBD on windows"
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
Facter::Util::RootHome.get_root_home.should == expected_root_home
before :each do
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
end
it "should be nil on windows" do
Facter::Util::RootHome.get_root_home.should be_nil
end
end
end