about summary refs log tree commit diff
path: root/src/libunixonacid/skaclient_start_cb.c
blob: ff11a2173bfb802940d33cc89d00e2069c6f10bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* ISC license. */

#include <errno.h>
#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <skalibs/unixmessage.h>
#include <skalibs/skaclient.h>
#include "skaclient-internal.h"

int skaclient_start_cb (unixmessage_t const *m, skaclient_cbdata_t *blah)
{
  if (m->len != blah->afterlen
   || byte_diff(m->s, m->len, blah->after)
   || m->nfds != 1)
  {
    unixmessage_drop(m) ;
    return (errno = EPROTO, 0) ;
  }
  blah->a->asyncin.fd = m->fds[0] ;
  blah->a->asyncout.fd = m->fds[0] ;
  if (!(blah->a->options & SKACLIENT_OPTION_ASYNC_ACCEPT_FDS))
    unixmessage_receiver_refuse_fds(&blah->a->asyncin) ;
  if (!(blah->a->options & SKACLIENT_OPTION_SYNC_ACCEPT_FDS))
    unixmessage_receiver_refuse_fds(&blah->a->syncin) ;
  return 1 ;
}