[108434] trunk/base/src/darwintracelib1.0/darwintrace.c

cal at macports.org cal at macports.org
Tue Jul 23 07:16:13 PDT 2013


Revision: 108434
          https://trac.macports.org/changeset/108434
Author:   cal at macports.org
Date:     2013-07-23 07:16:13 -0700 (Tue, 23 Jul 2013)
Log Message:
-----------
darwintrace: clean up execve code, add support for access(2) used by CMake

Modified Paths:
--------------
    trunk/base/src/darwintracelib1.0/darwintrace.c

Modified: trunk/base/src/darwintracelib1.0/darwintrace.c
===================================================================
--- trunk/base/src/darwintracelib1.0/darwintrace.c	2013-07-23 13:23:24 UTC (rev 108433)
+++ trunk/base/src/darwintracelib1.0/darwintrace.c	2013-07-23 14:16:13 UTC (rev 108434)
@@ -723,8 +723,6 @@
 	int result = 0;
 	struct stat st;
 
-	debug_printf("dependency_check: %s\n", path);
-
 	if (-1 == stat(path, &st)) {
 		return 1;
 	}
@@ -759,6 +757,8 @@
 			break;
 	}
 
+	debug_printf("dependency_check: %s returned %d\n", path, result);
+
 	free(p);
 	return result;
 #undef stat
@@ -1027,19 +1027,17 @@
 	 * and "gcc" are contributors
 	 */
 	if (lstat(path, &sb) == 0) {
-		int fd;
+		if (!__darwintrace_is_in_sandbox(path, NULL)) {
+			errno = ENOENT;
+			return -1;
+		}
 
-		fd = open(path, O_RDONLY, 0);
+#if		0
+		int fd = open(path, O_RDONLY, 0);
 		if (fd > 0) {
 			char buffer[MAXPATHLEN + 1];
 			ssize_t bytes_read;
 
-			if (!__darwintrace_is_in_sandbox(path, NULL)) {
-				close(fd);
-				errno = ENOENT;
-				return -1;
-			}
-
 			/* read the file for the interpreter */
 			bytes_read = read(fd, buffer, MAXPATHLEN);
 			buffer[bytes_read] = 0;
@@ -1066,6 +1064,7 @@
 			/* TODO check the iterpreter against the sandbox */
 			close(fd);
 		}
+#endif
 	}
 
 	/* our variables won't survive exec, clean up */
@@ -1454,4 +1453,25 @@
 	return sz;
 #undef getdirentries
 }
+
+int access(const char *path, int amode) {
+#define access(x, y) syscall(SYS_access, (x), (y))
+	char newpath[MAXPATHLEN];
+
+	debug_printf("access(%s, %d)\n", path, amode);
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		errno = ENOENT;
+		return -1;
+	}
+
+	if (*newpath) {
+		return access(newpath, amode);
+	}
+
+	return access(path, amode);
+#undef access
+}
+
 #endif /* __APPLE__ */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130723/6c347295/attachment.html>


More information about the macports-changes mailing list