UserCommands: add field CreateUserHome
This commit is contained in:
@ -15,7 +15,7 @@ func (l LinuxUserManager) NewLinuxManager() *LinuxUserManager {
|
||||
}
|
||||
|
||||
// AddUser adds a new user to the system.
|
||||
func (l LinuxUserManager) AddUser(username, homeDir, shell string, isSystem bool, groups, args []string) (string, []string) {
|
||||
func (l LinuxUserManager) AddUser(username, homeDir, shell string, createHome, isSystem bool, groups, args []string) (string, []string) {
|
||||
baseArgs := []string{}
|
||||
|
||||
if isSystem {
|
||||
@ -38,6 +38,11 @@ func (l LinuxUserManager) AddUser(username, homeDir, shell string, isSystem bool
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
|
||||
if createHome {
|
||||
baseArgs = append(baseArgs, "-m")
|
||||
|
||||
}
|
||||
|
||||
args = append(baseArgs, username)
|
||||
|
||||
cmd := "useradd"
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// UserManager defines the interface for user management operations.
|
||||
// All functions but one return a string for the command and any args.
|
||||
type UserManager interface {
|
||||
AddUser(username, homeDir, shell string, isSystem bool, groups, args []string) (string, []string)
|
||||
AddUser(username, homeDir, shell string, createHome, isSystem bool, groups, args []string) (string, []string)
|
||||
RemoveUser(username string) (string, []string)
|
||||
ModifyUser(username, homeDir, shell string, groups []string) (string, []string)
|
||||
// Modify password uses chpasswd for Linux systems to build the command to change the password
|
||||
|
Reference in New Issue
Block a user