summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-15 02:11:26 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-15 02:11:26 -0500
commitc99eb3f4236ee23fecf7bdff83296b47b6df43ec (patch)
treedeb3ba7a83107b749ebef71a3db1d52de3cc026f
parent32cf169d5a1e2594c60956c61ea9169b84fcc61b (diff)
downloadhorizon-c99eb3f4236ee23fecf7bdff83296b47b6df43ec.tar.gz
horizon-c99eb3f4236ee23fecf7bdff83296b47b6df43ec.tar.bz2
horizon-c99eb3f4236ee23fecf7bdff83296b47b6df43ec.tar.xz
horizon-c99eb3f4236ee23fecf7bdff83296b47b6df43ec.zip
hscript: Ensure user commands are run in the target
-rw-r--r--hscript/user.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/hscript/user.cc b/hscript/user.cc
index 81deafd..de92067 100644
--- a/hscript/user.cc
+++ b/hscript/user.cc
@@ -225,7 +225,9 @@ bool Username::execute() const {
}
#ifdef HAS_INSTALL_ENV
- if(run_command("useradd", {"-c", "Adélie User", "-m", "-U", _value}) != 0)
+ if(run_command("useradd", {"-c", "Adélie User", "-m",
+ "-R", script->targetDirectory(),
+ "-U", _value}) != 0)
{
output_error("installfile:" + std::to_string(line),
"username: failed to create user account");
@@ -267,7 +269,8 @@ bool UserAlias::execute() const {
}
#ifdef HAS_INSTALL_ENV
- if(run_command("usermod", {"-c", _alias, _username}) != 0) {
+ if(run_command("usermod", {"-c", _alias, "-R", script->targetDirectory(),
+ _username}) != 0) {
output_error("installfile:" + std::to_string(line),
"useralias: failed to change GECOS of user " + _username);
return false;
@@ -315,7 +318,9 @@ bool UserPassphrase::execute() const {
}
#ifdef HAS_INSTALL_ENV
- if(run_command("usermod", {"-p", _passphrase, _username}) != 0) {
+ if(run_command("usermod", {"-p", _passphrase,
+ "-R", script->targetDirectory(),
+ _username}) != 0) {
output_error("installfile:" + std::to_string(line),
"userpw: failed to set passphrase for " + _username);
return false;
@@ -473,7 +478,9 @@ bool UserGroups::execute() const {
}
#ifdef HAS_INSTALL_ENV
- if(run_command("usermod", {"-a", "-G", groups, _username}) != 0) {
+ if(run_command("usermod", {"-a", "-G", groups,
+ "-R", script->targetDirectory(),
+ _username}) != 0) {
output_error("installfile:" + std::to_string(line),
"usergroups: failed to add groups to " + _username);
return false;