Skip to content

Commit

Permalink
Merge pull request #157 from yast/fix-no-root
Browse files Browse the repository at this point in the history
Do not crash if root is not defined
  • Loading branch information
imobachgs committed Apr 6, 2018
2 parents 71d2a9b + ac0d4a1 commit 1b48621
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
6 changes: 6 additions & 0 deletions package/yast2-users.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Apr 6 13:34:48 UTC 2018 - igonzalezsosa@suse.com

- Do not crash if root user is not defined (bsc#1088183).
- 3.2.15

-------------------------------------------------------------------
Thu Mar 1 09:36:25 UTC 2018 - mvidner@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-users.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-users
Version: 3.2.14
Version: 3.2.15
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
11 changes: 7 additions & 4 deletions src/modules/Users.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4070,10 +4070,13 @@ sub WriteAuthorizedKeys {
}
}

# Write root authorized keys(bsc#1066342)
my %root_user = %{$modified_users{"system"}{"root"}};
if ($root_user{"modified"} eq "imported") {
SSHAuthorizedKeys->write_keys($root_user{"homeDirectory"});
# Do not crash if 'root' is undefined (bsc#1088183)
if (defined($modified_users{"system"}{"root"})) {
# Write root authorized keys(bsc#1066342)
my %root_user = %{$modified_users{"system"}{"root"}};
if ($root_user{"modified"} eq "imported") {
SSHAuthorizedKeys->write_keys($root_user{"homeDirectory"});
}
}
}

Expand Down
20 changes: 19 additions & 1 deletion test/users_auto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
end

describe "#AutoYaST" do

context "Import" do
before do
allow(Yast::WFM).to receive(:Args).with(no_args).and_return([func,users])
Expand All @@ -44,5 +43,24 @@
end
end
end

context "#Write" do
let(:func) { "Write" }

before do
allow(Yast::WFM).to receive(:Args).with(no_args).and_return([func])
allow(Yast::WFM).to receive(:Args).with(0).and_return(func)
end

context "when root user is not defined" do
before do
Yast::Users.Import({})
end

it "returns true" do
expect(subject.main).to eq(true)
end
end
end
end
end

0 comments on commit 1b48621

Please sign in to comment.