Projects
Browse Source     Search     Timeline     Wiki

Changeset 23219

Show
Ignore:
Timestamp:
04/12/07 14:35:37 (21 months ago)
Author:
zarzycki@…
Message:

<rdar://problem/4945275> setuid processes should have their exception ports repointed at the ReportCrash launchdaemon

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchd_core_logic.c

    r23218 r23219  
    372372static void job_log_error(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); 
    373373static void job_log_bug(job_t j, const char *rcs_rev, const char *path, unsigned int line, const char *test); 
     374static void job_set_exeception_port(job_t j, mach_port_t port); 
    374375static kern_return_t job_handle_mpm_wait(job_t j, mach_port_t srp, int *waitstatus); 
    375376 
     
    33983399#endif 
    33993400 
    3400         job_assumes(j, task_set_exception_ports(target_task, em, the_exception_server, 
    3401                                 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); 
    3402  
     3401        if (target_task) { 
     3402                job_assumes(j, task_set_exception_ports(target_task, em, the_exception_server, 
     3403                                        EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); 
     3404        } else if (getpid() == 1) { 
     3405                mach_port_t mhp = mach_host_self(); 
     3406                job_assumes(j, host_set_exception_ports(mhp, em, the_exception_server, 
     3407                                        EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, f) == KERN_SUCCESS); 
     3408                job_assumes(j, launchd_mport_deallocate(mhp) == KERN_SUCCESS); 
     3409        } 
     3410 
     3411} 
     3412 
     3413void 
     3414job_set_exeception_port(job_t j, mach_port_t port) 
     3415{ 
     3416        if (!the_exception_server) { 
     3417                the_exception_server = port; 
     3418                job_setup_exception_port(j, 0); 
     3419        } else { 
     3420                job_log(j, LOG_WARNING, "The exception server is already claimed!"); 
     3421        } 
    34033422} 
    34043423 
     
    34483467                        ms->hide = b; 
    34493468                } else if (strcasecmp(key, LAUNCH_JOBKEY_MACH_EXCEPTIONSERVER) == 0) { 
    3450                         if (!the_exception_server) { 
    3451                                 the_exception_server = ms->port; 
    3452                         } else { 
    3453                                 job_log(ms->job, LOG_WARNING, "The exception server is already claimed!"); 
    3454                         } 
     3469                        job_set_exeception_port(ms->job, ms->port); 
    34553470                } else if (strcasecmp(key, LAUNCH_JOBKEY_MACH_KUNCSERVER) == 0) { 
    34563471                        ms->kUNCServer = b; 
     
    34593474                break; 
    34603475        case LAUNCH_DATA_DICTIONARY: 
    3461                 if (!the_exception_server) { 
    3462                         the_exception_server = ms->port; 
    3463                 } else { 
    3464                         job_log(ms->job, LOG_WARNING, "The exception server is already claimed!"); 
    3465                 } 
     3476                job_set_exeception_port(ms->job, ms->port); 
    34663477                break; 
    34673478        default: