summaryrefslogtreecommitdiff
path: root/src/helsinki.at
diff options
context:
space:
mode:
Diffstat (limited to 'src/helsinki.at')
-rw-r--r--src/helsinki.at/rhimport/fetcher.go11
-rw-r--r--src/helsinki.at/rhimportd/ctrlWebSimple.go4
2 files changed, 15 insertions, 0 deletions
diff --git a/src/helsinki.at/rhimport/fetcher.go b/src/helsinki.at/rhimport/fetcher.go
index 05074b1..a86f7ca 100644
--- a/src/helsinki.at/rhimport/fetcher.go
+++ b/src/helsinki.at/rhimport/fetcher.go
@@ -128,6 +128,11 @@ func FetchFileCurl(ctx *ImportContext, uri *url.URL) (err error) {
return
}
+// TODO: check path to import from -> don't touch problematic files like /etc/shadow...
+// the daemon shouldn't be running as a user who can do any harm anyway
+// still: let's make a special configurable directory the local:/// dir
+// and only allow absolute paths here which will be based on the
+// 'local' directory
func FetchFileLocal(ctx *ImportContext, uri *url.URL) (err error) {
rhl.Printf("Local fetcher called for '%s'", ctx.SourceUri)
if ctx.ProgressCallBack != nil {
@@ -141,6 +146,11 @@ func FetchFileLocal(ctx *ImportContext, uri *url.URL) (err error) {
type FetchFunc func(*ImportContext, *url.URL) (err error)
+
+// TODO: implement fetchers for:
+// archiv://
+// public://
+// home:// ?????
var (
fetchers = map[string]FetchFunc{
"local": FetchFileLocal,
@@ -170,6 +180,7 @@ func fetcher_init() {
}
}
+// TODO: make sure a (partially) fetched file get's deleted on error
func FetchFile(ctx *ImportContext) (err error) {
var uri *url.URL
diff --git a/src/helsinki.at/rhimportd/ctrlWebSimple.go b/src/helsinki.at/rhimportd/ctrlWebSimple.go
index 3f9c48d..a57e8c5 100644
--- a/src/helsinki.at/rhimportd/ctrlWebSimple.go
+++ b/src/helsinki.at/rhimportd/ctrlWebSimple.go
@@ -108,6 +108,10 @@ func webSimpleHandler(conf *rhimport.Config, rddb *rhimport.RdDb, trusted bool,
return
}
+ // TODO: add a sanity check for the context:
+ // it would be nice to know whether a request is bogus
+ // *before* we fetch a big file!
+
if err = rhimport.FetchFile(ctx); err != nil {
webSimpleErrorResponse(w, http.StatusInternalServerError, err.Error())
return