From 025decc3d74f7ba860e8bb89903646af1a799aa5 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 3 Apr 2012 09:09:28 -0400 Subject: [PATCH] Remove paths. prefix from call sites --- main.go | 2 +- server/paths.go | 8 ++++---- server/server.go | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index fec5411..5fe6ef4 100644 --- a/main.go +++ b/main.go @@ -53,6 +53,6 @@ func main() { // Run the server. fmt.Printf("Starting Armadillo on port %d with root:\n %v\n", configuration.Port, configuration.JailRoot) - paths.SetConfig(configuration) + server.SetConfig(configuration) server.RunBackEnd(configuration) } diff --git a/server/paths.go b/server/paths.go index b18359e..ee46174 100644 --- a/server/paths.go +++ b/server/paths.go @@ -41,13 +41,13 @@ func checkInJail(the_path string) bool { return true } -func IsValid(path string) (bool, string) { +func IsValidPathPath(path string) (bool, string) { path = canonicalizePath(path) _, err := os.Lstat(path) return err == nil && checkInJail(path), path } -func List(the_path string) (files []string, err error) { +func ListPath(the_path string) (files []string, err error) { full_path := canonicalizePath(the_path) if !checkInJail(full_path) { return nil, errors.New("Path outside of jail") @@ -77,7 +77,7 @@ func List(the_path string) (files []string, err error) { return files, nil } -func Remove(the_path string) error { +func RemovePath(the_path string) error { full_path := canonicalizePath(the_path) if !checkInJail(full_path) { return errors.New("Path outside of jail") @@ -85,7 +85,7 @@ func Remove(the_path string) error { return os.RemoveAll(full_path) } -func Move(source string, target string) error { +func MovePath(source string, target string) error { source = canonicalizePath(source) target = canonicalizePath(target) if !checkInJail(source) { diff --git a/server/server.go b/server/server.go index 88ad930..d508290 100644 --- a/server/server.go +++ b/server/server.go @@ -47,14 +47,14 @@ func serviceHandler(response http.ResponseWriter, request *http.Request) { switch request.FormValue("action") { case "list": - files, err := paths.List(request.FormValue("path")) + files, err := ListPath(request.FormValue("path")) if err != nil { errorResponse(response, err.Error()) } else { okResponse(response, files) } case "remove": - err := paths.Remove(request.FormValue("path")) + err := RemovePath(request.FormValue("path")) if err != nil { errorResponse(response, err.Error()) } else { @@ -66,7 +66,7 @@ func serviceHandler(response http.ResponseWriter, request *http.Request) { case "move": source := request.FormValue("source") target := request.FormValue("target") - err := paths.Move(source, target) + err := MovePath(source, target) if err != nil { errorResponse(response, err.Error()) } else { @@ -78,7 +78,7 @@ func serviceHandler(response http.ResponseWriter, request *http.Request) { } case "mkdir": path := request.FormValue("path") - err := paths.MakeDir(path) + err := MakeDir(path) if err != nil { errorResponse(response, err.Error()) } else { @@ -158,7 +158,7 @@ func performProxy(url_ *url.URL, response http.ResponseWriter, origRequest *http } func downloadHandler(response http.ResponseWriter, request *http.Request) { - valid, fullPath := paths.IsValid(request.FormValue("path")) + valid, fullPath := IsValidPath(request.FormValue("path")) if valid { info, _ := os.Lstat(fullPath) // Error is already checked by |valid|. if info.IsDir() { -- 2.43.5