nss_files: Move into libc

This is the first step towards fixing bug 27959.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Florian Weimer 2021-07-07 18:33:52 +02:00
parent 36861a968a
commit 6212bb67f4
11 changed files with 37 additions and 64 deletions

View File

@ -798,29 +798,6 @@ for linking")
# define libdl_hidden_data_ver(local, name) # define libdl_hidden_data_ver(local, name)
#endif #endif
#if IS_IN (libnss_files)
# define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libnss_files_hidden_tls_proto(name, attrs...) \
hidden_tls_proto (name, ##attrs)
# define libnss_files_hidden_def(name) hidden_def (name)
# define libnss_files_hidden_weak(name) hidden_weak (name)
# define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
# define libnss_files_hidden_data_def(name) hidden_data_def (name)
# define libnss_files_hidden_tls_def(name) hidden_tls_def (name)
# define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
# define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
#else
# define libnss_files_hidden_proto(name, attrs...)
# define libnss_files_hidden_tls_proto(name, attrs...)
# define libnss_files_hidden_def(name)
# define libnss_files_hidden_weak(name)
# define libnss_files_hidden_ver(local, name)
# define libnss_files_hidden_data_def(name)
# define libnss_files_hidden_tls_def(name)
# define libnss_files_hidden_data_weak(name)
# define libnss_files_hidden_data_ver(local, name)
#endif
#if IS_IN (libnsl) #if IS_IN (libnsl)
# define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
# define libnsl_hidden_tls_proto(name, attrs...) \ # define libnsl_hidden_tls_proto(name, attrs...) \

View File

@ -217,7 +217,7 @@ extern enum nss_status _nss_netgroup_parseline (char **cursor,
struct __netgrent *result, struct __netgrent *result,
char *buffer, size_t buflen, char *buffer, size_t buflen,
int *errnop); int *errnop);
libnss_files_hidden_proto (_nss_netgroup_parseline) libc_hidden_proto (_nss_netgroup_parseline)
#define DECLARE_NSS_PROTOTYPES(service) \ #define DECLARE_NSS_PROTOTYPES(service) \
extern enum nss_status _nss_ ## service ## _setprotoent (int); \ extern enum nss_status _nss_ ## service ## _setprotoent (int); \

View File

@ -124,13 +124,13 @@ extern nss_files_parse_line _nss_files_parse_servent;
extern nss_files_parse_line _nss_files_parse_sgent; extern nss_files_parse_line _nss_files_parse_sgent;
extern nss_files_parse_line _nss_files_parse_spent; extern nss_files_parse_line _nss_files_parse_spent;
libnss_files_hidden_proto (_nss_files_parse_etherent) libc_hidden_proto (_nss_files_parse_etherent)
libc_hidden_proto (_nss_files_parse_grent) libc_hidden_proto (_nss_files_parse_grent)
libnss_files_hidden_proto (_nss_files_parse_netent) libc_hidden_proto (_nss_files_parse_netent)
libnss_files_hidden_proto (_nss_files_parse_protoent) libc_hidden_proto (_nss_files_parse_protoent)
libc_hidden_proto (_nss_files_parse_pwent) libc_hidden_proto (_nss_files_parse_pwent)
libnss_files_hidden_proto (_nss_files_parse_rpcent) libc_hidden_proto (_nss_files_parse_rpcent)
libnss_files_hidden_proto (_nss_files_parse_servent) libc_hidden_proto (_nss_files_parse_servent)
libc_hidden_proto (_nss_files_parse_sgent) libc_hidden_proto (_nss_files_parse_sgent)
libc_hidden_proto (_nss_files_parse_spent) libc_hidden_proto (_nss_files_parse_spent)

View File

@ -98,9 +98,11 @@ subdir-dirs = $(services:%=nss_%)
vpath %.c $(subdir-dirs) ../locale/programs ../intl vpath %.c $(subdir-dirs) ../locale/programs ../intl
libnss_files-routines := $(addprefix files-, \ routines += \
$(filter-out key, $(databases))) \ $(addprefix files-, $(filter-out key, $(databases))) \
files-initgroups files-init files-init \
files-initgroups \
# routines
libnss_db-dbs := $(addprefix db-,\ libnss_db-dbs := $(addprefix db-,\
$(filter-out hosts network key alias,\ $(filter-out hosts network key alias,\
@ -116,12 +118,9 @@ libnss_compat-routines := $(addprefix compat-,grp pwd spwd initgroups) \
install-others += $(inst_vardbdir)/Makefile install-others += $(inst_vardbdir)/Makefile
# Build static module into libc if requested # Build static module into libc if requested
libnss_files-inhibit-o = $(filter-out .os,$(object-suffixes))
libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes)) libnss_db-inhibit-o = $(filter-out .os,$(object-suffixes))
libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes)) libnss_compat-inhibit-o = $(filter-out .os,$(object-suffixes))
ifeq ($(build-static-nss),yes) ifeq ($(build-static-nss),yes)
routines += $(libnss_files-routines)
static-only-routines += $(libnss_files-routines)
tests-static += tst-nss-static tests-static += tst-nss-static
endif endif
extra-test-objs += nss_test1.os nss_test2.os extra-test-objs += nss_test1.os nss_test2.os
@ -138,8 +137,6 @@ libnss-libc = $(common-objpfx)linkobj/libc.so
# for new links: # for new links:
$(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc)
$(objpfx)libnss_db.so: $(objpfx)libnss_files.so
$(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
@rm -f $@.new @rm -f $@.new
(echo '#define EXTERN_PARSER';\ (echo '#define EXTERN_PARSER';\

View File

@ -23,11 +23,8 @@ libc {
__nss_files_data_open; __nss_files_data_open;
__nss_files_data_put; __nss_files_data_put;
__nss_files_data_setent; __nss_files_data_setent;
}
}
libnss_files { # Routines formerly in libnss_files.so.2.
GLIBC_PRIVATE {
_nss_files_setaliasent; _nss_files_setaliasent;
_nss_files_endaliasent; _nss_files_endaliasent;
_nss_files_getaliasbyname_r; _nss_files_getaliasbyname_r;
@ -113,6 +110,14 @@ libnss_files {
} }
} }
libnss_files {
GLIBC_PRIVATE {
# Keep a version node (with a synthesized local: * directive) so that
# __bss_* symbols are hidden on targets that need it.
__libnss_files_version_placeholder;
}
}
libnss_db { libnss_db {
GLIBC_PRIVATE { GLIBC_PRIVATE {
_nss_db_setetherent; _nss_db_setetherent;

View File

@ -98,7 +98,7 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result,
/* Read the first line. It must contain the alias name and /* Read the first line. It must contain the alias name and
possibly some alias names. */ possibly some alias names. */
first_unused[room_left - 1] = '\xff'; first_unused[room_left - 1] = '\xff';
line = fgets_unlocked (first_unused, room_left, stream); line = __fgets_unlocked (first_unused, room_left, stream);
if (line == NULL) if (line == NULL)
/* Nothing to read. */ /* Nothing to read. */
break; break;
@ -187,7 +187,7 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result,
/* If the file does not exist we simply ignore /* If the file does not exist we simply ignore
the statement. */ the statement. */
if (listfile != NULL if (listfile != NULL
&& (old_line = strdup (line)) != NULL) && (old_line = __strdup (line)) != NULL)
{ {
while (! feof_unlocked (listfile)) while (! feof_unlocked (listfile))
{ {
@ -199,8 +199,8 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result,
} }
first_unused[room_left - 1] = '\xff'; first_unused[room_left - 1] = '\xff';
line = fgets_unlocked (first_unused, room_left, line = __fgets_unlocked (first_unused, room_left,
listfile); listfile);
if (line == NULL) if (line == NULL)
break; break;
if (first_unused[room_left - 1] != '\xff') if (first_unused[room_left - 1] != '\xff')
@ -302,7 +302,7 @@ get_next_alias (FILE *stream, const char *match, struct aliasent *result,
/* The just read character is a white space and so /* The just read character is a white space and so
can be ignored. */ can be ignored. */
first_unused[room_left - 1] = '\xff'; first_unused[room_left - 1] = '\xff';
line = fgets_unlocked (first_unused, room_left, stream); line = __fgets_unlocked (first_unused, room_left, stream);
if (line == NULL) if (line == NULL)
{ {
/* Continuation line without any data and /* Continuation line without any data and

View File

@ -57,12 +57,13 @@ LINE_PARSER
STRING_FIELD (addr, isspace, 1); STRING_FIELD (addr, isspace, 1);
/* Parse address. */ /* Parse address. */
if (inet_pton (af == AF_UNSPEC ? AF_INET : af, addr, entdata->host_addr) if (__inet_pton (af == AF_UNSPEC ? AF_INET : af, addr, entdata->host_addr)
> 0) > 0)
af = af == AF_UNSPEC ? AF_INET : af; af = af == AF_UNSPEC ? AF_INET : af;
else else
{ {
if (af == AF_INET && inet_pton (AF_INET6, addr, entdata->host_addr) > 0) if (af == AF_INET
&& __inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
{ {
if (IN6_IS_ADDR_V4MAPPED (entdata->host_addr)) if (IN6_IS_ADDR_V4MAPPED (entdata->host_addr))
memcpy (entdata->host_addr, entdata->host_addr + 12, INADDRSZ); memcpy (entdata->host_addr, entdata->host_addr + 12, INADDRSZ);
@ -76,7 +77,7 @@ LINE_PARSER
return 0; return 0;
} }
else if (af == AF_UNSPEC else if (af == AF_UNSPEC
&& inet_pton (AF_INET6, addr, entdata->host_addr) > 0) && __inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
af = AF_INET6; af = AF_INET6;
else else
/* Illegal address: ignore line. */ /* Illegal address: ignore line. */

View File

@ -32,7 +32,7 @@ NSS_DECLARE_MODULE_FUNCTIONS (files)
#define DATAFILE "/etc/netgroup" #define DATAFILE "/etc/netgroup"
libnss_files_hidden_proto (_nss_files_endnetgrent) libc_hidden_proto (_nss_files_endnetgrent)
#define EXPAND(needed) \ #define EXPAND(needed) \
do \ do \
@ -164,7 +164,7 @@ _nss_files_endnetgrent (struct __netgrent *result)
result->cursor = NULL; result->cursor = NULL;
return NSS_STATUS_SUCCESS; return NSS_STATUS_SUCCESS;
} }
libnss_files_hidden_def (_nss_files_endnetgrent) libc_hidden_def (_nss_files_endnetgrent)
static char * static char *
strip_whitespace (char *str) strip_whitespace (char *str)
@ -279,7 +279,7 @@ _nss_netgroup_parseline (char **cursor, struct __netgrent *result,
return status; return status;
} }
libnss_files_hidden_def (_nss_netgroup_parseline) libc_hidden_def (_nss_netgroup_parseline)
enum nss_status enum nss_status

View File

@ -21,8 +21,7 @@
#include <netdb.h> #include <netdb.h>
#include <stdint.h> #include <stdint.h>
#include <nss.h> #include <nss.h>
#include <nss_files.h>
NSS_DECLARE_MODULE_FUNCTIONS (files)
#define ENTNAME netent #define ENTNAME netent
#define DATABASE "networks" #define DATABASE "networks"
@ -71,7 +70,7 @@ LINE_PARSER
*cp = '\0'; *cp = '\0';
addr = newp; addr = newp;
} }
result->n_net = inet_network (addr); result->n_net = __inet_network (addr);
result->n_addrtype = AF_INET; result->n_addrtype = AF_INET;
}) })

View File

@ -74,13 +74,7 @@ struct parser_data
/* Export the line parser function so it can be used in nss_db. */ /* Export the line parser function so it can be used in nss_db. */
# define parser_stclass /* Global */ # define parser_stclass /* Global */
# define parse_line CONCAT(_nss_files_parse_,ENTNAME) # define parse_line CONCAT(_nss_files_parse_,ENTNAME)
# if IS_IN (libc) # define nss_files_parse_hidden_def(name) libc_hidden_def (name)
/* We are defining one of the functions that actually lives in libc
because it is used to implement fget*ent and suchlike. */
# define nss_files_parse_hidden_def(name) libc_hidden_def (name)
# else
# define nss_files_parse_hidden_def(name) libnss_files_hidden_def (name)
# endif
#endif #endif

View File

@ -40,7 +40,7 @@ __nss_readline (FILE *fp, char *buf, size_t len, off64_t *poffset)
*poffset = __ftello64 (fp); *poffset = __ftello64 (fp);
buf[len - 1] = '\xff'; /* Marker to recognize truncation. */ buf[len - 1] = '\xff'; /* Marker to recognize truncation. */
if (fgets_unlocked (buf, len, fp) == NULL) if (__fgets_unlocked (buf, len, fp) == NULL)
{ {
if (feof_unlocked (fp)) if (feof_unlocked (fp))
{ {
@ -61,7 +61,7 @@ __nss_readline (FILE *fp, char *buf, size_t len, off64_t *poffset)
line on the next call. */ line on the next call. */
return __nss_readline_seek (fp, *poffset); return __nss_readline_seek (fp, *poffset);
/* fgets_unlocked succeeded. */ /* __fgets_unlocked succeeded. */
/* Remove leading whitespace. */ /* Remove leading whitespace. */
char *p = buf; char *p = buf;