/*
* System Security Services Daemon. NSS client interface
*
* Copyright (C) Simo Sorce 2007
*
* 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 */
#include <nss.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "sss_cli.h"
#include "nss_mc.h"
#include "nss_common.h"
static struct sss_nss_getpwent_data {
static void sss_nss_getpwent_data_clean(void) {
}
sss_nss_getpwent_data.len = 0;
sss_nss_getpwent_data.ptr = 0;
}
/* GETPWNAM Request:
*
* 0-X: string with name
*
* GERTPWUID Request:
*
* 0-3: 32bit number with uid
*
* Replies:
*
* 0-3: 32bit unsigned number of results
* For each result:
* 0-3: 32bit number uid
* 4-7: 32bit number gid
* 8-X: sequence of 5, 0 terminated, strings (name, passwd, gecos, dir, shell)
*/
{
char *sbuf;
uint32_t c;
return EBADMSG;
}
i = 0;
NULL);
NULL);
NULL);
NULL);
NULL);
return 0;
}
{
int ret;
/* Caught once glibc passing in buffer == 0x0 */
return NSS_STATUS_TRYAGAIN;
}
if (ret != 0) {
return NSS_STATUS_NOTFOUND;
}
switch (ret) {
case 0:
*errnop = 0;
return NSS_STATUS_SUCCESS;
case ERANGE:
return NSS_STATUS_TRYAGAIN;
case ENOENT:
/* fall through, we need to actively ask the parent
* if no entry is found */
break;
default:
/* if using the mmapped cache failed,
* fall back to socket based comms */
break;
}
sss_nss_lock();
/* previous thread might already initialize entry in mmap cache */
switch (ret) {
case 0:
*errnop = 0;
goto out;
case ERANGE:
goto out;
case ENOENT:
/* fall through, we need to actively ask the parent
* if no entry is found */
break;
default:
/* if using the mmapped cache failed,
* fall back to socket based comms */
break;
}
if (nret != NSS_STATUS_SUCCESS) {
goto out;
}
/* Get number of results from repbuf. */
/* no results if not found */
if (num_results == 0) {
goto out;
}
/* only 1 result is accepted for this function */
if (num_results != 1) {
goto out;
}
if (ret) {
goto out;
}
out:
return nret;
}
{
int ret;
/* Caught once glibc passing in buffer == 0x0 */
return NSS_STATUS_TRYAGAIN;
}
switch (ret) {
case 0:
*errnop = 0;
return NSS_STATUS_SUCCESS;
case ERANGE:
return NSS_STATUS_TRYAGAIN;
case ENOENT:
/* fall through, we need to actively ask the parent
* if no entry is found */
break;
default:
/* if using the mmapped cache failed,
* fall back to socket based comms */
break;
}
sss_nss_lock();
/* previous thread might already initialize entry in mmap cache */
switch (ret) {
case 0:
*errnop = 0;
goto out;
case ERANGE:
goto out;
case ENOENT:
/* fall through, we need to actively ask the parent
* if no entry is found */
break;
default:
/* if using the mmapped cache failed,
* fall back to socket based comms */
break;
}
if (nret != NSS_STATUS_SUCCESS) {
goto out;
}
/* Get number of results from repbuf. */
/* no results if not found */
if (num_results == 0) {
goto out;
}
/* only 1 result is accepted for this function */
if (num_results != 1) {
goto out;
}
if (ret) {
goto out;
}
out:
return nret;
}
{
int errnop;
sss_nss_lock();
/* make sure we do not have leftovers, and release memory */
if (nret != NSS_STATUS_SUCCESS) {
}
return nret;
}
int *errnop)
{
int ret;
/* Caught once glibc passing in buffer == 0x0 */
return NSS_STATUS_TRYAGAIN;
}
/* if there are leftovers return the next one */
if (ret) {
return NSS_STATUS_TRYAGAIN;
}
/* advance buffer pointer */
return NSS_STATUS_SUCCESS;
}
/* release memory if any */
/* retrieve no more than SSS_NSS_MAX_ENTRIES at a time */
if (nret != NSS_STATUS_SUCCESS) {
return nret;
}
/* Get number of results from repbuf. */
/* no results if not found */
return NSS_STATUS_NOTFOUND;
}
/* call again ourselves, this will return the first result */
}
int *errnop)
{
sss_nss_lock();
return nret;
}
{
int errnop;
sss_nss_lock();
/* make sure we do not have leftovers, and release memory */
if (nret != NSS_STATUS_SUCCESS) {
}
return nret;
}