From f5ecc05d62aeb253ac609c48c5baa7aac20682fd Mon Sep 17 00:00:00 2001 From: Richard Marshall Date: Fri, 6 Mar 2015 14:16:19 -0800 Subject: [PATCH 1/2] config/system: add shell user attribute This adds support for specifying the login shell of created users. --- config/config_test.go | 5 +++++ config/user.go | 1 + system/user.go | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/config/config_test.go b/config/config_test.go index 71033b7..efcdd18 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -374,6 +374,7 @@ users: no_user_group: true system: y no_log_init: True + shell: /bin/sh ` cfg, err := NewCloudConfig(contents) if err != nil { @@ -441,6 +442,10 @@ users: if !user.NoLogInit { 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) { diff --git a/config/user.go b/config/user.go index 024b6fa..e89a258 100644 --- a/config/user.go +++ b/config/user.go @@ -29,4 +29,5 @@ type User struct { NoUserGroup bool `yaml:"no_user_group"` System bool `yaml:"system"` NoLogInit bool `yaml:"no_log_init"` + Shell string `yaml:"shell"` } diff --git a/system/user.go b/system/user.go index 2f5d85d..3f973c3 100644 --- a/system/user.go +++ b/system/user.go @@ -72,6 +72,10 @@ func CreateUser(u *config.User) error { args = append(args, "--no-log-init") } + if u.Shell != "" { + args = append(args, "--shell", u.Shell) + } + args = append(args, u.Name) output, err := exec.Command("useradd", args...).CombinedOutput() From e8c8b811fe4e265e762b9d86fac231d24998eea6 Mon Sep 17 00:00:00 2001 From: Richard Marshall Date: Fri, 6 Mar 2015 21:12:43 -0800 Subject: [PATCH 2/2] docs: add user shell field --- Documentation/cloud-config.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/cloud-config.md b/Documentation/cloud-config.md index 1256482..feab3cd 100644 --- a/Documentation/cloud-config.md +++ b/Documentation/cloud-config.md @@ -299,6 +299,7 @@ All but the `passwd` and `ssh-authorized-keys` fields will be ignored if the use - **coreos-ssh-import-url**: Authorize SSH keys imported from a url endpoint. - **system**: Create the user as a system user. No home directory will be created. - **no-log-init**: Boolean. Skip initialization of lastlog and faillog databases. +- **shell**: User's login shell. The following fields are not yet implemented: