/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "imap-urlauth-common.h"
#include "array.h"
#include "ioloop.h"
#include "net.h"
#include "fdpass.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "strescape.h"
#include "eacces-error.h"
#include "llist.h"
#include "hostpid.h"
#include "execv-const.h"
#include "env-util.h"
#include "var-expand.h"
#include "restrict-access.h"
#include "master-service.h"
#include "master-interface.h"
#include <unistd.h>
#define IMAP_URLAUTH_PROTOCOL_MINOR_VERSION 0
/* max. length of input lines (URLs) */
/* Disconnect client after idling this many milliseconds */
#define IS_STANDALONE() \
unsigned int imap_urlauth_client_count;
{
const char *app;
/* always use nonblocking I/O */
if (client_worker_connect(client) < 0) {
return -1;
}
/* determine user's special privileges */
if (set->mail_debug)
app = "submit+";
}
if (set->mail_debug)
app = "stream";
}
}
return 0;
}
{
return;
T_BEGIN {
} T_END;
}
{
const char *socket_path;
unsigned char data;
i_error("imap-urlauth-client: %s",
eacces_error_get("net_connect_unix",
socket_path));
} else {
i_error("imap-urlauth-client: net_connect_unix(%s) failed: %m",
}
return -1;
}
/* transfer one or two fds */
data = '0';
}
if (ret <= 0) {
if (ret < 0) {
i_error("fd_send(%s, %d) failed: %m",
} else {
i_error("fd_send(%s, %d) failed to send byte",
}
return -1;
}
/* send protocol version handshake */
i_error("Error sending handshake to imap-urlauth worker: %m");
return -1;
}
client->ctrl_input =
return 0;
}
{
}
}
static int
{
const char *const *apps;
unsigned int count, i;
bool restart;
int ret;
switch (client->worker_state) {
return -1;
}
for (i = 1; i < count; i++) {
}
}
if (ret < 0) {
"Failed to send ACCESS control command to worker");
return -1;
}
break;
"Failed to negotiate access parameters");
return -1;
}
break;
/* worker detected client disconnect */
/* unknown response */
"Worker finished with unknown response");
return -1;
}
i_debug("Worker finished successfully");
if (restart) {
/* connect to new worker for accessing different user */
if (client_worker_connect(client) < 0) {
"Failed to connect to new worker");
return -1;
}
/* indicate success of "END" command */
} else {
}
return -1;
default:
i_unreached();
}
return 0;
}
{
const char *line;
/* disconnected */
return;
}
switch (i_stream_read(input)) {
case -1:
/* disconnected */
return;
case -2:
/* input buffer full */
return;
}
return;
}
}
{
if (!client->disconnected) {
reason = "Connection closed";
}
}
{
}
{
if (client->disconnected)
return;
}
void clients_destroy_all(void)
{
while (imap_urlauth_clients != NULL)
}