summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-15 02:29:01 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-15 02:29:01 -0500
commit46af8229026a6122ca640f063c24d68876acdb11 (patch)
tree168f6993708f254a940dff521f52c03bb0aeb59a
parent5ae043001202cd064334c3c826ba3c4f656699ec (diff)
downloadhorizon-46af8229026a6122ca640f063c24d68876acdb11.tar.gz
horizon-46af8229026a6122ca640f063c24d68876acdb11.tar.bz2
horizon-46af8229026a6122ca640f063c24d68876acdb11.tar.xz
horizon-46af8229026a6122ca640f063c24d68876acdb11.zip
hscript: Ensure user commands are correct in simulator
-rw-r--r--hscript/user.cc13
-rw-r--r--tests/spec/simulator_spec.rb22
2 files changed, 20 insertions, 15 deletions
diff --git a/hscript/user.cc b/hscript/user.cc
index de92067..0dc4eba 100644
--- a/hscript/user.cc
+++ b/hscript/user.cc
@@ -219,7 +219,8 @@ bool Username::execute() const {
"username: creating account " + _value);
if(script->options().test(Simulate)) {
- std::cout << "useradd -c \"Adélie User\" -m -U " << _value
+ std::cout << "useradd -c \"Adélie User\" -m -R "
+ << script->targetDirectory() << " -U " << _value
<< std::endl;
return true;
}
@@ -263,7 +264,8 @@ bool UserAlias::execute() const {
"useralias: setting GECOS name for " + _username);
if(script->options().test(Simulate)) {
- std::cout << "usermod -c \"" << _alias << "\" " << _username
+ std::cout << "usermod -c \"" << _alias << "\" "
+ << "-R " << script->targetDirectory() << " " << _username
<< std::endl;
return true;
}
@@ -312,7 +314,8 @@ bool UserPassphrase::execute() const {
"userpw: setting passphrase for " + _username);
if(script->options().test(Simulate)) {
- std::cout << "usermod -p '" << _passphrase << "' " << _username
+ std::cout << "usermod -p '" << _passphrase << "' "
+ << "-R " << script->targetDirectory() << " " << _username
<< std::endl;
return true;
}
@@ -473,7 +476,9 @@ bool UserGroups::execute() const {
groups.pop_back();
if(script->options().test(Simulate)) {
- std::cout << "usermod -aG " << groups << " " << _username << std::endl;
+ std::cout << "usermod -aG " << groups
+ << "-R " << script->targetDirectory()
+ << " " << _username << std::endl;
return true;
}
diff --git a/tests/spec/simulator_spec.rb b/tests/spec/simulator_spec.rb
index 1206ab2..60e0186 100644
--- a/tests/spec/simulator_spec.rb
+++ b/tests/spec/simulator_spec.rb
@@ -335,29 +335,29 @@ printf '%s\\t%s\\t%s\\t%s\\t0\\t0\\n' /dev/gwyn/source /usr/src auto noatime >>
it "creates the user account" do
use_fixture '0082-username-basic.installfile'
run_simulate
- expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -U chris')
- expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -U kayla')
- expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -U meg')
- expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -U steph')
- expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -U amanda')
+ expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -R /target -U chris')
+ expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -R /target -U kayla')
+ expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -R /target -U meg')
+ expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -R /target -U steph')
+ expect(last_command_started.stdout).to include('useradd -c "Adélie User" -m -R /target -U amanda')
end
end
context "simulating 'useralias' execution" do
it "sets aliases on all named accounts" do
use_fixture '0087-useralias-basic.installfile'
run_simulate
- expect(last_command_started.stdout).to include('usermod -c "Christopher" chris')
- expect(last_command_started.stdout).to include('usermod -c "Kayla" kayla')
- expect(last_command_started.stdout).to include('usermod -c "Meaghan" meg')
- expect(last_command_started.stdout).to include('usermod -c "Stephanie" steph')
- expect(last_command_started.stdout).to include('usermod -c "Amanda Jane" amanda')
+ expect(last_command_started.stdout).to include('usermod -c "Christopher" -R /target chris')
+ expect(last_command_started.stdout).to include('usermod -c "Kayla" -R /target kayla')
+ expect(last_command_started.stdout).to include('usermod -c "Meaghan" -R /target meg')
+ expect(last_command_started.stdout).to include('usermod -c "Stephanie" -R /target steph')
+ expect(last_command_started.stdout).to include('usermod -c "Amanda Jane" -R /target amanda')
end
end
context "simulating 'userpw' execution" do
it "sets the user's passphrase" do
use_fixture '0091-userpw-basic.installfile'
run_simulate
- expect(last_command_started.stdout).to include("usermod -p '$6$UZJm/vBmVgyIdMZr$ppKEulz/HY0/e7RcXXujQbcqDXkUYgIqNEVPQJO6.le9kUpz8GvvRezY3ifqUUEwjhSo9tTOMG7lhqjn8gGpH0' awilfox")
+ expect(last_command_started.stdout).to include("usermod -p '$6$UZJm/vBmVgyIdMZr$ppKEulz/HY0/e7RcXXujQbcqDXkUYgIqNEVPQJO6.le9kUpz8GvvRezY3ifqUUEwjhSo9tTOMG7lhqjn8gGpH0' -R /target awilfox")
end
end
context "simulating 'usergroups' execution" do