sdap_access.c revision 87f2bb60510f31fec012d126411f09a99c72140e
/*
SSSD
Authors:
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2010 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 <security/pam_modules.h>
#include <talloc.h>
#include <tevent.h>
#include <errno.h>
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_access.h"
#include "providers/ldap/sdap_async.h"
#include "providers/data_provider.h"
#include "providers/dp_backend.h"
{
}
else {
}
}
struct tevent_context *ev,
struct sdap_access_ctx *access_ctx,
const char *username);
{
struct tevent_req *req;
struct sdap_access_ctx *access_ctx;
struct sdap_access_ctx);
return;
}
}
struct sdap_access_req_ctx {
const char *username;
const char *filter;
struct tevent_context *ev;
struct sdap_access_ctx *access_ctx;
struct sdap_id_ctx *sdap_ctx;
struct sdap_id_op *sdap_op;
struct sysdb_handle *handle;
const char **attrs;
int pam_status;
bool cached_access;
char *basedn;
};
struct tevent_context *ev,
struct sdap_access_ctx *access_ctx,
const char *username)
{
struct sdap_access_req_ctx *state;
struct tevent_req *req;
struct ldb_result *res;
const char *basedn;
return NULL;
}
/* If no filter is set, default to restrictive */
return req;
}
goto failed;
}
/* Get original user DN */
&res);
/* If we can't find the user, return permission denied */
goto finished;
}
goto failed;
}
else {
/* If we can't find the user, return permission denied */
goto finished;
}
goto failed;
}
}
/* Exactly one result returned */
false);
/* Ok, we have one result, check if we are online or offline */
/* Ok, we're offline. Return from the cache */
goto finished;
}
/* Perform online operation */
NULL);
goto failed;
}
goto failed;
}
/* Construct the filter */
"(&(%s=%s)(objectclass=%s)%s)",
DEBUG(0, ("Could not construct access filter\n"));
goto failed;
}
goto failed;
}
goto failed;
}
return req;
return NULL;
return req;
}
{
struct sdap_access_req_ctx *state =
if (state->cached_access) {
} else {
}
}
{
struct sdap_access_req_ctx *state =
struct tevent_req *subreq;
int ret;
if (!subreq) {
return ret;
}
return EOK;
}
{
struct tevent_req);
struct sdap_access_req_ctx *state =
if (dp_error == DP_ERR_OFFLINE) {
return;
}
return;
}
/* Connection to LDAP succeeded
* Send filter request
*/
NULL, 0);
return;
}
}
{
bool found = false;
struct sysdb_attrs *attrs;
struct sysdb_attrs **results;
struct tevent_req *req =
struct sdap_access_req_ctx *state =
&num_results, &results);
/* retry */
return;
}
} else if (dp_error == DP_ERR_OFFLINE) {
} else {
}
goto done;
}
/* Check the number of responses we got
* If it's exactly 1, we passed the check
* If it's < 1, we failed the check
* Anything else is an error
*/
if (num_results < 1) {
found = false;
}
goto done;
}
else if (num_results > 1) {
/* It should not be possible to get more than one reply
* here, since we're doing a base-scoped search
*/
goto done;
}
else { /* Ok, we got a single reply */
found = true;
}
if (found) {
/* Save "allow" to the cache for future offline
* access checks.
*/
}
else {
/* Save "disallow" to the cache for future offline
* access checks.
*/
}
goto done;
}
true :
false);
/* Failing to save to the cache is non-fatal.
* Just return the result.
*/
goto done;
}
/* Failing to save to the cache is non-fatal.
* Just return the result.
*/
goto done;
}
done:
}
else {
}
}
{
struct sdap_access_req_ctx *state =
return EOK;
}
{
int pam_status;
}
}