sshsrv_cmd.c revision e7311aec8d691e5427317442387af1bc8fff3742
/*
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 <talloc.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] 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
{
("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 errno_t
{
size_t c = 0;
char *name;
if (reserved != 0) {
return EINVAL;
}
if (name_len == 0) {
return EINVAL;
}
return EINVAL;
}
c += name_len;
return ENOENT;
}
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;
}