endif
CPPFLAGS-getent.c = -DHAVE_SUNRPC=$(have-sunrpc)
+optdatabases = grp pwd spwd sgrp
+
others := getent makedb
install-bin := getent makedb
makedb-modules = xmalloc hash-string
endif
# Specify rules for the nss_* modules. We have some services.
-services := files db compat
+services := files db compat optfiles
extra-libs = $(services:%=libnss_%)
# These libraries will be built in the `others' pass rather than
install-lib-ldscripts = libnss_files.so
$(inst_libdir)/libnss_files.so:
+libnss_optfiles-routines := $(addprefix optfiles-,$(optdatabases)) \
+ optfiles-initgroups optfiles-init
+
libnss_db-dbs := $(addprefix db-,\
$(filter-out hosts network key alias,\
$(databases))) \
install-others += $(inst_vardbdir)/Makefile
# Build static module into libc if requested
+libnss_optfiles-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))
ifeq ($(build-static-nss),yes)
}
}
+libnss_optfiles {
+ GLIBC_PRIVATE {
+ _nss_optfiles_setgrent;
+ _nss_optfiles_endgrent;
+ _nss_optfiles_getgrent_r;
+ _nss_optfiles_getgrgid_r;
+ _nss_optfiles_getgrnam_r;
+
+ _nss_optfiles_setpwent;
+ _nss_optfiles_endpwent;
+ _nss_optfiles_getpwent_r;
+ _nss_optfiles_getpwnam_r;
+ _nss_optfiles_getpwuid_r;
+
+ _nss_optfiles_setspent;
+ _nss_optfiles_endspent;
+ _nss_optfiles_getspent_r;
+ _nss_optfiles_getspnam_r;
+
+ _nss_optfiles_setsgent;
+ _nss_optfiles_endsgent;
+ _nss_optfiles_getsgent_r;
+ _nss_optfiles_getsgnam_r;
+
+ _nss_optfiles_initgroups_dyn;
+
+ _nss_optfiles_init;
+ }
+}
+
libnss_db {
GLIBC_PRIVATE {
_nss_db_setetherent;
#define ENTNAME_r CONCAT(ENTNAME,_r)
-#define DATAFILE "/etc/" DATABASE
+#ifndef DATAFILE_PREFIX_PATH
+# define DATAFILE "/etc/" DATABASE
+#else
+# define DATAFILE DATAFILE_PREFIX_PATH DATABASE
+#endif
+
+#ifndef NSSNAME
+# define NSSNAME files
+#endif
#ifdef NEED_H_ERRNO
# include <netdb.h>
# define EXTRA_ARGS_VALUE
#endif
+#define CONCAT4(a,b,c,d) _CONCAT4(a,b,c,d)
+#define _CONCAT4(a,b,c,d) a##b##c##d
+
\f
/* Maintenance of the stream open on the database file. For getXXent
operations the stream needs to be held open across calls, the other
/* Thread-safe, exported version of that. */
enum nss_status
-CONCAT(_nss_files_set,ENTNAME) (int stayopen)
+CONCAT4(_nss_, NSSNAME, _set, ENTNAME) (int stayopen)
{
return __nss_files_data_setent (CONCAT (nss_file_, ENTNAME), DATAFILE);
}
libc_hidden_def (CONCAT (_nss_files_set,ENTNAME))
enum nss_status
-CONCAT(_nss_files_end,ENTNAME) (void)
+CONCAT4(_nss_, NSSNAME, _end, ENTNAME) (void)
{
return __nss_files_data_endent (CONCAT (nss_file_, ENTNAME));
}
/* Return the next entry from the database file, doing locking. */
enum nss_status
-CONCAT(_nss_files_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
+CONCAT(_nss_, CONCAT(NSSNAME, CONCAT(_get, ENTNAME_r))) (struct STRUCTURE *result, char *buffer,
size_t buflen, int *errnop H_ERRNO_PROTO)
{
/* Return next entry in host file. */
to the lookup key arguments and does `break;' if they match. */
#define DB_LOOKUP(name, db_char, keysize, keypattern, break_if_match, proto...)\
+DB_LOOKUP_NSSNAME(NSSNAME, name, db_char, keysize, keypattern, break_if_match, proto)
+
+#define DB_LOOKUP_NSSNAME(nssname, name, db_char, keysize, keypattern, break_if_match, proto...)\
+DB_LOOKUP_NSSNAME0(nssname, name, db_char, keysize, keypattern, break_if_match, proto)
+
+#define DB_LOOKUP_NSSNAME0(nssname, name, db_char, keysize, keypattern, break_if_match, proto...)\
enum nss_status \
-_nss_files_get##name##_r (proto, \
+_nss_##nssname##_get##name##_r (proto, \
struct STRUCTURE *result, char *buffer, \
size_t buflen, int *errnop H_ERRNO_PROTO) \
{ \
#include <nss.h>
#include <nss_files.h>
+#ifndef DATAFILE_PREFIX_PATH
+# define DATAFILE "/etc/group"
+#else
+# define DATAFILE DATAFILE_PREFIX_PATH "group"
+#endif
+
+#ifndef NSSNAME
+# define NSSNAME files
+#endif
+
+#define CONCAT3(a,b,c) _CONCAT3(a,b,c)
+#define _CONCAT3(a,b,c) a##b##c
+
enum nss_status
-_nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
+CONCAT3(_nss_, NSSNAME, _initgroups_dyn) (const char *user, gid_t group, long int *start,
long int *size, gid_t **groupsp, long int limit,
int *errnop)
{
- FILE *stream = __nss_files_fopen ("/etc/group");
+ FILE *stream = fopen (DATAFILE, "rce");
if (stream == NULL)
{
*errnop = errno;
--- /dev/null
+../nss_files/files-XXX.c
\ No newline at end of file
--- /dev/null
+../nss_files/files-parse.c
\ No newline at end of file
--- /dev/null
+#define DATAFILE_PREFIX_PATH "/opt/etc/"
+#define NSSNAME optfiles
--- /dev/null
+#include "optfiles-config.h"
+#include <nss/nss_files/files-grp.c>
--- /dev/null
+/* Based on ../nss_files/files-init.c
+
+ Initialization in nss_files module.
+ Copyright (C) 2011-2015 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
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef USE_NSCD
+
+#include <string.h>
+#include <nscd/nscd.h>
+
+
+#define TF(id, filename, ...) \
+static union \
+{ \
+ struct traced_file file; \
+ char buf[sizeof (struct traced_file) + sizeof (filename)]; \
+} id##_traced_file = \
+ { \
+ .file = \
+ { \
+ __VA_ARGS__ \
+ } \
+ }
+
+TF (pwd, "/opt/etc/passwd");
+TF (grp, "/opt/etc/group");
+
+void
+_nss_files_init (void (*cb) (size_t, struct traced_file *))
+{
+ strcpy (pwd_traced_file.file.fname, "/opt/etc/passwd");
+ cb (pwddb, &pwd_traced_file.file);
+
+ strcpy (grp_traced_file.file.fname, "/opt/etc/group");
+ cb (grpdb, &grp_traced_file.file);
+
+}
+
+#endif
--- /dev/null
+#include "optfiles-config.h"
+#include <nss/nss_files/files-initgroups.c>
--- /dev/null
+#include "optfiles-config.h"
+#include <nss/nss_files/files-pwd.c>
--- /dev/null
+#include "optfiles-config.h"
+#include <nss/nss_files/files-sgrp.c>
--- /dev/null
+#include "optfiles-config.h"
+#include <nss/nss_files/files-spwd.c>
/%{_lib}/libnss_dns.so.2
/%{_lib}/libnss_files-%{glibc_major_version}.so
/%{_lib}/libnss_files.so.2
+/%{_lib}/libnss_optfiles-%{glibc_major_version}.so
+/%{_lib}/libnss_optfiles.so.2
/%{_lib}/libnss_hesiod-%{glibc_major_version}.so
/%{_lib}/libnss_hesiod.so.2
/%{_lib}/libnss_nis-%{glibc_major_version}.so
# shadow: files nis
# group: files nis
-passwd: compat
+passwd: compat optfiles
group: securitymanager [success=continue] compat
+shadow: compat optfiles
hosts: files dns
networks: files dns
# in nss/nsswitch.h, which determines the library names used for service
# names given in /etc/nsswitch.conf.
libnss_files=2
+libnss_optfiles=2
libnss_dns=2
libnss_compat=2
libnss_ldap=2