1/* 2 * Copyright (c) 2009 Kungliga Tekniska H�gskolan 3 * (Royal Institute of Technology, Stockholm, Sweden). 4 * All rights reserved. 5 * 6 * Portions Copyright (c) 2009 Apple Inc. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * 3. Neither the name of the Institute nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#include "config.h" 37 38#include <sys/types.h> 39#include <sys/socket.h> 40#ifdef HAVE_SYS_UN_H 41#include <sys/un.h> 42#endif 43 44#define __APPLE_USE_RFC_3542 1 45 46#include <netinet/in.h> 47 48#include <sys/poll.h> 49 50#include <ctype.h> 51#include <stdio.h> 52#include <stdlib.h> 53#include <string.h> 54#include <errno.h> 55 56#ifdef HAVE_GETPEERUCRED 57#include <ucred.h> 58#endif 59 60#include <krb5-types.h> 61#include <asn1-common.h> 62 63#include <heimbase.h> 64#include <base64.h> 65 66#include <heim-ipc.h> 67 68#define MAX_PACKET_SIZE (128 * 1024) 69 70#if defined(__APPLE__) && defined(HAVE_GCD) 71#include <mach/mach.h> 72#include <servers/bootstrap.h> 73#include <dispatch/dispatch.h> 74#include <bsm/libbsm.h> 75 76#ifndef __APPLE_PRIVATE__ /* awe, using private interface */ 77typedef boolean_t (*dispatch_mig_callback_t)(mach_msg_header_t *message, mach_msg_header_t *reply); 78 79mach_msg_return_t 80dispatch_mig_server(dispatch_source_t ds, size_t maxmsgsz, dispatch_mig_callback_t callback); 81#else 82#include <dispatch/private.h> 83#endif 84 85#endif 86 87 88#include <roken.h> 89 90int 91_heim_ipc_create_cred(uid_t, gid_t, pid_t, pid_t, heim_icred *); 92 93int 94_heim_ipc_create_network_cred(struct sockaddr *, krb5_socklen_t, 95 struct sockaddr *, krb5_socklen_t, 96 heim_icred *); 97void 98_heim_ipc_suspend_timer(void); 99 100void 101_heim_ipc_restart_timer(void); 102