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