sdap_async_autofs.c revision a3c8390d19593b1e5277d95bfb4ab206d4785150
/*
SSSD
Async LDAP Helper routines for autofs
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2012 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 "providers/ldap/sdap_async_private.h"
#include "db/sysdb_autofs.h"
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_autofs.h"
enum autofs_map_op {
};
/* ====== Utility functions ====== */
static const char *
{
struct ldb_message_element *el;
&el);
}
static const char *
enum sdap_autofs_entry_attrs attr)
{
struct ldb_message_element *el;
&el);
return NULL;
}
}
static const char *
{
}
static const char *
{
}
static errno_t
const char *map,
struct sdap_options *opts,
struct sysdb_attrs *entry)
{
const char *key;
const char *value;
if (!key) {
return EINVAL;
}
if (!value) {
return EINVAL;
}
}
static errno_t
struct sdap_options *opts,
const char *map,
char **add_dn_list,
{
size_t i;
int hret;
struct sysdb_attrs *entry;
if (!add_dn_list) {
return EOK;
}
for (i=0; add_dn_list[i]; i++) {
if (hret != HASH_SUCCESS) {
"Cannot retrieve entry [%s] from hash\n", add_dn_list[i]);
continue;
}
if (!entry) {
"Cannot retrieve entry [%s] from ptr\n", add_dn_list[i]);
continue;
}
"Saving autofs entry [%s]\n", add_dn_list[i]);
if (ret) {
"Cannot save entry [%s] to cache\n", add_dn_list[i]);
continue;
}
}
return EOK;
}
static errno_t
struct sdap_options *opts,
const char *map,
char **del_dn_list)
{
size_t i;
for (i=0; del_dn_list[i]; i++) {
"Removing autofs entry [%s]\n", del_dn_list[i]);
if (ret) {
"Cannot delete entry %s\n", del_dn_list[i]);
continue;
}
}
return EOK;
}
static errno_t
struct sdap_options *opts,
struct sysdb_attrs *map)
{
const char *mapname;
return ret;
}
return EOK;
}
struct automntmaps_process_members_state {
struct tevent_context *ev;
struct sdap_options *opts;
struct sdap_handle *sh;
struct sss_domain_info *dom;
int timeout;
const char *orig_dn;
char *base_filter;
char *filter;
const char **attrs;
struct sdap_search_base **search_bases;
struct sysdb_attrs *map;
struct sysdb_attrs **entries;
};
static void
static errno_t
static struct tevent_req *
struct tevent_context *ev,
struct sdap_options *opts,
struct sdap_handle *sh,
struct sss_domain_info *dom,
struct sdap_search_base **search_bases,
int timeout,
struct sysdb_attrs *map)
{
struct tevent_req *req;
struct automntmaps_process_members_state *state;
struct automntmaps_process_members_state);
if (!state->base_filter) {
goto immediate;
}
goto immediate;
}
goto immediate;
}
goto immediate;
}
return req;
} else {
}
return req;
}
static errno_t
{
struct tevent_req *subreq;
struct automntmaps_process_members_state *state =
return ENOMEM;
}
"Searching for automount map entries with base [%s]\n",
if (!subreq) {
return EIO;
}
return EOK;
}
static void
{
struct tevent_req);
struct automntmaps_process_members_state *state =
struct sysdb_attrs **entries;
size_t entries_count, i;
&entries_count, &entries);
if (ret) {
return;
}
if (entries_count > 0) {
struct sysdb_attrs *,
return;
}
for (i=0; i < entries_count; i++) {
}
}
return;
}
}
"Search for autofs entries, returned %zu results.\n",
return;
}
static errno_t
struct sysdb_attrs ***entries)
{
struct automntmaps_process_members_state *state;
if (entries_count) {
}
if (entries) {
}
return EOK;
}
struct sdap_get_automntmap_state {
struct tevent_context *ev;
struct sdap_options *opts;
struct sdap_handle *sh;
struct sss_domain_info *dom;
const char **attrs;
const char *base_filter;
char *filter;
int timeout;
char *higher_timestamp;
struct sysdb_attrs **map;
struct sysdb_attrs **entries;
struct sdap_search_base **search_bases;
};
static errno_t
static void
static struct tevent_req *
struct tevent_context *ev,
struct sss_domain_info *dom,
struct sdap_options *opts,
struct sdap_search_base **search_bases,
struct sdap_handle *sh,
const char **attrs,
const char *filter,
int timeout)
{
struct tevent_req *req;
struct sdap_get_automntmap_state *state;
}
return req;
}
static errno_t
{
struct tevent_req *subreq;
struct sdap_get_automntmap_state *state;
return ENOMEM;
}
"Searching for automount maps with base [%s]\n",
false);
if (!subreq) {
return EIO;
}
return EOK;
}
static void
static void
{
struct tevent_req);
struct sdap_get_automntmap_state);
if (ret) {
return;
}
/* No maps found in this search */
/* There are more search bases to try */
}
return;
}
return;
"The search yielded more than one autofs map\n");
return;
}
if (!subreq) {
return;
}
return;
}
static void
{
struct tevent_req);
struct sdap_get_automntmap_state);
return;
}
return;
}
static errno_t
struct sysdb_attrs **map,
struct sysdb_attrs ***entries)
{
struct sdap_get_automntmap_state);
if (map) {
}
if (entries_count) {
}
if (entries) {
}
return EOK;
}
struct sdap_autofs_setautomntent_state {
char *filter;
const char **attrs;
struct sdap_options *opts;
struct sdap_handle *sh;
struct sdap_id_op *sdap_op;
struct sss_domain_info *dom;
const char *mapname;
struct sysdb_attrs *map;
struct sysdb_attrs **entries;
int dp_error;
};
static void
struct tevent_req *
struct tevent_context *ev,
struct sss_domain_info *dom,
struct sdap_handle *sh,
struct sdap_id_op *op,
struct sdap_options *opts,
const char *mapname)
{
struct tevent_req *req;
struct tevent_req *subreq;
struct sdap_autofs_setautomntent_state *state;
char *clean_mapname;
struct sdap_autofs_setautomntent_state);
if (!mapname) {
goto fail;
}
goto fail;
}
goto fail;
}
goto fail;
}
if (!subreq) {
goto fail;
}
return req;
fail:
return req;
}
static errno_t
static void
{
struct tevent_req);
struct sdap_autofs_setautomntent_state);
} else {
"sdap_get_automntmap_recv failed [%d]: %s\n",
}
return;
}
return;
}
return;
}
static errno_t
{
struct sdap_autofs_setautomntent_state);
bool in_transaction = false;
const char *key;
const char *val;
char **sysdb_entrylist;
char **ldap_entrylist;
char **add_entries;
char **del_entries;
size_t i, j;
int hret;
if (state->entries_count == 0) {
/* No entries for this map in LDAP.
* We need to ensure that there are no entries
* in the sysdb either.
*/
} else {
if (!ldap_entrylist) {
goto done;
}
if (ret) {
goto done;
}
/* Get a list of the map members by DN */
for (i=0, j=0; i < state->entries_count; i++) {
continue;
}
if (!ldap_entrylist[j]) {
goto done;
}
if (hret != HASH_SUCCESS) {
goto done;
}
j++;
}
}
"cache lookup for the map failed [%d]: %s\n",
goto done;
}
if (count == 0) {
/* No map members for this map in sysdb currently */
} else {
if (!sysdb_entrylist) {
goto done;
}
/* Get a list of the map members by DN */
for (i=0; i < count; i++) {
if (!sysdb_entrylist[i]) {
goto done;
}
}
}
/* Find the differences between the sysdb and LDAP lists
* Entries in the sysdb only must be removed.
*/
"Cannot start sysdb transaction [%d]: %s\n",
goto done;
}
in_transaction = true;
/* Save the map itself */
"Cannot save autofs map entry [%d]: %s\n",
goto done;
}
/* Create entries that don't exist yet */
if (add_entries && add_entries[0]) {
"Cannot save autofs entries [%d]: %s\n",
goto done;
}
}
/* Delete entries that don't exist anymore */
if (del_entries && del_entries[0]) {
"Cannot delete autofs entries [%d]: %s\n",
goto done;
}
}
"Cannot commit sysdb transaction [%d]: %s\n",
goto done;
}
in_transaction = false;
done:
if (in_transaction) {
"Cannot cancel sysdb transaction [%d]: %s\n",
}
}
return ret;
}
{
return EOK;
}