remove trailing whitespace
This commit is contained in:
@@ -90,7 +90,7 @@ mach_init(const char *service, void **ctx)
|
||||
}
|
||||
|
||||
static int
|
||||
mach_ipc(void *ctx,
|
||||
mach_ipc(void *ctx,
|
||||
const heim_idata *request, heim_idata *response,
|
||||
heim_icred *cred)
|
||||
{
|
||||
@@ -146,21 +146,21 @@ mach_ipc(void *ctx,
|
||||
if (errorcode) {
|
||||
if (replyout_length)
|
||||
vm_deallocate (mach_task_self (), (vm_address_t) replyout,
|
||||
replyout_length);
|
||||
replyout_length);
|
||||
return errorcode;
|
||||
}
|
||||
|
||||
|
||||
if (replyout_length) {
|
||||
response->data = malloc(replyout_length);
|
||||
if (response->data == NULL) {
|
||||
vm_deallocate (mach_task_self (), (vm_address_t) replyout,
|
||||
replyout_length);
|
||||
replyout_length);
|
||||
return ENOMEM;
|
||||
}
|
||||
memcpy(response->data, replyout, replyout_length);
|
||||
response->length = replyout_length;
|
||||
vm_deallocate (mach_task_self (), (vm_address_t) replyout,
|
||||
replyout_length);
|
||||
replyout_length);
|
||||
} else {
|
||||
response->data = malloc(replyin_length);
|
||||
if (response->data == NULL)
|
||||
@@ -206,7 +206,7 @@ mheim_ado_acall_reply(mach_port_t server_port,
|
||||
(*c->func)(c->userctx, returnvalue, &response, NULL);
|
||||
|
||||
if (replyoutCnt)
|
||||
vm_deallocate (mach_task_self (), (vm_address_t) replyout, replyoutCnt);
|
||||
vm_deallocate (mach_task_self (), (vm_address_t) replyout, replyoutCnt);
|
||||
|
||||
dispatch_source_cancel(c->source);
|
||||
|
||||
@@ -217,7 +217,7 @@ mheim_ado_acall_reply(mach_port_t server_port,
|
||||
|
||||
|
||||
static int
|
||||
mach_async(void *ctx, const heim_idata *request, void *userctx,
|
||||
mach_async(void *ctx, const heim_idata *request, void *userctx,
|
||||
void (*func)(void *, int, heim_idata *, heim_icred))
|
||||
{
|
||||
struct mach_ctx *ipc = ctx;
|
||||
@@ -246,12 +246,12 @@ mach_async(void *ctx, const heim_idata *request, void *userctx,
|
||||
|
||||
dispatch_source_set_event_handler(c->source, ^{
|
||||
dispatch_mig_server(c->source,
|
||||
sizeof(union __RequestUnion__mheim_ado_mheim_aipc_subsystem),
|
||||
sizeof(union __RequestUnion__mheim_ado_mheim_aipc_subsystem),
|
||||
mheim_aipc_server);
|
||||
});
|
||||
|
||||
dispatch_source_set_cancel_handler(c->source, ^{
|
||||
mach_port_mod_refs(mach_task_self(), c->mp,
|
||||
mach_port_mod_refs(mach_task_self(), c->mp,
|
||||
MACH_PORT_RIGHT_RECEIVE, -1);
|
||||
dispatch_release(c->queue);
|
||||
dispatch_release(c->source);
|
||||
@@ -353,7 +353,7 @@ common_path_init(const char *service,
|
||||
s->fd = -1;
|
||||
|
||||
asprintf(&s->path, "/var/run/.heim_%s-%s", service, file);
|
||||
|
||||
|
||||
*ctx = s;
|
||||
|
||||
return 0;
|
||||
@@ -442,7 +442,7 @@ door_init(const char *service,
|
||||
}
|
||||
|
||||
static int
|
||||
door_ipc(void *ctx,
|
||||
door_ipc(void *ctx,
|
||||
const heim_idata *request, heim_idata *response,
|
||||
heim_icred *cred)
|
||||
{
|
||||
@@ -460,7 +460,7 @@ door_ipc(void *ctx,
|
||||
close(fd);
|
||||
if (ret != 0)
|
||||
return errno;
|
||||
|
||||
|
||||
response->data = malloc(arg.rsize);
|
||||
if (response->data == NULL) {
|
||||
munmap(arg.rbuf, arg.rsize);
|
||||
@@ -480,7 +480,7 @@ struct hipc_ops {
|
||||
int (*init)(const char *, void **);
|
||||
int (*release)(void *);
|
||||
int (*ipc)(void *,const heim_idata *, heim_idata *, heim_icred *);
|
||||
int (*async)(void *, const heim_idata *, void *,
|
||||
int (*async)(void *, const heim_idata *, void *,
|
||||
void (*)(void *, int, heim_idata *, heim_icred));
|
||||
};
|
||||
|
||||
@@ -509,20 +509,20 @@ heim_ipc_init_context(const char *name, heim_ipc *ctx)
|
||||
for(i = 0; i < sizeof(ipcs)/sizeof(ipcs[0]); i++) {
|
||||
size_t prefix_len = strlen(ipcs[i].prefix);
|
||||
heim_ipc c;
|
||||
if(strncmp(ipcs[i].prefix, name, prefix_len) == 0
|
||||
if(strncmp(ipcs[i].prefix, name, prefix_len) == 0
|
||||
&& name[prefix_len] == ':') {
|
||||
} else if (strncmp("ANY:", name, 4) == 0) {
|
||||
prefix_len = 3;
|
||||
any = 1;
|
||||
} else
|
||||
continue;
|
||||
|
||||
|
||||
c = calloc(1, sizeof(*c));
|
||||
if (c == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
|
||||
c->ops = &ipcs[i];
|
||||
|
||||
|
||||
ret = (c->ops->init)(name + prefix_len + 1, &c->ctx);
|
||||
if (ret) {
|
||||
free(c);
|
||||
@@ -530,7 +530,7 @@ heim_ipc_init_context(const char *name, heim_ipc *ctx)
|
||||
continue;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
*ctx = c;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -73,14 +73,14 @@ set_timer(void)
|
||||
dispatch_source_set_timer(timer,
|
||||
dispatch_time(DISPATCH_TIME_NOW,
|
||||
timeoutvalue * NSEC_PER_SEC),
|
||||
timeoutvalue * NSEC_PER_SEC, 1000000);
|
||||
timeoutvalue * NSEC_PER_SEC, 1000000);
|
||||
}
|
||||
|
||||
static void
|
||||
init_globals(void)
|
||||
{
|
||||
static dispatch_once_t once;
|
||||
dispatch_once(&once, ^{
|
||||
dispatch_once(&once, ^{
|
||||
timerq = dispatch_queue_create("hiem-sipc-timer-q", NULL);
|
||||
timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, timerq);
|
||||
dispatch_source_set_event_handler(timer, ^{ timer_ev(); } );
|
||||
@@ -138,7 +138,7 @@ mach_complete_sync(heim_sipc_call ctx, int returnvalue, heim_idata *reply)
|
||||
kr = KERN_SUCCESS;
|
||||
} else {
|
||||
replyinCnt = 0;
|
||||
kr = vm_read(mach_task_self(),
|
||||
kr = vm_read(mach_task_self(),
|
||||
(vm_address_t)reply->data, reply->length,
|
||||
(vm_address_t *)&replyout, &replyoutCnt);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ mach_complete_async(heim_sipc_call ctx, int returnvalue, heim_idata *reply)
|
||||
kr = KERN_SUCCESS;
|
||||
} else {
|
||||
replyinCnt = 0;
|
||||
kr = vm_read(mach_task_self(),
|
||||
kr = vm_read(mach_task_self(),
|
||||
(vm_address_t)reply->data, reply->length,
|
||||
(vm_address_t *)&replyout, &replyoutCnt);
|
||||
}
|
||||
@@ -219,19 +219,19 @@ mheim_do_call(mach_port_t server_port,
|
||||
s = malloc(sizeof(*s));
|
||||
if (s == NULL)
|
||||
return KERN_MEMORY_FAILURE; /* XXX */
|
||||
|
||||
|
||||
s->reply_port = reply_port;
|
||||
|
||||
|
||||
audit_token_to_au32(client_creds, NULL, &uid, &gid, NULL, NULL, &pid, &session, NULL);
|
||||
|
||||
|
||||
kr = _heim_ipc_create_cred(uid, gid, pid, session, &s->cred);
|
||||
if (kr) {
|
||||
free(s);
|
||||
return kr;
|
||||
}
|
||||
|
||||
|
||||
suspend_timer();
|
||||
|
||||
|
||||
if (requestinCnt) {
|
||||
s->req.data = malloc(requestinCnt);
|
||||
memcpy(s->req.data, requestin, requestinCnt);
|
||||
@@ -241,7 +241,7 @@ mheim_do_call(mach_port_t server_port,
|
||||
memcpy(s->req.data, requestout, requestoutCnt);
|
||||
s->req.length = requestoutCnt;
|
||||
}
|
||||
|
||||
|
||||
dispatch_async(workq, ^{
|
||||
(ctx->callback)(ctx->userctx, &s->req, s->cred,
|
||||
mach_complete_sync, (heim_sipc_call)s);
|
||||
@@ -266,23 +266,23 @@ mheim_do_call_request(mach_port_t server_port,
|
||||
gid_t gid;
|
||||
pid_t pid;
|
||||
au_asid_t session;
|
||||
|
||||
|
||||
s = malloc(sizeof(*s));
|
||||
if (s == NULL)
|
||||
return KERN_MEMORY_FAILURE; /* XXX */
|
||||
|
||||
|
||||
s->reply_port = reply_port;
|
||||
|
||||
|
||||
audit_token_to_au32(client_creds, NULL, &uid, &gid, NULL, NULL, &pid, &session, NULL);
|
||||
|
||||
|
||||
kr = _heim_ipc_create_cred(uid, gid, pid, session, &s->cred);
|
||||
if (kr) {
|
||||
free(s);
|
||||
return kr;
|
||||
}
|
||||
|
||||
|
||||
suspend_timer();
|
||||
|
||||
|
||||
if (requestinCnt) {
|
||||
s->req.data = malloc(requestinCnt);
|
||||
memcpy(s->req.data, requestin, requestinCnt);
|
||||
@@ -292,12 +292,12 @@ mheim_do_call_request(mach_port_t server_port,
|
||||
memcpy(s->req.data, requestout, requestoutCnt);
|
||||
s->req.length = requestoutCnt;
|
||||
}
|
||||
|
||||
|
||||
dispatch_async(workq, ^{
|
||||
(ctx->callback)(ctx->userctx, &s->req, s->cred,
|
||||
mach_complete_async, (heim_sipc_call)s);
|
||||
});
|
||||
|
||||
|
||||
return KERN_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ mach_init(const char *service, mach_port_t sport, heim_sipc ctx)
|
||||
free(name);
|
||||
s->sport = sport;
|
||||
|
||||
s->source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV,
|
||||
s->source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV,
|
||||
s->sport, 0, s->queue);
|
||||
if (s->source == NULL) {
|
||||
dispatch_release(s->queue);
|
||||
@@ -338,7 +338,7 @@ mach_init(const char *service, mach_port_t sport, heim_sipc ctx)
|
||||
dispatch_source_set_cancel_handler(s->source, ^{
|
||||
heim_sipc ctx = dispatch_get_context(dispatch_get_current_queue());
|
||||
struct mach_service *st = ctx->mech;
|
||||
mach_port_mod_refs(mach_task_self(), st->sport,
|
||||
mach_port_mod_refs(mach_task_self(), st->sport,
|
||||
MACH_PORT_RIGHT_RECEIVE, -1);
|
||||
dispatch_release(st->queue);
|
||||
dispatch_release(st->source);
|
||||
@@ -376,7 +376,7 @@ mach_checkin_or_register(const char *service)
|
||||
if (kr != KERN_SUCCESS)
|
||||
return MACH_PORT_NULL;
|
||||
|
||||
kr = mach_port_insert_right(mach_task_self(), mp, mp,
|
||||
kr = mach_port_insert_right(mach_task_self(), mp, mp,
|
||||
MACH_MSG_TYPE_MAKE_SEND);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
mach_port_destroy(mach_task_self(), mp);
|
||||
@@ -425,7 +425,7 @@ heim_sipc_launchd_mach_init(const char *service,
|
||||
c->release = mach_release;
|
||||
c->userctx = user;
|
||||
c->callback = callback;
|
||||
|
||||
|
||||
ret = mach_init(service, sport, c);
|
||||
if (ret)
|
||||
goto error;
|
||||
@@ -436,7 +436,7 @@ heim_sipc_launchd_mach_init(const char *service,
|
||||
if (c)
|
||||
free(c);
|
||||
if (sport != MACH_PORT_NULL)
|
||||
mach_port_mod_refs(mach_task_self(), sport,
|
||||
mach_port_mod_refs(mach_task_self(), sport,
|
||||
MACH_PORT_RIGHT_RECEIVE, -1);
|
||||
return ret;
|
||||
#else /* !(__APPLE__ && HAVE_GCD) */
|
||||
@@ -501,7 +501,7 @@ update_client_creds(struct client *c)
|
||||
/* Solaris 10 */
|
||||
{
|
||||
ucred_t *peercred;
|
||||
|
||||
|
||||
if (getpeerucred(c->fd, &peercred) != 0) {
|
||||
c->unixrights.uid = ucred_geteuid(peercred);
|
||||
c->unixrights.gid = ucred_getegid(peercred);
|
||||
@@ -563,7 +563,7 @@ update_client_creds(struct client *c)
|
||||
void *crmsg;
|
||||
struct cmsghdr *cmp;
|
||||
struct sockcred *sc;
|
||||
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
crmsgsize = CMSG_SPACE(SOCKCREDSIZE(NGROUPS));
|
||||
if (crmsgsize == 0)
|
||||
@@ -574,32 +574,32 @@ update_client_creds(struct client *c)
|
||||
goto failed_scm_creds;
|
||||
|
||||
memset(crmsg, 0, crmsgsize);
|
||||
|
||||
|
||||
msg.msg_control = crmsg;
|
||||
msg.msg_controllen = crmsgsize;
|
||||
|
||||
|
||||
if (recvmsg(c->fd, &msg, 0) < 0) {
|
||||
free(crmsg);
|
||||
goto failed_scm_creds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (msg.msg_controllen == 0 || (msg.msg_flags & MSG_CTRUNC) != 0) {
|
||||
free(crmsg);
|
||||
goto failed_scm_creds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cmp = CMSG_FIRSTHDR(&msg);
|
||||
if (cmp->cmsg_level != SOL_SOCKET || cmp->cmsg_type != SCM_CREDS) {
|
||||
free(crmsg);
|
||||
goto failed_scm_creds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sc = (struct sockcred *)(void *)CMSG_DATA(cmp);
|
||||
|
||||
|
||||
c->unixrights.uid = sc->sc_euid;
|
||||
c->unixrights.gid = sc->sc_egid;
|
||||
c->unixrights.pid = 0;
|
||||
|
||||
|
||||
free(crmsg);
|
||||
return 1;
|
||||
} else {
|
||||
@@ -624,7 +624,7 @@ add_new_socket(int fd,
|
||||
c = calloc(1, sizeof(*c));
|
||||
if (c == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (flags & LISTEN_SOCKET) {
|
||||
c->fd = fd;
|
||||
} else {
|
||||
@@ -644,13 +644,13 @@ add_new_socket(int fd,
|
||||
|
||||
#ifdef HAVE_GCD
|
||||
init_globals();
|
||||
|
||||
c->in = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,
|
||||
|
||||
c->in = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,
|
||||
c->fd, 0, eventq);
|
||||
c->out = dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE,
|
||||
c->fd, 0, eventq);
|
||||
|
||||
dispatch_source_set_event_handler(c->in, ^{
|
||||
|
||||
dispatch_source_set_event_handler(c->in, ^{
|
||||
int rw = (c->flags & WAITING_WRITE);
|
||||
handle_read(c);
|
||||
if (rw == 0 && (c->flags & WAITING_WRITE))
|
||||
@@ -666,7 +666,7 @@ add_new_socket(int fd,
|
||||
}
|
||||
maybe_close(c);
|
||||
});
|
||||
|
||||
|
||||
dispatch_resume(c->in);
|
||||
#else
|
||||
clients = erealloc(clients, sizeof(clients[0]) * (num_clients + 1));
|
||||
@@ -882,7 +882,7 @@ handle_read(struct client *c)
|
||||
c->len + 1024);
|
||||
c->len += 1024;
|
||||
}
|
||||
|
||||
|
||||
len = read(c->fd, c->inmsg + c->ptr, c->len - c->ptr);
|
||||
if (len <= 0) {
|
||||
c->flags |= WAITING_CLOSE;
|
||||
@@ -892,10 +892,10 @@ handle_read(struct client *c)
|
||||
c->ptr += len;
|
||||
if (c->ptr > c->len)
|
||||
abort();
|
||||
|
||||
|
||||
while (c->ptr >= sizeof(dlen)) {
|
||||
struct socket_call *cs;
|
||||
|
||||
|
||||
if((c->flags & ALLOW_HTTP) && c->ptr >= 4 &&
|
||||
strncmp((char *)c->inmsg, "GET ", 4) == 0 &&
|
||||
strncmp((char *)c->inmsg + c->ptr - 4, "\r\n\r\n", 4) == 0) {
|
||||
@@ -923,24 +923,24 @@ handle_read(struct client *c)
|
||||
if (dlen > c->ptr - sizeof(dlen)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
cs = emalloc(sizeof(*cs));
|
||||
cs->c = c;
|
||||
cs->in.data = emalloc(dlen);
|
||||
memcpy(cs->in.data, c->inmsg + sizeof(dlen), dlen);
|
||||
cs->in.length = dlen;
|
||||
|
||||
|
||||
c->ptr -= sizeof(dlen) + dlen;
|
||||
memmove(c->inmsg,
|
||||
c->inmsg + sizeof(dlen) + dlen,
|
||||
c->ptr);
|
||||
}
|
||||
|
||||
|
||||
c->calls++;
|
||||
|
||||
if ((c->flags & UNIX_SOCKET) != 0) {
|
||||
if (update_client_creds(c))
|
||||
_heim_ipc_create_cred(c->unixrights.uid, c->unixrights.gid,
|
||||
_heim_ipc_create_cred(c->unixrights.uid, c->unixrights.gid,
|
||||
c->unixrights.pid, -1, &cs->cred);
|
||||
}
|
||||
|
||||
@@ -995,7 +995,7 @@ process_loop(void)
|
||||
fds[n].events |= POLLIN;
|
||||
if (clients[n]->flags & WAITING_WRITE)
|
||||
fds[n].events |= POLLOUT;
|
||||
|
||||
|
||||
fds[n].revents = 0;
|
||||
}
|
||||
|
||||
|
@@ -80,11 +80,11 @@ test_ipc(const char *service)
|
||||
|
||||
req.length = 0;
|
||||
req.data = NULL;
|
||||
|
||||
|
||||
ret = heim_ipc_call(ipc, &req, &rep, NULL);
|
||||
if (ret)
|
||||
errx(1, "heim_ipc_call: %d", ret);
|
||||
|
||||
|
||||
s = heim_ipc_semaphore_create(0);
|
||||
if (s == NULL)
|
||||
errx(1, "heim_ipc_semaphore_create");
|
||||
@@ -108,10 +108,10 @@ main(int argc, char **argv)
|
||||
|
||||
if (getarg(args, num_args, argc, argv, &optidx))
|
||||
usage(1);
|
||||
|
||||
|
||||
if (help_flag)
|
||||
usage(0);
|
||||
|
||||
|
||||
if (version_flag) {
|
||||
print_version(NULL);
|
||||
exit(0);
|
||||
|
@@ -119,10 +119,10 @@ main(int argc, char **argv)
|
||||
|
||||
if (getarg(args, num_args, argc, argv, &optidx))
|
||||
usage(1);
|
||||
|
||||
|
||||
if (help_flag)
|
||||
usage(0);
|
||||
|
||||
|
||||
if (version_flag) {
|
||||
print_version(NULL);
|
||||
exit(0);
|
||||
|
@@ -81,10 +81,10 @@ main(int argc, char **argv)
|
||||
|
||||
if (getarg(args, num_args, argc, argv, &optidx))
|
||||
usage(1);
|
||||
|
||||
|
||||
if (help_flag)
|
||||
usage(0);
|
||||
|
||||
|
||||
if (version_flag) {
|
||||
print_version(NULL);
|
||||
exit(0);
|
||||
|
Reference in New Issue
Block a user