sudosrv_private.h revision dee665060ba71ff61ad223e755ae61441118fbba
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber/*
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber Authors:
fd5c4f905861964cb473cf3df3336447a9365962Stéphane Graber Pavel Březina <pbrezina@redhat.com>
fd5c4f905861964cb473cf3df3336447a9365962Stéphane Graber
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber Copyright (C) 2011 Red Hat
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber This program is free software; you can redistribute it and/or modify
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber it under the terms of the GNU General Public License as published by
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber the Free Software Foundation; either version 3 of the License, or
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber (at your option) any later version.
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber This program is distributed in the hope that it will be useful,
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber but WITHOUT ANY WARRANTY; without even the implied warranty of
afeecbba0359d2b4404cdf896e6b6d0b5a8443b0Serge Hallyn MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ae5c8b8ed5feb9a47c5007c986ce01ea39b5075fSerge Hallyn GNU General Public License for more details.
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn
0115f8fd27b1a31d367bb161a121694f92b45e62Dwight Engen You should have received a copy of the GNU General Public License
f5dd1d532a76a1b57cf341db821eae85ea1118c5Serge Hallyn along with this program. If not, see <http://www.gnu.org/licenses/>.
f209d63a97a8a2df5324608fee7b0d7a494d69ebS.Çağlar Onur*/
b494d2ddf769220da1ef75fd24275ce68cdf297cSerge Hallyn
2aa123185e055bbe2506a6210e795e0b9375e477Serge Hallyn#ifndef _SUDOSRV_PRIVATE_H_
a41f104bfbd69e5f068e5ca312a2eb513d9e81b8Serge Hallyn#define _SUDOSRV_PRIVATE_H_
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen
710bde5e52ec3f1260f0ed7d50b7c46a8d7bbda3S.Çağlar Onur#include <stdint.h>
198b363fff1de9afcee2f26b9aa847316f589afeSerge Hallyn#include <talloc.h>
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber#include <sys/types.h>
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber#include "src/db/sysdb.h"
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber#include "responder/common/responder.h"
2a59a68183e55e38beedb6442938e31eb7d4749cSerge Hallyn
0a18b5458b6d0fcad9a82b96f99035254af50c7aSerge Hallyn#define SSS_SUDO_ERROR_OK 0
061ba5d071e4c2b4bfe76c84875bc29cc5334c27Stéphane Graber
061ba5d071e4c2b4bfe76c84875bc29cc5334c27Stéphane Graberenum sss_dp_sudo_type {
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber SSS_DP_SUDO_REFRESH_RULES,
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen SSS_DP_SUDO_FULL_REFRESH
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen};
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engenenum sss_sudo_type {
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen SSS_SUDO_DEFAULTS,
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen SSS_SUDO_USER
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen};
72863294f63e27ac263a774aab37aace20dc1bc5Dwight Engen
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graberstruct sudo_ctx {
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber struct resp_ctx *rctx;
ae5c8b8ed5feb9a47c5007c986ce01ea39b5075fSerge Hallyn
8befa924f89520784ca2cb876279ab6098cd73e1Serge Hallyn /*
2aa123185e055bbe2506a6210e795e0b9375e477Serge Hallyn * options
198b363fff1de9afcee2f26b9aa847316f589afeSerge Hallyn */
198b363fff1de9afcee2f26b9aa847316f589afeSerge Hallyn bool timed;
20ab58c777136a449b3199e0733b62fa87ecfa61Serge Hallyn bool inverse_order;
e6744e9b39c20166e900479339076631902e6d8fSerge Hallyn int threshold;
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber};
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn
188adf0594f623a1273b89a646402484b6816f90Stéphane Graberstruct sudo_cmd_ctx {
8d1ea537851718553358a4a9767274f893b40420Christian Brauner struct cli_ctx *cli_ctx;
7aff4f43fd84b021db12b2ffed1a4aa1b4cf65efSerge Hallyn struct sudo_ctx *sudo_ctx;
188adf0594f623a1273b89a646402484b6816f90Stéphane Graber enum sss_sudo_type type;
c4532a2036fd4a9283275b499b7a379fa9689172Serge Hallyn
592fd47a6245508b79fe6ac819fe6d3b2c1289beSerge Hallyn /* input data */
188adf0594f623a1273b89a646402484b6816f90Stéphane Graber uid_t uid;
188adf0594f623a1273b89a646402484b6816f90Stéphane Graber char *rawname;
188adf0594f623a1273b89a646402484b6816f90Stéphane Graber
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn /* output data */
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn struct sysdb_attrs **rules;
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber uint32_t num_rules;
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen};
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engenstruct sss_cmd_table *get_sudo_cmds(void);
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graber
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graberstruct tevent_req *sudosrv_get_rules_send(TALLOC_CTX *mem_ctx,
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graber struct tevent_context *ev,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen struct sudo_ctx *sudo_ctx,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen enum sss_sudo_type type,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen uid_t cli_uid,
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graber const char *username);
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engenerrno_t sudosrv_get_rules_recv(TALLOC_CTX *mem_ctx,
8b605e2305d74b17ac4cd653a7a0637e65c62bffStéphane Graber struct tevent_req *req,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen struct sysdb_attrs ***_rules,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen uint32_t *_num_rules);
8d1ea537851718553358a4a9767274f893b40420Christian Brauner
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Grabererrno_t sudosrv_parse_query(TALLOC_CTX *mem_ctx,
7aff4f43fd84b021db12b2ffed1a4aa1b4cf65efSerge Hallyn uint8_t *query_body,
188adf0594f623a1273b89a646402484b6816f90Stéphane Graber size_t query_len,
67702c2129c462b5e8124020a496fbf6b7ae5540Serge Hallyn char **_rawname,
e6744e9b39c20166e900479339076631902e6d8fSerge Hallyn uid_t *_uid);
c4532a2036fd4a9283275b499b7a379fa9689172Serge Hallyn
592fd47a6245508b79fe6ac819fe6d3b2c1289beSerge Hallynerrno_t sudosrv_build_response(TALLOC_CTX *mem_ctx,
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graber uint32_t error,
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graber uint32_t rules_num,
45794802f13e5db18b5d7acb45169e1f4e8b70b2Stéphane Graber struct sysdb_attrs **rules,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen uint8_t **_response_body,
90341b9e39561e37797777a34d0589c14c0c2a68Dwight Engen size_t *_response_len);
f209d63a97a8a2df5324608fee7b0d7a494d69ebS.Çağlar Onur
8b605e2305d74b17ac4cd653a7a0637e65c62bffStéphane Graberstruct tevent_req *
sss_dp_get_sudoers_send(TALLOC_CTX *mem_ctx,
struct resp_ctx *rctx,
struct sss_domain_info *dom,
bool fast_reply,
enum sss_dp_sudo_type type,
const char *name,
uint32_t num_rules,
struct sysdb_attrs **rules);
errno_t
sss_dp_get_sudoers_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
dbus_uint16_t *err_maj,
dbus_uint32_t *err_min,
char **err_msg);
#endif /* _SUDOSRV_PRIVATE_H_ */