// 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)
}
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")
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")
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) {
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 {
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 {
}
case "mkdir":
path := request.FormValue("path")
- err := paths.MakeDir(path)
+ err := MakeDir(path)
if err != nil {
errorResponse(response, err.Error())
} else {
}
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() {