nss_mc_passwd.c revision 581de96fc30b7fe44070f17a8a73f3374d38d6ff
/*
* 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/>.
*/
/* PASSWD 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"
{
struct sss_mc_pwd_data *data;
void *cookie;
int ret;
/* additional checks before filling result*/
/* entry is now invalid */
return EINVAL;
}
return ERANGE;
}
/* fill in glibc provided structs */
/* copy in buffer */
/* fill in passwd */
if (ret) {
return ret;
}
if (ret) {
return ret;
}
if (ret) {
return ret;
}
if (ret) {
return ret;
}
if (ret) {
return ret;
}
return EINVAL;
}
return 0;
}
{
struct sss_mc_pwd_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. */
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 data_table */
goto done;
}
break;
}
}
goto done;
}
done:
return ret;
}
{
struct sss_mc_pwd_data *data;
char uidstr[11];
int len;
int ret;
if (ret) {
return ret;
}
if (len > 10) {
return EINVAL;
}
/* 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. */
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;
}