cleanup
This commit is contained in:
parent
c52f37e711
commit
09fab10c7a
@ -5,4 +5,4 @@ dbfile = "dbfile.db"
|
|||||||
filelen = 6
|
filelen = 6
|
||||||
folder = "files"
|
folder = "files"
|
||||||
default_ttl = 86400
|
default_ttl = 86400
|
||||||
maximum_ttl = 432000
|
maximum_ttl = 604800
|
14
main.go
14
main.go
@ -111,7 +111,6 @@ func Exists(path string) bool {
|
|||||||
|
|
||||||
func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// expiry time
|
// expiry time
|
||||||
var name string
|
|
||||||
var ttl int64
|
var ttl int64
|
||||||
|
|
||||||
ttl = 0
|
ttl = 0
|
||||||
@ -150,6 +149,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate + check name
|
// generate + check name
|
||||||
|
var name string
|
||||||
for {
|
for {
|
||||||
id := NameGen()
|
id := NameGen()
|
||||||
name = id + mtype.Extension()
|
name = id + mtype.Extension()
|
||||||
@ -225,24 +225,22 @@ func main() {
|
|||||||
log.Fatal().Err(err).Msg("unable to create database file")
|
log.Fatal().Err(err).Msg("unable to create database file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err := landlock.V2.BestEffort().RestrictPaths(
|
|
||||||
|
if err := landlock.V2.BestEffort().RestrictPaths(
|
||||||
landlock.RWDirs(conf.FileFolder),
|
landlock.RWDirs(conf.FileFolder),
|
||||||
landlock.RWDirs(conf.Webroot),
|
landlock.RWDirs(conf.Webroot),
|
||||||
landlock.RWFiles(conf.DBFile),
|
landlock.RWFiles(conf.DBFile),
|
||||||
)
|
); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Warn().Err(err).Msg("could not landlock")
|
log.Warn().Err(err).Msg("could not landlock")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Open("/etc/passwd")
|
if _, err := os.Open("/etc/passwd"); err != nil {
|
||||||
if err == nil {
|
|
||||||
log.Warn().Msg("landlock failed, could open /etc/passwd, are you on a 5.13+ kernel?")
|
log.Warn().Msg("landlock failed, could open /etc/passwd, are you on a 5.13+ kernel?")
|
||||||
} else {
|
} else {
|
||||||
log.Info().Err(err).Msg("landlocked")
|
log.Info().Err(err).Msg("landlocked")
|
||||||
}
|
}
|
||||||
|
|
||||||
db, err = bolt.Open(conf.DBFile, 0600, nil)
|
db, err := bolt.Open(conf.DBFile, 0600, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("unable to open database file")
|
log.Fatal().Err(err).Msg("unable to open database file")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user