providers.c revision efc65e78fa4e01e6cecc8690a9899af61213be62
/*
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 "responder/secrets/secsrv_private.h"
#include "responder/secrets/secsrv_local.h"
#include "responder/secrets/secsrv_proxy.h"
#include <jansson.h>
char **mapped_path)
{
/* change path to be user specific */
*mapped_path =
if (!*mapped_path) {
"Failed to map request to user specific url\n");
return ENOMEM;
}
return EOK;
}
struct provider_handle **handle)
{
char **sections;
char *def_provider;
char *provider;
int num_sections;
int ret;
/* patch must start with /secrets/ for now */
if (ret != 0) {
return EPERM;
}
/* source default provider */
&def_provider);
&num_sections);
// TODO order by length ?
for (int i = 0; i < num_sections; i++) {
int slen;
char *secname;
sections[i]);
&provider);
break;
}
}
} else {
"Unknown provider type: %s\n", provider);
}
}
}
return ret;
}
return EOK;
}
static struct sec_http_status_format_table {
int status;
const char *text;
const char *description;
} sec_http_status_format_table[] = {
{ 200, "OK", "Success" },
{ 400, "Bad Request",
"The request format is invalid." },
{ 401, "Unauthorized",
"Access to the requested resource requires authentication." },
{ 403, "Forbidden",
"Access to the requested resource is forbidden." },
{ 404, "Not Found",
"The requested resource was not found." },
{ 405, "Method Not Allowed",
"Request method not allowed for this resource." },
{ 406, "Not Acceptable",
"The request cannot be accepted." },
{ 409, "Conflict",
"The requested resource already exists." },
{ 500, "Internal Server Error",
"The server encountered an internal error." },
};
enum sec_http_status_codes code)
{
"<html>\r\n"
"<head>\r\n<title>%d %s</title></head>\r\n"
"<body>\r\n"
"<h1>%s</h1>\r\n"
"<p>%s</p>\r\n"
"</body>",
"HTTP/1.1 %d %s\r\n"
"Content-Length: %u\r\n"
"\r\n"
"%s",
return EOK;
}
enum sec_http_status_codes code,
const char *content_type,
{
int head_size;
"HTTP/1.1 %d %s\r\n"
"Content-Type: %s\r\n"
"Content-Length: %zu\r\n"
"\r\n",
return EOK;
}
{
} else {
}
return EOK;
}
int status_code, const char *reason,
{
bool add_content_length = true;
bool has_content_type = false;
int ret;
/* Status-Line */
/* Headers */
for (int i = 0; i < num_headers; i++) {
add_content_length = false;
has_content_type = true;
}
}
if (!has_content_type) return EINVAL;
if (add_content_length) {
}
/* CRLF separator before body */
/* Message-Body */
}
return EOK;
}
{
switch (err) {
case EOK:
return STATUS_200;
case EINVAL:
return STATUS_400;
case EACCES:
return STATUS_401;
case EPERM:
return STATUS_403;
case ENOENT:
return STATUS_404;
case EISDIR:
return STATUS_405;
case EMEDIUMTYPE:
return STATUS_406;
case EEXIST:
return STATUS_409;
default:
return STATUS_500;
}
}
const char *input,
char **secret)
{
int ret;
if (!root) {
"Failed to parse JSON payload on line %d: %s\n",
return EINVAL;
}
if (!json_is_object(root)) {
goto done;
}
if (!element) {
goto done;
}
if (!json_is_string(element)) {
goto done;
}
ret = EMEDIUMTYPE;
goto done;
}
if (!element) {
goto done;
}
if (!json_is_string(element)) {
goto done;
}
if (!*secret) {
} else {
}
done:
return ret;
}
const char *secret,
char **output)
{
int ret;
if (!jsonized) {
goto done;
}
if (!*output) {
goto done;
}
done:
return ret;
}
char **output)
{
int ret;
root = json_array();
for (int i = 0; i < count; i++) {
// FIXME: json_string mem leak ?
// FIXME: Error checking
}
if (!jsonized) {
goto done;
}
if (!*output) {
goto done;
}
done:
return ret;
}
struct provider_handle **out_handle)
{
struct provider_handle *handle;
continue;
}
*out_handle = handle;
return EOK;
}
return ENOENT;
}
{
int c;
continue;
struct provider_handle *, c + 2);
return EOK;
}
{
for (int i = 0; i < req->num_headers; i++) {
}
}
return false;
}