config/system: add shell user attribute
This adds support for specifying the login shell of created users.
This commit is contained in:
parent
66a2f00679
commit
f5ecc05d62
@ -374,6 +374,7 @@ users:
|
|||||||
no_user_group: true
|
no_user_group: true
|
||||||
system: y
|
system: y
|
||||||
no_log_init: True
|
no_log_init: True
|
||||||
|
shell: /bin/sh
|
||||||
`
|
`
|
||||||
cfg, err := NewCloudConfig(contents)
|
cfg, err := NewCloudConfig(contents)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -441,6 +442,10 @@ users:
|
|||||||
if !user.NoLogInit {
|
if !user.NoLogInit {
|
||||||
t.Errorf("Failed to parse no_log_init field")
|
t.Errorf("Failed to parse no_log_init field")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.Shell != "/bin/sh" {
|
||||||
|
t.Errorf("Failed to parse shell field, got %q", user.Shell)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCloudConfigUsersGithubUser(t *testing.T) {
|
func TestCloudConfigUsersGithubUser(t *testing.T) {
|
||||||
|
@ -29,4 +29,5 @@ type User struct {
|
|||||||
NoUserGroup bool `yaml:"no_user_group"`
|
NoUserGroup bool `yaml:"no_user_group"`
|
||||||
System bool `yaml:"system"`
|
System bool `yaml:"system"`
|
||||||
NoLogInit bool `yaml:"no_log_init"`
|
NoLogInit bool `yaml:"no_log_init"`
|
||||||
|
Shell string `yaml:"shell"`
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,10 @@ func CreateUser(u *config.User) error {
|
|||||||
args = append(args, "--no-log-init")
|
args = append(args, "--no-log-init")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if u.Shell != "" {
|
||||||
|
args = append(args, "--shell", u.Shell)
|
||||||
|
}
|
||||||
|
|
||||||
args = append(args, u.Name)
|
args = append(args, u.Name)
|
||||||
|
|
||||||
output, err := exec.Command("useradd", args...).CombinedOutput()
|
output, err := exec.Command("useradd", args...).CombinedOutput()
|
||||||
|
Loading…
Reference in New Issue
Block a user