Changeset 23459
- Timestamp:
- 2007-12-07 13:15:23 (10 months ago)
- Location:
- branches/SULeopard/launchd/src
- Files:
-
- 6 modified
-
Makefile.am (modified) (3 diffs)
-
Makefile.in (modified) (7 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
-
branches/SULeopard/launchd/src/Makefile.am
r23408 r23459 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 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 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 55 55 … … 58 58 notifyServer.c notifyServer.h: /usr/include/mach/notify.defs 59 59 mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs 60 61 mach_excServer.c mach_excServer.h: /usr/include/mach/mach_exc.defs 62 mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader mach_excServer.h /usr/include/mach/mach_exc.defs 60 63 61 64 job_replyUser.c job_reply.h: $(srcdir)/protocol_job_reply.defs -
branches/SULeopard/launchd/src/Makefile.in
r23408 r23459 97 97 launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c \ 98 98 launchd_internalUser.c launchd_internalServer.c \ 99 job_replyUser.c launchd_runtime.c launchd_runtime_kill.c 99 job_replyUser.c launchd_runtime.c launchd_runtime_kill.c \ 100 mach_excServer.c 100 101 @LIBS_ONLY_FALSE@am_launchd_OBJECTS = launchd-launchd.$(OBJEXT) \ 101 102 @LIBS_ONLY_FALSE@ launchd-launchd_core_logic.$(OBJEXT) \ … … 107 108 @LIBS_ONLY_FALSE@ launchd-job_replyUser.$(OBJEXT) \ 108 109 @LIBS_ONLY_FALSE@ launchd-launchd_runtime.$(OBJEXT) \ 109 @LIBS_ONLY_FALSE@ launchd-launchd_runtime_kill.$(OBJEXT) 110 @LIBS_ONLY_FALSE@ launchd-launchd_runtime_kill.$(OBJEXT) \ 111 @LIBS_ONLY_FALSE@ launchd-mach_excServer.$(OBJEXT) 110 112 launchd_OBJECTS = $(am_launchd_OBJECTS) 111 113 launchd_LDADD = $(LDADD) … … 239 241 CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \ 240 242 launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \ 241 notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c 243 notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h 242 244 243 245 @LIBS_ONLY_TRUE@noinst_LIBRARIES = liblaunch.a liblaunch_profile.a … … 254 256 @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter 255 257 @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm 256 @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 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 mach_excServer.c 257 259 @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security 258 260 @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 … … 424 426 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime_kill.Po@am__quote@ 425 427 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_unix_ipc.Po@am__quote@ 428 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-mach_excServer.Po@am__quote@ 426 429 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@ 427 430 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@ … … 788 791 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 789 792 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-launchd_runtime_kill.obj `if test -f 'launchd_runtime_kill.c'; then $(CYGPATH_W) 'launchd_runtime_kill.c'; else $(CYGPATH_W) '$(srcdir)/launchd_runtime_kill.c'; fi` 793 794 launchd-mach_excServer.o: mach_excServer.c 795 @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 796 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-mach_excServer.Tpo $(DEPDIR)/launchd-mach_excServer.Po 797 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mach_excServer.c' object='launchd-mach_excServer.o' libtool=no @AMDEPBACKSLASH@ 798 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 799 @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 800 801 launchd-mach_excServer.obj: mach_excServer.c 802 @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` 803 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-mach_excServer.Tpo $(DEPDIR)/launchd-mach_excServer.Po 804 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mach_excServer.c' object='launchd-mach_excServer.obj' libtool=no @AMDEPBACKSLASH@ 805 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 806 @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` 790 807 install-man1: $(man1_MANS) $(man_MANS) 791 808 @$(NORMAL_INSTALL) … … 1149 1166 @LIBS_ONLY_TRUE@ cp liblaunch_profile.a $(DESTDIR)/usr/local/lib/system/liblaunch_profile.a 1150 1167 1151 @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h 1168 @LIBS_ONLY_FALSE@launchd_runtime.c:: notifyServer.h launchd_internal.h mach_excServer.h 1152 1169 @LIBS_ONLY_FALSE@launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h 1153 1170 1154 1171 @LIBS_ONLY_FALSE@notifyServer.c notifyServer.h: /usr/include/mach/notify.defs 1155 1172 @LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader notifyServer.h /usr/include/mach/notify.defs 1173 1174 @LIBS_ONLY_FALSE@mach_excServer.c mach_excServer.h: /usr/include/mach/mach_exc.defs 1175 @LIBS_ONLY_FALSE@ mig $(MIGFLAGS) -header /dev/null -user /dev/null -sheader mach_excServer.h /usr/include/mach/mach_exc.defs 1156 1176 1157 1177 @LIBS_ONLY_FALSE@job_replyUser.c job_reply.h: $(srcdir)/protocol_job_reply.defs -
branches/SULeopard/launchd/src/launchd_core_logic.c
r23437 r23459 334 334 char *stdoutpath; 335 335 char *stderrpath; 336 char *alt_exc_handler; 336 337 struct machservice *lastlookup; 337 338 unsigned int lastlookup_gennum; … … 361 362 wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, 362 363 per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, 363 poll_for_vfs_changes:1 ;364 poll_for_vfs_changes:1, internal_exc_handler:1; 364 365 const char label[0]; 365 366 }; … … 862 863 free(j->stderrpath); 863 864 } 865 if (j->alt_exc_handler) { 866 free(j->alt_exc_handler); 867 } 864 868 if (j->seatbelt_profile) { 865 869 free(j->seatbelt_profile); … … 1324 1328 } 1325 1329 break; 1330 case 'm': 1331 case 'M': 1332 if (strcasecmp(key, LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER) == 0) { 1333 j->internal_exc_handler = value; 1334 found_key = true; 1335 } 1336 break; 1326 1337 case 'i': 1327 1338 case 'I': … … 1377 1388 1378 1389 switch (key[0]) { 1390 case 'm': 1391 case 'M': 1392 if (strcasecmp(key, LAUNCH_JOBKEY_MACHEXCEPTIONHANDLER) == 0) { 1393 where2put = &j->alt_exc_handler; 1394 } 1395 break; 1379 1396 case 'p': 1380 1397 case 'P': … … 4003 4020 job_setup_exception_port(job_t j, task_t target_task) 4004 4021 { 4022 struct machservice *ms; 4005 4023 thread_state_flavor_t f = 0; 4006 4007 if (!the_exception_server) { 4024 mach_port_t exc_port = the_exception_server; 4025 4026 if (j->alt_exc_handler) { 4027 ms = jobmgr_lookup_service(j->mgr, j->alt_exc_handler, true, 0); 4028 if (ms) { 4029 exc_port = machservice_port(ms); 4030 } else { 4031 job_log(j, LOG_WARNING, "Falling back to default Mach exception handler. Could not find: %s", j->alt_exc_handler); 4032 } 4033 } else if (j->internal_exc_handler) { 4034 exc_port = runtime_get_kernel_port(); 4035 } else if (!exc_port) { 4008 4036 return; 4009 4037 } … … 4016 4044 4017 4045 if (target_task) { 4018 job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, the_exception_server,4046 job_assumes(j, task_set_exception_ports(target_task, EXC_MASK_CRASH, exc_port, 4019 4047 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); 4020 } else if (getpid() == 1 ) {4048 } else if (getpid() == 1 && the_exception_server) { 4021 4049 mach_port_t mhp = mach_host_self(); 4022 4050 job_assumes(j, host_set_exception_ports(mhp, EXC_MASK_CRASH, the_exception_server, -
branches/SULeopard/launchd/src/launchd_runtime.c
r23456 r23459 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 void … … 847 855 if (launchd_internal_server_routine(Request)) { 848 856 return launchd_internal_server(Request, Reply); 849 } 850 851 return notify_server(Request, Reply); 857 } else if (notify_server_routine(Request)) { 858 return notify_server(Request, Reply); 859 } else { 860 return mach_exc_server(Request, Reply); 861 } 852 862 } 853 863 … … 1451 1461 runtime_busy_cnt--; 1452 1462 } 1463 1464 kern_return_t 1465 catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, 1466 exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) 1467 { 1468 runtime_syslog(LOG_NOTICE, "%s(): thread: 0x%x task: 0x%x type: 0x%x code: %p codeCnt: 0x%x", 1469 __func__, thread, task, exception, code, codeCnt); 1470 1471 launchd_assumes(launchd_mport_deallocate(thread) == KERN_SUCCESS); 1472 launchd_assumes(launchd_mport_deallocate(task) == KERN_SUCCESS); 1473 1474 return 0; 1475 } 1476 1477 kern_return_t 1478 catch_mach_exception_raise_state(mach_port_t exception_port, 1479 exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, 1480 int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, 1481 thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) 1482 { 1483 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", 1484 __func__, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt); 1485 1486 memcpy(new_state, old_state, old_stateCnt * sizeof(old_state[0])); 1487 *new_stateCnt = old_stateCnt; 1488 1489 return 0; 1490 } 1491 1492 kern_return_t 1493 catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, 1494 exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, 1495 int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, 1496 thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) 1497 { 1498 runtime_syslog(LOG_NOTICE, "%s(): thread: 0x%x task: 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", 1499 __func__, thread, task, exception, code, codeCnt, flavor, old_state, old_stateCnt, new_state, new_stateCnt); 1500 1501 memcpy(new_state, old_state, old_stateCnt * sizeof(old_state[0])); 1502 *new_stateCnt = old_stateCnt; 1503 1504 launchd_assumes(launchd_mport_deallocate(thread) == KERN_SUCCESS); 1505 launchd_assumes(launchd_mport_deallocate(task) == KERN_SUCCESS); 1506 1507 return 0; 1508 } -
branches/SULeopard/launchd/src/launchd_runtime.h
r23432 r23459 57 57 typedef void (*timeout_callback)(void); 58 58 59 boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);59 mach_port_t runtime_get_kernel_port(void); 60 60 61 61 void runtime_add_ref(void); -
branches/SULeopard/launchd/src/liblaunch_private.h
r23266 r23459 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"

