From f5ecc05d62aeb253ac609c48c5baa7aac20682fd Mon Sep 17 00:00:00 2001 From: Richard Marshall Date: Fri, 6 Mar 2015 14:16:19 -0800 Subject: [PATCH 1/4] 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/4] 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: From a9e894013285217d96f50ac34bc21d2f6d69006c Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Wed, 1 Apr 2015 14:58:09 -0700 Subject: [PATCH 3/4] coreos-cloudinit: bump to v1.3.4 --- coreos-cloudinit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreos-cloudinit.go b/coreos-cloudinit.go index 50be23b..c8642c1 100644 --- a/coreos-cloudinit.go +++ b/coreos-cloudinit.go @@ -39,7 +39,7 @@ import ( ) const ( - version = "1.3.3+git" + version = "1.3.4" datasourceInterval = 100 * time.Millisecond datasourceMaxInterval = 30 * time.Second datasourceTimeout = 5 * time.Minute From 5b159fcf564f54c57957971ed01a8a143595ca16 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Wed, 1 Apr 2015 14:58:25 -0700 Subject: [PATCH 4/4] coreos-cloudinit: bump to v1.3.4+git --- coreos-cloudinit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreos-cloudinit.go b/coreos-cloudinit.go index c8642c1..617c715 100644 --- a/coreos-cloudinit.go +++ b/coreos-cloudinit.go @@ -39,7 +39,7 @@ import ( ) const ( - version = "1.3.4" + version = "1.3.4+git" datasourceInterval = 100 * time.Millisecond datasourceMaxInterval = 30 * time.Second datasourceTimeout = 5 * time.Minute