about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/Makefile14
-rw-r--r--nss/Versions1
-rw-r--r--nss/aliases.h63
-rw-r--r--nss/getaliasent.c28
-rw-r--r--nss/getaliasent_r.c30
-rw-r--r--nss/getaliasname.c31
-rw-r--r--nss/getaliasname_r.c30
7 files changed, 197 insertions, 0 deletions
diff --git a/nss/Makefile b/nss/Makefile
index 84cf62af2b..2dfa7ebef9 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -23,6 +23,7 @@ subdir	:= nss
 include ../Makeconfig
 
 headers := \
+  aliases.h \
   grp.h \
   gshadow.h \
   nss.h \
@@ -54,6 +55,19 @@ routines = \
   valid_list_field \
   # routines
 
+# alias routines:
+routines += \
+  getaliasent \
+  getaliasent_r \
+  getaliasname \
+  getaliasname_r \
+  # routines
+
+ifeq ($(have-thread-library),yes)
+CFLAGS-getaliasent_r.c += -fexceptions
+CFLAGS-getaliasent.c += -fexceptions
+endif
+
 # grp routines:
 routines += \
   fgetgrent \
diff --git a/nss/Versions b/nss/Versions
index 632af25be4..5d1b1dac3d 100644
--- a/nss/Versions
+++ b/nss/Versions
@@ -17,6 +17,7 @@ libc {
     fgetspent; fgetspent_r;
 
     # g*
+    getaliasbyname; getaliasbyname_r; getaliasent; getaliasent_r;
     getgrent; getgrent_r; getgrgid; getgrgid_r; getgrnam; getgrnam_r;
     getgroups;
     getpw; getpwent; getpwent_r; getpwnam; getpwnam_r; getpwuid; getpwuid_r;
diff --git a/nss/aliases.h b/nss/aliases.h
new file mode 100644
index 0000000000..bdd704ac6f
--- /dev/null
+++ b/nss/aliases.h
@@ -0,0 +1,63 @@
+/* Copyright (C) 1996-2023 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/>.  */
+
+#ifndef _ALIASES_H
+#define _ALIASES_H	1
+
+#include <features.h>
+
+#include <sys/types.h>
+
+
+__BEGIN_DECLS
+
+/* Structure to represent one entry of the alias database.  */
+struct aliasent
+  {
+    char *alias_name;
+    size_t alias_members_len;
+    char **alias_members;
+    int alias_local;
+  };
+
+
+/* Open alias data base files.  */
+extern void setaliasent (void) __THROW;
+
+/* Close alias database files.  */
+extern void endaliasent (void) __THROW;
+
+/* Get the next entry from the alias database.  */
+extern struct aliasent *getaliasent (void) __THROW;
+
+/* Get the next entry from the alias database and put it in RESULT_BUF.  */
+extern int getaliasent_r (struct aliasent *__restrict __result_buf,
+			  char *__restrict __buffer, size_t __buflen,
+			  struct aliasent **__restrict __result) __THROW;
+
+/* Get alias entry corresponding to NAME.  */
+extern struct aliasent *getaliasbyname (const char *__name) __THROW;
+
+/* Get alias entry corresponding to NAME and put it in RESULT_BUF.  */
+extern int getaliasbyname_r (const char *__restrict __name,
+			     struct aliasent *__restrict __result_buf,
+			     char *__restrict __buffer, size_t __buflen,
+			     struct aliasent **__restrict __result) __THROW;
+
+__END_DECLS
+
+#endif /* aliases.h */
diff --git a/nss/getaliasent.c b/nss/getaliasent.c
new file mode 100644
index 0000000000..16ec063d1e
--- /dev/null
+++ b/nss/getaliasent.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1996-2023 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 <aliases.h>
+
+
+#define LOOKUP_TYPE	struct aliasent
+#define	GETFUNC_NAME	getaliasent
+#define BUFLEN		1024
+
+/* There is no nscd support for the aliases file.  */
+#undef	USE_NSCD
+
+#include "../nss/getXXent.c"
diff --git a/nss/getaliasent_r.c b/nss/getaliasent_r.c
new file mode 100644
index 0000000000..8ce9d3a58c
--- /dev/null
+++ b/nss/getaliasent_r.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1996-2023 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 <aliases.h>
+
+
+#define LOOKUP_TYPE		struct aliasent
+#define SETFUNC_NAME		setaliasent
+#define	GETFUNC_NAME		getaliasent
+#define	ENDFUNC_NAME		endaliasent
+#define DATABASE_NAME		aliases
+
+/* There is no nscd support for the aliases file.  */
+#undef	USE_NSCD
+
+#include "../nss/getXXent_r.c"
diff --git a/nss/getaliasname.c b/nss/getaliasname.c
new file mode 100644
index 0000000000..3687467fe2
--- /dev/null
+++ b/nss/getaliasname.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1996-2023 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 <aliases.h>
+
+
+#define LOOKUP_TYPE	struct aliasent
+#define FUNCTION_NAME	getaliasbyname
+#define DATABASE_NAME	aliases
+#define ADD_PARAMS	const char *name
+#define ADD_VARIABLES	name
+#define BUFLEN		1024
+
+/* There is no nscd support for the aliases file.  */
+#undef	USE_NSCD
+
+#include "../nss/getXXbyYY.c"
diff --git a/nss/getaliasname_r.c b/nss/getaliasname_r.c
new file mode 100644
index 0000000000..85f3d89006
--- /dev/null
+++ b/nss/getaliasname_r.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1996-2023 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 <aliases.h>
+
+
+#define LOOKUP_TYPE		struct aliasent
+#define FUNCTION_NAME		getaliasbyname
+#define DATABASE_NAME		aliases
+#define ADD_PARAMS		const char *name
+#define ADD_VARIABLES		name
+
+/* There is no nscd support for the aliases file.  */
+#undef	USE_NSCD
+
+#include "../nss/getXXbyYY_r.c"