summaryrefslogtreecommitdiff
path: root/src/tls/s6tls_ucspi_exec_app.c
blob: 34c05e2cc4036b0075f4e0761fe4e3d5ac38a141 (plain)
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
27
28
29
30
31
32
33
34
/* ISC license. */

#include <stdint.h>
#include <string.h>
#include <unistd.h>

#include <skalibs/types.h>
#include <skalibs/exec.h>

#include "s6tls-internal.h"

void s6tls_ucspi_exec_app (char const *const *argv, int const p[4][2], uint32_t options)
{
  size_t m = 0 ;
  char modif[sizeof(s6tls_envvars) + 33 + 3 * UINT_FMT] ;
  close(p[2][1]) ;
  close(p[1][1]) ;
  close(p[0][0]) ;
  if (options & 1)
  {
    memcpy(modif + m, s6tls_envvars, sizeof(s6tls_envvars)) ;
    m += sizeof(s6tls_envvars) ;
  }
  memcpy(modif + m, "SSLCTLFD=", 9) ; m += 9 ;
  m += uint_fmt(modif + m, p[2][0]) ;
  modif[m++] = 0 ;
  memcpy(modif + m, "SSLREADFD=", 10) ; m += 10 ;
  m += uint_fmt(modif + m, p[1][0]) ;
  modif[m++] = 0 ;
  memcpy(modif + m, "SSLWRITEFD=", 11) ; m += 11 ;
  m += uint_fmt(modif + m, p[0][1]) ;
  modif[m++] = 0 ;
  xmexec_m(argv, modif, m) ;
}