Skip to content

Commit

Permalink
Change adduser to useradd
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Oct 21, 2023
1 parent f2b5dae commit d68cc39
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/post_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ func SetTimezone(targetRoot, tz string) error {
}

func AddUser(targetRoot, username, fullname string, groups []string, withPassword bool, password ...string) error {
// TODO: "adduser" isn't distro agnostic. Change to "useradd"?
adduserCmd := "adduser --quiet --disabled-password --shell /bin/bash --gecos \"%s\" %s"
adduserCmd := "useradd --shell /bin/bash %s && usermod -c \"%s\" %s"

var err error
if targetRoot != "" {
err = RunInChroot(targetRoot, fmt.Sprintf(adduserCmd, fullname, username))
err = RunInChroot(targetRoot, fmt.Sprintf(adduserCmd, username, fullname, username))
} else {
err = RunCommand(fmt.Sprintf(adduserCmd, fullname, username))
err = RunCommand(fmt.Sprintf(adduserCmd, username, fullname, username))
}
if err != nil {
return fmt.Errorf("Failed to create user: %s", err)
Expand Down

0 comments on commit d68cc39

Please sign in to comment.