1
1
Fork 0
mirror of https://tildegit.org/solderpunk/molly-brown synced 2024-04-28 06:45:03 +02:00

Make unprivileged user configurable, thanks nervuri! (see issue #16)

This commit is contained in:
Solderpunk 2023-02-15 21:16:49 +01:00
parent c0c67f7ba6
commit 182e58ffe3
3 changed files with 8 additions and 3 deletions

View File

@ -395,6 +395,9 @@ facility.
chroot happens immediately after reading the config file. All other
paths specified in the config file (e.g. `DocBase`, `KeyPath`,
`AccessLog`) must be specified relative to `ChrootDir`.
* `UnprivUsername`: The username of an unprivileged user on the system
which MollyBrown will change setuid() to if started by the superuser
or when run as a setuid binary (default value "nobody").
## .molly files

View File

@ -17,6 +17,7 @@ type Config struct {
DocBase string
HomeDocBase string
ChrootDir string
UnprivUsername string
GeminiExt string
DefaultLang string
DefaultEncoding string
@ -61,6 +62,7 @@ func getConfig(filename string) (Config, error) {
config.DocBase = "/var/gemini/"
config.HomeDocBase = "users"
config.ChrootDir = ""
config.UnprivUsername = "nobody"
config.GeminiExt = "gmi"
config.DefaultLang = ""
config.DefaultEncoding = ""

View File

@ -47,13 +47,13 @@ func main() {
uid := os.Getuid()
nobody_uid := -1
if uid == 0 {
nobody_user, err := user.Lookup("nobody")
nobody_user, err := user.Lookup(config.UnprivUsername)
if err != nil {
log.Fatal("Running as root but could not lookup UID for user " + "nobody" + ": " + err.Error())
log.Fatal("Running as root but could not lookup UID for user " + config.UnprivUsername + ": " + err.Error())
}
nobody_uid, err = strconv.Atoi(nobody_user.Uid)
if err != nil {
log.Fatal("Running as root but could not lookup UID fr user " + "nobody" + ": " + err.Error())
log.Fatal("Running as root but could not lookup UID for user " + config.UnprivUsername + ": " + err.Error())
}
}