sudosrv_get_sudorules.c revision f6171b2bc954a367f316853ab71090eb213bdee3
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen Pavel Březina <pbrezina@redhat.com>
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen Jakub Hrozek <jhrozek@redhat.com>
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen Copyright (C) 2011 Red Hat
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen This program is free software; you can redistribute it and/or modify
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen it under the terms of the GNU General Public License as published by
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen the Free Software Foundation; either version 3 of the License, or
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen (at your option) any later version.
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen This program is distributed in the hope that it will be useful,
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen GNU General Public License for more details.
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen You should have received a copy of the GNU General Public License
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
e28b88ee83b47dc2257140600f491482704c7b79Stephan Boschstatic errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx);
8bca5ef713f2916dbd60bb2b76e7cc06f4800d4dStephan Boschstatic errno_t sudosrv_get_rules(struct sudo_dom_ctx *dctx);
8bca5ef713f2916dbd60bb2b76e7cc06f4800d4dStephan Boscherrno_t sudosrv_get_sudorules(struct sudo_dom_ctx *dctx)
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen ("Looking up the user info from Data Provider\n"));
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen ("Error looking up user information [%d]: %s\n", ret, strerror(ret)));
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen /* OK, got the user from cache. Try to get the rules. */
7ef3553585e556f35d5919589cfdc1de3329e4bbTimo Sirainen ("Looking up the sudo rules from Data Provider\n"));
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen ("Error looking up sudo rules [%d]: %s\n", ret, strerror(ret)));
27a33f6aaa3d02d88c020315ae613e0c4910e950Timo Sirainenstatic void sudosrv_dp_send_acct_req_done(struct tevent_req *req);
27a33f6aaa3d02d88c020315ae613e0c4910e950Timo Sirainenstatic void sudosrv_check_user_dp_callback(uint16_t err_maj, uint32_t err_min,
27a33f6aaa3d02d88c020315ae613e0c4910e950Timo Sirainenstatic errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx)
27a33f6aaa3d02d88c020315ae613e0c4910e950Timo Sirainen struct cli_ctx *cli_ctx = dctx->cmd_ctx->cli_ctx;
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen /* if it is a domainless search, skip domains that require fully
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen * qualified names instead */
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen while (dom && cmd_ctx->check_next && dom->fqnames) {
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen if (!dom) break;
c3c07d6527ad28c8546cbbf84c257d178e23c184Timo Sirainen /* make sure to update the dctx if we changed domain */
9983cbb4cef92d68ffde87dcc91913cc2fed3da5Martti Rannanjärvi DEBUG(SSSDBG_FUNC_DATA, ("Requesting info about [%s@%s]\n",
9983cbb4cef92d68ffde87dcc91913cc2fed3da5Martti Rannanjärvi ret = sysdb_get_ctx_from_list(cli_ctx->rctx->db_list,
9983cbb4cef92d68ffde87dcc91913cc2fed3da5Martti Rannanjärvi ("sysdb context not found for this domain!\n"));
9983cbb4cef92d68ffde87dcc91913cc2fed3da5Martti Rannanjärvi ret = sysdb_getpwnam(dctx, sysdb, cmd_ctx->username, &dctx->user);
return EIO;
return EIO;
if (dom) continue;
return ENOENT;
SYSDB_CACHE_EXPIRE, 0);
if (!dpreq) {
return ENOMEM;
if(!cb_ctx) {
return ENOMEM;
return EAGAIN;
return EOK;
return ENOENT;
char *err_msg;
&err_msg);
if (err_maj) {
goto done;
goto done;
done:
return EIO;
if (!cb_ctx) {
return ENOMEM;
return EAGAIN;
char *err_msg;
&err_msg);
if (err_maj) {
const char *username,
char **groupnames,
char **groupnames;
goto done;
goto done;
goto done;
done:
return ret;
static errno_t
const char *username,
char **groupnames,
char *filter;
NULL };
goto done;
goto done;
*_count = 0;
goto done;
goto done;
goto done;
done:
return ret;
sudo_order_cmp_fn(const void *a, const void *b)
int ret;
o1 = 0;
o2 = 0;
static errno_t
return EOK;
const char *query_body,
int query_len)
return NULL;
int rules_num,
return ENOMEM;
goto fail;
goto done;
goto fail;
for (i = 0; i < rules_num; i++) {
goto fail;
done:
fail:
return ret;