/*
SSSD
Secrets Responder
Copyright (C) Simo Sorce <ssorce@redhat.com> 2016
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "responder/common/responder.h"
#include "responder/secrets/secsrv_private.h"
/* ##### Request Handling ##### */
struct sec_http_request_state {
};
struct tevent_context *ev,
struct sec_req_ctx *secreq)
{
/* Go through the pipeline */
/* 1. mapping and path conversion */
if (ret) {
goto done;
}
/* 2. backend invocation */
if (!subreq) {
goto done;
}
return req;
done:
}
}
{
/* 3. reply construction */
} else {
}
}
{
return EOK;
}
/* --- */
static void
{
int ret;
} else {
"sec_http_request_recv failed [%d]: %s\n",
}
/* Always return an error if we get here */
}
"Failed to find reply, aborting client!\n");
return;
}
/* Turn writable on so we can write back the reply */
}
{
if (!req) {
"Failed to schedule secret retrieval\n.");
return;
}
}
/* ##### HTTP Parsing Callbacks ##### */
{
if (*dest) {
} else {
}
}
{
"Request too big, aborting client!\n");
return true;
}
return false;
}
{
return 0;
}
{
if (!req->request_url) {
"Failed to store URL, aborting client!\n");
return -1;
}
return 0;
}
{
int n = req->num_headers;
} else if ((n % 10 == 0) &&
struct sec_kvp, n + 10);
}
}
"Failed to store headers, aborting client!\n");
return -1;
}
/* new field */
n++;
}
"Failed to store header name, aborting client!\n");
return -1;
}
return 0;
}
{
int n = req->num_headers;
"Invalid headers pointer, aborting client!\n");
return -1;
}
/* we increment on new value */
n = ++req->num_headers;
}
"Failed to store header value, aborting client!\n");
return -1;
}
return 0;
}
{
/* TODO: if message has no body we should return 1 */
return 0;
}
{
"Failed to store body, aborting client!\n");
return -1;
}
return 0;
}
struct http_parser_url *parsed,
char *source_buf,
char **dest)
{
if (!*dest) {
"Failed to parse url, aborting client!\n");
return ENOMEM;
}
return EOK;
}
{
int ret;
/* parse url as well */
0, &parsed);
if (ret) {
return ret;
}
if (ret) {
return -1;
}
}
if (ret) {
return -1;
}
}
}
if (ret) {
return -1;
}
}
if (ret) {
return -1;
}
}
if (ret) {
return -1;
}
}
if (ret) {
return -1;
}
}
return 0;
}
/* ##### Communications ##### */
{
errno = 0;
if (len == -1) {
return EAGAIN;
} else {
return ret;
}
}
if (len == 0) {
return EIO;
}
return EOK;
}
{
int ret;
/* not all data was sent, loop again */
return;
}
return;
}
/* ok all sent */
return;
}
{
errno = 0;
if (len == -1) {
return EAGAIN;
} else {
return ret;
}
}
if (len == 0) {
return ENODATA;
}
return EOK;
}
{
int ret;
if (!req) {
/* A new request comes in, setup data structures */
if (!req) {
"Failed to setup request handlers, aborting client\n");
return;
}
}
switch (ret) {
case ENODATA:
"Client closed connection.\n");
return;
case EAGAIN:
"Interrupted before any data could be read, retry later\n");
return;
case EOK:
/* all fine */
break;
default:
"Failed to receive data (%d, %s), aborting client\n",
return;
}
"Failed to parse request, aborting client!\n");
return;
}
return;
}
/* do not read anymore, client is done sending */
}
{
/* Always reset the idle timer on any activity */
"Could not create idle timer for client. "
"This connection may not auto-terminate\n");
/* Non-fatal, continue */
}
if (flags & TEVENT_FD_READ) {
return;
}
if (flags & TEVENT_FD_WRITE) {
return;
}
}
.on_url = sec_on_url,
.on_body = sec_on_body,
};
{
if (!protocol_ctx) return ENOMEM;
return EOK;
}
/* Dummy, not used here but required to link to other responder files */
{
return NULL;
}