sysdb_views.c revision fe2ab0d67fe8c66fb6352e9d8f845bb46d1848cb
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek System Database - View and Override related calls
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek Copyright (C) 2014 Sumit Bose <sbose@redhat.com>
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek This program is free software; you can redistribute it and/or modify
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek it under the terms of the GNU General Public License as published by
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek the Free Software Foundation; either version 3 of the License, or
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek (at your option) any later version.
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek This program is distributed in the hope that it will be useful,
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek GNU General Public License for more details.
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek You should have received a copy of the GNU General Public License
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek/* In general is should not be possible that there is a view container without
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek * a view name set. But to be on the safe side we return both information
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek * separately. */
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozekstatic errno_t sysdb_get_view_name_ex(TALLOC_CTX *mem_ctx,
03b859510dc13a13a456ca4aa94c0561a0e9684cJakub Hrozek view_base_dn = ldb_dn_new(tmp_ctx, sysdb->ldb, SYSDB_TMPL_VIEW_BASE);
goto done;
goto done;
*view_container_exists = false;
goto done;
*view_container_exists = true;
NULL);
goto done;
done:
return ret;
char **view_name)
bool view_container_exists;
const char *view_name)
char *tmp_str;
bool view_container_exists = false;
bool add_view_name = false;
return ENOMEM;
goto done;
goto done;
goto done;
add_view_name = true;
goto done;
goto done;
NULL);
goto done;
goto done;
if (view_container_exists) {
goto done;
done:
return ret;
int ret;
return ENOMEM;
goto done;
goto done;
done:
return ret;
static errno_t
bool add_name,
const char *name_override)
int ret;
return ENOMEM;
fq_name);
goto done;
if (add_name) {
goto done;
goto done;
done:
return ret;
const char *view_name,
const char *anchor;
int ret;
const char *override_dn_str;
const char *obj_dn_str;
NULL};
const char *obj_override_dn;
bool add_ref = true;
size_t c;
bool in_transaction = false;
bool has_override = true;
const char *name_override;
goto done;
has_override = true;
&anchor);
goto done;
goto done;
has_override = false;
goto done;
goto done;
goto done;
NULL);
goto done;
add_ref = false;
in_transaction = true;
if (has_override) {
goto done;
goto done;
goto done;
goto done;
goto done;
switch(type) {
case SYSDB_MEMBER_USER:
case SYSDB_MEMBER_GROUP:
goto done;
goto done;
NULL);
goto done;
goto done;
goto done;
if (add_ref) {
goto done;
NULL);
goto done;
goto done;
goto done;
done:
if (in_transaction) {
return ret;
const char **allowed_attrs)
int ret;
size_t c;
char *orig_attr_name;
return ENOMEM;
goto done;
allowed_attrs[c]);
goto done;
goto done;
allowed_attrs[c]);
goto done;
done:
return ret;
int ret;
size_t c;
size_t d;
NULL };
bool override_attrs_found = false;
return ENOMEM;
goto done;
&el);
override_attrs_found = true;
goto done;
goto done;
for (d = 0; d < num_values; d++) {
goto done;
goto done;
if (override_attrs_found) {
goto done;
goto done;
done:
return ret;
#define SYSDB_USER_NAME_OVERRIDE_FILTER "(&(objectClass="SYSDB_OVERRIDE_USER_CLASS")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_USER_UID_OVERRIDE_FILTER "(&(objectClass="SYSDB_OVERRIDE_USER_CLASS")("SYSDB_UIDNUM"=%lu))"
#define SYSDB_GROUP_NAME_OVERRIDE_FILTER "(&(objectClass="SYSDB_OVERRIDE_GROUP_CLASS")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
#define SYSDB_GROUP_GID_OVERRIDE_FILTER "(&(objectClass="SYSDB_OVERRIDE_GROUP_CLASS")("SYSDB_GIDNUM"=%lu))"
enum override_object_type {
OO_TYPE_UNDEF = 0,
const char *name,
const char *filter,
const char **attrs,
char *sanitized_name;
char *lc_sanitized_name;
const char *src_name;
int ret;
const char *orig_obj_dn;
if (!tmp_ctx) {
return ENOMEM;
goto done;
goto done;
goto done;
goto done;
name);
goto done;
goto done;
NULL);
goto done;
goto done;
goto done;
done:
return ret;
const char *name,
const char **attrs,
const char *name,
const char **attrs,
const char *name,
const char *name,
unsigned long int id,
const char **attrs;
int ret;
const char *orig_obj_dn;
const char *filter;
if (!tmp_ctx) {
return ENOMEM;
goto done;
switch(type) {
case OO_TYPE_USER:
case OO_TYPE_GROUP:
type);
goto done;
goto done;
goto done;
goto done;
NULL);
goto done;
goto done;
goto done;
done:
return ret;
const char **req_attrs)
int ret;
const char *override_dn_str;
const char **attrs;
struct attr_map {
const char *attr;
const char *new_attr;
} attr_map[] = {
size_t c;
size_t d;
return ENOMEM;
goto done;
goto done;
goto done;
if (uid == 0) {
goto done;
goto done;
goto done;
goto done;
done:
return ret;
int ret;
size_t c;
const char *override_dn_str;
const char *memberuid;
return EOK;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
NULL);
NULL);
goto done;
goto done;
done:
return ret;
struct ldb_message_element *
const char *attr_name)
char *override_attr_name;
goto done;
goto done;
goto done;
done:
return val;
const char *attr_name,
char *override_attr_name;
goto done;
goto done;
goto done;
done:
return val;
const char *attr_name,
const char * default_value)
const char *val;
char *override_attr_name;
goto done;
goto done;
goto done;
done:
return val;