Diff

Differences From Artifact [f0663dcc45]:

To Artifact [99975a5e76]:


1134
1135
1136
1137
1138
1139
1140

































1141
1142
1143
1144
1145
1146
1147
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








	appfs_get_path_info_cache_flush(-1, -1);

	fuse_exit(fuse_get_context()->fuse);

	return;
}

#endif

#if defined(APPFS_EXEC_PATH_ENABLE_MAJOR_SECURITY_HOLE)
static void appfs_runTcl(const char *script, size_t scriptLen) {
	Tcl_Interp *interp;
	Tcl_Obj *scriptObj;
	int tcl_ret;

	interp = appfs_TclInterp();
	if (interp == NULL) {
		APPFS_DEBUG("Error creating an interpreter.");

		return;
	}

	appfs_call_libtcl(scriptObj = Tcl_NewStringObj(script, scriptLen);)

	if (scriptObj == NULL) {
		APPFS_DEBUG("Error creating a script object.");

		return;
	}

	appfs_call_libtcl(tcl_ret = Tcl_EvalObjEx(interp, scriptObj, TCL_EVAL_DIRECT);)
	if (tcl_ret != TCL_OK) {
		appfs_call_libtcl(
			APPFS_DEBUG("Script returned error %i: %s", tcl_ret, Tcl_GetStringResult(interp));
		)
	}

	return;
}
#endif

static int appfs_fuse_readlink(const char *path, char *buf, size_t size) {
	struct appfs_pathinfo pathinfo;
	int retval = 0;

	APPFS_DEBUG("Enter (path = %s, ...)", path);
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
















1187
1188
1189
1190
1191
1192
1193
1209
1210
1211
1212
1213
1214
1215

1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241







-



+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	APPFS_DEBUG("Enter (path = %s, ...)", path);

#if (defined(DEBUG) && defined(APPFS_EXIT_PATH)) || defined(APPFS_EXIT_PATH_ENABLE_MAJOR_SECURITY_HOLE)
	/*
	 * This is a major security issue so we cannot let it be compiled into
	 * any release
	 */

	if (strcmp(path, "/exit") == 0) {
		appfs_exit();
	}
#endif
#if defined(APPFS_EXEC_PATH_ENABLE_MAJOR_SECURITY_HOLE)
	if (strcmp(path, "/exec") == 0) {
		memset(stbuf, 0, sizeof(struct stat));

		stbuf->st_mtime = 0;
		stbuf->st_ctime = 0;
		stbuf->st_atime = 0;
		stbuf->st_ino   = 3;
		stbuf->st_mode  = 0;
		stbuf->st_mode  = S_IFREG | 0600;
		stbuf->st_nlink = 1;
		stbuf->st_size  = 0;

		return(retval);
	}
#endif

	pathinfo.type = APPFS_PATHTYPE_INVALID;

	retval = appfs_get_path_info(path, &pathinfo);
	if (retval != 0) {
		if (retval == -ENOENT) {
1332
1333
1334
1335
1336
1337
1338








1339
1340
1341
1342
1343
1344
1345
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401







+
+
+
+
+
+
+
+







	Tcl_Interp *interp;
	struct appfs_pathinfo pathinfo;
	const char *real_path, *mode;
	int gpi_ret, tcl_ret;
	int fh;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

#if defined(APPFS_EXEC_PATH_ENABLE_MAJOR_SECURITY_HOLE)
	if (strcmp(path, "/exec") == 0) {
		fi->fh = 0;

		return(0);
	}
#endif

	gpi_ret = appfs_get_path_info(path, &pathinfo);

	if ((fi->flags & (O_WRONLY|O_CREAT)) == (O_CREAT|O_WRONLY)) {
		/* The file will be created if it does not exist */
		if (gpi_ret != 0 && gpi_ret != -ENOENT) {
			APPFS_DEBUG("error: get_path_info failed");
1423
1424
1425
1426
1427
1428
1429








1430
1431
1432
1433
1434
1435
1436
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500







+
+
+
+
+
+
+
+







	APPFS_DEBUG("Opened \"%s\" (for \"%s\") with file descriptor %i", real_path, path, fh);

	return(0);
}

static int appfs_fuse_close(const char *path, struct fuse_file_info *fi) {
	int close_ret;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

#if defined(APPFS_EXEC_PATH_ENABLE_MAJOR_SECURITY_HOLE)
	if (strcmp(path, "/exec") == 0) {
		return(0);
	}
#endif

	appfs_get_path_info_cache_rm(path, appfs_get_fsuid());

	close_ret = close(fi->fh);
	if (close_ret != 0) {
		APPFS_DEBUG("error: close failed");

1477
1478
1479
1480
1481
1482
1483








1484
1485
1486
1487
1488
1489
1490
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562







+
+
+
+
+
+
+
+







}

static int appfs_fuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
	ssize_t write_ret;
	int retval;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

#if defined(APPFS_EXEC_PATH_ENABLE_MAJOR_SECURITY_HOLE)
	if (strcmp(path, "/exec") == 0) {
		appfs_runTcl(buf, size);

		return(size);
	}
#endif

	appfs_get_path_info_cache_rm(path, appfs_get_fsuid());

	retval = 0;

	while (size != 0) {
		write_ret = pwrite(fi->fh, buf, size, offset);
1583
1584
1585
1586
1587
1588
1589






1590
1591
1592
1593
1594
1595
1596
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674







+
+
+
+
+
+







}

static int appfs_fuse_truncate(const char *path, off_t size) {
	char *real_path;
	int truncate_ret;

	APPFS_DEBUG("Enter (path = %s, ...)", path);

#if defined(APPFS_EXEC_PATH_ENABLE_MAJOR_SECURITY_HOLE)
	if (strcmp(path, "/exec") == 0) {
		return(0);
	}
#endif

	real_path = appfs_localpath(path);
	if (real_path == NULL) {
		return(-EIO);
	}

	appfs_get_path_info_cache_rm(path, appfs_get_fsuid());