ipa_idmap.c revision db18dda869bc6c52a41797b2066cf121cf10f49c
/*
SSSD
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2013 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_idmap.h"
#include "providers/ipa/ipa_common.h"
#include "util/util_sss_idmap.h"
const char *dom_name,
const char *dom_sid_str,
struct range_info **range_list)
{
bool has_algorithmic_mapping;
enum idmap_error_code err;
struct sss_domain_info *dom;
struct sss_domain_info *forest_root;
size_t c;
struct sss_idmap_range range;
struct range_info *r;
char *range_id;
bool found = false;
int ret;
if (err == IDMAP_SUCCESS) {
"Idmap of domain [%s] already known, nothing to do.\n",
return EOK;
} else {
if (err == IDMAP_SUCCESS) {
"Idmap of domain [%s] already known, nothing to do.\n",
return EOK;
}
}
"sss_idmap_domain_has_algorithmic_mapping failed.\n");
return EINVAL;
}
"find_domain_by_sid failed with SID [%s].\n", dom_sid_str);
return EINVAL;
}
return EINVAL;
}
if (forest_root == NULL) {
"find_domain_by_name failed to find forest root [%s].\n",
return ENOENT;
}
return EINVAL;
}
return ENOMEM;
}
for (c = 0; c < range_count; c++) {
r = range_list[c];
if (r->trusted_dom_sid != NULL
if (r->range_type == NULL
"Forest root does not have range type [%s].\n",
goto done;
}
goto done;
}
"Could not add range [%s] to ID map\n", range_id);
goto done;
}
found = true;
}
}
if (!found) {
goto done;
}
done:
return ret;
}
struct sss_idmap_range *_range,
bool *_external_mapping)
{
if (r->range_type == NULL) {
/* Older IPA servers might not have the range_type attribute, but
* only support local ranges and trusts with algorithmic mapping. */
/* local IPA domain */
*_rid = 0;
*_external_mapping = true;
*_name = domain_name;
} else if (r->trusted_dom_sid != NULL
&& r->secondary_base_rid == 0) {
/* trusted domain */
*_external_mapping = false;
*_name = r->trusted_dom_sid;
*_sid = r->trusted_dom_sid;
} else {
"for id range [%s].\n",
r->name);
return EINVAL;
}
} else {
*_rid = 0;
*_external_mapping = true;
*_name = domain_name;
*_rid = 0;
*_external_mapping = true;
*_name = r->trusted_dom_sid;
*_sid = r->trusted_dom_sid;
*_external_mapping = false;
*_name = r->trusted_dom_sid;
*_sid = r->trusted_dom_sid;
} else {
"[%s] not supported.\n", \
r->range_type, r->name);
return EINVAL;
}
}
return EOK;
}
const char *dom_name,
const char *dom_sid_str,
bool allow_collisions)
{
int ret;
struct range_info **range_list;
size_t c;
enum idmap_error_code err;
struct sss_idmap_range range;
bool external_mapping;
char *name;
char *sid;
return ENOMEM;
}
&range_count, &range_list);
goto done;
}
for (c = 0; c < range_count; c++) {
"id range [%s], skipping.\n",
range_list[c]->name);
continue;
}
if (err != IDMAP_SUCCESS) {
range_list[c]->name);
goto done;
}
}
}
goto done;
}
}
done:
return ret;
}
const char *dom_name,
const char *dom_sid_str)
{
true);
}
struct sdap_id_ctx *id_ctx,
struct sdap_idmap_ctx **_idmap_ctx)
{
enum idmap_error_code err;
if (!idmap_ctx) {
goto done;
}
/* Initialize the map */
if (err != IDMAP_SUCCESS) {
"Could not initialize the ID map: [%s]\n",
if (err == IDMAP_OUT_OF_MEMORY) {
} else {
}
goto done;
}
goto done;
}
done:
return ret;
}