Merge pull request #326 from richardmarshall/user_shell_config
config/system: add shell user attribute
This commit is contained in:
		| @@ -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: | ||||
|  | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -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"` | ||||
| } | ||||
|   | ||||
| @@ -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() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user