/* Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify 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.
The GNU C Library 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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <nss.h>
#include <nsswitch.h>
#include <shadow.h>
#include <stdio_ext.h>
#include <string.h>
#include <libc-lock.h>
#include <kernel-features.h>
#include <nss_files.h>
#include "netgroup.h"
#include "nisdomain.h"
NSS_DECLARE_MODULE_FUNCTIONS (compat)
static nss_action_list ni;
static enum nss_status (*setspent_impl) (int stayopen);
static enum nss_status (*getspnam_r_impl) (const char *name, struct spwd * sp,
char *buffer, size_t buflen,
int *errnop);
static enum nss_status (*getspent_r_impl) (struct spwd * sp, char *buffer,
size_t buflen, int *errnop);
static enum nss_status (*endspent_impl) (void);
/* Get the declaration of the parser function. */
#define ENTNAME spent
#define STRUCTURE spwd
#define EXTERN_PARSER
#include <nss/nss_files/files-parse.c>
/* Structure for remembering -@netgroup and -user members ... */
#define BLACKLIST_INITIAL_SIZE 512
#define BLACKLIST_INCREMENT 256
struct blacklist_t
{
char *data;
int current;
int size;
};
struct ent_t
{
bool netgroup;
bool files;
bool first;
enum nss_status setent_status;
FILE *stream;
struct blacklist_t blacklist;
struct spwd pwd;
struct __netgrent netgrdata;
};
typedef struct ent_t