Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(user): Allow overriding the default shell #1097

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/apko_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ accounts:
users:
- username: nginx
uid: 10000
shell: /bin/sh
run-as: nginx

# optional environment configuration
Expand Down Expand Up @@ -160,6 +161,7 @@ There are several child elements:
users:
- username: nginx
uid: 10000
shell: /bin/sh
```
- `run-as`: name of the user to run the main process under (should match a username or uid specified in
users)
Expand Down
5 changes: 4 additions & 1 deletion pkg/build/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ func userToUserEntry(user types.User) passwd.UserEntry {
if user.GID == 0 {
user.GID = user.UID
}
if user.Shell == "" {
user.Shell = "/bin/sh"
}
return passwd.UserEntry{
UserName: user.UserName,
UID: user.UID,
GID: user.GID,
HomeDir: "/home/" + user.UserName,
Password: "x",
Info: "Account created by apko",
Shell: "/bin/sh",
Shell: user.Shell,
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/build/types/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@
"gid": {
"type": "integer",
"description": "Required: The user's group ID"
},
"shell": {
"type": "string",
"description": "Required: The user's shell"
}
},
"additionalProperties": false,
Expand Down
2 changes: 2 additions & 0 deletions pkg/build/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type User struct {
UID uint32 `json:"uid,omitempty"`
// Required: The user's group ID
GID uint32 `json:"gid,omitempty"`
// Required: The user's shell
Shell string `json:"shell,omitempty"`
}

type Group struct {
Expand Down
Loading