Diff

Differences From Artifact [388927f9ca]:

To Artifact [647fdab61a]:


   646    646   	}
   647    647   
   648    648   	if (uid >= 0) {
   649    649   		retval += uid;
   650    650   		retval++;
   651    651   	}
   652    652   
          653  +	APPFS_DEBUG("Looked up inode number for path=%s,uid=%i: %u", path, uid, retval);
          654  +
   653    655   	return(retval);
   654    656   }
   655    657   
   656    658   /*
   657    659    * Cache Get Path Info lookups for speed
   658    660    */
   659    661   static int appfs_get_path_info_cache_get(const char *path, uid_t uid, struct appfs_pathinfo *pathinfo) {
................................................................................
   665    667   
   666    668   	pthread_ret = pthread_mutex_lock(&appfs_path_info_cache_mutex);
   667    669   	if (pthread_ret != 0) {
   668    670   		APPFS_DEBUG("Unable to lock path_info cache mutex !");
   669    671   
   670    672   		return(-1);
   671    673   	}
          674  +
          675  +	APPFS_DEBUG("Looking up cache entry for path=%s,uid=%lli...", path, (long long) uid);
   672    676   
   673    677   	if (appfs_path_info_cache != NULL) {
   674    678   		hash_idx = (appfs_get_path_inode(path, uid)) % appfs_path_info_cache_size;
   675    679   
   676    680   		if (appfs_path_info_cache[hash_idx]._cache_path != NULL) {
   677    681   			if (strcmp(appfs_path_info_cache[hash_idx]._cache_path, path) == 0 && appfs_path_info_cache[hash_idx]._cache_uid == uid) {
   678    682   				retval = 0;
................................................................................
   687    691   	if (pthread_ret != 0) {
   688    692   		APPFS_DEBUG("Unable to unlock path_info cache mutex !");
   689    693   
   690    694   		return(-1);
   691    695   	}
   692    696   
   693    697   	if (retval == 0) {
   694         -		APPFS_DEBUG("Cache hit on %s", path);
          698  +		APPFS_DEBUG("Cache hit on path=%s,uid=%lli", path, (long long) uid);
   695    699   	} else {
   696         -		APPFS_DEBUG("Cache miss on %s", path);
          700  +		APPFS_DEBUG("Cache miss on path=%s,uid=%lli", path, (long long) uid);
   697    701   	}
   698    702   
   699    703   	return(retval);
   700    704   }
   701    705   
   702    706   static void appfs_get_path_info_cache_add(const char *path, uid_t uid, struct appfs_pathinfo *pathinfo) {
   703    707   	unsigned int hash_idx;
................................................................................
  1019   1023   
  1020   1024   	if (pathinfo->packaged) {
  1021   1025   		pathinfo->inode = appfs_get_path_inode(path, -1);
  1022   1026   	} else {
  1023   1027   		pathinfo->inode = appfs_get_path_inode(path, fsuid);
  1024   1028   	}
  1025   1029   
         1030  +	APPFS_DEBUG("Caching inode for path=%s,uid=%lli as %llu (packaged = %i)", path, (long long) fsuid, pathinfo->inode, pathinfo->packaged);
         1031  +
  1026   1032   	if (retval == 0) {
  1027   1033   		appfs_get_path_info_cache_add(path, fsuid, pathinfo);
  1028   1034   	} else {
  1029   1035   		APPFS_DEBUG("error: Invalid type for \"%s\" from Tcl", path);
  1030   1036   	}
  1031   1037   
  1032   1038   	return(retval);
................................................................................
  1211   1217   		case APPFS_PATHTYPE_FILE:
  1212   1218   			stbuf->st_mode = S_IFREG | 0444;
  1213   1219   
  1214   1220   			if (pathinfo.typeinfo.file.executable) {
  1215   1221   				stbuf->st_mode |= 0111;
  1216   1222   			}
  1217   1223   
  1218         -			if (pathinfo.typeinfo.file.suidRoot) {
  1219         -				changeOwnerToUserIfPackaged = 0;
         1224  +			if (pathinfo.packaged) {
         1225  +				if (pathinfo.typeinfo.file.suidRoot) {
         1226  +					changeOwnerToUserIfPackaged = 0;
  1220   1227   
  1221         -				stbuf->st_mode |= 04000;
         1228  +					stbuf->st_mode |= 04000;
         1229  +				}
  1222   1230   			}
  1223   1231   
  1224   1232   			if (pathinfo.typeinfo.file.worldaccessible) {
  1225   1233   				stbuf->st_mode &= ~077;
  1226   1234   			}
  1227   1235   
  1228   1236   			stbuf->st_nlink = 1;
................................................................................
  1250   1258   			break;
  1251   1259   		case APPFS_PATHTYPE_INVALID:
  1252   1260   			retval = -EIO;
  1253   1261   
  1254   1262   			break;
  1255   1263   	}
  1256   1264   
  1257         -	if (pathinfo.packaged && changeOwnerToUserIfPackaged) {
         1265  +	if ((pathinfo.packaged && changeOwnerToUserIfPackaged) || (!pathinfo.packaged)) {
  1258   1266   		stbuf->st_uid   = appfs_get_fsuid();
  1259   1267   		stbuf->st_gid   = appfs_get_fsgid();
  1260   1268   		stbuf->st_mode |= 0200;
  1261   1269   	}
  1262   1270   
  1263   1271   	return(retval);
  1264   1272   }
................................................................................
  2016   2024   #else
  2017   2025   	appfs_threaded_tcl = 0;
  2018   2026   #endif
  2019   2027   
  2020   2028   	/**
  2021   2029   	 ** Add FUSE arguments which we always supply
  2022   2030   	 **/
  2023         -	fuse_opt_add_arg(args, "-odefault_permissions,fsname=appfs,subtype=appfsd,use_ino,kernel_cache,entry_timeout=0,attr_timeout=0,big_writes,intr,hard_remove");
         2031  +	fuse_opt_add_arg(args, "-odefault_permissions,fsname=appfs,subtype=appfsd,use_ino,direct_io,entry_timeout=0,attr_timeout=0,big_writes,intr,hard_remove");
  2024   2032   
  2025   2033   	if (getuid() == 0) {
  2026   2034   		fuse_opt_parse(args, NULL, NULL, NULL);
  2027   2035   		fuse_opt_add_arg(args, "-oallow_other");
  2028   2036   
  2029   2037   		/*
  2030   2038   		 * This should generally be avoided, but if there are security