[launchd-changes] [22897] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 16 14:16:29 PDT 2006
Revision: 22897
http://trac.macosforge.org/projects/launchd/changeset/22897
Author: zarzycki at apple.com
Date: 2006-10-16 14:16:29 -0700 (Mon, 16 Oct 2006)
Log Message:
-----------
<rdar://problem/4684434> setsockopt() with the executable path as the argument
Modified Paths:
--------------
trunk/launchd/src/Makefile.am
trunk/launchd/src/Makefile.in
trunk/launchd/src/launchctl.c
Modified: trunk/launchd/src/Makefile.am
===================================================================
--- trunk/launchd/src/Makefile.am 2006-10-16 17:34:18 UTC (rev 22896)
+++ trunk/launchd/src/Makefile.am 2006-10-16 21:16:29 UTC (rev 22897)
@@ -34,7 +34,7 @@
sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown
-launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
+launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders
launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib
SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -fvisibility=hidden
Modified: trunk/launchd/src/Makefile.in
===================================================================
--- trunk/launchd/src/Makefile.in 2006-10-16 17:34:18 UTC (rev 22896)
+++ trunk/launchd/src/Makefile.in 2006-10-16 21:16:29 UTC (rev 22897)
@@ -232,7 +232,7 @@
@LIBS_ONLY_TRUE at liblaunch_profile_a_SOURCES = liblaunch.c bootstrap_public.c
@LIBS_ONLY_FALSE at sbin_SCRIPTS = service
@LIBS_ONLY_FALSE at sysconf_DATA = hostconfig rc.common rc.netboot rc.shutdown
- at LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
+ at LIBS_ONLY_FALSE@launchctl_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -I/System/Library/Frameworks/System.framework/PrivateHeaders
@LIBS_ONLY_FALSE at launchctl_LDFLAGS = -framework CoreFoundation -weak_library /usr/lib/libedit.dylib
@LIBS_ONLY_FALSE at SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -fvisibility=hidden
@LIBS_ONLY_FALSE at SystemStarter_LDFLAGS = -framework CoreFoundation
Modified: trunk/launchd/src/launchctl.c
===================================================================
--- trunk/launchd/src/launchctl.c 2006-10-16 17:34:18 UTC (rev 22896)
+++ trunk/launchd/src/launchctl.c 2006-10-16 21:16:29 UTC (rev 22897)
@@ -131,6 +131,7 @@
static int touch_file(const char *path, mode_t m);
static void do_sysversion_sysctl(void);
static void workaround4465949(void);
+static void do_application_firewal_magic(int sfd, launch_data_t thejob);
static int bootstrap_cmd(int argc, char *const argv[]);
static int load_and_unload_cmd(int argc, char *const argv[]);
@@ -842,6 +843,9 @@
fprintf(stderr, "socket(): %s\n", strerror(errno));
return;
}
+
+ do_application_firewal_magic(sfd, thejob);
+
if (hints.ai_flags & AI_PASSIVE) {
if (AF_INET6 == res->ai_family && -1 == setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY,
(void *)&sock_opt, sizeof(sock_opt))) {
@@ -2661,3 +2665,62 @@
CFRelease(versdict);
}
+
+void
+do_application_firewal_magic(int sfd, launch_data_t thejob)
+{
+ const char *prog = NULL, *partialprog = NULL;
+ char *path, *pathtmp, **pathstmp;
+ char *paths[100];
+ launch_data_t tmp;
+
+ /*
+ * Sigh...
+ * <rdar://problem/4684434> setsockopt() with the executable path as the argument
+ */
+
+ if ((tmp = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_PROGRAM))) {
+ prog = launch_data_get_string(tmp);
+ }
+
+ if (!prog) {
+ if ((tmp = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_PROGRAMARGUMENTS))) {
+ if ((tmp = launch_data_array_get_index(tmp, 0))) {
+ if (assumes((partialprog = launch_data_get_string(tmp)) != NULL)) {
+ if (partialprog[0] == '/') {
+ prog = partialprog;
+ }
+ }
+ }
+ }
+ }
+
+ if (!prog) {
+ pathtmp = path = strdup(getenv("PATH"));
+
+ pathstmp = paths;
+
+ while ((*pathstmp = strsep(&pathtmp, ":"))) {
+ if (**pathstmp != '\0') {
+ pathstmp++;
+ }
+ }
+
+ free(path);
+ pathtmp = alloca(MAXPATHLEN);
+
+ pathstmp = paths;
+
+ for (; *pathstmp; pathstmp++) {
+ snprintf(pathtmp, MAXPATHLEN, "%s/%s", *pathstmp, partialprog);
+ if (path_check(pathtmp)) {
+ prog = pathtmp;
+ break;
+ }
+ }
+ }
+
+ if (assumes(prog != NULL)) {
+ assumes(setsockopt(sfd, SOL_SOCKET, SO_EXECPATH, prog, strlen(prog) + 1) != -1);
+ }
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20061016/27bdc793/attachment.html
More information about the launchd-changes
mailing list