simple_access_check.c revision cc2d77d5218c188119fa954c856e858cbde76947
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce Simple access control
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce Copyright (C) Sumit Bose <sbose@redhat.com> 2010
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce This program is free software; you can redistribute it and/or modify
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce it under the terms of the GNU General Public License as published by
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce the Free Software Foundation; either version 3 of the License, or
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce (at your option) any later version.
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce This program is distributed in the hope that it will be useful,
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce but WITHOUT ANY WARRANTY; without even the implied warranty of
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce GNU General Public License for more details.
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce You should have received a copy of the GNU General Public License
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce along with this program. If not, see <http://www.gnu.org/licenses/>.
79f128801d598ca57a6acebade01136525a47e00Pavel Reichl#define NON_EXIST_USR_ALLOW "The user %s does not exist. Possible typo in simple_allow_users.\n"
79f128801d598ca57a6acebade01136525a47e00Pavel Reichl#define NON_EXIST_USR_DENY "The user %s does not exist. Possible typo in simple_deny_users.\n"
79f128801d598ca57a6acebade01136525a47e00Pavel Reichl#define NON_EXIST_GRP_ALLOW "The group %s does not exist. Possible typo in simple_allow_groups.\n"
79f128801d598ca57a6acebade01136525a47e00Pavel Reichl#define NON_EXIST_GRP_DENY "The group %s does not exist. Possible typo in simple_deny_groups.\n"
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char *val;
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek val = ldb_msg_find_attr_as_string(group, SYSDB_POSIX, NULL);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek return true;
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek return false;
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek/* Returns EOK if the result is definitive, EAGAIN if only partial result
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_users(struct simple_ctx *ctx, const char *username,
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* First, check whether the user is in the allowed users list */
b011330c77168cdd864aaae54a75214935136c05Pavel Reichl domain = find_domain_by_object_name(ctx->domain,
79f128801d598ca57a6acebade01136525a47e00Pavel Reichl DEBUG(SSSDBG_CRIT_FAILURE, NON_EXIST_USR_ALLOW,
a0d010f488bf15fb3e170ce04092013fa494401fPavel Březina if (sss_string_equal(domain->case_sensitive, username,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "User [%s] found in allow list, access granted.\n",
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* Do not return immediately on explicit allow
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce * We need to make sure none of the user's groups
958037cf32ea156dfdde426a45ac1d972fe46618Pavel Reichl * are denied. But there's no need to check username
958037cf32ea156dfdde426a45ac1d972fe46618Pavel Reichl * matches any more.
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* If neither allow rule is in place, we'll assume allowed
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce * unless a deny rule disables us below.
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "No allow rule, assumuing allow unless explicitly denied\n");
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* Next check whether this user has been specifically denied */
b011330c77168cdd864aaae54a75214935136c05Pavel Reichl domain = find_domain_by_object_name(ctx->domain,
a0d010f488bf15fb3e170ce04092013fa494401fPavel Březina if (sss_string_equal(domain->case_sensitive, username,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "User [%s] found in deny list, access denied.\n",
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* Return immediately on explicit denial */
8e195a545d41647e591c1d06082133cbd25dc0a4Jakub Hrozeksimple_check_groups(struct simple_ctx *ctx, const char **group_names,
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* Now process allow and deny group rules
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce * If access was already granted above, we'll skip
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce * this redundant rule check
b011330c77168cdd864aaae54a75214935136c05Pavel Reichl domain = find_domain_by_object_name(ctx->domain,
79f128801d598ca57a6acebade01136525a47e00Pavel Reichl DEBUG(SSSDBG_CRIT_FAILURE, NON_EXIST_GRP_ALLOW,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek for(j = 0; group_names[j]; j++) {
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* If any group has matched, we can skip out on the
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce * processing early
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Group [%s] found in allow list, access granted.\n",
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* Finally, process the deny group rules */
b011330c77168cdd864aaae54a75214935136c05Pavel Reichl domain = find_domain_by_object_name(ctx->domain,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek for(j = 0; group_names[j]; j++) {
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce /* If any group has matched, we can skip out on the
225d845476b6136be9b77f528ed986bba7a7f732Simo Sorce * processing early
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Group [%s] found in deny list, access denied.\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char *name;
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_resolve_group_check(struct simple_resolve_group_state *state);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic void simple_resolve_group_done(struct tevent_req *subreq);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic struct tevent_req *
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* First check if the group was updated already. If it was (maybe its
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * parent was updated first), then just shortcut */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_LIBS, "Group already updated\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Cannot check if group was already updated [%d]: %s\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* EAGAIN - still needs update */
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek ar->filter_value = talloc_asprintf(ar, "%llu", (unsigned long long) gid);
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina ar->domain = talloc_strdup(ar, state->domain->name);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek subreq = be_get_account_info_send(state, ev, NULL, ctx->be_ctx, ar);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_set_callback(subreq, simple_resolve_group_done, req);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_resolve_group_check(struct simple_resolve_group_state *state)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char *group_attrs[] = { SYSDB_NAME, SYSDB_POSIX,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* Check the cache by GID again and fetch the name */
4c08db0fb0dda3d27b1184248ca5c800d7ce23f0Michal Zidek ret = sysdb_search_group_by_gid(state, state->domain, state->gid,
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina /* The group is missing, we will try to update it. */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Could not look up group by gid [%"SPRIgid"]: [%d][%s]\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state->name = ldb_msg_find_attr_as_string(group, SYSDB_NAME, NULL);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "No group name\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "The group is still non-POSIX\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_LIBS, "Got POSIX group\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic void simple_resolve_group_done(struct tevent_req *subreq)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek req = tevent_req_callback_data(subreq, struct tevent_req);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state = tevent_req_data(req, struct simple_resolve_group_state);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "be_get_account_info_recv failed\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Cannot refresh data from DP: %u,%u: %s\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* Check the cache by GID again and fetch the name */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Refresh failed\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_resolve_group_recv(struct tevent_req *req,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char **name)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state = tevent_req_data(req, struct simple_resolve_group_state);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic void simple_check_get_groups_next(struct tevent_req *subreq);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_get_groups_primary(struct simple_check_groups_state *state,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_process_group(struct simple_check_groups_state *state,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic struct tevent_req *
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_get_groups_send(TALLOC_CTX *mem_ctx,
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina const char *attrs[] = { SYSDB_NAME, SYSDB_POSIX, SYSDB_GIDNUM,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_LIBS, "Looking up groups for user %s\n", username);
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina /* get domain from username */
b011330c77168cdd864aaae54a75214935136c05Pavel Reichl state->domain = find_domain_by_object_name(ctx->domain, username);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "Invalid user %s!\n", username);
4c08db0fb0dda3d27b1184248ca5c800d7ce23f0Michal Zidek ret = sysdb_search_user_by_name(state, state->domain, username, attrs,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_MINOR_FAILURE, "No such user %s\n", username);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Could not look up username [%s]: [%d][%s]\n",
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "User %s is a member of %zu supplemental groups\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* One extra space for terminator, one extra space for private group */
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state->group_names = talloc_zero_array(state, const char *, group_count + 2);
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina state->lookup_groups = talloc_zero_array(state, struct simple_group,
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina if (!state->group_names || !state->lookup_groups) {
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek for (i=0; i < group_count; i++) {
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* Some providers (like the AD provider) might perform initgroups
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * without resolving the group names. In order for the simple access
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * provider to work correctly, we need to resolve the groups before
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * performing the access check. In AD provider, the situation is
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * even more tricky b/c the groups HAVE name, but their name
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * attribute is set to SID and they are set as non-POSIX
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek ret = simple_check_process_group(state, groups[i]);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek gid = ldb_msg_find_attr_as_uint64(user, SYSDB_GIDNUM, 0);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_MINOR_FAILURE, "User %s has no gid?\n", username);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek ret = simple_check_get_groups_primary(state, gid);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* If all groups could have been resolved by name, we are
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "All groups had name attribute\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "Need to resolve %zu groups\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek subreq = simple_resolve_group_send(req, state->ev, state->ctx,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_set_callback(subreq, simple_check_get_groups_next, req);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic void simple_check_get_groups_next(struct tevent_req *subreq)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_callback_data(subreq, struct tevent_req);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_data(req, struct simple_check_groups_state);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek ret = simple_resolve_group_recv(subreq, state->group_names,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Could not resolve name of group with GID %"SPRIgid"\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek subreq = simple_resolve_group_send(req, state->ev, state->ctx,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_set_callback(subreq, simple_check_get_groups_next, req);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_INTERNAL, "All groups resolved. Done.\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_process_group(struct simple_check_groups_state *state,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char *name;
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek name = ldb_msg_find_attr_as_string(group, SYSDB_NAME, NULL);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek gid = ldb_msg_find_attr_as_uint64(group, SYSDB_GIDNUM, 0);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* With the current sysdb layout, every group has a name */
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek if (posix == true) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "POSIX group without GID\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* Non-posix group with a name. Still can be used for access
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * control as the name should point to the real name, no SID
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state->group_names[state->num_names] = talloc_strdup(state->group_names,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_INTERNAL, "Adding group %s\n", name);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* Here are only groups with a name and gid. POSIX group can already
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * be used, non-POSIX groups can be resolved */
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state->group_names[state->num_names] = talloc_strdup(state->group_names,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_INTERNAL, "Adding group %s\n", name);
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina /* Try to get group SID and assign it a domain */
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina group_sid = ldb_msg_find_attr_as_string(group, SYSDB_SID_STR, NULL);
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina /* We will look it up in main domain. */
9ca0071db0e226e4e65b2a80fdeddd5048ca8990Pavel Reichl domain = find_domain_by_sid(state->ctx->domain, group_sid);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "There is no domain information for "
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina /* It is a non-posix group with a GID. Needs resolving */
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina state->lookup_groups[state->num_groups].domain = domain;
115241b0eeedd033d34d9721a896f031140944d7Pavel Březina state->lookup_groups[state->num_groups].gid = gid;
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_INTERNAL, "Adding GID %"SPRIgid"\n", gid);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_get_groups_primary(struct simple_check_groups_state *state,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char *group_attrs[] = { SYSDB_NAME, SYSDB_POSIX,
4c08db0fb0dda3d27b1184248ca5c800d7ce23f0Michal Zidek ret = sysdb_search_group_by_gid(state, state->domain, gid, group_attrs,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Could not look up primary group [%"SPRIgid"]: [%d][%s]\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* We have to treat this as non-fatal, because the primary
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * group may be local to the machine and not available in
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * our ID provider.
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Cannot process primary group\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozeksimple_check_get_groups_recv(struct tevent_req *req,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek const char ***_group_names)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state = tevent_req_data(req, struct simple_check_groups_state);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek *_group_names = talloc_steal(mem_ctx, state->group_names);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic void simple_access_check_done(struct tevent_req *subreq);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstruct tevent_req *simple_access_check_send(TALLOC_CTX *mem_ctx,
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek state->username = talloc_strdup(state, username);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_FUNC_DATA, "Simple access check for %s\n", username);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek ret = simple_check_users(ctx, username, &state->access_granted);
18f01e63c1968c29bddb9e48c279b583c0444730Jakub Hrozek /* EAGAIN -- check groups */
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* There are no group restrictions, so just return
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * here with whatever we've decided.
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_LIBS, "No group restrictions, end request\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* The group names might not be available. Fire a request to
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek * gather them. In most cases, the request will just shortcut
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek subreq = simple_check_get_groups_send(state, ev, ctx, username);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_set_callback(subreq, simple_access_check_done, req);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekstatic void simple_access_check_done(struct tevent_req *subreq)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_callback_data(subreq, struct tevent_req);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_data(req, struct simple_access_check_state);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* We know the names now. Run the check. */
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek ret = simple_check_get_groups_recv(subreq, state, &state->group_names);
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* If the user wasn't found, just shortcut */
82a958e6592c4a4078e45b7197bbe4751b70f511Pavel Reichl "Could not collect groups of user %s\n", state->username);
82a958e6592c4a4078e45b7197bbe4751b70f511Pavel Reichl "But no deny groups were defined so we can continue.\n");
82a958e6592c4a4078e45b7197bbe4751b70f511Pavel Reichl "Some deny groups were defined, we can't continue\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Could not collect groups of user %s\n", state->username);
8e195a545d41647e591c1d06082133cbd25dc0a4Jakub Hrozek ret = simple_check_groups(state->ctx, state->group_names,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Could not check group access [%d]: %s\n",
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek /* Now just return whatever we decided */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_INTERNAL, "Group check done\n");
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozekerrno_t simple_access_check_recv(struct tevent_req *req, bool *access_granted)
c0bca1722d6f9dfb654ad78397be70f79ff39af1Jakub Hrozek tevent_req_data(req, struct simple_access_check_state);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Access %sgranted\n", state->access_granted ? "" : "not ");