[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r8350 - in /fsf/trunk/libc: ./ gshadow/ include/ misc/ misc/sys/ nss/ nss/nss_files/ shadow/ stdlib/ sysdeps/generic/ sysdep...
- To: commits@xxxxxxxxxx
- Subject: [commits] r8350 - in /fsf/trunk/libc: ./ gshadow/ include/ misc/ misc/sys/ nss/ nss/nss_files/ shadow/ stdlib/ sysdeps/generic/ sysdep...
- From: eglibc@xxxxxxxxxx
- Date: Fri, 24 Apr 2009 07:04:29 -0000
Author: eglibc
Date: Fri Apr 24 00:04:28 2009
New Revision: 8350
Log:
Import glibc-mainline for 2009-04-24
Added:
fsf/trunk/libc/gshadow/
fsf/trunk/libc/gshadow/Makefile
fsf/trunk/libc/gshadow/Versions
fsf/trunk/libc/gshadow/fgetsgent.c
fsf/trunk/libc/gshadow/fgetsgent_r.c
fsf/trunk/libc/gshadow/getsgent.c
fsf/trunk/libc/gshadow/getsgent_r.c
fsf/trunk/libc/gshadow/getsgnam.c
fsf/trunk/libc/gshadow/getsgnam_r.c
fsf/trunk/libc/gshadow/gshadow.h
fsf/trunk/libc/gshadow/putsgent.c
fsf/trunk/libc/gshadow/sgetsgent.c
fsf/trunk/libc/gshadow/sgetsgent_r.c
fsf/trunk/libc/gshadow/tst-gshadow.c
fsf/trunk/libc/include/gshadow.h
fsf/trunk/libc/nss/nss_files/files-sgrp.c
fsf/trunk/libc/nss/sgrp-lookup.c
fsf/trunk/libc/shadow/tst-shadow.c
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/Makeconfig
fsf/trunk/libc/Makefile
fsf/trunk/libc/NEWS
fsf/trunk/libc/misc/preadv.c
fsf/trunk/libc/misc/preadv64.c
fsf/trunk/libc/misc/pwritev.c
fsf/trunk/libc/misc/pwritev64.c
fsf/trunk/libc/misc/sys/uio.h
fsf/trunk/libc/nss/Makefile
fsf/trunk/libc/nss/Versions
fsf/trunk/libc/nss/nss_files/files-parse.c
fsf/trunk/libc/nss/nsswitch.conf
fsf/trunk/libc/shadow/Makefile
fsf/trunk/libc/shadow/sgetspent_r.c
fsf/trunk/libc/stdlib/random_r.c
fsf/trunk/libc/sysdeps/generic/paths.h
fsf/trunk/libc/sysdeps/posix/preadv.c
fsf/trunk/libc/sysdeps/posix/pwritev.c
fsf/trunk/libc/sysdeps/unix/make-syscalls.sh
fsf/trunk/libc/sysdeps/unix/sysv/linux/paths.h
fsf/trunk/libc/sysdeps/unix/sysv/linux/preadv.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/pwritev.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/mount.h
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Fri Apr 24 00:04:28 2009
@@ -1,3 +1,71 @@
+2009-04-23 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ [BZ #9920]
+ * stdlib/random_r.c (__srandom_r): Change type of word to int32_t
+ to get consistency between 32 and 64 bit architectures.
+
+ [BZ #10052]
+ * sysdeps/unix/make-syscalls.sh: Add rule to create target
+ directory for dummy syscall rules.
+ Patch by Chris Steinbroner <hesh@xxxxxxxxx>.
+
+2009-04-23 Aurelien Jarno <aurelien@xxxxxxxxxxx>
+
+ [BZ #10092]
+ * sysdeps/unix/sysv/linux/sys/mount.h: Define MNT_DETACH and
+ MNT_EXPIRE.
+
+2009-04-23 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/preadv.c: The kernel API changed. Adjust.
+ * sysdeps/unix/sysv/linux/pwritev.c: Likewise.
+
+2009-04-23 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * sysdeps/posix/pwritev.c (PWRITEV): Fix up comment. Copy
+ data from vector to temporary buffer and call PWRITEV after it
+ instead of vice versa.
+ * sysdeps/posix/preadv.c: Fix up comment.
+ * misc/preadv.c: Likewise.
+ * misc/preadv64.c: Likewise.
+ * misc/pwritev.c: Likewise.
+ * misc/pwritev64.c: Likewise.
+ * misc/sys/uio.h (preadv, pwritev, preadv64, pwritev64): Likewise.
+
+2009-04-23 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * shadow/sgetspent_r.c (__sgetspent_r): Recognize too small buffers.
+
+ * shadow/Makefile (tests): Add tst-shadow.
+ * shadow/tst-shadow.c: New file.
+
+ [BZ #9955]
+ * gshadow/Makefile: New file.
+ * gshadow/Versions: New file.
+ * gshadow/fgetsgent.c: New file.
+ * gshadow/fgetsgent_r.c: New file.
+ * gshadow/getsgent.c: New file.
+ * gshadow/getsgent_r.c: New file.
+ * gshadow/getsgnam.c: New file.
+ * gshadow/getsgnam_r.c: New file.
+ * gshadow/gshadow.h: New file.
+ * gshadow/putsgent.c: New file.
+ * gshadow/sgetsgent.c: New file.
+ * gshadow/sgetsgent_r.c: New file.
+ * gshadow/tst-gshadow.c: New file.
+ * include/gshadow.h: New file.
+ * Makeconfig (all-subdirs): Add gshadow.
+ * Makefile (installed-headers): Add gshadow/gshadow.h.
+ * nss/Makefile (databases): Add sgrp.
+ * nss/Versions: Add gshadow functions as private exports.
+ * nss/nsswitch.conf: Add gshadow entry.
+ * nss/sgrp-lookup.c: New file.
+ * nss/nss_files/files-parse.c: Add STRING_LIST macro. Rewrite
+ parse_list to handle STRING_LIST and TRAILING_LIST_PARSER.
+ * nss/nss_files/files-sgrp.c: New file.
+ * sysdeps/generic/paths.h: Add _PATH_GSHADOW.
+ * sysdeps/unix/sysv/linux/paths.h: Likewise.
+
2009-04-22 Ulrich Drepper <drepper@xxxxxxxxxx>
* stdio-common/printf.h: Add missing const to register_printf_modifier.
@@ -71,7 +139,7 @@
* malloc/arena.c (ptmalloc_init): Load hook variable into variable
before test and force into register.
* malloc/hooks.c (top_check): Likewise.
- (public_s_ET_STATe): Pretty printing.
+ (public_sET_STATe): Pretty printing.
* resolv/res_send.c (send_dg): Don't just ignore the result we got
in case we only receive one reply in single-request mode.
Modified: fsf/trunk/libc/Makeconfig
==============================================================================
--- fsf/trunk/libc/Makeconfig (original)
+++ fsf/trunk/libc/Makeconfig Fri Apr 24 00:04:28 2009
@@ -918,7 +918,7 @@
all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
stdlib stdio-common libio malloc string wcsmbs time dirent \
grp pwd posix io termios resource misc socket sysvipc gmon \
- gnulib iconv iconvdata wctype manual shadow po argp \
+ gnulib iconv iconvdata wctype manual shadow gshadow po argp \
crypt nss localedata timezone rt conform debug \
$(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
Modified: fsf/trunk/libc/Makefile
==============================================================================
--- fsf/trunk/libc/Makefile (original)
+++ fsf/trunk/libc/Makefile Fri Apr 24 00:04:28 2009
@@ -271,7 +271,7 @@
crypt/crypt.h ctype/ctype.h debug/execinfo.h \
dirent/dirent.h dlfcn/dlfcn.h elf/elf.h elf/link.h \
gmon/sys/gmon.h gmon/sys/gmon_out.h gmon/sys/profil.h \
- grp/grp.h iconv/iconv.h iconv/gconv.h \
+ grp/grp.h gshadow/gshadow.h iconv/iconv.h iconv/gconv.h \
$(wildcard inet/netinet/*.h) \
$(wildcard inet/arpa/*.h inet/protocols/*.h) \
inet/aliases.h inet/ifaddrs.h inet/netinet/ip6.h \
Modified: fsf/trunk/libc/NEWS
==============================================================================
--- fsf/trunk/libc/NEWS (original)
+++ fsf/trunk/libc/NEWS Fri Apr 24 00:04:28 2009
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes. 2009-4-13
+GNU C Library NEWS -- history of user-visible changes. 2009-4-23
Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc.
See the end for copying conditions.
@@ -42,6 +42,9 @@
* Extended printf hook support. It is possible to use user-defined types
and extend existing format specifiers.
+ Implemented by Ulrich Drepper.
+
+* Handling for group shadow files has been added.
Implemented by Ulrich Drepper.
Added: fsf/trunk/libc/gshadow/Makefile
==============================================================================
--- fsf/trunk/libc/gshadow/Makefile (added)
+++ fsf/trunk/libc/gshadow/Makefile Fri Apr 24 00:04:28 2009
@@ -1,0 +1,38 @@
+# Copyright (C) 2009 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, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+#
+# Makefile for gshadow.
+#
+subdir := gshadow
+
+headers = gshadow.h
+routines = getsgent getsgnam sgetsgent fgetsgent putsgent \
+ getsgent_r getsgnam_r sgetsgent_r fgetsgent_r
+
+tests = tst-gshadow
+
+CFLAGS-getsgent_r.c = -fexceptions
+CFLAGS-getsgent.c = -fexceptions
+CFLAGS-fgetsgent.c = -fexceptions
+CFLAGS-fgetsgent_r.c = -fexceptions -D_IO_MTSAFE_IO
+CFLAGS-putsgent.c = -fexceptions -D_IO_MTSAFE_IO
+CFLAGS-getsgnam.c = -fexceptions
+CFLAGS-getsgnam_r.c = -fexceptions
+
+include ../Rules
Added: fsf/trunk/libc/gshadow/Versions
==============================================================================
--- fsf/trunk/libc/gshadow/Versions (added)
+++ fsf/trunk/libc/gshadow/Versions Fri Apr 24 00:04:28 2009
@@ -1,0 +1,21 @@
+libc {
+ GLIBC_2.10 {
+ # e*
+ endsgent;
+
+ # f*
+ fgetsgent; fgetsgent_r;
+
+ # g*
+ getsgent; getsgent_r; getsgnam; getsgnam_r; getsgent_r; getsgnam_r;
+
+ # p*
+ putsgent;
+
+ # s*
+ setsgent;
+
+ # s*
+ sgetsgent; sgetsgent_r;
+ }
+}
Added: fsf/trunk/libc/gshadow/fgetsgent.c
==============================================================================
--- fsf/trunk/libc/gshadow/fgetsgent.c (added)
+++ fsf/trunk/libc/gshadow/fgetsgent.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,88 @@
+/* Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <bits/libc-lock.h>
+#include <gshadow.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+/* A reasonable size for a buffer to start with. */
+#define BUFLEN_SPWD 1024
+
+/* We need to protect the dynamic buffer handling. */
+__libc_lock_define_initialized (static, lock);
+
+libc_freeres_ptr (static char *buffer);
+
+/* Read one shadow entry from the given stream. */
+struct sgrp *
+fgetsgent (FILE *stream)
+{
+ static size_t buffer_size;
+ static struct sgrp resbuf;
+ fpos_t pos;
+ struct sgrp *result;
+ int save;
+
+ if (fgetpos (stream, &pos) != 0)
+ return NULL;
+
+ /* Get lock. */
+ __libc_lock_lock (lock);
+
+ /* Allocate buffer if not yet available. */
+ if (buffer == NULL)
+ {
+ buffer_size = BUFLEN_SPWD;
+ buffer = malloc (buffer_size);
+ }
+
+ while (buffer != NULL
+ && (__fgetsgent_r (stream, &resbuf, buffer, buffer_size, &result)
+ == ERANGE))
+ {
+ char *new_buf;
+ buffer_size += BUFLEN_SPWD;
+ new_buf = realloc (buffer, buffer_size);
+ if (new_buf == NULL)
+ {
+ /* We are out of memory. Free the current buffer so that the
+ process gets a chance for a normal termination. */
+ save = errno;
+ free (buffer);
+ __set_errno (save);
+ }
+ buffer = new_buf;
+
+ /* Reset the stream. */
+ if (fsetpos (stream, &pos) != 0)
+ buffer = NULL;
+ }
+
+ if (buffer == NULL)
+ result = NULL;
+
+ /* Release lock. Preserve error value. */
+ save = errno;
+ __libc_lock_unlock (lock);
+ __set_errno (save);
+
+ return result;
+}
Added: fsf/trunk/libc/gshadow/fgetsgent_r.c
==============================================================================
--- fsf/trunk/libc/gshadow/fgetsgent_r.c (added)
+++ fsf/trunk/libc/gshadow/fgetsgent_r.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,76 @@
+/* Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <ctype.h>
+#include <errno.h>
+#include <gshadow.h>
+#include <stdio.h>
+
+/* Define a line parsing function using the common code
+ used in the nss_files module. */
+
+#define STRUCTURE sgrp
+#define ENTNAME sgent
+#define EXTERN_PARSER 1
+struct sgent_data {};
+
+#include <nss/nss_files/files-parse.c>
+
+
+/* Read one shadow entry from the given stream. */
+int
+__fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
+ struct sgrp **result)
+{
+ char *p;
+
+ _IO_flockfile (stream);
+ do
+ {
+ buffer[buflen - 1] = '\xff';
+ p = fgets_unlocked (buffer, buflen, stream);
+ if (p == NULL && feof_unlocked (stream))
+ {
+ _IO_funlockfile (stream);
+ *result = NULL;
+ __set_errno (ENOENT);
+ return errno;
+ }
+ if (p == NULL || buffer[buflen - 1] != '\xff')
+ {
+ _IO_funlockfile (stream);
+ *result = NULL;
+ __set_errno (ERANGE);
+ return errno;
+ }
+
+ /* Skip leading blanks. */
+ while (isspace (*p))
+ ++p;
+ } while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */
+ /* Parse the line. If it is invalid, loop to
+ get the next line of the file to parse. */
+ ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen,
+ &errno));
+
+ _IO_funlockfile (stream);
+
+ *result = resbuf;
+ return 0;
+}
+weak_alias (__fgetsgent_r, fgetsgent_r)
Added: fsf/trunk/libc/gshadow/getsgent.c
==============================================================================
--- fsf/trunk/libc/gshadow/getsgent.c (added)
+++ fsf/trunk/libc/gshadow/getsgent.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,30 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2009.
+
+ 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <gshadow.h>
+
+
+#define LOOKUP_TYPE struct sgrp
+#define SETFUNC_NAME setsgent
+#define GETFUNC_NAME getsgent
+#define ENDFUNC_NAME endsgent
+#define DATABASE_NAME gshadow
+#define BUFLEN 1024
+
+#include "../nss/getXXent.c"
Added: fsf/trunk/libc/gshadow/getsgent_r.c
==============================================================================
--- fsf/trunk/libc/gshadow/getsgent_r.c (added)
+++ fsf/trunk/libc/gshadow/getsgent_r.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,30 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2009.
+
+ 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <gshadow.h>
+
+
+#define LOOKUP_TYPE struct sgrp
+#define SETFUNC_NAME setsgent
+#define GETFUNC_NAME getsgent
+#define ENDFUNC_NAME endsgent
+#define DATABASE_NAME gshadow
+#define BUFLEN 1024
+
+#include "../nss/getXXent_r.c"
Added: fsf/trunk/libc/gshadow/getsgnam.c
==============================================================================
--- fsf/trunk/libc/gshadow/getsgnam.c (added)
+++ fsf/trunk/libc/gshadow/getsgnam.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,30 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2009.
+
+ 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <gshadow.h>
+
+
+#define LOOKUP_TYPE struct sgrp
+#define FUNCTION_NAME getsgnam
+#define DATABASE_NAME gshadow
+#define ADD_PARAMS const char *name
+#define ADD_VARIABLES name
+#define BUFLEN 1024
+
+#include "../nss/getXXbyYY.c"
Added: fsf/trunk/libc/gshadow/getsgnam_r.c
==============================================================================
--- fsf/trunk/libc/gshadow/getsgnam_r.c (added)
+++ fsf/trunk/libc/gshadow/getsgnam_r.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,30 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2009.
+
+ 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <gshadow.h>
+
+
+#define LOOKUP_TYPE struct sgrp
+#define FUNCTION_NAME getsgnam
+#define DATABASE_NAME gshadow
+#define ADD_PARAMS const char *name
+#define ADD_VARIABLES name
+#define BUFLEN 1024
+
+#include "../nss/getXXbyYY_r.c"
Added: fsf/trunk/libc/gshadow/gshadow.h
==============================================================================
--- fsf/trunk/libc/gshadow/gshadow.h (added)
+++ fsf/trunk/libc/gshadow/gshadow.h Fri Apr 24 00:04:28 2009
@@ -1,0 +1,131 @@
+/* Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Declaration of types and functions for shadow group suite. */
+
+#ifndef _GSHADOW_H
+#define _GSHADOW_H 1
+
+#include <features.h>
+
+#include <paths.h>
+
+#define __need_FILE
+#include <stdio.h>
+#define __need_size_t
+#include <stddef.h>
+
+/* Path to the user database files. */
+#define GSHADOW _PATH_GSHADOW
+
+
+__BEGIN_DECLS
+
+/* Structure of the group file. */
+struct sgrp
+ {
+ char *sg_namp; /* Group name. */
+ char *sg_passwd; /* Encrypted password. */
+ char **sg_adm; /* Group administrator list. */
+ char **sg_mem; /* Group member list. */
+ };
+
+
+/* Open database for reading.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern void setsgent (void);
+
+/* Close database.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern void endsgent (void);
+
+/* Get next entry from database, perhaps after opening the file.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern struct sgrp *getsgent (void);
+
+/* Get shadow entry matching NAME.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern struct sgrp *getsgnam (__const char *__name);
+
+/* Read shadow entry from STRING.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern struct sgrp *sgetsgent (__const char *__string);
+
+/* Read next shadow entry from STREAM.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern struct sgrp *fgetsgent (FILE *__stream);
+
+/* Write line containing shadow password entry to stream.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern int putsgent (__const struct sgrp *__g, FILE *__stream);
+
+
+#ifdef __USE_MISC
+/* Reentrant versions of some of the functions above.
+
+ These functions are not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation they are cancellation points and
+ therefore not marked with __THROW. */
+extern int getsgent_r (struct sgrp *__result_buf, char *__buffer,
+ size_t __buflen, struct sgrp **__result);
+
+extern int getsgnam_r (__const char *__name, struct sgrp *__result_buf,
+ char *__buffer, size_t __buflen,
+ struct sgrp **__result);
+
+extern int sgetsgent_r (__const char *__string, struct sgrp *__result_buf,
+ char *__buffer, size_t __buflen,
+ struct sgrp **__result);
+
+extern int fgetsgent_r (FILE *__stream, struct sgrp *__result_buf,
+ char *__buffer, size_t __buflen,
+ struct sgrp **__result);
+#endif /* misc */
+
+__END_DECLS
+
+#endif /* gshadow.h */
Added: fsf/trunk/libc/gshadow/putsgent.c
==============================================================================
--- fsf/trunk/libc/gshadow/putsgent.c (added)
+++ fsf/trunk/libc/gshadow/putsgent.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,71 @@
+/* Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <gshadow.h>
+
+#define _S(x) x ? x : ""
+
+
+/* Write an entry to the given stream.
+ This must know the format of the group file. */
+int
+putsgent (const struct sgrp *g, FILE *stream)
+{
+ int errors = 0;
+
+ _IO_flockfile (stream);
+
+ if (fprintf (stream, "%s:%s:", g->sg_namp, _S (g->sg_passwd)) < 0)
+ ++errors;
+
+ bool first = true;
+ char **sp = g->sg_adm;
+ if (sp != NULL)
+ while (*sp != NULL)
+ {
+ if (fprintf (stream, "%s%s", first ? "" : ",", *sp++) < 0)
+ {
+ ++errors;
+ break;
+ }
+ first = false;
+ }
+ if (putc_unlocked (':', stream) == EOF)
+ ++errors;
+
+ first = true;
+ sp = g->sg_mem;
+ if (sp != NULL)
+ while (*sp != NULL)
+ {
+ if (fprintf (stream, "%s%s", first ? "" : ",", *sp++) < 0)
+ {
+ ++errors;
+ break;
+ }
+ first = false;
+ }
+ if (putc_unlocked ('\n', stream) == EOF)
+ ++errors;
+
+ _IO_funlockfile (stream);
+
+ return errors ? -1 : 0;
+}
Added: fsf/trunk/libc/gshadow/sgetsgent.c
==============================================================================
--- fsf/trunk/libc/gshadow/sgetsgent.c (added)
+++ fsf/trunk/libc/gshadow/sgetsgent.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,78 @@
+/* Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <bits/libc-lock.h>
+#include <gshadow.h>
+#include <stdlib.h>
+
+
+/* A reasonable size for a buffer to start with. */
+#define BUFLEN_SPWD 1024
+
+/* We need to protect the dynamic buffer handling. */
+__libc_lock_define_initialized (static, lock);
+
+/* Read one shadow entry from the given stream. */
+struct sgrp *
+sgetsgent (const char *string)
+{
+ static char *buffer;
+ static size_t buffer_size;
+ static struct sgrp resbuf;
+ struct sgrp *result;
+ int save;
+
+ /* Get lock. */
+ __libc_lock_lock (lock);
+
+ /* Allocate buffer if not yet available. */
+ if (buffer == NULL)
+ {
+ buffer_size = BUFLEN_SPWD;
+ buffer = malloc (buffer_size);
+ }
+
+ while (buffer != NULL
+ && __sgetsgent_r (string, &resbuf, buffer, buffer_size, &result) != 0
+ && errno == ERANGE)
+ {
+ char *new_buf;
+ buffer_size += BUFLEN_SPWD;
+ new_buf = realloc (buffer, buffer_size);
+ if (new_buf == NULL)
+ {
+ /* We are out of memory. Free the current buffer so that the
+ process gets a chance for a normal termination. */
+ save = errno;
+ free (buffer);
+ __set_errno (save);
+ }
+ buffer = new_buf;
+ }
+
+ if (buffer == NULL)
+ result = NULL;
+
+ /* Release lock. Preserve error value. */
+ save = errno;
+ __libc_lock_unlock (lock);
+ __set_errno (save);
+
+ return result;
+}
Added: fsf/trunk/libc/gshadow/sgetsgent_r.c
==============================================================================
--- fsf/trunk/libc/gshadow/sgetsgent_r.c (added)
+++ fsf/trunk/libc/gshadow/sgetsgent_r.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,75 @@
+/* Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <ctype.h>
+#include <errno.h>
+#include <gshadow.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Define a line parsing function using the common code
+ used in the nss_files module. */
+
+#define STRUCTURE sgrp
+#define ENTNAME sgent
+struct sgent_data {};
+
+
+#define TRAILING_LIST_MEMBER sg_mem
+#define TRAILING_LIST_SEPARATOR_P(c) ((c) == ',')
+#include <nss/nss_files/files-parse.c>
+LINE_PARSER
+(,
+ STRING_FIELD (result->sg_namp, ISCOLON, 0);
+ if (line[0] == '\0'
+ && (result->sg_namp[0] == '+' || result->sg_namp[0] == '-'))
+ {
+ result->sg_passwd = NULL;
+ result->sg_adm = NULL;
+ result->sg_mem = NULL;
+ }
+ else
+ {
+ STRING_FIELD (result->sg_passwd, ISCOLON, 0);
+ STRING_LIST (result->sg_adm, ':');
+ }
+ )
+
+
+/* Read one shadow entry from the given stream. */
+int
+__sgetsgent_r (const char *string, struct sgrp *resbuf, char *buffer,
+ size_t buflen, struct sgrp **result)
+{
+ char *sp;
+ if (string < buffer || string >= buffer + buflen)
+ {
+ buffer[buflen - 1] = '\0';
+ sp = strncpy (buffer, string, buflen);
+ if (buffer[buflen - 1] != '\0')
+ return ERANGE;
+ }
+ else
+ sp = (char *) string;
+
+ int parse_result = parse_line (sp, resbuf, (void *) buffer, buflen, &errno);
+ *result = parse_result > 0 ? resbuf : NULL;
+
+ return *result == NULL ? errno : 0;
+}
+weak_alias (__sgetsgent_r, sgetsgent_r)
Added: fsf/trunk/libc/gshadow/tst-gshadow.c
==============================================================================
--- fsf/trunk/libc/gshadow/tst-gshadow.c (added)
+++ fsf/trunk/libc/gshadow/tst-gshadow.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,141 @@
+#include <gshadow.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static const struct sgrp data[] =
+ {
+ { (char *) "one", (char *) "pwdone",
+ (char *[]) { (char *) "admoneone", (char *) "admonetwo",
+ (char *) "admonethree", NULL },
+ (char *[]) { (char *) "memoneone", (char *) "memonetwo",
+ (char *) "memonethree", NULL } },
+ { (char *) "two", (char *) "pwdtwo",
+ (char *[]) { (char *) "admtwoone", (char *) "admtwotwo", NULL },
+ (char *[]) { (char *) "memtwoone", (char *) "memtwotwo",
+ (char *) "memtwothree", NULL } },
+ { (char *) "three", (char *) "pwdthree",
+ (char *[]) { (char *) "admthreeone", (char *) "admthreetwo", NULL },
+ (char *[]) { (char *) "memthreeone", (char *) "memthreetwo", NULL } },
+ { (char *) "four", (char *) "pwdfour",
+ (char *[]) { (char *) "admfourone", (char *) "admfourtwo", NULL },
+ (char *[]) { NULL } },
+ { (char *) "five", (char *) "pwdfive",
+ (char *[]) { NULL },
+ (char *[]) { (char *) "memfiveone", (char *) "memfivetwo", NULL } },
+ };
+#define ndata (sizeof (data) / sizeof (data[0]))
+
+
+static int
+do_test (void)
+{
+ FILE *fp = tmpfile ();
+ if (fp == NULL)
+ {
+ puts ("cannot open temporary file");
+ return 1;
+ }
+
+ for (size_t i = 0; i < ndata; ++i)
+ if (putsgent (&data[i], fp) != 0)
+ {
+ printf ("putsgent call %zu failed\n", i + 1);
+ return 1;
+ }
+
+ rewind (fp);
+
+ int result = 0;
+ int seen = -1;
+ struct sgrp *g;
+ while ((g = fgetsgent (fp)) != NULL)
+ {
+ ++seen;
+ if (strcmp (g->sg_namp, data[seen].sg_namp) != 0)
+ {
+ printf ("sg_namp of entry %d does not match: %s vs %s\n",
+ seen + 1, g->sg_namp, data[seen].sg_namp);
+ result = 1;
+ }
+ if (strcmp (g->sg_passwd, data[seen].sg_passwd) != 0)
+ {
+ printf ("sg_passwd of entry %d does not match: %s vs %s\n",
+ seen + 1, g->sg_passwd, data[seen].sg_passwd);
+ result = 1;
+ }
+ if (g->sg_adm == NULL)
+ {
+ printf ("sg_adm of entry %d is NULL\n", seen + 1);
+ result = 1;
+ }
+ else
+ {
+ int i = 1;
+ char **sp1 = g->sg_adm;
+ char **sp2 = data[seen].sg_adm;
+ while (*sp1 != NULL && *sp2 != NULL)
+ {
+ if (strcmp (*sp1, *sp2) != 0)
+ {
+ printf ("sg_adm[%d] of entry %d does not match: %s vs %s\n",
+ i, seen + 1, *sp1, *sp2);
+ result = 1;
+ }
+ ++sp1;
+ ++sp2;
+ ++i;
+ }
+ if (*sp1 == NULL && *sp2 != NULL)
+ {
+ printf ("sg_adm of entry %d has too few entries\n", seen + 1);
+ result = 1;
+ }
+ else if (*sp1 != NULL && *sp2 == NULL)
+ {
+ printf ("sg_adm of entry %d has too many entries\n", seen + 1);
+ result = 1;
+ }
+ }
+ if (g->sg_mem == NULL)
+ {
+ printf ("sg_mem of entry %d is NULL\n", seen + 1);
+ result = 1;
+ }
+ else
+ {
+ int i = 1;
+ char **sp1 = g->sg_mem;
+ char **sp2 = data[seen].sg_mem;
+ while (*sp1 != NULL && *sp2 != NULL)
+ {
+ if (strcmp (*sp1, *sp2) != 0)
+ {
+ printf ("sg_mem[%d] of entry %d does not match: %s vs %s\n",
+ i, seen + 1, *sp1, *sp2);
+ result = 1;
+ }
+ ++sp1;
+ ++sp2;
+ ++i;
+ }
+ if (*sp1 == NULL && *sp2 != NULL)
+ {
+ printf ("sg_mem of entry %d has too few entries\n", seen + 1);
+ result = 1;
+ }
+ else if (*sp1 != NULL && *sp2 == NULL)
+ {
+ printf ("sg_mem of entry %d has too many entries\n", seen + 1);
+ result = 1;
+ }
+ }
+ }
+
+ fclose (fp);
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Added: fsf/trunk/libc/include/gshadow.h
==============================================================================
--- fsf/trunk/libc/include/gshadow.h (added)
+++ fsf/trunk/libc/include/gshadow.h Fri Apr 24 00:04:28 2009
@@ -1,0 +1,15 @@
+#ifndef _GSHADOW_H
+#include <gshadow/gshadow.h>
+
+extern int __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer,
+ size_t buflen, struct sgrp **result);
+extern int __sgetsgent_r (const char *string, struct sgrp *resbuf,
+ char *buffer, size_t buflen, struct sgrp **result);
+
+struct parser_data;
+extern int _nss_files_parse_sgent (char *line, struct sgrp *result,
+ struct parser_data *data,
+ size_t datalen, int *errnop);
+libc_hidden_proto (_nss_files_parse_sgent)
+
+#endif
Modified: fsf/trunk/libc/misc/preadv.c
==============================================================================
--- fsf/trunk/libc/misc/preadv.c (original)
+++ fsf/trunk/libc/misc/preadv.c Fri Apr 24 00:04:28 2009
@@ -24,7 +24,7 @@
without change the file pointer, and put the result in the buffers
described by VECTOR, which is a vector of COUNT 'struct iovec's.
The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in VECTOR instead
+ 'pread' (see <unistd.h>) except that data are put in VECTOR instead
of a contiguous buffer. */
ssize_t
preadv (fd, vector, count, offset)
Modified: fsf/trunk/libc/misc/preadv64.c
==============================================================================
--- fsf/trunk/libc/misc/preadv64.c (original)
+++ fsf/trunk/libc/misc/preadv64.c Fri Apr 24 00:04:28 2009
@@ -24,7 +24,7 @@
without change the file pointer, and put the result in the buffers
described by VECTOR, which is a vector of COUNT 'struct iovec's.
The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in VECTOR instead
+ 'pread' (see <unistd.h>) except that data are put in VECTOR instead
of a contiguous buffer. */
ssize_t
preadv64 (fd, vector, count, offset)
Modified: fsf/trunk/libc/misc/pwritev.c
==============================================================================
--- fsf/trunk/libc/misc/pwritev.c (original)
+++ fsf/trunk/libc/misc/pwritev.c Fri Apr 24 00:04:28 2009
@@ -23,7 +23,7 @@
/* Write data pointed by the buffers described by VECTOR, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
position OFFSET without change the file pointer. The data is
- written in the order specified. Operates just like 'write' (see
+ written in the order specified. Operates just like 'pwrite' (see
<unistd.h>) except that the data are taken from VECTOR instead of a
contiguous buffer. */
ssize_t
Modified: fsf/trunk/libc/misc/pwritev64.c
==============================================================================
--- fsf/trunk/libc/misc/pwritev64.c (original)
+++ fsf/trunk/libc/misc/pwritev64.c Fri Apr 24 00:04:28 2009
@@ -23,7 +23,7 @@
/* Write data pointed by the buffers described by VECTOR, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
position OFFSET without change the file pointer. The data is
- written in the order specified. Operates just like 'write' (see
+ written in the order specified. Operates just like 'pwrite' (see
<unistd.h>) except that the data are taken from VECTOR instead of a
contiguous buffer. */
ssize_t
Modified: fsf/trunk/libc/misc/sys/uio.h
==============================================================================
--- fsf/trunk/libc/misc/sys/uio.h (original)
+++ fsf/trunk/libc/misc/sys/uio.h Fri Apr 24 00:04:28 2009
@@ -58,7 +58,7 @@
without change the file pointer, and put the result in the buffers
described by IOVEC, which is a vector of COUNT 'struct iovec's.
The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in IOVEC instead
+ 'pread' (see <unistd.h>) except that data are put in IOVEC instead
of a contiguous buffer.
This function is a cancellation point and therefore not marked with
@@ -69,7 +69,7 @@
/* Write data pointed by the buffers described by IOVEC, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
position OFFSET without change the file pointer. The data is
- written in the order specified. Operates just like 'write' (see
+ written in the order specified. Operates just like 'pwrite' (see
<unistd.h>) except that the data are taken from IOVEC instead of a
contiguous buffer.
@@ -96,7 +96,7 @@
without change the file pointer, and put the result in the buffers
described by IOVEC, which is a vector of COUNT 'struct iovec's.
The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in IOVEC instead
+ 'pread' (see <unistd.h>) except that data are put in IOVEC instead
of a contiguous buffer.
This function is a cancellation point and therefore not marked with
@@ -107,7 +107,7 @@
/* Write data pointed by the buffers described by IOVEC, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
position OFFSET without change the file pointer. The data is
- written in the order specified. Operates just like 'write' (see
+ written in the order specified. Operates just like 'pwrite' (see
<unistd.h>) except that the data are taken from IOVEC instead of a
contiguous buffer.
Modified: fsf/trunk/libc/nss/Makefile
==============================================================================
--- fsf/trunk/libc/nss/Makefile (original)
+++ fsf/trunk/libc/nss/Makefile Fri Apr 24 00:04:28 2009
@@ -1,4 +1,4 @@
-# Copyright (C) 1996-1998,2000,2001,2002,2007 Free Software Foundation, Inc.
+# Copyright (C) 1996-1998,2000-2002,2007,2009 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
@@ -34,7 +34,7 @@
# Caution: if you add a database here, you must add its real name
# in databases.def, too.
databases = proto service hosts network grp pwd rpc ethers \
- spwd netgrp key alias
+ spwd netgrp key alias sgrp
others := getent
install-bin := getent
Modified: fsf/trunk/libc/nss/Versions
==============================================================================
--- fsf/trunk/libc/nss/Versions (original)
+++ fsf/trunk/libc/nss/Versions Fri Apr 24 00:04:28 2009
@@ -9,7 +9,7 @@
}
GLIBC_PRIVATE {
_nss_files_parse_grent; _nss_files_parse_pwent; _nss_files_parse_spent;
- __nss_disable_nscd; __nss_lookup_function;
+ __nss_disable_nscd; __nss_lookup_function; _nss_files_parse_sgent;
__nss_passwd_lookup2; __nss_group_lookup2; __nss_hosts_lookup2;
__nss_services_lookup2; __nss_next2;
@@ -87,6 +87,11 @@
_nss_files_getspent_r;
_nss_files_getspnam_r;
+ _nss_files_setsgent;
+ _nss_files_endsgent;
+ _nss_files_getsgent_r;
+ _nss_files_getsgnam_r;
+
_nss_netgroup_parseline;
_nss_files_getpublickey;
_nss_files_getsecretkey;
Modified: fsf/trunk/libc/nss/nss_files/files-parse.c
==============================================================================
--- fsf/trunk/libc/nss/nss_files/files-parse.c (original)
+++ fsf/trunk/libc/nss/nss_files/files-parse.c Fri Apr 24 00:04:28 2009
@@ -103,6 +103,7 @@
EXTRA_ARGS_DECL) \
{ \
ENTDATA_DECL (data) \
+ BUFFER_PREPARE \
char *p = strpbrk (line, EOLSET "\n"); \
if (p != NULL) \
*p = '\0'; \
@@ -125,6 +126,21 @@
++line; \
while (swallow && terminator_p (*line)); \
} \
+ }
+
+# define STRING_LIST(variable, terminator_c) \
+ { \
+ char **list = parse_list (&line, buf_start, buf_end, terminator_c, \
+ errnop); \
+ if (list) \
+ variable = list; \
+ else \
+ return -1; /* -1 indicates we ran out of space. */ \
+ \
+ /* Determine the new end of the buffer. */ \
+ while (*list != NULL) \
+ ++list; \
+ buf_start = (char *) (list + 1); \
}
/* Helper function. */
@@ -178,12 +194,39 @@
# ifndef TRAILING_LIST_MEMBER
+# define BUFFER_PREPARE /* Nothing to do. */
# define TRAILING_LIST_PARSER /* Nothing to do. */
# else
-# define TRAILING_LIST_PARSER \
+# define BUFFER_PREPARE \
+ char *buf_start = NULL; \
+ char *buf_end = (char *) data + datalen; \
+ if (line >= data->linebuffer && line < buf_end) \
+ /* Find the end of the line buffer, we will use the space in \
+ DATA after it for storing the vector of pointers. */ \
+ buf_start = strchr (line, '\0') + 1; \
+ else \
+ /* LINE does not point within DATA->linebuffer, so that space is \
+ not being used for scratch space right now. We can use all of \
+ it for the pointer vector storage. */ \
+ buf_start = data->linebuffer; \
+
+# define TRAILING_LIST_PARSER \
{ \
- char **list = parse_list (line, data, datalen, errnop); \
+ if (buf_start == NULL) \
+ { \
+ if (line >= data->linebuffer && line < buf_end) \
+ /* Find the end of the line buffer, we will use the space in \
+ DATA after it for storing the vector of pointers. */ \
+ buf_start = strchr (line, '\0') + 1; \
+ else \
+ /* LINE does not point within DATA->linebuffer, so that space is \
+ not being used for scratch space right now. We can use all of \
+ it for the pointer vector storage. */ \
+ buf_start = data->linebuffer; \
+ } \
+ \
+ char **list = parse_list (&line, buf_start, buf_end, '\0', errnop); \
if (list) \
result->TRAILING_LIST_MEMBER = list; \
else \
@@ -192,19 +235,12 @@
static inline char **
__attribute ((always_inline))
-parse_list (char *line, struct parser_data *data, size_t datalen, int *errnop)
+parse_list (char **linep, char *eol, char *buf_end, int terminator_c,
+ int *errnop)
{
- char *eol, **list, **p;
-
- if (line >= data->linebuffer && line < (char *) data + datalen)
- /* Find the end of the line buffer, we will use the space in DATA after
- it for storing the vector of pointers. */
- eol = strchr (line, '\0') + 1;
- else
- /* LINE does not point within DATA->linebuffer, so that space is
- not being used for scratch space right now. We can use all of
- it for the pointer vector storage. */
- eol = data->linebuffer;
+ char *line = *linep;
+ char **list, **p;
+
/* Adjust the pointer so it is aligned for storing pointers. */
eol += __alignof__ (char *) - 1;
eol -= (eol - (char *) 0) % __alignof__ (char *);
@@ -214,25 +250,30 @@
p = list;
while (1)
{
- char *elt;
-
- if ((size_t) ((char *) &p[1] - (char *) data) > datalen)
+ if ((char *) (p + 2) > buf_end)
{
/* We cannot fit another pointer in the buffer. */
*errnop = ERANGE;
return NULL;
}
+
if (*line == '\0')
break;
+ if (*line == terminator_c)
+ {
+ ++line;
+ break;
+ }
/* Skip leading white space. This might not be portable but useful. */
while (isspace (*line))
++line;
- elt = line;
+ char *elt = line;
while (1)
{
- if (*line == '\0' || TRAILING_LIST_SEPARATOR_P (*line))
+ if (*line == '\0' || *line == terminator_c
+ || TRAILING_LIST_SEPARATOR_P (*line))
{
/* End of the next entry. */
if (line > elt)
@@ -241,13 +282,20 @@
/* Terminate string if necessary. */
if (*line != '\0')
- *line++ = '\0';
+ {
+ char endc = *line;
+ *line++ = '\0';
+ if (endc == terminator_c)
+ goto out;
+ }
break;
}
++line;
}
}
+ out:
*p = NULL;
+ *linep = line;
return list;
}
Added: fsf/trunk/libc/nss/nss_files/files-sgrp.c
==============================================================================
--- fsf/trunk/libc/nss/nss_files/files-sgrp.c (added)
+++ fsf/trunk/libc/nss/nss_files/files-sgrp.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,38 @@
+/* User file parser in nss_files module.
+ Copyright (C) 2009 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <gshadow.h>
+
+#define STRUCTURE sgrp
+#define ENTNAME sgent
+#define DATABASE "gshadow"
+struct sgent_data {};
+
+/* Our parser function is already defined in sgetspent_r.c, so use that
+ to parse lines from the database file. */
+#define EXTERN_PARSER
+#include "files-parse.c"
+#include GENERIC
+
+DB_LOOKUP (sgnam, 1 + strlen (name), (".%s", name),
+ {
+ if (name[0] != '+' && name[0] != '-'
+ && ! strcmp (name, result->sg_namp))
+ break;
+ }, const char *name)
Modified: fsf/trunk/libc/nss/nsswitch.conf
==============================================================================
--- fsf/trunk/libc/nss/nsswitch.conf (original)
+++ fsf/trunk/libc/nss/nsswitch.conf Fri Apr 24 00:04:28 2009
@@ -6,6 +6,7 @@
passwd: db files
group: db files
shadow: db files
+gshadow: files
hosts: files dns
networks: files dns
Added: fsf/trunk/libc/nss/sgrp-lookup.c
==============================================================================
--- fsf/trunk/libc/nss/sgrp-lookup.c (added)
+++ fsf/trunk/libc/nss/sgrp-lookup.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,24 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2009.
+
+ 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define DATABASE_NAME gshadow
+#define ALTERNATE_NAME group
+#define DEFAULT_CONFIG "files"
+
+#include "XXX-lookup.c"
Modified: fsf/trunk/libc/shadow/Makefile
==============================================================================
--- fsf/trunk/libc/shadow/Makefile (original)
+++ fsf/trunk/libc/shadow/Makefile Fri Apr 24 00:04:28 2009
@@ -1,4 +1,4 @@
-# Copyright (C) 1996, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1996, 2003, 2004, 2009 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
@@ -26,6 +26,8 @@
getspent_r getspnam_r sgetspent_r fgetspent_r \
lckpwdf
+tests = tst-shadow
+
CFLAGS-getspent_r.c = -fexceptions
CFLAGS-getspent.c = -fexceptions
CFLAGS-fgetspent.c = -fexceptions
Modified: fsf/trunk/libc/shadow/sgetspent_r.c
==============================================================================
--- fsf/trunk/libc/shadow/sgetspent_r.c (original)
+++ fsf/trunk/libc/shadow/sgetspent_r.c Fri Apr 24 00:04:28 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2005, 2009 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
@@ -91,8 +91,12 @@
__sgetspent_r (const char *string, struct spwd *resbuf, char *buffer,
size_t buflen, struct spwd **result)
{
- int parse_result = parse_line (strncpy (buffer, string, buflen),
- resbuf, NULL, 0, &errno);
+ buffer[buflen - 1] = '\0';
+ char *sp = strncpy (buffer, string, buflen);
+ if (buffer[buflen - 1] != '\0')
+ return ERANGE;
+
+ int parse_result = parse_line (sp, resbuf, NULL, 0, &errno);
*result = parse_result > 0 ? resbuf : NULL;
return *result == NULL ? errno : 0;
Added: fsf/trunk/libc/shadow/tst-shadow.c
==============================================================================
--- fsf/trunk/libc/shadow/tst-shadow.c (added)
+++ fsf/trunk/libc/shadow/tst-shadow.c Fri Apr 24 00:04:28 2009
@@ -1,0 +1,84 @@
+#include <shadow.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static const struct spwd data[] =
+ {
+ { (char *) "one", (char *) "pwdone", 1, 2, 3, 4, 5, 6, 7 },
+ { (char *) "two", (char *) "pwdtwo", 11, 12, 13, 14, 15, 16, 17 },
+ { (char *) "three", (char *) "pwdthree", -1, 22, 23, 24, 25, 26, 27 },
+ { (char *) "four", (char *) "pwdfour", 31, -1, 33, 34, 35, 36, 37 },
+ { (char *) "five", (char *) "pwdfive", 41, 42, -1, 44, 45, 46, 47 },
+ { (char *) "six", (char *) "pwdsix", 51, 52, 53, -1, 55, 56, 57 },
+ { (char *) "seven", (char *) "pwdseven", 61, 62, 63, 64, -1, 66, 67 },
+ { (char *) "eight", (char *) "pwdeigth", 71, 72, 73, 74, 75, -1, 77 },
+ { (char *) "nine", (char *) "pwdnine", 81, 82, 83, 84, 85, 86, ~0ul },
+ };
+#define ndata (sizeof (data) / sizeof (data[0]))
+
+
+static int
+do_test (void)
+{
+ FILE *fp = tmpfile ();
+ if (fp == NULL)
+ {
+ puts ("cannot open temporary file");
+ return 1;
+ }
+
+ for (size_t i = 0; i < ndata; ++i)
+ if (putspent (&data[i], fp) != 0)
+ {
+ printf ("putspent call %zu failed\n", i + 1);
+ return 1;
+ }
+
+ rewind (fp);
+
+ int result = 0;
+ int seen = -1;
+ struct spwd *p;
+ while ((p = fgetspent (fp)) != NULL)
+ {
+ ++seen;
+ if (strcmp (p->sp_namp, data[seen].sp_namp) != 0)
+ {
+ printf ("sp_namp of entry %d does not match: %s vs %s\n",
+ seen + 1, p->sp_namp, data[seen].sp_namp);
+ result = 1;
+ }
+ if (strcmp (p->sp_pwdp, data[seen].sp_pwdp) != 0)
+ {
+ printf ("sp_pwdp of entry %d does not match: %s vs %s\n",
+ seen + 1, p->sp_pwdp, data[seen].sp_pwdp);
+ result = 1;
+ }
+#define T(f) \
+ if (p->f != data[seen].f) \
+ { \
+ printf ("%s of entry %d wrong: %ld vs %ld\n", \
+ #f, seen + 1, p->f, data[seen].f); \
+ result = 1; \
+ }
+ T (sp_lstchg);
+ T (sp_min);
+ T (sp_max);
+ T (sp_warn);
+ T (sp_expire);
+ if (p->sp_flag != data[seen].sp_flag)
+ {
+ printf ("sp_flag of entry %d wrong: %lu vs %lu\n",
+ seen + 1, p->sp_flag, data[seen].sp_flag);
+ result = 1;
+ }
+ }
+
+ fclose (fp);
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Modified: fsf/trunk/libc/stdlib/random_r.c
==============================================================================
--- fsf/trunk/libc/stdlib/random_r.c (original)
+++ fsf/trunk/libc/stdlib/random_r.c Fri Apr 24 00:04:28 2009
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 2005 Free Software Foundation
+ Copyright (C) 1995, 2005, 2009 Free Software Foundation
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -166,7 +166,7 @@
int type;
int32_t *state;
long int i;
- long int word;
+ int32_t word;
int32_t *dst;
int kc;
Modified: fsf/trunk/libc/sysdeps/generic/paths.h
==============================================================================
--- fsf/trunk/libc/sysdeps/generic/paths.h (original)
+++ fsf/trunk/libc/sysdeps/generic/paths.h Fri Apr 24 00:04:28 2009
@@ -44,6 +44,7 @@
#define _PATH_DEVDB "/var/run/dev.db"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_DRUM "/dev/drum"
+#define _PATH_GSHADOW "/etc/gshadow"
#define _PATH_KMEM "/dev/kmem"
#define _PATH_MAILDIR "/var/mail"
#define _PATH_LASTLOG "/var/log/lastlog"
Modified: fsf/trunk/libc/sysdeps/posix/preadv.c
==============================================================================
--- fsf/trunk/libc/sysdeps/posix/preadv.c (original)
+++ fsf/trunk/libc/sysdeps/posix/preadv.c Fri Apr 24 00:04:28 2009
@@ -48,7 +48,7 @@
without change the file pointer, and put the result in the buffers
described by VECTOR, which is a vector of COUNT 'struct iovec's.
The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in VECTOR instead
+ 'pread' (see <unistd.h>) except that data are put in VECTOR instead
of a contiguous buffer. */
ssize_t
PREADV (int fd, const struct iovec *vector, int count, OFF_T offset)
Modified: fsf/trunk/libc/sysdeps/posix/pwritev.c
==============================================================================
--- fsf/trunk/libc/sysdeps/posix/pwritev.c (original)
+++ fsf/trunk/libc/sysdeps/posix/pwritev.c Fri Apr 24 00:04:28 2009
@@ -44,12 +44,12 @@
}
-/* Read data from file descriptor FD at the given position OFFSET
- without change the file pointer, and put the result in the buffers
- described by VECTOR, which is a vector of COUNT 'struct iovec's.
- The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in VECTOR instead
- of a contiguous buffer. */
+/* Write data pointed by the buffers described by IOVEC, which is a
+ vector of COUNT 'struct iovec's, to file descriptor FD at the given
+ position OFFSET without change the file pointer. The data is
+ written in the order specified. Operates just like 'write' (see
+ <unistd.h>) except that the data are taken from IOVEC instead of a
+ contiguous buffer. */
ssize_t
PWRITEV (int fd, const struct iovec *vector, int count, OFF_T offset)
{
@@ -81,26 +81,14 @@
return -1;
}
- /* Read the data. */
- ssize_t bytes_read = PWRITE (fd, buffer, bytes, offset);
- if (bytes_read <= 0)
- return -1;
+ /* Copy the data from BUFFER into the memory specified by VECTOR. */
+ char *ptr = buffer;
+ for (int i = 0; i < count; ++i)
+ ptr = __mempcpy ((void *) ptr, (void *) vector[i].iov_base,
+ vector[i].iov_len);
- /* Copy the data from BUFFER into the memory specified by VECTOR. */
- bytes = bytes_read;
- for (int i = 0; i < count; ++i)
- {
- size_t copy = MIN (vector[i].iov_len, bytes);
-
- (void) memcpy ((void *) vector[i].iov_base, (void *) buffer, copy);
-
- buffer += copy;
- bytes -= copy;
- if (bytes == 0)
- break;
- }
-
- return bytes_read;
+ /* Write the data. */
+ return PWRITE (fd, buffer, bytes, offset);
}
#if __WORDSIZE == 64 && defined pwritev64
# undef pwritev64
Modified: fsf/trunk/libc/sysdeps/unix/make-syscalls.sh
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/make-syscalls.sh (original)
+++ fsf/trunk/libc/sysdeps/unix/make-syscalls.sh Fri Apr 24 00:04:28 2009
@@ -155,6 +155,7 @@
case x"$callnum" in
x_)
echo "\
+ \$(make-target-directory)
(echo '/* Dummy module requested by syscalls.list */'; \\"
;;
x*)
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/paths.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/paths.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/paths.h Fri Apr 24 00:04:28 2009
@@ -44,6 +44,7 @@
#define _PATH_DEVDB "/var/run/dev.db"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_DRUM "/dev/drum"
+#define _PATH_GSHADOW "/etc/gshadow"
#define _PATH_KLOG "/proc/kmsg"
#define _PATH_KMEM "/dev/kmem"
#define _PATH_LASTLOG "/var/log/lastlog"
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/preadv.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/preadv.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/preadv.c Fri Apr 24 00:04:28 2009
@@ -37,6 +37,10 @@
# define OFF_T off_t
#endif
+#define LO_HI_LONG(val) \
+ (off_t) val, \
+ (off_t) ((((uint64_t) (val)) >> (sizeof (long) * 4)) >> (sizeof (long) * 4))
+
#ifndef __ASSUME_PREADV
static ssize_t PREADV_REPLACEMENT (int, __const struct iovec *,
int, OFF_T) internal_function;
@@ -55,15 +59,13 @@
if (SINGLE_THREAD_P)
result = INLINE_SYSCALL (preadv, 5, fd, vector, count,
- (off_t) ((off64_t) offset >> 32),
- (off_t) (offset & 0xffffffff));
+ LO_HI_LONG (offset));
else
{
int oldtype = LIBC_CANCEL_ASYNC ();
result = INLINE_SYSCALL (preadv, 5, fd, vector, count,
- (off_t) ((off64_t) offset >> 32),
- (off_t) (offset & 0xffffffff));
+ LO_HI_LONG (offset));
LIBC_CANCEL_RESET (oldtype);
}
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/pwritev.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/pwritev.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/pwritev.c Fri Apr 24 00:04:28 2009
@@ -37,6 +37,10 @@
# define OFF_T off_t
#endif
+#define LO_HI_LONG(val) \
+ (off_t) val, \
+ (off_t) ((((uint64_t) (val)) >> (sizeof (long) * 4)) >> (sizeof (long) * 4))
+
#ifndef __ASSUME_PWRITEV
static ssize_t PWRITEV_REPLACEMENT (int, __const struct iovec *,
int, OFF_T) internal_function;
@@ -55,15 +59,13 @@
if (SINGLE_THREAD_P)
result = INLINE_SYSCALL (pwritev, 5, fd, vector, count,
- (off_t) ((off64_t) offset >> 32),
- (off_t) (offset & 0xffffffff));
+ LO_HI_LONG (offset));
else
{
int oldtype = LIBC_CANCEL_ASYNC ();
result = INLINE_SYSCALL (pwritev, 5, fd, vector, count,
- (off_t) ((off64_t) offset >> 32),
- (off_t) (offset & 0xffffffff));
+ LO_HI_LONG (offset));
LIBC_CANCEL_RESET (oldtype);
}
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/mount.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/mount.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/mount.h Fri Apr 24 00:04:28 2009
@@ -96,8 +96,12 @@
/* Possible value for FLAGS parameter of `umount2'. */
enum
{
- MNT_FORCE = 1 /* Force unmounting. */
+ MNT_FORCE = 1, /* Force unmounting. */
#define MNT_FORCE MNT_FORCE
+ MNT_DETACH = 2, /* Just detach from the tree. */
+#define MNT_DETACH MNT_DETACH
+ MNT_EXPIRE = 4 /* Mark for expiry. */
+#define MNT_EXPIRE MNT_EXPIRE
};