pacsrv_utils.c revision 4b49384056874e7999d8338ce5288f3d5c27a7b8
/*
SSSD
PAC Responder - utility finctions
Copyright (C) Sumit Bose <sbose@redhat.com> 2012
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 <stdbool.h>
#include <util/data_blob.h>
#include <gen_ndr/security.h>
{
return EINVAL;
}
return EOK;
}
/**
* Find the Posix ID to a SID from the local IPA domain
*/
{
int ret;
return EINVAL;
}
return ret;
}
} else {
return ENOENT;
}
return ERANGE;
}
return EOK;
}
const char *id_str)
{
struct sss_domain_info *dom;
size_t c;
return NULL;
}
continue;
}
break;
}
for (c = 0; c < dom->subdomain_count; c++) {
break;
}
}
}
if (!ret_dom) {
id_str));
}
return ret_dom;
}
/**
* Add a new remote domain and the corresponding ID range to the context of
* the libsss_idmap. Without this it is not possible to find the Posix UID for
* a user fo the remote domain.
*/
const char *domain_name,
const char *dom_sid_str)
{
struct sss_idmap_range range = {0, 0};
enum idmap_error_code err;
struct range_info **range_list;
size_t c;
int ret;
return EINVAL;
}
return ENOMEM;
}
goto done;
}
for (c = 0; c < range_count; c++) {
/* TODO: add support for multiple ranges. */
break;
}
}
goto done;
}
if (err != IDMAP_SUCCESS) {
return EFAULT;
}
done:
return ret;
}
/**
* Find the corresponding UID for a user from a remote domain based on the
* domain SID of the remote domain and the RID of the user.
*/
const char *domain_name,
{
enum idmap_error_code err;
char *dom_sid_str = NULL;
int ret;
&dom_sid_str);
if (err != IDMAP_SUCCESS) {
goto done;
}
return ENOMEM;
}
if (err == IDMAP_NO_DOMAIN) {
goto done;
}
if (err != IDMAP_SUCCESS) {
"even in the second attempt.\n"));
goto done;
}
goto done;
}
done:
return ret;
}
/**
* Return information about the local domain from the main PAC responder
* context or try to read it from cache and store it in the context.
*/
struct sss_domain_info *dom,
struct local_mapping_ranges **_range_map)
{
int ret;
const char *attrs[] = {SYSDB_SUBDOMAIN_ID,
NULL};
const char *sid_str;
struct ldb_message **msgs;
enum idmap_error_code err;
struct range_info **range_list;
size_t c;
} else {
}
goto done;
}
goto done;
}
goto done;
}
if (ret != LDB_SUCCESS) {
goto done;
}
if (msgs_count != 1) {
"expected 1.\n", msgs_count));
goto done;
}
goto done;
}
if (err != IDMAP_SUCCESS) {
goto done;
}
sizeof(struct dom_sid));
goto done;
}
}
goto done;
}
for (c = 0; c < range_count; c++) {
range_list[c]->secondary_base_rid != 0) {
struct local_mapping_ranges);
goto done;
}
/* TODO: add support for multiple ranges. */
break;
}
}
goto done;
}
}
}
done:
return ret;
}
/**
* Check if a given SID belongs to a domain identified by the domain SID.
*/
{
size_t c;
if (!domain_sid || !sid) {
return false;
}
return false;
}
for (c = 0; c < 6; c++) {
return false;
}
}
return false;
}
return false;
}
}
return true;
}
struct sss_domain_info *grp_dom,
struct pac_dom_grps *dom_grps)
{
int ret;
size_t g;
struct hash_iter_context_t *iter;
return EINVAL;
}
if (gid_count == 0) {
goto done;
}
goto done;
}
goto done;
}
g = 0;
g++;
}
if (gid_count != g) {
"match.\n"));
goto done;
}
done:
} else {
}
return ret;
}
/**
* Find all Posix GIDs from a PAC by searching for group SIDs from the local
* domain and convert them to GIDs.
*/
struct local_mapping_ranges *range_map,
struct dom_sid *domain_sid,
struct PAC_LOGON_INFO *logon_info,
{
int ret;
size_t s;
struct netr_SamInfo3 *info3;
struct sss_domain_info *grp_dom;
enum idmap_error_code err;
return EINVAL;
}
goto done;
}
goto done;
}
/* Currently three group containers are allocated, one for the IPA domain, one
* for the trusted AD domain and an empty one to indicate the end of the
* list. */
goto done;
}
goto done;
}
&sid_str);
if (err != IDMAP_SUCCESS) {
goto done;
}
goto done;
}
&id);
goto done;
}
if (ret != HASH_SUCCESS) {
goto done;
}
}
}
goto done;
}
goto done;
}
&sid_str);
if (err != IDMAP_SUCCESS) {
goto done;
}
goto done;
}
if (err != IDMAP_SUCCESS) {
goto done;
}
&id);
if (err != IDMAP_SUCCESS) {
"[%s] [%d].\n", sid_str,
goto done;
}
if (ret != HASH_SUCCESS) {
goto done;
}
}
goto done;
}
done:
*_gid_count = gid_count;
}
return ret;
}
/**
* Extract the PAC logon data from an NDR blob.
*/
struct PAC_LOGON_INFO **_logon_info)
{
enum ndr_err_code ndr_err;
size_t c;
int ret;
return ENOMEM;
}
return ENOMEM;
}
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
return EBADMSG;
}
for(c = 0; c < pac_data->num_buffers; c++) {
return EOK;
}
}
return ret;
}
/**
* Fill up the passwd struct with data from the PAC logon info
*/
struct sss_domain_info *dom,
struct PAC_LOGON_INFO *logon_info,
struct sysdb_attrs **_attrs)
{
struct netr_SamBaseInfo *base_info;
int ret;
char *lname;
char *uc_realm;
char *upn;
return ENOMEM;
}
goto done;
}
goto done;
}
/* To be compatible with winbind based lookups we have to use lower
* case names only, effectively making the domain case-insenvitive. */
goto done;
}
goto done;
}
goto done;
}
goto done;
}
} else {
"gecos field will by empty.\n "));
}
if (dom->subdomain_homedir) {
goto done;
}
}
goto done;
}
goto done;
}
goto done;
}
goto done;
}
goto done;
}
done:
}
return ret;
}
struct grp_info *cur_grp_list,
struct pac_dom_grps *new_gid_list,
struct pac_dom_grps **_add_gid_list,
struct grp_info ***_del_grp_list)
{
int ret;
size_t c;
size_t g;
size_t add_gid_num = 0;
size_t del_grp_num = 0;
unsigned long value_count;
size_t new_dom_num = 0;
return EINVAL;
}
if (cur_grp_num == 0 && new_gid_num == 0) {
goto done;
}
goto done;
}
if (new_gid_num != 0) {
new_dom_num++);
}
if (cur_grp_num == 0 && new_gid_num != 0) {
new_dom_num + 1);
if (add_gid_list == NULL) {
goto done;
}
for (c = 0; c < new_dom_num; c++) {
if (new_gid_list[c].gid_count != 0) {
new_gid_list[c].gid_count);
goto done;
}
for (g = 0; g < new_gid_list[c].gid_count; g++) {
}
}
}
goto done;
}
if (cur_grp_num != 0 && new_gid_num == 0) {
if (del_grp_list == NULL) {
goto done;
}
for (c = 0; c < del_grp_num; c++) {
del_grp_list[c] = &cur_grp_list[c];
}
goto done;
}
/* Add all current GIDs to a hash and then compare with the new ones in a
* single loop */
goto done;
}
for (c = 0; c < cur_grp_num; c++) {
if (ret != HASH_SUCCESS) {
goto done;
}
}
new_dom_num + 1);
if (add_gid_list == NULL) {
goto done;
}
for (c = 0; c < new_dom_num; c++) {
add_gid_list[c].gid_count = 0;
for (g = 0; g < new_gid_list[c].gid_count; g++) {
if (ret == HASH_ERROR_KEY_NOT_FOUND) {
/* gid not found, must be added */
add_gid_list[c].gid_count++;
add_gid_list[c].gid_count);
goto done;
}
new_gid_list[c].gids[g];
} else if (ret != HASH_SUCCESS) {
goto done;
}
}
}
/* the remaining entries in the hash are not in the new list anymore and
* must be deleted */
if (ret != HASH_SUCCESS) {
goto done;
}
if (del_grp_list == NULL) {
goto done;
}
for (c = 0; c < del_grp_num; c++) {
}
done:
}
return ret;
}
const char *attr)
{
const char *str;
return true;
}
return false;
}
{
return true;
}
return true;
}
return true;
}
return true;
}
return true;
}
return false;
}