55 const char *msgprefix =
"ERROR: failure executing process for tun:";
60 const char *program = dev_node + strlen(
"unix:");
82 if (!(socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) == 0))
84 msg(
M_ERR,
"Cannot create socket pair for AF_UNIX socket to external "
146 const char *
msg =
"ERROR: failure during write to AF_UNIX socket: ";
153 return write(tt->fd, buf, len);
159 const char *
msg =
"ERROR: failure during read from AF_UNIX socket: ";
167 return read(tt->fd, buf, len);
174 msg(
M_ERR,
"AF_UNIX socket support not available on this platform");
void argv_free(struct argv *a)
Frees all memory allocations allocated by the struct argv related functions.
bool argv_printf(struct argv *argres, const char *format,...)
printf() variant which populates a struct argv.
struct argv argv_new(void)
Allocates a new struct argv and ensures it is initialised.
char * string_alloc(const char *str, struct gc_arena *gc)
static void gc_free(struct gc_arena *a)
static struct gc_arena gc_new(void)
void setenv_int(struct env_set *es, const char *name, int value)
void setenv_str(struct env_set *es, const char *name, const char *value)
void env_set_inherit(struct env_set *es, const struct env_set *src)
struct env_set * env_set_create(struct gc_arena *gc)
void set_cloexec(socket_descriptor_t fd)
bool openvpn_waitpid_check(pid_t pid, const char *msg_prefix, int msglevel)
Checks if a running process is still running.
int openvpn_execve_check(const struct argv *a, const struct env_set *es, const unsigned int flags, const char *error_message)
#define S_NOWAITPID
instead of waiting for child process to exit and report the status, return the pid of the child proce...
void socket_set_buffers(socket_descriptor_t fd, const struct socket_buffer_size *sbs, bool reduce_size)
Sets the receive and send buffer sizes of a socket descriptor.
Garbage collection arena used to keep track of dynamically allocated memory.
const char * route_default_gateway
const char * dev_type_string(const char *dev, const char *dev_type)
void open_tun_afunix(struct options *o, int mtu, struct tuntap *tt, struct env_set *orig_env)
Opens an AF_UNIX based tun device.
static void tun_afunix_exec_child(const char *dev_node, struct tuntap *tt, struct env_set *env)
ssize_t read_tun_afunix(struct tuntap *tt, uint8_t *buf, int len)
Reads a packet from a AF_UNIX based tun device.
void close_tun_afunix(struct tuntap *tt)
Closes the socket used for the AF_UNIX based device.
ssize_t write_tun_afunix(struct tuntap *tt, uint8_t *buf, int len)
Writes a packet to a AF_UNIX based tun device.