36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
+
+
+
+
+
+
+
+
+
|
return "http://$hostname/appfs/$method/$hash"
}
# User-replaceable function get the home directory of the current user
proc get_homedir {} {
return [::appfsd::get_homedir]
}
# User-replacable function to update permissions
proc change_perms {file perms} {
if {[info exists ::appfs::user::add_perms($file)]} {
append perms $::appfs::user::add_perms($file)
}
return $perms
}
}
namespace eval ::appfs {
variable cachedir "/tmp/appfs-cache"
variable ttl 3600
variable nttl 60
variable trusted_cas [list]
|
751
752
753
754
755
756
757
758
759
760
761
762
763
764
|
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
|
+
+
+
+
|
"directory" {
set retval(type) "directory"
set retval(childcount) [llength [getchildren $path]]
}
"file" {
set retval(type) "file"
set retval(size) $localpathinfo(size)
# Once the user writes to a file, all its other
# attributes (such as suid) are lost
_as_user {
if {[file executable $localpath]} {
set retval(perms) "x-"
} else {
set retval(perms) "-"
}
}
|
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
|
+
+
+
+
+
|
set file [lindex $work end]
if {$directory == "" && $file == ""} {
array set retval [list type directory]
}
::appfs::db eval {SELECT type, time, source, size, perms FROM files WHERE package_sha1 = $pathinfo(package_sha1) AND file_directory = $directory AND file_name = $file;} retval {}
# Allow an administrator to supply additional permissions to remote files
if {[info exists retval(perms)]} {
set retval(perms) [::appfs::user::change_perms $path $retval(perms)]
}
if {[info exists retval(type)] && $retval(type) == "directory"} {
set retval(childcount) [llength [getchildren $path]]
}
unset -nocomplain retval(*)
}
|