sudosrv_cmd.c revision d117004902c767d46430848b6ef1c11c3ad82835
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes/*
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes Authors:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes Pavel Březina <pbrezina@redhat.com>
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes Copyright (C) 2011 Red Hat
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes This program is free software; you can redistribute it and/or modify
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes it under the terms of the GNU General Public License as published by
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes the Free Software Foundation; either version 3 of the License, or
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes (at your option) any later version.
0662ed52e814f8f08ef0e09956413a792584eddffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes This program is distributed in the hope that it will be useful,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes but WITHOUT ANY WARRANTY; without even the implied warranty of
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes GNU General Public License for more details.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes You should have received a copy of the GNU General Public License
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes along with this program. If not, see <http://www.gnu.org/licenses/>.
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes*/
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes
16b55a35cff91315d261d1baa776138af465c4e4fuankg#include <stdint.h>
16b55a35cff91315d261d1baa776138af465c4e4fuankg#include <errno.h>
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include <talloc.h>
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include "util/util.h"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include "responder/common/responder.h"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include "responder/common/responder_packet.h"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include "responder/sudo/sudosrv_private.h"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include "db/sysdb_sudo.h"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#include "sss_client/sss_cli.h"
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic errno_t sudosrv_cmd_send_reply(struct sudo_cmd_ctx *cmd_ctx,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes uint8_t *response_body,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes size_t response_len)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes errno_t ret;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes uint8_t *packet_body = NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes size_t packet_len = 0;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes struct cli_ctx *cli_ctx = cmd_ctx->cli_ctx;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes TALLOC_CTX *tmp_ctx;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes tmp_ctx = talloc_new(NULL);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (!tmp_ctx) return ENOMEM;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sss_packet_new(cli_ctx->creq, 0,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes sss_packet_get_cmd(cli_ctx->creq->in),
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes &cli_ctx->creq->out);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_CRIT_FAILURE,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ("Unable to create a new packet [%d]; %s\n",
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret, strerror(ret)));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes goto done;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sss_packet_grow(cli_ctx->creq->out, response_len);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_CRIT_FAILURE,
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg ("Unable to create response: %s\n", strerror(ret)));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes goto done;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes sss_packet_get_body(cli_ctx->creq->out, &packet_body, &packet_len);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes memcpy(packet_body, response_body, response_len);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes sss_packet_set_error(cli_ctx->creq->out, EOK);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes sss_cmd_done(cmd_ctx->cli_ctx, cmd_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = EOK;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdone:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes talloc_zfree(tmp_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return ret;
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic errno_t sudosrv_cmd_send_error(TALLOC_CTX *mem_ctx,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes struct sudo_cmd_ctx *cmd_ctx,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes uint32_t error)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes uint8_t *response_body = NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes size_t response_len = 0;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes int ret = EOK;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (error == EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_MINOR_FAILURE, ("Everything is fine but we are "
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "returning error?\n"));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sudosrv_build_response(mem_ctx, error, NULL, 0, NULL,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes &response_body, &response_len);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return ret;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg return sudosrv_cmd_send_reply(cmd_ctx, response_body, response_len);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
ac7985784d08a3655291f24f711812b4d8b1cbcffuankgerrno_t sudosrv_cmd_done(struct sudo_cmd_ctx *cmd_ctx, int ret)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes uint8_t *response_body = NULL;
0a39e7683f6611d66c55712f50bb240428d832a1bnicholes size_t response_len = 0;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes size_t num_rules = cmd_ctx->num_rules;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes struct sysdb_attrs **rules = cmd_ctx->rules;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes switch (ret) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes case EOK:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /*
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * Parent of cmd_ctx->rules is in-memory cache, we must not talloc_free it!
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes */
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg if (cmd_ctx->sudo_ctx->timed) {
0662ed52e814f8f08ef0e09956413a792584eddffuankg /* filter rules by time */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sysdb_sudo_filter_rules_by_time(cmd_ctx, cmd_ctx->num_rules,
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg cmd_ctx->rules, 0,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes &num_rules, &rules);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* send result */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sudosrv_build_response(cmd_ctx, SSS_SUDO_ERROR_OK,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx->domain->name, num_rules, rules,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes &response_body, &response_len);
0662ed52e814f8f08ef0e09956413a792584eddffuankg if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sudosrv_cmd_send_reply(cmd_ctx, response_body, response_len);
0662ed52e814f8f08ef0e09956413a792584eddffuankg break;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes case EAGAIN:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* async processing, just return here */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EOK;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes case EFAULT:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* very bad error */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
0662ed52e814f8f08ef0e09956413a792584eddffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* case ENOENT:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes * - means user not found
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg * - send error ENOENT
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes default:
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg /* send error */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sudosrv_cmd_send_error(cmd_ctx, cmd_ctx, ret);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes break;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_CRIT_FAILURE, ("Fatal error, killing connection!\n"));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes talloc_free(cmd_ctx->cli_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EOK;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int sudosrv_cmd(enum sss_sudo_type type, struct cli_ctx *cli_ctx)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes struct sudo_cmd_ctx *cmd_ctx = NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes struct sudo_dom_ctx *dom_ctx = NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes uint8_t *query_body = NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes size_t query_len = 0;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes errno_t ret;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* create cmd_ctx */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx = talloc_zero(cli_ctx, struct sudo_cmd_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (cmd_ctx == NULL) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* kill the connection here as we have no context for reply */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_FATAL_FAILURE, ("Out of memory?\n"));
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg return ENOMEM;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx->domain = NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx->cli_ctx = cli_ctx;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx->type = type;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx->sudo_ctx = talloc_get_type(cli_ctx->rctx->pvt_ctx, struct sudo_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (cmd_ctx->sudo_ctx == NULL) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_FATAL_FAILURE, ("sudo_ctx not set, killing connection!\n"));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* if protocol is invalid return */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (cli_ctx->cli_protocol_version->version != SSS_SUDO_PROTOCOL_VERSION) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_FATAL_FAILURE, ("Invalid protocol! [%d]\n",
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cli_ctx->cli_protocol_version->version));
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg ret = EFAULT;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes goto done;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* parse query */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes sss_packet_get_body(cli_ctx->creq->in, &query_body, &query_len);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (query_len <= 0 || query_body == NULL) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_CRIT_FAILURE, ("Query is empty\n"));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = EINVAL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes goto done;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sudosrv_parse_query(cmd_ctx, cli_ctx->rctx,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes query_body, query_len,
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes &cmd_ctx->uid, &cmd_ctx->username, &cmd_ctx->domain);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (ret != EOK) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_CRIT_FAILURE, ("Invalid query: %s\n", strerror(ret)));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes goto done;
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg }
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes cmd_ctx->check_next = cmd_ctx->domain == NULL;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes switch (cmd_ctx->type) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes case SSS_SUDO_DEFAULTS:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_FUNC_DATA, ("Requesting default options "
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg "for [%s] from [%s]\n", cmd_ctx->username,
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg cmd_ctx->domain ? cmd_ctx->domain->name : "<ALL>"));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes break;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes case SSS_SUDO_USER:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes DEBUG(SSSDBG_FUNC_DATA, ("Requesting rules "
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes "for [%s] from [%s]\n", cmd_ctx->username,
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg cmd_ctx->domain ? cmd_ctx->domain->name : "<ALL>"));
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes break;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes /* create domain ctx */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes dom_ctx = talloc_zero(cmd_ctx, struct sudo_dom_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes if (dom_ctx == NULL) {
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = ENOMEM;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes goto done;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes }
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg dom_ctx->cmd_ctx = cmd_ctx;
0662ed52e814f8f08ef0e09956413a792584eddffuankg dom_ctx->domain = cmd_ctx->domain != NULL ? cmd_ctx->domain
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes : cli_ctx->rctx->domains;
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes ret = sudosrv_get_sudorules(dom_ctx);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesdone:
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return sudosrv_cmd_done(cmd_ctx, ret);
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesstatic int sudosrv_cmd_get_sudorules(struct cli_ctx *cli_ctx)
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes{
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes return sudosrv_cmd(SSS_SUDO_USER, cli_ctx);
0662ed52e814f8f08ef0e09956413a792584eddffuankg}
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
ac7985784d08a3655291f24f711812b4d8b1cbcffuankgstatic int sudosrv_cmd_get_defaults(struct cli_ctx *cli_ctx)
{
return sudosrv_cmd(SSS_SUDO_DEFAULTS, cli_ctx);
}
struct cli_protocol_version *register_cli_protocol_version(void)
{
static struct cli_protocol_version sudo_cli_protocol_version[] = {
{1, "2012-05-14", "require uid and domain"},
{0, NULL, NULL}
};
return sudo_cli_protocol_version;
}
struct sss_cmd_table *get_sudo_cmds(void) {
static struct sss_cmd_table sudo_cmds[] = {
{SSS_GET_VERSION, sss_cmd_get_version},
{SSS_SUDO_GET_SUDORULES, sudosrv_cmd_get_sudorules},
{SSS_SUDO_GET_DEFAULTS, sudosrv_cmd_get_defaults},
{SSS_CLI_NULL, NULL}
};
return sudo_cmds;
}