sysdb_autofs.c revision dd7192379e5fc5bb852863e60ad4b6a20c5da183
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek Copyright (C) 2012 Red Hat
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek This program is free software; you can redistribute it and/or modify
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek it under the terms of the GNU General Public License as published by
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek (at your option) any later version.
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek This program is distributed in the hope that it will be useful,
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek GNU General Public License for more details.
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek You should have received a copy of the GNU General Public License
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek#define SYSDB_TMPL_AUTOFS_ENTRY SYSDB_NAME"=%s,"SYSDB_TMPL_CUSTOM
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozekstatic struct ldb_dn *
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozekstatic struct ldb_dn *
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek ret = sysdb_dn_sanitize(tmp_ctx, entry_name, &clean_name);
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek ret = sysdb_dn_sanitize(tmp_ctx, entry_value, &clean_value);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov rdn = talloc_asprintf(tmp_ctx, "%s%s", clean_name, clean_value);
3b08dec5ee634f83ee18e1753d5ffe0ac5e3c458Jakub Hrozek dn = ldb_dn_new_fmt(mem_ctx, sysdb->ldb, SYSDB_TMPL_AUTOFS_ENTRY,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *name,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_TRACE_FUNC, ("Adding autofs map %s\n", autofsmapname));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_string(attrs, SYSDB_OBJECTCLASS,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set map object class [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_string(attrs, SYSDB_AUTOFS_MAP_NAME, autofsmapname);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set map name [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_string(attrs, SYSDB_NAME, name);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set name attribute [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_time_t(attrs, SYSDB_LAST_UPDATE, now);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set sysdb lastUpdate [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_time_t(attrs, SYSDB_CACHE_EXPIRE,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set sysdb cache expire [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_store_custom(sysdb_ctx, sysdb_ctx->domain, name, AUTOFS_MAP_SUBDIR, attrs);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("sysdb_store_custom failed [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorcesysdb_delete_autofsmap(struct sysdb_ctx *sysdb_ctx,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *name)
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_TRACE_FUNC, ("Deleting autofs map %s\n", name));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce return sysdb_delete_custom(sysdb_ctx, name, AUTOFS_MAP_SUBDIR);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *filter;
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sss_filter_sanitize(tmp_ctx, map_name, &safe_map_name);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ("Cannot sanitize map [%s] error [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce filter = talloc_asprintf(tmp_ctx, "(&(objectclass=%s)(%s=%s))",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_search_custom(tmp_ctx, sysdb, filter,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ("Error looking up autofs map [%s]", safe_map_name));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ("More than one map named %s\n", safe_map_name));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorcesysdb_save_autofsentry(struct sysdb_ctx *sysdb_ctx,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *map,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *key,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *value,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce const char *name;
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ("Adding autofs entry [%s] - [%s]\n", key, value));
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_string(attrs, SYSDB_OBJECTCLASS,
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set entry object class [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_string(attrs, SYSDB_AUTOFS_ENTRY_KEY, key);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set entry key [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce ret = sysdb_attrs_add_string(attrs, SYSDB_AUTOFS_ENTRY_VALUE, value);
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Could not set entry key [%d]: %s\n",
625bb2ddf15e8f305a53afa44e87f2146fa930afSimo Sorce name = talloc_asprintf(tmp_ctx, "%s%s", key, value);
goto done;
if (!dn) {
goto done;
if (!msg) {
goto done;
done:
return ret;
const char *map,
const char *key,
const char *value)
if (!dn) {
return ENOMEM;
return ret;
const char *mapname,
char *filter;
NULL };
if (!tmp_ctx) {
return ENOMEM;
if (!mapdn) {
goto done;
if (!filter) {
goto done;
goto done;
*_count = 0;
goto done;
done:
return ret;
const char *name,
int mod_op)
if (!tmp_ctx) {
return ENOMEM;
if (!dn) {
goto done;
done:
return ret;
const char *filter;
NULL };
const char *name;
bool in_transaction = false;
int sret;
if (!filter) {
goto done;
goto done;
goto done;
if (!sys_attrs) {
goto done;
goto done;
goto done;
in_transaction = true;
for (i = 0; i < count; i++) {
if (!name) {
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;