Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
delorean committed Jan 16, 2024
1 parent c52f37e commit 09fab10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ dbfile = "dbfile.db"
filelen = 6
folder = "files"
default_ttl = 86400
maximum_ttl = 432000
maximum_ttl = 604800
14 changes: 6 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func Exists(path string) bool {

func UploadHandler(w http.ResponseWriter, r *http.Request) {
// expiry time
var name string
var ttl int64

ttl = 0
Expand Down Expand Up @@ -150,6 +149,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
}

// generate + check name
var name string
for {
id := NameGen()
name = id + mtype.Extension()
Expand Down Expand Up @@ -225,24 +225,22 @@ func main() {
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.Webroot),
landlock.RWFiles(conf.DBFile),
)

if err != nil {
); err != nil {
log.Warn().Err(err).Msg("could not landlock")
}

_, err = os.Open("/etc/passwd")
if err == nil {
if _, err := os.Open("/etc/passwd"); err != nil {
log.Warn().Msg("landlock failed, could open /etc/passwd, are you on a 5.13+ kernel?")
} else {
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 {
log.Fatal().Err(err).Msg("unable to open database file")
}
Expand Down

0 comments on commit 09fab10

Please sign in to comment.