/*
* System Security Services Daemon. NSS client interface
*
* Copyright (C) Simo Sorce 2011
*
* 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/>.
*/
/* GROUP 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 };
{
void *cookie;
char *membuf;
int ret;
int i;
/* additional checks before filling result*/
/* entry is now invalid */
return EINVAL;
}
return ERANGE;
}
/* fill in glibc provided structs */
/* copy in buffer */
/* fill in group */
/* The address &buffer[0] must be aligned to sizeof(char *) */
if (!IS_ALIGNED(buffer, char *)) {
/* The buffer is not properly aligned. */
return EFAULT;
}
if (ret) {
return ret;
}
if (ret) {
return ret;
}
if (ret) {
return ret;
}
}
return EINVAL;
}
return 0;
}
{
char *rec_name;
int ret;
if (ret) {
return ret;
}
/* Get max size 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
* - name_len cannot be longer than all strings
* - data->name cannot point outside strings
* - all strings must be within copy of record
* - size of record must be lower that data table size */
goto done;
}
break;
}
}
goto done;
}
done:
return ret;
}
{
int len;
int ret;
if (ret) {
return ret;
}
if (len > 10) {
goto done;
}
/* 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 uid hash does not match we can skip this immediately */
continue;
}
break;
}
}
goto done;
}
done:
return ret;
}