sshsrv_cmd.c revision b42b5d5aaf4da165582e73ad985fdff6e34e61e4
/*
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;
}
} else {
cmd_ctx->check_next = true;
}
done:
}
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
{
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 ENOENT;
}
if (cmd_ctx->results_len == 0) {
/* 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;
/* if it is a domainless search, skip domains that require fully
* qualified names instead */
}
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
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;
}
("Host search by name (%s) returned > 1 results!\n",
return ENOENT;
}
if (cmd_ctx->results_len == 0) {
/* if a multidomain search, try with next */
if (cmd_ctx->check_next) {
return ssh_host_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 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++) {
SSS_SSH_FORMAT_OPENSSH, "");
if (!pubkey) {
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++) {
SSS_SSH_FORMAT_OPENSSH, "");
if (!pubkey) {
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;
if (!tmp_ctx) {
return ENOMEM;
}
/* write known_hosts file */
if (!filename) {
goto done;
}
if (fd == -1) {
goto done;
}
while (dom) {
("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:
return ret;
}
static errno_t
{
size_t c = 0;
char *name;
char *alias;
if (flags > 1) {
return EINVAL;
}
if (name_len == 0) {
return EINVAL;
}
return EINVAL;
}
c += name_len;
return ENOENT;
}
if (flags & 1) {
if (alias_len == 0) {
return EINVAL;
}
return EINVAL;
}
c += alias_len;
}
}
return EOK;
}
static errno_t
{
size_t c = 0;
size_t i;
unsigned int j;
struct ldb_message_element *el;
const char *name;
char *fqname;
return ret;
}
/* count number of results */
for (i = 0; i < cmd_ctx->results_len; i++) {
if (!el) {
continue;
}
}
return ret;
}
SAFEALIGN_SET_UINT32(body+c, 0, &c);
for (i = 0; i < cmd_ctx->results_len; i++) {
SYSDB_NAME, NULL);
if (!name) {
("Got unnamed result for [%s@%s]\n",
return ENOENT;
}
if (!fqname) {
return ENOMEM;
}
if (!el) {
/* this object has no SSH public keys */
continue;
}
for (j = 0; j < el->num_values; j++) {
&key_len);
if (!key) {
return ENOMEM;
}
return ret;
}
SAFEALIGN_SET_UINT32(body+c, 0, &c);
count++;
}
}
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;
}
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;
}