sshsrv_cmd.c revision 4de84af23db74e13e867985c9093f394c9fa8d51
/*
Authors:
Jan Cholasta <jcholast@redhat.com>
Copyright (C) 2012 Red Hat
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 <talloc.h>
#include <string.h>
#include <netdb.h>
#include "util/crypto/sss_crypto.h"
#include "db/sysdb_ssh.h"
#include "providers/data_provider.h"
#include "responder/common/responder.h"
#include "responder/common/responder_packet.h"
#include "responder/ssh/sshsrv_private.h"
static errno_t
static errno_t
static errno_t
int
{
struct ssh_cmd_ctx *cmd_ctx;
if (!cmd_ctx) {
return ENOMEM;
}
goto done;
}
"Requesting SSH user public keys for [%s] from [%s]\n",
goto done;
}
goto done;
}
} else {
cmd_ctx->check_next = true;
}
done:
}
static errno_t
static errno_t
static int
{
struct ssh_cmd_ctx *cmd_ctx;
if (!cmd_ctx) {
return ENOMEM;
}
goto done;
}
"Requesting SSH host public keys for [%s][%s] from [%s]\n",
goto done;
}
} else {
cmd_ctx->check_next = true;
}
done:
}
static void
{
struct dp_callback_ctx *cb_ctx =
char *err_msg;
&err_msg);
"Fatal error, killing connection!\n");
return;
}
}
static errno_t
static void
const char *err_msg,
void *ptr);
static errno_t
{
struct tevent_req *req;
struct dp_callback_ctx *cb_ctx;
/* if it is a domainless search, skip domains that require fully
* qualified names instead */
}
return ENOENT;
}
/* refresh the user's cache entry */
if (!req) {
"Out of memory sending data provider request\n");
return ENOMEM;
}
if (!cb_ctx) {
return ENOMEM;
}
/* tell caller we are in an async call */
return EAGAIN;
}
return ssh_user_pubkeys_search_next(cmd_ctx);
}
static errno_t
{
NULL };
struct ldb_result *res;
"Requesting SSH user public keys for [%s@%s]\n",
"Fatal: Sysdb CTX not found for this domain!\n");
return EFAULT;
}
"Failed to make request to our cache!\n");
return EIO;
}
"User search by name (%s) returned > 1 results!\n",
return EINVAL;
}
/* if a multidomain search, try with next */
if (cmd_ctx->check_next) {
return ssh_user_pubkeys_search(cmd_ctx);
}
return ENOENT;
}
/* one result found */
return EOK;
}
static void
const char *err_msg,
void *ptr)
{
if (err_maj) {
"Unable to get information from Data Provider\n"
"Error: %u, %u, %s\n",
}
}
static errno_t
static void
const char *err_msg,
void *ptr);
static errno_t
{
struct tevent_req *req;
struct dp_callback_ctx *cb_ctx;
return ENOENT;
}
/* refresh the host's cache entry */
if (!req) {
"Out of memory sending data provider request\n");
return ENOMEM;
}
if (!cb_ctx) {
return ENOMEM;
}
/* tell caller we are in an async call */
return EAGAIN;
}
return ssh_host_pubkeys_search_next(cmd_ctx);
}
static errno_t
{
"Requesting SSH host public keys for [%s@%s]\n",
"Fatal: Sysdb CTX not found for this domain!\n");
return EFAULT;
}
"Failed to make request to our cache!\n");
return EIO;
}
/* if a multidomain search, try with next */
if (cmd_ctx->check_next) {
return ssh_host_pubkeys_search(cmd_ctx);
}
return ENOENT;
}
return EOK;
}
static void
const char *err_msg,
void *ptr)
{
if (err_maj) {
"Unable to get information from Data Provider\n"
"Error: %u, %u, %s\n",
}
}
static char *
struct sss_ssh_ent *ent)
{
size_t i;
if (!tmp_ctx) {
return NULL;
}
if (!name) {
goto done;
}
for (i = 0; i < ent->num_aliases; i++) {
if (!name) {
goto done;
}
}
if (!result) {
goto done;
}
for (i = 0; i < ent->num_pubkeys; i++) {
goto done;
}
if (!result) {
goto done;
}
}
done:
return result;
}
static char *
struct sss_ssh_ent *ent)
{
size_t i, j, k;
if (!tmp_ctx) {
return NULL;
}
if (!result) {
goto done;
}
for (i = 0; i < ent->num_pubkeys; i++) {
goto done;
}
for (j = 0; j <= ent->num_aliases; j++) {
for (k = 0; k < SSS_SHA1_LENGTH; k++) {
}
hash);
"sss_hmac_sha1() failed (%d): %s\n",
goto done;
}
if (!saltstr) {
goto done;
}
if (!hashstr) {
goto done;
}
if (!result) {
goto done;
}
}
}
done:
return result;
}
static errno_t
{
const char *attrs[] = {
};
struct ldb_message **hosts;
struct sss_ssh_ent *ent;
int fd = -1;
char *entstr;
if (!tmp_ctx) {
return ENOMEM;
}
goto done;
}
}
/* write known_hosts file */
if (!filename) {
goto done;
}
if (fd == -1) {
goto done;
}
"Fatal: Sysdb CTX not found for this domain!\n");
goto done;
}
}
continue;
}
for (i = 0; i < num_hosts; i++) {
"Failed to get SSH host public keys\n");
continue;
}
if (ssh_ctx->hash_known_hosts) {
} else {
}
if (!entstr) {
"Failed to format known_hosts data for [%s]\n",
continue;
}
if (wret == -1) {
goto done;
}
}
}
if (ret == -1) {
goto done;
}
if (ret == -1) {
goto done;
}
done:
/* non-fatal failure */
"Failed to remove file: %s - %d : [%s]!\n",
}
}
return ret;
}
static errno_t
{
struct ssh_ctx);
size_t c = 0;
char *name;
return EINVAL;
}
return EINVAL;
}
return EINVAL;
}
c += name_len;
if (flags & SSS_SSH_REQ_ALIAS) {
return EINVAL;
}
return EINVAL;
}
c += alias_len;
}
if (flags & SSS_SSH_REQ_DOMAIN) {
if (domain_len > 0) {
if (domain_len > body_len - c) {
return EINVAL;
}
"Domain is not valid UTF-8 string\n");
return EINVAL;
}
c += domain_len;
}
} else {
return ENOENT;
}
}
"Invalid name received [%s]\n", name);
return ENOENT;
}
} else {
}
}
}
}
return EOK;
}
struct ldb_message_element *el,
bool cert_data,
const char *fqname,
size_t *c)
{
int ret;
size_t d;
return EOK;
}
return ENOMEM;
}
for (d = 0; d < el->num_values; d++) {
if (cert_data) {
return ret;
}
} else {
&key_len);
goto done;
}
}
goto done;
}
SAFEALIGN_SET_UINT32(body+(*c), 0, c);
}
done:
return ret;
}
static errno_t
{
size_t c = 0;
const char *name;
char *fqname;
struct ssh_ctx);
return ret;
}
if (el) {
}
if (el_orig) {
}
if (el_override) {
}
}
if (el_user_cert) {
/* TODO check if cert is valid */
}
return ret;
}
SAFEALIGN_SET_UINT32(body+c, 0, &c);
if (count == 0) {
return EOK;
}
if (!name) {
"Got unnamed result for [%s@%s]\n",
return ENOENT;
}
if (!fqname) {
return ENOMEM;
}
fqname_len, fqname, &c);
return ret;
}
fqname_len, fqname, &c);
return ret;
}
fqname_len, fqname, &c);
return ret;
}
fqname_len, fqname, &c);
return ret;
}
return EOK;
}
static errno_t
{
return ret;
}
return EOK;
}
static errno_t
{
/* create response packet */
return ret;
}
return EOK;
}
static errno_t
{
switch (ret) {
case EOK:
break;
case EAGAIN:
return EOK;
case EFAULT:
break;
default:
break;
}
return EFAULT;
}
return EOK;
}
static errno_t
{
}
static errno_t
{
}
}
struct cli_protocol_version *register_cli_protocol_version(void)
{
static struct cli_protocol_version ssh_cli_protocol_version[] = {
};
return ssh_cli_protocol_version;
}
struct sss_cmd_table *get_ssh_cmds(void) {
static struct sss_cmd_table ssh_cmds[] = {
{SSS_CLI_NULL, NULL}
};
return ssh_cmds;
}