Changeset 23445
- Timestamp:
- 10/23/07 08:47:01 (14 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 6 modified
-
Makefile.am (modified) (3 diffs)
-
Makefile.in (modified) (8 diffs)
-
launchd_core_logic.c (modified) (7 diffs)
-
launchd_runtime.c (modified) (5 diffs)
-
launchd_runtime.h (modified) (1 diff)
-
liblaunch_private.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/Makefile.am
r23443 r23445 3 3 CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ 4 4 launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ 5 notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c 5 notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h 6 6 7 7 protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h: $(srcdir)/protocol_job.defs … … 49 49 launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter 50 50 launchd_LDFLAGS = -lbsm 51 launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c 51 launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c 52 52 53 launchd_runtime.c:: notifyServer.h launchd_internal.h 53 launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h 54 54 launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h job_forward.h 55 55 … … 61 61 notifyServer.c notifyServer.h: /usr/include/mach/notify.defs 62 62 mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs 63 64 mach_excServer.c mach_excServer.h: /usr/include/mach/mach_exc.defs 65 mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader mach_excServer.h /usr/include/mach/mach_exc.defs 63 66 64 67 job_replyUser.c job_reply.h: $(srcdir)/protocol_job_reply.defs -
trunk/launchd/src/Makefile.in
r23443 r23445 98 98 launchd_internalUser.c launchd_internalServer.c \ 99 99 job_replyUser.c launchd_runtime.c launchd_runtime_kill.c \ 100 job_forwardUser.c 100 job_forwardUser.c mach_excServer.c 101 101 @LIBS_ONLY_FALSE@am_launchd_OBJECTS = launchd-launchd.$(OBJEXT) \ 102 102 @LIBS_ONLY_FALSE@ launchd-launchd_core_logic.$(OBJEXT) \ … … 109 109 @LIBS_ONLY_FALSE@ launchd-launchd_runtime.$(OBJEXT) \ 110 110 @LIBS_ONLY_FALSE@ launchd-launchd_runtime_kill.$(OBJEXT) \ 111 @LIBS_ONLY_FALSE@ launchd-job_forwardUser.$(OBJEXT) 111 @LIBS_ONLY_FALSE@ launchd-job_forwardUser.$(OBJEXT) \ 112 @LIBS_ONLY_FALSE@ launchd-mach_excServer.$(OBJEXT) 112 113 launchd_OBJECTS = $(am_launchd_OBJECTS) 113 114 launchd_LDADD = $(LDADD) … … 241 242 CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ 242 243 launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ 243 notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c 244 notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h 244 245 245 246 @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a … … 256 257 @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter 257 258 @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm 258 @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c 259 @LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c 259 260 @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security 260 261 @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 … … 427 428 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime_kill.Po@am__quote@ 428 429 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_unix_ipc.Po@am__quote@ 430 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-mach_excServer.Po@am__quote@ 429 431 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@ 430 432 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@ … … 805 807 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 806 808 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-job_forwardUser.obj `if test -f 'job_forwardUser.c'; then $(CYGPATH_W) 'job_forwardUser.c'; else $(CYGPATH_W) '$(srcdir)/job_forwardUser.c'; fi` 809 810 launchd-mach_excServer.o: mach_excServer.c 811 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-mach_excServer.o -MD -MP -MF $(DEPDIR)/launchd-mach_excServer.Tpo -c -o launchd-mach_excServer.o `test -f 'mach_excServer.c' || echo '$(srcdir)/'`mach_excServer.c 812 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-mach_excServer.Tpo $(DEPDIR)/launchd-mach_excServer.Po 813 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mach_excServer.c' object='launchd-mach_excServer.o' libtool=no @AMDEPBACKSLASH@ 814 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 815 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-mach_excServer.o `test -f 'mach_excServer.c' || echo '$(srcdir)/'`mach_excServer.c 816 817 launchd-mach_excServer.obj: mach_excServer.c 818 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-mach_excServer.obj -MD -MP -MF $(DEPDIR)/launchd-mach_excServer.Tpo -c -o launchd-mach_excServer.obj `if test -f 'mach_excServer.c'; then $(CYGPATH_W) 'mach_excServer.c'; else $(CYGPATH_W) '$(srcdir)/mach_excServer.c'; fi` 819 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-mach_excServer.Tpo $(DEPDIR)/launchd-mach_excServer.Po 820 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mach_excServer.c' object='launchd-mach_excServer.obj' libtool=no @AMDEPBACKSLASH@ 821 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 822 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-mach_excServer.obj `if test -f 'mach_excServer.c'; then $(CYGPATH_W) 'mach_excServer.c'; else $(CYGPATH_W) '$(srcdir)/mach_excServer.c'; fi` 807 823 install-man1: $(man1_MANS) $(man_MANS) 808 824 @$(NORMAL_INSTALL) … … 1166 1182 @LIBS_ONLY_TRUE@ cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a 1167 1183 1168 @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h 1184 @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h 1169 1185 @LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h job_forward.h 1170 1186 … … 1174 1190 @LIBS_ONLY_FALSE@notifyServer.c notifyServer.h: /usr/include/mach/notify.defs 1175 1191 @LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs 1192 1193 @LIBS_ONLY_FALSE@mach_excServer.c mach_excServer.h: /usr/include/mach/mach_exc.defs 1194 @LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader mach_excServer.h /usr/include/mach/mach_exc.defs 1176 1195 1177 1196 @LIBS_ONLY_FALSE@job_replyUser.c job_reply.h: $(srcdir)/protocol_job_reply.defs -
trunk/launchd/src/launchd_core_logic.c
r23443 r23445 335 335 char *stdoutpath; 336 336 char *stderrpath; 337 char *alt_exc_handler; 337 338 struct machservice *lastlookup; 338 339 unsigned int lastlookup_gennum; … … 362 363 wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, 363 364 per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, 364 poll_for_vfs_changes:1 ;365 poll_for_vfs_changes:1, internal_exc_handler:1; 365 366 const char label[0]; 366 367 }; … … 863 864 free(j->stderrpath); 864 865 } 866 if (j->alt_exc_handler) { 867 free(j->alt_exc_handler); 868 } 865 869 if (j->seatbelt_profile) { 866 870 free(j->seatbelt_profile); … … 1325 1329 } 1326 1330 break; 1331 case 'm': 1332 case 'M': 1333 if (strcasecmp(key, LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER) == 0) { 1334 j->internal_exc_handler = value; 1335 found_key = true; 1336 } 1337 break; 1327 1338 case 'i': 1328 1339 case 'I': … … 1378 1389 1379 1390 switch (key[0]) { 1391 case 'm': 1392 case 'M': 1393 if (strcasecmp(key, LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER) == 0) { 1394 where2put = &j->alt_exc_handler; 1395 } 1396 break; 1380 1397 case 'p': 1381 1398 case 'P': … … 4004 4021 job_setup_exception_port(job_t j, task_t target_task) 4005 4022 { 4023 struct machservice *ms; 4006 4024 thread_state_flavor_t f = 0; 4007 4008 if (!the_exception_server) { 4025 mach_port_t exc_port = the_exception_server; 4026 4027 if (j->alt_exc_handler) { 4028 ms = jobmgr_lookup_service(j->mgr, j->alt_exc_handler, true, 0); 4029 if (ms) { 4030 exc_port = machservice_port(ms); 4031 } else { 4032 job_log(j, LOG_WARNING, "Falling back to default Mach exception handler. Could not find: %s", j->alt_exc_handler); 4033 } 4034 } else if (j->internal_exc_handler) { 4035 exc_port = runtime_get_kernel_port(); 4036 } else if (!exc_port) { 4009 4037 return; 4010 4038 } … … 4017 4045 4018 4046 if (target_task) { 4019 job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, the_exception_server,4047 job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, exc_port, 4020 4048 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); 4021 } else if (getpid() == 1 ) {4049 } else if (getpid() == 1 && the_exception_server) { 4022 4050 mach_port_t mhp = mach_host_self(); 4023 4051 job_assumes(j, host_set_exception_ports(mhp, EXC_MASK_CRASH, the_exception_server, -
trunk/launchd/src/launchd_runtime.c
r23444 r23445 62 62 #include "launchd_internal.h" 63 63 #include "notifyServer.h" 64 #include "mach_excServer.h" 64 65 65 66 /* We shouldn't be including these */ … … 87 88 static void log_kevent_struct(int level, struct kevent *kev, int indx); 88 89 90 static boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); 89 91 static void record_caller_creds(mach_msg_header_t *mh); 90 92 static void launchd_runtime2(mach_msg_size_t msg_size, mig_reply_error_t *bufRequest, mig_reply_error_t *bufReply); … … 115 117 }; 116 118 static sigset_t sigign_set; 119 120 mach_port_t 121 runtime_get_kernel_port(void) 122 { 123 return launchd_internal_port; 124 } 117 125 118 126 static int internal_mask_pri = LOG_UPTO(LOG_NOTICE); … … 851 859 if (launchd_internal_server_routine(Request)) { 852 860 return launchd_internal_server(Request, Reply); 853 } 854 855 return notify_server(Request, Reply); 861 } else if (notify_server_routine(Request)) { 862 return notify_server(Request, Reply); 863 } else { 864 return mach_exc_server(Request, Reply); 865 } 856 866 } 857 867 … … 1452 1462 runtime_busy_cnt--; 1453 1463 } 1464 1465 kern_return_t 1466 catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, 1467 exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) 1468 { 1469 pid_t p4t = -1; 1470 1471 launchd_assumes(pid_for_task(task, &p4t) == 0); 1472 1473 runtime_syslog(LOG_NOTICE, "%s(): PID: %u thread: 0x%x type: 0x%x code: %p codeCnt: 0x%x", 1474 __func__, p4t, thread, exception, code, codeCnt); 1475 1476 launchd_assumes(launchd_mport_deallocate(thread) == KERN_SUCCESS); 1477 launchd_assumes(launchd_mport_deallocate(task) == KERN_SUCCESS); 1478 1479 return 0; 1480 } 1481 1482 kern_return_t 1483 catch_mach_exception_raise_state(mach_port_t exception_port, 1484 exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, 1485 int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, 1486 thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) 1487 { 1488 runtime_syslog(LOG_NOTICE, "%s(): type: 0x%x code: %p codeCnt: 0x%x flavor: %p old_state: %p old_stateCnt: 0x%x new_state: %p new_stateCnt: %p", 1489 __func__, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt); 1490 1491 memcpy(new_state, old_state, old_stateCnt * sizeof(old_state[0])); 1492 *new_stateCnt = old_stateCnt; 1493 1494 return 0; 1495 } 1496 1497 kern_return_t 1498 catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, 1499 exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, 1500 int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, 1501 thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) 1502 { 1503 pid_t p4t = -1; 1504 1505 launchd_assumes(pid_for_task(task, &p4t) == 0); 1506 1507 runtime_syslog(LOG_NOTICE, "%s(): PID: %u thread: 0x%x type: 0x%x code: %p codeCnt: 0x%x flavor: %p old_state: %p old_stateCnt: 0x%x new_state: %p new_stateCnt: %p", 1508 __func__, p4t, thread, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt); 1509 1510 memcpy(new_state, old_state, old_stateCnt * sizeof(old_state[0])); 1511 *new_stateCnt = old_stateCnt; 1512 1513 launchd_assumes(launchd_mport_deallocate(thread) == KERN_SUCCESS); 1514 launchd_assumes(launchd_mport_deallocate(task) == KERN_SUCCESS); 1515 1516 return 0; 1517 } -
trunk/launchd/src/launchd_runtime.h
r23444 r23445 99 99 typedef void (*timeout_callback)(void); 100 100 101 boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);101 mach_port_t runtime_get_kernel_port(void); 102 102 103 103 void runtime_add_ref(void); -
trunk/launchd/src/liblaunch_private.h
r23266 r23445 56 56 #define LAUNCH_JOBKEY_SERVICEIPC "ServiceIPC" 57 57 #define LAUNCH_JOBKEY_BINARYORDERPREFERENCE "BinaryOrderPreference" 58 #define LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER "MachExceptionHandler" 58 59 59 60 #define LAUNCH_JOBKEY_MACH_KUNCSERVER "kUNCServer"

