Skip to content

Commit

Permalink
Merge pull request #236 from subutai-io/dev
Browse files Browse the repository at this point in the history
Allow subutai user delete other's artifacts
  • Loading branch information
crioto authored Feb 9, 2018
2 parents 7e2946b + bac08da commit 457f2f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ func Info(id string) map[string]string {
}
return nil
})
list["id"] = id
if len(list) != 0 {
list["id"] = id
}
return list
}

Expand Down
5 changes: 3 additions & 2 deletions upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ func Delete(w http.ResponseWriter, r *http.Request) string {
w.Write([]byte("Bad request"))
return ""
}

if db.CheckRepo(user, repo[3], id) == 0 {
if db.CheckRepo(user, repo[3], id) == 0 && user != "subutai" {
log.Warn("File " + info["name"] + "(" + id + ") in " + repo[3] + " repo is not owned by " + user + ", rejecting deletion request")
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("File " + info["name"] + " not found or it has different owner"))
return ""
}
user = db.FileField(id, "owner")[0]

md5, _ := db.Hash(id)
f, err := os.Stat(config.Storage.Path + md5)
if !log.Check(log.WarnLevel, "Reading file stats", err) {
Expand Down

0 comments on commit 457f2f3

Please sign in to comment.