Skip to content

Commit

Permalink
commands: Ensure we set full path for groupadd
Browse files Browse the repository at this point in the history
This helps with solus-project/solbuild#15

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeydoherty committed Nov 13, 2017
1 parent 221f435 commit 39032fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions commands/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ func ChrootExec(dir, command string) error {

// AddGroup will chroot into the given root and add a group
func AddGroup(root, groupName string, groupID int) error {
cmd := fmt.Sprintf("groupadd -g %d \"%s\"", groupID, groupName)
cmd := fmt.Sprintf("/usr/sbin/groupadd -g %d \"%s\"", groupID, groupName)
return ChrootExec(root, cmd)
}

// AddUser will chroot into the given root and add a user
func AddUser(root, userName, gecos, home, shell string, uid, gid int) error {
cmd := fmt.Sprintf("useradd -m -d \"%s\" -s \"%s\" -u %d -g %d \"%s\" -c \"%s\"",
cmd := fmt.Sprintf("/usr/sbin/useradd -m -d \"%s\" -s \"%s\" -u %d -g %d \"%s\" -c \"%s\"",
home, shell, uid, gid, userName, gecos)
return ChrootExec(root, cmd)
}

// AddSystemUser will chroot into the given root and add a system user
func AddSystemUser(root, userName, gecos, home, shell string, uid, gid int) error {
cmd := fmt.Sprintf("useradd -m -d \"%s\" -r -s \"%s\" -u %d -g %d \"%s\" -c \"%s\"",
cmd := fmt.Sprintf("/usr/sbin/useradd -m -d \"%s\" -r -s \"%s\" -u %d -g %d \"%s\" -c \"%s\"",
home, shell, uid, gid, userName, gecos)
return ChrootExec(root, cmd)
}

0 comments on commit 39032fc

Please sign in to comment.