/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file
*/
#include "lib.h"
#include "ioloop.h"
#include "str.h"
#include "strescape.h"
#include "array.h"
#include "net.h"
#include "write-full.h"
#include "eacces-error.h"
#include "istream-private.h"
#include "ostream.h"
#include "dns-lookup.h"
#include "program-client-private.h"
#include <unistd.h>
#include <sysexits.h>
PROGRAM_CLIENT_VERSION_MAJOR "\t" \
static
/*
* Script client input stream
*/
struct program_client_istream {
};
static
{
(struct program_client_istream *) stream;
}
static void
{
return;
}
case '+':
break;
case '-':
break;
default:
}
}
static ssize_t
{
(struct program_client_istream *) stream;
reserved = 0;
}
if (pos == 0)
ret = -1;
} else
do {
return -2; /* input buffer full */
}
break;
/* Check return code at EOF */
}
if (ret >= reserve_mod) {
ret -= reserve_mod;
}
}
/* Parent EOF and not more data to return; EOF here as well */
if (pos == 0)
ret = -1;
}
} while (ret == 0);
return ret;
}
static
{
i_panic("program_client_istream sync() not implemented");
}
static
{
(struct program_client_istream *) stream;
int ret;
/* Stat the original stream */
return ret;
return ret;
}
static
{
i_stream_seek(input, 0);
}
/*
* Program client
*/
struct program_client_remote {
const char *hostname;
unsigned int ips_count;
unsigned int ips_left;
};
static
{
(struct program_client_remote *) pclient;
i_stream_unref(&is);
}
const char *const *env;
}
}
else
}
}
i_error("write(%s) failed: %s",
return;
}
(void)program_client_connected(pclient);
}
static
static
{
(void)program_client_unix_connect(pclient);
}
static
{
(struct program_client_remote *) pclient;
int fd;
switch (errno) {
case EACCES:
i_error("%s",
eacces_error_get("net_connect_unix",
return -1;
case EAGAIN:
timeout_add_short(100,
pclient);
return 0;
default:
i_error("net_connect_unix(%s) failed: %m",
return -1;
}
}
return 0;
}
static
{
i_error("connect(%s) failed: timeout in %u milliseconds",
/* set error to timeout here */
}
/* see if connect succeeded or not, if it did, then proceed
normally, otherwise try reconnect to next address */
static
{
i_error("connect(%s) failed: %m",
/* disconnect and try again */
} else {
}
}
static
{
const char *str;
(struct program_client_remote *) pclient;
i_unreached();
i_debug("Trying to connect %s (timeout %u msecs)",
}
/* try to connect */
int fd;
&net_ip4_any : &net_ip6_any))) < 0) {
pclient);
return;
}
}
}
static
{
(struct program_client_remote *) pclient;
i_error("program-client-net: %s: No addresses left to try",
error :
return;
};
}
static
struct program_client *pclient)
{
(struct program_client_remote *) pclient;
i_error("program-client-net: Cannot resolve '%s': %s",
return;
}
/* reduce timeout */
/* we ran out of time */
return;
}
}
/* then connect */
}
static
{
(struct program_client_remote *) pclient;
net_ip2addr(&ip));
} else {
return 0;
} else {
unsigned int ips_count;
int err;
/* guess we do it here then.. */
i_error("program-client-remote: "
"Cannot resolve '%s': %s",
return -1;
}
ips,
}
}
pclient);
return 0;
}
static
{
return 1;
/* Shutdown output; program stdin will get EOF */
if (fd_out >= 0) {
if (fd_in >= 0) {
i_error("shutdown(%s, SHUT_WR) failed: %m",
return -1;
}
return -1;
}
}
return 1;
}
static
{
(struct program_client_remote *)pclient;
/* nothing */
const unsigned char *data;
/* Skip any remaining program output and parse the exit code */
while (i_stream_read_more
}
/* Check for error and EOF. Since we're disconnected, always
mark an internal error when not all input is read. This is
generally unlikely to occur. */
} else {
}
}
static
{
(struct program_client_remote *)pclient;
}
struct program_client *
const struct program_client_settings *set,
bool noreply)
{
}
struct program_client *
const char *const *args,
const struct program_client_settings *set,
bool noreply)
{
}
struct program_client *
const char *const *args,
const struct program_client_settings *set,
bool noreply)
{
}