From 752b779d1f8e2c768144a94f5bb1506ebf7f95c7 Mon Sep 17 00:00:00 2001 From: "Michael (Parker) Parker" Date: Mon, 18 Dec 2023 14:25:48 -0500 Subject: [PATCH] update to make passwd file toggle-able --- config/config.go | 11 ++++------- server/mounts.go | 10 ++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/config/config.go b/config/config.go index a3df219..2493c7b 100644 --- a/config/config.go +++ b/config/config.go @@ -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 @@ -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 diff --git a/server/mounts.go b/server/mounts.go index 077a9bb..1b750e7 100644 --- a/server/mounts.go +++ b/server/mounts.go @@ -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.