Changeset 27 in code for trunk/partage.go


Ignore:
Timestamp:
Oct 19, 2021, 6:57:32 AM (4 years ago)
Author:
dev
Message:

Add option to chroot into a directory on startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/partage.go

    r26 r27  
    1010        "time"
    1111        "path"
     12        "syscall"
    1213        "path/filepath"
    1314        "html/template"
     
    3637        metapath string
    3738        rootdir  string
     39        chroot   string
    3840        templatedir string
    3941        filectx  string
     
    223225        flag.StringVar(&conf.metactx,     "metactx",     "/m/", "Context to serve metadata from (default: /m/)")
    224226        flag.StringVar(&conf.rootdir,     "rootdir",     "./static", "Root directory (default: ./static)")
     227        flag.StringVar(&conf.chroot,      "chroot",      "", "Directory to chroot into upon starting (default: no chroot)")
    225228        flag.StringVar(&conf.templatedir, "templatedir", "./templates", "Templates directory (default: ./templates)")
    226229        flag.Int64Var(&conf.maxsize,      "maxsize",     30064771072, "Maximum file size (default: 28Gib)")
     
    229232        iniflags.Parse()
    230233
     234        if (conf.chroot != "") {
     235                syscall.Chroot(conf.chroot)
     236        }
     237
    231238        http.HandleFunc("/", uploader)
    232239        http.Handle(conf.filectx, http.StripPrefix(conf.filectx, http.FileServer(http.Dir(conf.filepath))))
Note: See TracChangeset for help on using the changeset viewer.