Skip to content

Commit

Permalink
update to make passwd file toggle-able
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervcp committed Dec 18, 2023
1 parent cc0dca4 commit 752b779
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 4 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ type SystemConfiguration struct {
Uid int `yaml:"uid"`
Gid int `yaml:"gid"`

Login bool `yaml:"login"`
// Passwd controls weather a passwd file is mounted in the container
// at /etc/passwd to resolve missing user issues
Passwd bool `json:"mount_passwd" yaml:"mount_passwd" default:"true"`
} `yaml:"user"`

// The amount of time in seconds that can elapse before a server's disk space calculation is
Expand Down Expand Up @@ -532,13 +534,8 @@ func ConfigureDirectories() error {
if passwd, err := os.Create("/etc/pterodactyl/passwd"); err != nil {
return err
} else {
shell := "/usr/sbin/nologin"
if _config.System.User.Login {
shell = "/bin/sh"
}

// the WriteFile method returns an error if unsuccessful
err := os.WriteFile(passwd.Name(), []byte(fmt.Sprintf("container:x:%d:%d::/home/container:%s", _config.System.User.Uid, _config.System.User.Gid, shell)), 0777)
err := os.WriteFile(passwd.Name(), []byte(fmt.Sprintf("container:x:%d:%d::/home/container:/usr/sbin/nologin", _config.System.User.Uid, _config.System.User.Gid)), 0755)
// handle this error
if err != nil {
// print it out
Expand Down
10 changes: 8 additions & 2 deletions server/mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ func (s *Server) Mounts() []environment.Mount {
Source: s.Filesystem().Path(),
ReadOnly: false,
},
{
}

// Mount passwd file if set to true
if config.Get().System.User.Passwd {
passwdMount := environment.Mount{
Default: true,
Target: "/etc/passwd",
Source: "/etc/pterodactyl/passwd",
ReadOnly: true,
},
}

m = append(m, passwdMount)
}

// Also include any of this server's custom mounts when returning them.
Expand Down

0 comments on commit 752b779

Please sign in to comment.