nss_mc_initgr.c revision 39b31427e2d11ca318df11fd48db33a7cc610aa7
/*
* System Security Services Daemon. NSS client interface
*
* Authors:
* Lukas Slebodnik <lslebodn@redhat.com>
*
* Copyright (C) 2015 Red Hat
*
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* INITGROUPs database NSS interface using mmap cache */
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <time.h>
#include "nss_mc.h"
#include "util/util_safealign.h"
NULL, 0, 0 };
{
struct sss_mc_initgr_data *data;
long int i;
long int max_ret;
/* additional checks before filling result*/
/* entry is now invalid */
return EINVAL;
}
/* check we have enough space in the buffer */
long int newsize;
}
if (!newgroups) {
return ENOMEM;
}
}
for (i = 0; i < max_ret; i++) {
*start += 1;
}
return 0;
}
{
struct sss_mc_initgr_data *data;
char *rec_name;
int ret;
if (ret) {
return ret;
}
/* Get max address of data table. */
/* hashes are calculated including the NULL terminator */
/* If slot is not within the bounds of mmaped region and
* it's value is not MC_INVALID_VAL, then the cache is
* probbably corrupted. */
/* free record from previous iteration */
if (ret) {
goto done;
}
/* check record matches what we are searching for */
/* if name hash does not match we can skip this immediately */
continue;
}
/* Integrity check
* - array with gids must be within data_table
* - string must be within data_table */
goto done;
}
break;
}
}
goto done;
}
done:
return ret;
}