Skip to content

Commit

Permalink
updated default shell to /bin/sh
Browse files Browse the repository at this point in the history
  • Loading branch information
djcass44 committed Oct 17, 2023
1 parent 1ec4e44 commit 1477338
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/linuxutil/passwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strings"
)

const DefaultShell = "/bin/sh"

// NewUser adds an entry to the /etc/passwd file to create a new Linux
// user.
func NewUser(ctx context.Context, rootfs fs.FullFS, username string, uid int) error {
Expand All @@ -39,7 +41,7 @@ func NewUser(ctx context.Context, rootfs fs.FullFS, username string, uid int) er
log.Error(err, "failed to open passwd file")
return err
}
if _, err := file.Write([]byte(fmt.Sprintf("%s:x:%d:0:Linux User,,,:/home/%s:/sbin/nologin\n", username, uid, username))); err != nil {
if _, err := file.Write([]byte(fmt.Sprintf("%s:x:%d:0:Linux User,,,:/home/%s:%s\n", username, uid, username, DefaultShell))); err != nil {
log.Error(err, "failed to write to passwd file")
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/linuxutil/testdata/existing
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ ntp:x:123:123:NTP:/var/empty:/sbin/nologin
smmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin
somebody:x:1001:0:Linux User,,,:/home/somebody:/sbin/nologin
somebody:x:1001:0:Linux User,,,:/home/somebody:/bin/sh
2 changes: 1 addition & 1 deletion pkg/linuxutil/testdata/single
Original file line number Diff line number Diff line change
@@ -1 +1 @@
somebody:x:1001:0:Linux User,,,:/home/somebody:/sbin/nologin
somebody:x:1001:0:Linux User,,,:/home/somebody:/bin/sh

0 comments on commit 1477338

Please sign in to comment.