]>
src.bluestatic.org Git - armadillo.git/blob - src/paths.go
11 func canonicalizePath(raw_path
string) string {
12 raw_path
= path
.Join(JailRoot
, raw_path
)
13 return path
.Clean(raw_path
)
16 func checkInJail(path
string) bool {
20 func List(the_path
string) (files vector
.StringVector
, err os
.Error
) {
21 full_path
:= canonicalizePath(the_path
)
22 if !checkInJail(full_path
) {
23 return nil, os
.NewError("path outside of jail")
26 fd
, file_error
:= os
.Open(full_path
, os
.O_RDONLY
, 0)
27 if file_error
!= nil {
28 return nil, file_error
31 fileinfos
, read_err
:= fd
.Readdir(-1)
36 for _
, info
:= range fileinfos
{
38 if info
.IsDirectory() {