- Timestamp:
- Jan 21, 2024, 3:23:44 AM (17 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r61 r63 1 1 PREFIX ?= /usr/local 2 GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT}" 3 VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "VERSION"` 4 COMMIT = `git rev-parse --short HEAD || echo "COMMIT"` 2 5 3 6 build: 4 go build -v./cmd/mai7 go build ${GOFLAGS} ./cmd/mai 5 8 clean: 6 9 rm -f mai -
trunk/cmd/mai/flag.go
r59 r63 8 8 func parseFlags() { 9 9 flag.StringVar(&configfile, "f", "", "Configuration file") 10 flag.BoolVar(&verbose, "v", false, "Verbose logging") 10 11 flag.Parse() 11 12 } -
trunk/cmd/mai/main.go
r62 r63 3 3 import ( 4 4 "bytes" 5 "fmt" 5 6 "net/http" 6 7 "net/url" … … 8 9 "time" 9 10 "runtime" 10 11 "syscall" 12 13 "marisa.chaotic.ninja/mai" 11 14 "marisa.chaotic.ninja/mai/engines" 15 12 16 "github.com/gofiber/fiber/v2" 13 17 "github.com/gofiber/fiber/v2/middleware/logger" … … 17 21 var ( 18 22 configfile string 23 verbose bool 19 24 ) 20 25 var conf struct { 26 group string 21 27 listen string 22 redisuri string23 28 staticpath string 24 29 tmplpath string 30 user string 25 31 } 26 32 func main() { … … 28 34 29 35 if configfile != "" { 36 if verbose { 37 fmt.Printf("[mai] Reading configuration file") 38 } 30 39 readConf(configfile) 31 40 } … … 35 44 conf.staticpath = "./static" 36 45 conf.tmplpath = "./views" 46 47 if conf.user != "" { 48 if verbose { 49 fmt.Printf("[mai] Dropping privileges to %s", conf.user) 50 } 51 uid, gid, err := usergroupids(conf.user, conf.group) 52 if err != nil { 53 fmt.Println(err) 54 os.Exit(1) 55 } 56 syscall.Setuid(uid) 57 syscall.Setgid(gid) 58 } 37 59 38 60 engine := html.New(conf.tmplpath, ".html") … … 266 288 }) 267 289 app.Listen(conf.listen) 290 291 if verbose { 292 fmt.Printf("Starting mai %v\n", mai.FullVersion()) 293 fmt.Printf("Listening on %s", conf.listen) 294 } 268 295 } -
trunk/cmd/mai/readconf.go
r61 r63 12 12 } 13 13 14 conf.group = cfg.Section("mai").Key("group").String() 14 15 conf.listen = cfg.Section("mai").Key("listen").String() 15 16 conf.staticpath = cfg.Section("mai").Key("static").String() 16 17 conf.tmplpath = cfg.Section("mai").Key("templates").String() 18 conf.user = cfg.Section("mai").Key("user").String() 17 19 18 20 return nil -
trunk/mai.ini.5
r61 r63 8 8 .Ss [mai] section 9 9 .Bl -tag -width 11n 10 .It group 11 Group ID for dropping privileges to. 12 If unset, assume the GID of user 10 13 .It listen 11 14 HTTP port for the server to listen. … … 17 20 Directory where the templates are located. 18 21 Default is "./views" 22 .It user 23 User ID for dropping privileges to. 19 24 .El 20 25 .Sh ENVIRONMENT
Note:
See TracChangeset
for help on using the changeset viewer.