sdap_async_autofs.c revision f17d26a8db285622a5cd5f21c7488b62eedc2cf8
/*
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"
enum autofs_map_op {
};
/* ====== Utility functions ====== */
static const char *
{
struct ldb_message_element *el;
&el);
}
static const char *
{
struct ldb_message_element *el;
&el);
}
static errno_t
const char *map,
struct sdap_options *opts,
struct sysdb_attrs *entry,
enum autofs_map_op mod_op)
{
const char *key;
const char *value;
struct ldb_message_element *el;
&el);
switch (mod_op) {
case AUTOFS_MAP_OP_ADD:
break;
case AUTOFS_MAP_OP_DEL:
break;
}
return ret;
}
static errno_t
struct sdap_options *opts,
const char *map,
char **mod_entries,
struct sysdb_attrs **entries,
enum autofs_map_op mod_op)
{
const char *key;
bool in_transaction = false;
int i, j;
("Cannot start sysdb transaction [%d]: %s\n",
goto done;
}
in_transaction = true;
/* Loop through entry names.. */
for (i=0; mod_entries[i]; i++) {
for (j=0; j < num_entries; j++) {
/* get a pointer to sysdb_attrs of an entry that is not
* cached, skip names that are not in **entries
*/
if (!key) {
("An entry without name? Skipping\n"));
return EINVAL;
}
continue;
}
("Cannot modify autofs entry [%d]: %s. Ignoring.\n",
continue;
}
}
}
("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;
}
static errno_t
struct sdap_options *opts,
const char *map,
char **add_entries,
struct sysdb_attrs **entries,
{
}
static errno_t
struct sdap_options *opts,
const char *map,
char **add_entries,
struct sysdb_attrs **entries,
{
}
static errno_t
struct sss_domain_info *dom,
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 %d results.\n",
state->entries_count));
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 *val;
char **sysdb_entrylist;
char **ldap_entrylist;
char **add_entries;
char **del_entries;
size_t i;
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 {
("sysdb_attrs_primary_name_list failed [%d]: %s\n",
goto done;
}
}
("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 name only */
for (i=0; i < count; i++) {
if (!val) {
continue;
}
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;
}