Skip to content

Commit 32bad79

Browse files
committed
Merge pull request #45 from jeffmccune/ticket/2.3.x/12357_disable_root_home_fact_on_windows
(#12357) Fix root_home fact on Windows
2 parents c0ac470 + afd22dd commit 32bad79

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/facter/root_home.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class << self
77
def get_root_home
88
root_ent = Facter::Util::Resolution.exec("getent passwd root")
99
# The home directory is the sixth element in the passwd entry
10-
root_ent.split(":")[5]
10+
# If the platform doesn't have getent, root_ent will be nil and we should
11+
# return it straight away.
12+
root_ent && root_ent.split(":")[5]
1113
end
1214
end
1315
end

spec/unit/facter/root_home_spec.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
end
3131
end
3232
context "windows" do
33-
let(:root_ent) { "FIXME TBD on Windows" }
34-
let(:expected_root_home) { "FIXME TBD on Windows" }
35-
36-
it "should return FIXME TBD on windows" do
37-
pending "FIXME: TBD on windows"
38-
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
39-
Facter::Util::RootHome.get_root_home.should == expected_root_home
33+
before :each do
34+
Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
35+
end
36+
it "should be nil on windows" do
37+
Facter::Util::RootHome.get_root_home.should be_nil
4038
end
4139
end
4240
end

0 commit comments

Comments
 (0)