Fix bugs, many other changes
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: file:///srv/svn/repo/mai/trunk@67 e410bdd4-646f-c54f-a7ce-fffcc4f439ae
This commit is contained in:
@@ -21,13 +21,13 @@ import (
|
||||
)
|
||||
var (
|
||||
configfile string
|
||||
groupname string
|
||||
username string
|
||||
)
|
||||
var conf struct {
|
||||
group string
|
||||
listen string
|
||||
staticpath string
|
||||
tmplpath string
|
||||
user string
|
||||
}
|
||||
func main() {
|
||||
parseFlags()
|
||||
@@ -41,8 +41,8 @@ func main() {
|
||||
conf.staticpath = "./static"
|
||||
conf.tmplpath = "./views"
|
||||
|
||||
if conf.user != "" {
|
||||
uid, gid, err := usergroupids(conf.user, conf.group)
|
||||
if username != "" {
|
||||
uid, gid, err := usergroupids(username, groupname)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
@@ -258,6 +258,9 @@ func main() {
|
||||
}
|
||||
}
|
||||
})
|
||||
app.Get("/robots.txt", func(c *fiber.Ctx) error {
|
||||
return c.SendString("User-Agent: *\nDisallow: /\n")
|
||||
})
|
||||
app.Get("/version", func(c *fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{
|
||||
"fiberversion": fiber.Version,
|
||||
|
||||
@@ -7,5 +7,7 @@ import (
|
||||
|
||||
func parseFlags() {
|
||||
flag.StringVar(&configfile, "f", "", "Configuration file")
|
||||
flag.StringVar(&username, "u", "", "Sets the user to which privilege dropping is done")
|
||||
flag.StringVar(&groupname, "g", "", "Sets the group to which privilege dropping is done")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
@@ -10,11 +10,9 @@ func readConf(file string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
conf.group = cfg.Section("mai").Key("group").String()
|
||||
conf.listen = cfg.Section("mai").Key("listen").String()
|
||||
conf.staticpath = cfg.Section("mai").Key("static").String()
|
||||
conf.tmplpath = cfg.Section("mai").Key("templates").String()
|
||||
conf.user = cfg.Section("mai").Key("user").String()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func usergroupids(username string, groupname string) (int, int, error) {
|
||||
uid, _ := strconv.Atoi(u.Uid)
|
||||
gid, _ := strconv.Atoi(u.Gid)
|
||||
|
||||
if conf.group != "" {
|
||||
if groupname != "" {
|
||||
g, err := user.LookupGroup(groupname)
|
||||
if err != nil {
|
||||
return uid, -1, err
|
||||
|
||||
Reference in New Issue
Block a user