Diff

Differences From Artifact [c5b01df3b2]:

To Artifact [ca14ca67ab]:


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