]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Fri, 30 Jan 1998 11:44:34 +0000 (11:44 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 30 Jan 1998 11:44:34 +0000 (11:44 +0000)
1998-01-30 19:58  Ulrich Drepper  <drepper@cygnus.com>

* include/cpio.h: Move to ...
* posix/cpio.h: ...here.

* locale/programs/ld-collate.c: Fix typo.

* signal/signal.h: Declare _sys_siglist with NSIG+1 elements.

* stdio-common/tiformat.c: Add checks for %#.0o and friends.

* login/utmp_file.c (pututline_file): Don't always report success
if similar entry is found.  Patch by Mark M. Kettenis.

1998-01-30 16:06  Philip Blundell  <pb@nexus.co.uk>

* manual/Makefile: Don't try to install the info files if makeinfo
is not available.

1998-01-30 12:05  Philip Blundell  <pb@nexus.co.uk>

* sysdeps/unix/sysv/linux/bits/ioctls.h: Include a copy of the
kernel's network ioctls, rather than using <linux/sockios.h> to
get them.  This way we are sure of maintaining compatibility if
the kernel interface should change.

1998-01-30 15:52  Ulrich Drepper  <drepper@cygnus.com>

* sysdeps/unix/sysv/linux/Dist: Add netrose/rose.h.

1998-01-25 19:54  Philip Blundell  <Philip.Blundell@pobox.com>

* sysdeps/unix/sysv/linux/netrose/rose.h: New file.
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install it.

1998-01-27 22:29  Zack Weinberg  <zack@rabi.phys.columbia.edu>

Implement System V pseudoterminal handling.

* login/Makefile
(routines): Add getpt, grantpt, unlockpt, ptsname.
(libutil-routines): Remove pty. Add openpty, forkpty.
(distribute): New internal header pty-internal.h.
(others): Add the helper program, pt_chown.
(install-others): Install it, in $(libexecdir), mode 4755.

* login/pty-internal.h: New file.
* login/openpty.c: New file.
* login/forkpty.c: New file.
* login/programs/pt_chown.c: New file.

* libc.map: Add getpt, grantpt, unlockpt, ptsname, ptsname_r.
* stdlib/stdlib.h: Prototype them.

* config.make.in: Define $(libexecdir).
* Makeconfig: Define $(inst_libexecdir).

* sysdeps/generic/pty.c: Removed.
* sysdeps/unix/sysv/linux/pty.c: Removed.

* sysdeps/generic/getpt.c: Stub out.
* sysdeps/generic/grantpt.c: Likewise.
* sysdeps/generic/ptsname.c: Likewise.
* sysdeps/generic/unlockpt.c: Likewise.

* sysdeps/unix/grantpt.c: New file.
* sysdeps/unix/bsd/getpt.c: New file.
* sysdeps/unix/bsd/unlockpt.c: New file.
* sysdeps/unix/sysv/linux/getpt.c: New file.
* sysdeps/unix/sysv/linux/ptsname.c: New file.
* sysdeps/unix/sysv/linux/unlockpt.c: New file.

1998-01-29 23:56  Ulrich Drepper  <drepper@cygnus.com>

* localedata/locales/ru_RU: Fix YESEXPR.  Patch by lav@yars.free.net.

1998-01-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* nss/Makefile (tests): Add rule for test-netdb.c.

* nss/test-netdb.c: New file.

1998-01-29 02:38  Ulrich Drepper  <drepper@cygnus.com>

* elf/dl-open.c (_dl_open): Make sure the variable `reloc' is
really kept as a variable.  Patch by Richard Henderson,
reported by Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>.

* elf/rtld.c (dl_main): Call _dl_init_paths before handling preloading.
* elf/genrtldtbl.awk: Mark machine dependent directory of generated
entries as not existing.

1998-01-26  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

* stdio-common/vfprintf.c (process_arg): Fix printing of octal
zero in alternate form with precision of zero, which must produce
"0".  Add braces to avoid ambiguous `else'.

1998-01-26  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>

* nis/nss_compat/compat-grp.c: Fix memory leak and trailing null
problem with strncpy.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/comapt-spwd.c: Likewise.

1998-01-28  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* assert/assert.h (assert_perror): Correct test for errnum.  Patch
by uch@nop.or.jp. [PR libc/437]

1997-12-20  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

* locales/pl_PL: Fix int_curr_symbol.

1998-01-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* nis/nis_cache.c: Include <unistd.h> for declaration of close.

1998-01-06  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* stdio-common/test-popen.c: Include <errno.h>.

* sysdeps/unix/sysv/linux/if_index.c: Include <unistd.h> for
close.

* inet/getnetgrent_r.c: Include <errno.h>.

* db2/db/db_conv.c: Include <string.h> for memcpy.

* gmon/bb_exit_func.c: Include <string.h> instead of <strings.h>
so that memcpy is declared.

* iconv/iconv_open.c: Include <stdlib.h> for alloca.

* misc/init-misc.c: Remove unneeded inclusion of <errno.h>.

1998-01-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* pwd/fgetpwent_r.c (__fgetpwent_r): Correctly handle buffer
overflow while reading line with fgets.
* grp/fgetgrent_r.c (__fgetgrent_r): Likewise.

1998-01-27 00:46  Ulrich Drepper  <drepper@cygnus.com>

* sysdeps/unix/sysv/linux/bits/types.h (__ipc_pid_t): Change to
unsigned short, not short.
Reported by Andreas Jaeger.

1998-01-06  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* sysdeps/unix/sysv/linux/mips/syscalls.list: Correct typo
(ccept->accept).

* sysdeps/generic/inttypes.h: Fix spelling.

1998-01-04  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* sysdeps/unix/sysv/linux/arm/Dist: Add bits/mman.h.

* sysdeps/unix/sysv/linux/alpha/Dist: Add net/route.h.

1998-01-27 00:30  Ulrich Drepper  <drepper@cygnus.com>

* stdio-common/printf.h (struct print_info): Add new bitfield is_char.
* stdio-common/printf-parse.h (parse_one_spec): Fill in is_char
field for hh modifier.
* stdio-common/vfprint.c: Use is_char field and do not depend in
is_short having the value 2.
Bug reported by Andreas Jaeger.

1998-01-05  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

* libio/freopen.c (freopen): Call _IO_old_freopen only if defined
PIC && DO_VERSIONING.

1998-01-24  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

* Rules: Add rules for $(common-objpfx)dummy$o.

63 files changed:
ChangeLog
Rules
assert/assert.h
config.make.in
db2/db/db_conv.c
elf/dl-open.c
elf/genrtldtbl.awk
elf/rtld.c
gmon/bb_exit_func.c
grp/fgetgrent_r.c
iconv/iconv_open.c
inet/getnetgrent_r.c
libc.map
libio/freopen.c
locale/programs/ld-collate.c
localedata/locales/pl_PL
localedata/locales/ru_RU
login/Makefile
login/forkpty.c [new file with mode: 0644]
login/openpty.c [new file with mode: 0644]
login/programs/pt_chown.c [new file with mode: 0644]
login/pty-internal.h [new file with mode: 0644]
login/utmp_file.c
manual/Makefile
misc/init-misc.c
nis/nis_cache.c
nis/nss_compat/compat-grp.c
nis/nss_compat/compat-pwd.c
nis/nss_compat/compat-spwd.c
nss/Makefile
nss/test-netdb.c [new file with mode: 0644]
posix/cpio.h [moved from include/cpio.h with 100% similarity]
pwd/fgetpwent_r.c
signal/signal.h
stdio-common/printf-parse.h
stdio-common/printf.h
stdio-common/test-popen.c
stdio-common/tiformat.c
stdio-common/vfprintf.c
stdlib/stdlib.h
sysdeps/generic/getpt.c [new file with mode: 0644]
sysdeps/generic/grantpt.c [new file with mode: 0644]
sysdeps/generic/inttypes.h
sysdeps/generic/ptsname.c [new file with mode: 0644]
sysdeps/generic/pty.c [deleted file]
sysdeps/generic/unlockpt.c [new file with mode: 0644]
sysdeps/unix/bsd/getpt.c [new file with mode: 0644]
sysdeps/unix/bsd/unlockpt.c [new file with mode: 0644]
sysdeps/unix/grantpt.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/Dist
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/alpha/Dist
sysdeps/unix/sysv/linux/arm/Dist
sysdeps/unix/sysv/linux/bits/ioctls.h
sysdeps/unix/sysv/linux/bits/types.h
sysdeps/unix/sysv/linux/getpt.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/if_index.c
sysdeps/unix/sysv/linux/mips/syscalls.list
sysdeps/unix/sysv/linux/netrose/rose.h [moved from sysdeps/unix/sysv/linux/m68k/sigreturn.S with 73% similarity]
sysdeps/unix/sysv/linux/ptsname.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/pty.c [deleted file]
sysdeps/unix/sysv/linux/siglist.c
sysdeps/unix/sysv/linux/unlockpt.c [new file with mode: 0644]

index 79e01b099cf169385687606984c11bac79fe9031..ffe27bf4e670e642f76e4abfaba3fd4f84d7f00e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,182 @@
+1998-01-30 19:58  Ulrich Drepper  <drepper@cygnus.com>
+
+       * include/cpio.h: Move to ...
+       * posix/cpio.h: ...here.
+
+       * locale/programs/ld-collate.c: Fix typo.
+
+       * signal/signal.h: Declare _sys_siglist with NSIG+1 elements.
+
+       * stdio-common/tiformat.c: Add checks for %#.0o and friends.
+
+       * login/utmp_file.c (pututline_file): Don't always report success
+       if similar entry is found.  Patch by Mark M. Kettenis.
+
+1998-01-30 16:06  Philip Blundell  <pb@nexus.co.uk>
+
+       * manual/Makefile: Don't try to install the info files if makeinfo
+       is not available.
+
+1998-01-30 12:05  Philip Blundell  <pb@nexus.co.uk>
+
+       * sysdeps/unix/sysv/linux/bits/ioctls.h: Include a copy of the
+       kernel's network ioctls, rather than using <linux/sockios.h> to
+       get them.  This way we are sure of maintaining compatibility if
+       the kernel interface should change.
+
+1998-01-30 15:52  Ulrich Drepper  <drepper@cygnus.com>
+
+       * sysdeps/unix/sysv/linux/Dist: Add netrose/rose.h.
+
+1998-01-25 19:54  Philip Blundell  <Philip.Blundell@pobox.com>
+
+       * sysdeps/unix/sysv/linux/netrose/rose.h: New file.
+       * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Install it.
+
+1998-01-27 22:29  Zack Weinberg  <zack@rabi.phys.columbia.edu>
+
+       Implement System V pseudoterminal handling.
+
+       * login/Makefile
+       (routines): Add getpt, grantpt, unlockpt, ptsname.
+       (libutil-routines): Remove pty. Add openpty, forkpty.
+       (distribute): New internal header pty-internal.h.
+       (others): Add the helper program, pt_chown.
+       (install-others): Install it, in $(libexecdir), mode 4755.
+
+       * login/pty-internal.h: New file.
+       * login/openpty.c: New file.
+       * login/forkpty.c: New file.
+       * login/programs/pt_chown.c: New file.
+
+       * libc.map: Add getpt, grantpt, unlockpt, ptsname, ptsname_r.
+       * stdlib/stdlib.h: Prototype them.
+
+       * config.make.in: Define $(libexecdir).
+       * Makeconfig: Define $(inst_libexecdir).
+
+       * sysdeps/generic/pty.c: Removed.
+       * sysdeps/unix/sysv/linux/pty.c: Removed.
+
+       * sysdeps/generic/getpt.c: Stub out.
+       * sysdeps/generic/grantpt.c: Likewise.
+       * sysdeps/generic/ptsname.c: Likewise.
+       * sysdeps/generic/unlockpt.c: Likewise.
+
+       * sysdeps/unix/grantpt.c: New file.
+       * sysdeps/unix/bsd/getpt.c: New file.
+       * sysdeps/unix/bsd/unlockpt.c: New file.
+       * sysdeps/unix/sysv/linux/getpt.c: New file.
+       * sysdeps/unix/sysv/linux/ptsname.c: New file.
+       * sysdeps/unix/sysv/linux/unlockpt.c: New file.
+
+1998-01-29 23:56  Ulrich Drepper  <drepper@cygnus.com>
+
+       * localedata/locales/ru_RU: Fix YESEXPR.  Patch by lav@yars.free.net.
+
+1998-01-29  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * nss/Makefile (tests): Add rule for test-netdb.c.
+
+       * nss/test-netdb.c: New file.
+
+1998-01-29 02:38  Ulrich Drepper  <drepper@cygnus.com>
+
+       * elf/dl-open.c (_dl_open): Make sure the variable `reloc' is
+       really kept as a variable.  Patch by Richard Henderson,
+       reported by Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>.
+
+       * elf/rtld.c (dl_main): Call _dl_init_paths before handling preloading.
+       * elf/genrtldtbl.awk: Mark machine dependent directory of generated
+       entries as not existing.
+
+1998-01-26  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * stdio-common/vfprintf.c (process_arg): Fix printing of octal
+       zero in alternate form with precision of zero, which must produce
+       "0".  Add braces to avoid ambiguous `else'.
+
+1998-01-26  Thorsten Kukuk  <kukuk@vt.uni-paderborn.de>
+
+       * nis/nss_compat/compat-grp.c: Fix memory leak and trailing null
+       problem with strncpy.
+       * nis/nss_compat/compat-pwd.c: Likewise.
+       * nis/nss_compat/comapt-spwd.c: Likewise.
+
+1998-01-28  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * assert/assert.h (assert_perror): Correct test for errnum.  Patch
+       by uch@nop.or.jp. [PR libc/437]
+
+1997-12-20  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * locales/pl_PL: Fix int_curr_symbol.
+
+1998-01-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * nis/nis_cache.c: Include <unistd.h> for declaration of close.
+
+1998-01-06  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * stdio-common/test-popen.c: Include <errno.h>.
+
+       * sysdeps/unix/sysv/linux/if_index.c: Include <unistd.h> for
+       close.
+
+       * inet/getnetgrent_r.c: Include <errno.h>.
+
+       * db2/db/db_conv.c: Include <string.h> for memcpy.
+
+       * gmon/bb_exit_func.c: Include <string.h> instead of <strings.h>
+       so that memcpy is declared.
+
+       * iconv/iconv_open.c: Include <stdlib.h> for alloca.
+
+       * misc/init-misc.c: Remove unneeded inclusion of <errno.h>.
+
+1998-01-26  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * pwd/fgetpwent_r.c (__fgetpwent_r): Correctly handle buffer
+       overflow while reading line with fgets.
+       * grp/fgetgrent_r.c (__fgetgrent_r): Likewise.
+
+1998-01-27 00:46  Ulrich Drepper  <drepper@cygnus.com>
+
+       * sysdeps/unix/sysv/linux/bits/types.h (__ipc_pid_t): Change to
+       unsigned short, not short.
+       Reported by Andreas Jaeger.
+
+1998-01-06  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * sysdeps/unix/sysv/linux/mips/syscalls.list: Correct typo
+       (ccept->accept).
+
+       * sysdeps/generic/inttypes.h: Fix spelling.
+
+1998-01-04  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * sysdeps/unix/sysv/linux/arm/Dist: Add bits/mman.h.
+
+       * sysdeps/unix/sysv/linux/alpha/Dist: Add net/route.h.
+
+1998-01-27 00:30  Ulrich Drepper  <drepper@cygnus.com>
+
+       * stdio-common/printf.h (struct print_info): Add new bitfield is_char.
+       * stdio-common/printf-parse.h (parse_one_spec): Fill in is_char
+       field for hh modifier.
+       * stdio-common/vfprint.c: Use is_char field and do not depend in
+       is_short having the value 2.
+       Bug reported by Andreas Jaeger.
+
+1998-01-05  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+       * libio/freopen.c (freopen): Call _IO_old_freopen only if defined
+       PIC && DO_VERSIONING.
+
+1998-01-24  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * Rules: Add rules for $(common-objpfx)dummy$o.
+
 1998-01-26  Richard Henderson  <rth@cygnus.com>
 
        * sysdeps/unix/sysv/linux/alpha/bits/mman.h: Dyke out the
diff --git a/Rules b/Rules
index f50abd1248a19aed04f4b29d018a60ff6af8bb13..90a518f8668fd21f2065ec528af138b39f7ddb32 100644 (file)
--- a/Rules
+++ b/Rules
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 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
@@ -71,7 +71,6 @@ define make-dummy-lib
 $(AR) cr$(verbose) $@ $<
 endef
 
-$(common-objpfx)dummy.o: $(common-objpfx)dummy.c; $(compile-command.c)
 $(common-objpfx)dummy.c:
        rm -f $@
        echo 'void __dummy__ (void) { }' > $@
@@ -162,6 +161,13 @@ endef
 object-suffixes-left := $(object-suffixes)
 include $(o-iterator)
 
+define o-iterator-doit
+$(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
+       $$(compile-command.c)
+endef
+object-suffixes-left := $(object-suffixes)
+include $(o-iterator)
+
 ifndef libc.so-version
 # Undefine this because it can't work when we libc.so is unversioned.
 static-only-routines =
index 3f0b55f866fe203ae0072319c2d04b388a05da20..ec54f64c05e32ee93f5be807b99520fa267d5306 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 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
@@ -80,9 +80,9 @@ __END_DECLS
 
 # ifdef        __USE_GNU
 #  define assert_perror(errnum)                                                      \
-  ((void) ((errnum) ? 0 : (__assert_perror_fail ((errnum),                   \
-                                                __FILE__, __LINE__,          \
-                                                __ASSERT_FUNCTION), 0)))
+  ((void) (!(errnum) ? 0 : (__assert_perror_fail ((errnum),                  \
+                                                 __FILE__, __LINE__,         \
+                                                 __ASSERT_FUNCTION), 0)))
 # endif
 
 /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
index 659ff409ce395a4f753c1cb79ab46f993c0c82a6..500333f4b0ca6c34edf3bbd60f6ba815319ba058 100644 (file)
@@ -8,6 +8,7 @@ prefix = @prefix@
 exec_prefix = @exec_prefix@
 slibdir = @libc_cv_slibdir@
 sysconfdir = @libc_cv_sysconfdir@
+libexecdir = @libexecdir@
 rootsbindir = @libc_cv_rootsbindir@
 
 # If ldconfig exists.  This will go away as soon as `ldconfig' is available
index c075df33fe4dfd73a0c1b9626dc53956ac4c206f..e9c4bf90bdec932a07dd96440ae4c378958edc15 100644 (file)
@@ -51,6 +51,7 @@ static const char sccsid[] = "@(#)db_conv.c   10.8 (Sleepycat) 1/8/98";
 #include <sys/types.h>
 
 #include <errno.h>
+#include <string.h>
 #endif
 
 #include "db_int.h"
index 84a76cfb4a4f24824549de7c72987eb0ae66eeba..b984aa8f898d6f70c804a62f59741f674bb3ba7e 100644 (file)
@@ -1,5 +1,5 @@
 /* Load a shared object at runtime, relocate it, and run its initializer.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 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
@@ -93,6 +93,13 @@ _dl_open (const char *file, int mode)
             between when _dl_object_relocation_scope returns and when we
             enter the dynamic linker's code (_dl_relocate_object).  */
          __typeof (_dl_relocate_object) *reloc = &_dl_relocate_object;
+
+         /* GCC is very clever.  If we wouldn't add some magic it would
+            simply optimize away our nice little variable `reloc' and we
+            would result in a not working binary.  So let's swing the
+            magic ward.  */
+         asm ("" : "=r" (reloc) : "0" (reloc));
+
          (*reloc) (l, _dl_object_relocation_scope (l),
                    (mode & RTLD_BINDING_MASK) == RTLD_LAZY);
          *_dl_global_scope_end = NULL;
index f5656a2b4409ab0a9ea4ea5d84e0d588c51b9424..63ada003f6b11f0902d919d8eb6c939647c5c275 100644 (file)
@@ -12,7 +12,7 @@ BEGIN {
 END {
   for (i = 0; i < count; ++i) {
     printf ("static struct r_search_path_elem rtld_search_dir%d =\n", i+1);
-    printf ("  { \"%s/\", %d, unknown, 0, unknown, ",
+    printf ("  { \"%s/\", %d, unknown, 0, nonexisting, ",
            dir[i], length (dir[i]) + 1);
     if (i== 0)
       printf ("NULL };\n");
index e0d35216b62109a7af898d2b079e86d7c88bc857..aa40d42097547149f66847f6f1a714fbd8ee4756 100644 (file)
@@ -482,6 +482,10 @@ of this helper program; chances are you did not intend to run this program.\n",
   preloads = NULL;
   npreloads = 0;
 
+  /* Initialize the data structures for the search paths for shared
+     objects.  */
+  _dl_init_paths ();
+
   preloadlist = getenv ("LD_PRELOAD");
   if (preloadlist)
     {
@@ -595,10 +599,6 @@ of this helper program; chances are you did not intend to run this program.\n",
       assert (i == npreloads);
     }
 
-  /* Initialize the data structures for the search paths for shared
-     objects.  */
-  _dl_init_paths ();
-
   /* Load all the libraries specified by DT_NEEDED entries.  If LD_PRELOAD
      specified some libraries to load, these are inserted before the actual
      dependencies in the executable's searchlist for symbol resolution.  */
index 53ddbfdbe98a09674fe86fd2c28e5f2d27d9175c..032e4f68b2ca02dd534438a203a69c27bc4aa631 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by David Mosberger (davidm@cs.arizona.edu).
 
@@ -24,7 +24,7 @@
 #include <sys/types.h>
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 
 /* structure emitted by -a */
 struct bb
index b142f908e6dafd69e8195c081909386a672de850..9ac9dc19efe315fff4768281a56949bd1bff622a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1998 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
@@ -61,12 +61,18 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen,
 
   do
     {
+      buffer[buflen] = '\xff';
       p = fgets (buffer, buflen, stream);
-      if (p == NULL)
+      if (p == NULL && feof (stream))
        {
          *result = NULL;
          return errno;
        }
+      if (p == NULL || buffer[buflen] != '\xff')
+       {
+         *result = NULL;
+         return errno = ERANGE;
+       }
 
       /* Skip leading blanks.  */
       while (isspace (*p))
index bfff00d91733922881dc0799efd986c1267f42fa..d178362ca792976bd0187f8675115af96cb71bf0 100644 (file)
@@ -1,5 +1,5 @@
 /* Get descriptor for character set conversion.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -21,6 +21,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <iconv.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <gconv.h>
index d7a2b58b78516b59dc18eca54be8fd3b79e5cc70..83e4c9ef57f98a746933f1d249bb73a4661ac2f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 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
@@ -17,6 +17,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <bits/libc-lock.h>
+#include <errno.h>
 #include <netdb.h>
 #include <stdlib.h>
 #include <string.h>
index af76e64227c6569c2416130cb390768a7380e194..593858fc2bfebfcc10ec8578d46ba7c1971fc458 100644 (file)
--- a/libc.map
+++ b/libc.map
@@ -210,8 +210,8 @@ GLIBC_2.0 {
     getnetname; getopt; getopt_long; getopt_long_only; getpagesize;
     getpass; getpeername; getpgid; getpgrp; getpid; getppid; getpriority;
     getprotobyname; getprotobyname_r; getprotobynumber;
-    getprotobynumber_r; getprotoent; getprotoent_r; getpublickey; getpw;
-    getpwent; getpwent_r; getpwnam; getpwnam_r; getpwuid; getpwuid_r;
+    getprotobynumber_r; getprotoent; getprotoent_r; getpt; getpublickey;
+    getpw; getpwent; getpwent_r; getpwnam; getpwnam_r; getpwuid; getpwuid_r;
     getresgid; getresuid;
     getrlimit; getrlimit64; getrpcbyname; getrpcbyname_r; getrpcbynumber;
     getrpcbynumber_r; getrpcent; getrpcent_r; getrpcport; getrusage; gets;
@@ -221,7 +221,7 @@ GLIBC_2.0 {
     gettext; gettimeofday; getttyent; getttynam; getuid; getusershell;
     getutent; getutent_r; getutid; getutid_r; getutline; getutline_r;
     getutxent; getutxid; getutxline; getw; getwd; glob; glob_pattern_p;
-    globfree; gmtime; gmtime_r; group_member; gsignal; gtty;
+    globfree; gmtime; gmtime_r; grantpt; group_member; gsignal; gtty;
 
     # h*
     hasmntopt; hcreate; hcreate_r; hdestroy; hdestroy_r; herror;
@@ -305,9 +305,10 @@ GLIBC_2.0 {
     pthread_self; pthread_setcancelstate; pthread_setcanceltype;
     pthread_setschedparam;
 
-    ptrace; putc; putc_unlocked; putchar;
-    putchar_unlocked; putenv; putpwent; puts; putspent; pututline;
-    pututxline; putw; pvalloc;
+    ptrace; ptsname; ptsname_r;
+    putc; putc_unlocked; putchar; putchar_unlocked;
+    putenv; putpwent; puts; putspent; pututline; pututxline;
+    putw; pvalloc;
 
     # q*
     qecvt; qecvt_r; query_module; qfcvt; qfcvt_r; qgcvt; qsort; quotactl;
@@ -382,7 +383,7 @@ GLIBC_2.0 {
     twalk; tzset;
 
     # u*
-    ualarm; ulckpwdf; ulimit; umask; umount; uname; ungetc; unlink;
+    ualarm; ulckpwdf; ulimit; umask; umount; uname; ungetc; unlink; unlockpt;
     unsetenv; updwtmp; uselib; user2netname; usleep; ustat; utime; utimes;
     utmpname;
 
index 808d8fab5840b2b99475ac15698ff4e87e907d68..0452e7e6bb523383c7a29a8b16f16c55d4493856 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU IO Library.
 
    This library is free software; you can redistribute it and/or
@@ -43,7 +43,7 @@ freopen (filename, mode, fp)
     return NULL;
   _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
   _IO_flockfile (fp);
-#ifdef PIC
+#if defined PIC && DO_VERSIONING
   if (&_IO_stdin_used == NULL)
     /* If the shared C library is used by the application binary which
        was linked against the older version of libio, we just use the
index 9c591f627184231aa03b58aa0680ea68d2b995ab..78a9cd92ac8ec8397883fbe1db04fc3aac8ef64b 100644 (file)
@@ -630,7 +630,7 @@ Computing table size for collation information might take a while..."),
     extra2[cnt] = SWAPU32 (extra2[cnt]);
 
   /* We need a simple hashing table to get a collation-element->chars
-     mapping.  We again use internal hasing using a secondary hashing
+     mapping.  We again use internal hashing using a secondary hashing
      function.
 
      Each string has an associate hashing value V, computed by a
index 0ad8f83a99a71f27cb37fa6572e06bfc1041af29..587811004c808aceb7aec7d51cb905166b29e17b 100644 (file)
@@ -2095,7 +2095,7 @@ noexpr  "<<(><n><N><)/>><.><*>"
 END LC_MESSAGES
 
 LC_MONETARY
-int_curr_symbol           "<P><L><N><SP>"
+int_curr_symbol           "<P><L><Z><SP>"
 currency_symbol           "<Z><l//>"
 mon_decimal_point         "<,>"
 mon_thousands_sep         "<.>"
index 252a10154d6b9e6a706eccb785cb1495faead30b..9da69826248437af854d471ae6f33c139214ae56 100644 (file)
@@ -2091,7 +2091,7 @@ order_end
 END LC_COLLATE
 
 LC_MESSAGES
-yesexpr "<<(><D=><d=><Y><Y><)/>><.><*>"
+yesexpr "<<(><D=><d=><Y><y><)/>><.><*>"
 noexpr  "<<(><N=><n=><N><n><)/>><.><*>"
 END LC_MESSAGES
 
index 3842b2f4af5d9764ad864237c72a281df752e2e2..04c6eeb8a4ceb69c3b93ef6edd8105fd141e7eb9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998 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
@@ -25,10 +25,14 @@ subdir      := login
 headers        := utmp.h bits/utmp.h utmpx.h bits/utmpx.h lastlog.h pty.h
 
 routines := getutent getutent_r getutid getutline getutid_r getutline_r \
-           utmp_file utmp_daemon utmpname updwtmp
+           utmp_file utmp_daemon utmpname updwtmp \
+           getpt grantpt unlockpt ptsname
 
-others = utmpd utmpdump
+CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"'
+
+others = utmpd utmpdump pt_chown
 install-sbin = utmpd
+install-others = $(inst_libexecdir)/pt_chown
 utmpd-routines := connection database error request xtmp
 extra-objs := $(utmpd-routines:=.o)
 
@@ -42,11 +46,15 @@ vpath %.c programs
 extra-libs      := libutil
 extra-libs-others := $(extra-libs)
 
-libutil-routines:= login login_tty logout logwtmp pty
+libutil-routines:= login login_tty logout logwtmp openpty forkpty
 libutil-map    := libutil.map
 
 include ../Rules
 
+# pt_chown needs to be setuid root.
+$(inst_libexecdir)/pt_chown: $(objpfx)pt_chown
+       $(INSTALL) -m 4755 -o root $< $@
+
 $(objpfx)utmpd: $(utmpd-routines:%=$(objpfx)%.o)
 
 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
diff --git a/login/forkpty.c b/login/forkpty.c
new file mode 100644 (file)
index 0000000..e0e3cce
--- /dev/null
@@ -0,0 +1,56 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/types.h>
+#include <termios.h>
+#include <unistd.h>
+#include <utmp.h>
+#include <pty.h>
+
+int
+forkpty (amaster, name, termp, winp)
+     int *amaster;
+     char *name;
+     struct termios *termp;
+     struct winsize *winp;
+{
+  int master, slave, pid;
+
+  if (openpty (&master, &slave, name, termp, winp) == -1)
+    return -1;
+
+  switch (pid = fork ())
+    {
+    case -1:
+      return -1;
+    case 0:
+      /* Child.  */
+      close (master);
+      if (login_tty (slave))
+       _exit (1);
+
+      return 0;
+    default:
+      /* Parent.  */
+      *amaster = master;
+      close (slave);
+
+      return pid;
+    }
+}
diff --git a/login/openpty.c b/login/openpty.c
new file mode 100644 (file)
index 0000000..12e8207
--- /dev/null
@@ -0,0 +1,73 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <fcntl.h>
+#include <pty.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "pty-internal.h"
+
+int
+openpty (pmast, pslave, pname, tio, wins)
+     int *pmast;
+     int *pslave;
+     char *pname;
+     struct termios *tio;
+     struct winsize *wins;
+{
+  int pfd, tfd;
+  char name[PTYNAMELEN];
+
+  pfd = getpt ();
+  if (pfd == -1)
+    return -1;
+
+  if (grantpt (pfd))
+    goto bail;
+
+  if (unlockpt (pfd))
+    goto bail;
+
+  if (!ptsname_r (pfd, name, PTYNAMELEN))
+    goto bail;
+
+  tfd = open (name, O_RDWR);
+  if (tfd == -1)
+    goto bail;
+
+  /* XXX Should we ignore errors here?  */
+  if(tio)
+    tcsetattr (tfd, TCSAFLUSH, tio);
+  if (wins)
+    ioctl (tfd, TIOCSWINSZ, wins);
+
+  *pmast = pfd;
+  *pslave = tfd;
+  if (pname != NULL)
+    strcpy (pname, name);
+  return 0;
+
+bail:
+  close (pfd);
+  return -1;
+}
diff --git a/login/programs/pt_chown.c b/login/programs/pt_chown.c
new file mode 100644 (file)
index 0000000..dbf79fc
--- /dev/null
@@ -0,0 +1,88 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by C. Scott Ananian <cananian@alumni.princeton.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* pt_chmod.c ... securely implement grantpt in user-land.  */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <grp.h>
+
+#include "pty-internal.h"
+#define Str(x) _Str(x)
+#define _Str(x) #x
+
+void
+usage (void)
+{
+  fprintf (stderr, _("usage: pt_chown FD>&%s\n"
+                    "This program is used internally by grantpt(3).\n"),
+          Str (PTY_FD));
+  exit (0);
+}
+
+void
+bad_installation (void)
+{
+  fputs (_("pt_chown: installation problem: "
+          "This program needs to be setuid root.\n"), stderr);
+  exit (FAIL_EXEC);
+}
+
+int
+main (int argc, char **argv)
+{
+  struct group *grp;
+  struct stat s;
+  char *pty;
+  gid_t gid;
+  uid_t uid;
+
+  if (argc != 1)
+    usage ();
+  if (geteuid () != 0)
+    bad_installation ();
+
+  grp = getgrnam (TTY_GROUP);
+  gid = grp ? grp->gr_gid : getgid ();
+  uid = getuid ();
+
+  /* Check that fd is a valid pty master -- call ptsname().  */
+  pty = ptsname (PTY_FD);
+  if (pty == NULL)
+    return errno == EBADF ? FAIL_EBADF : FAIL_EINVAL;
+  close (PTY_FD);
+
+  /* Check that target file is a character device.  */
+  if (stat (pty, &s))
+    return FAIL_EINVAL; /* This should only fail if pty doesn't exist.  */
+  if (!S_ISCHR (s.st_mode))
+    return FAIL_EINVAL;
+
+  if (chmod (pty, 0620))
+    return FAIL_EACCES;  /* XXX: Probably not true. */
+
+  if (chown (pty, uid, gid))
+    return FAIL_EACCES;
+
+  return 0;
+}
diff --git a/login/pty-internal.h b/login/pty-internal.h
new file mode 100644 (file)
index 0000000..c185886
--- /dev/null
@@ -0,0 +1,41 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* Internal constants used by the pseudoterminal handling code. */
+
+#ifndef _PTY_INTERNAL_H
+#define _PTY_INTERNAL_H        1
+
+/* Length of a buffer to hold a pty name. */
+#define PTYNAMELEN 15   /* "/dev/pts/65535$" */
+
+/* Which group should pty slaves belong to: */
+#define TTY_GROUP "tty"
+
+/* Communication between grantpt and pt_chown. */
+#define PTY_FD 3
+enum  /* failure modes */
+{
+  FAIL_EBADF = 1,
+  FAIL_EINVAL,
+  FAIL_EACCES,
+  FAIL_EXEC
+};
+
+#endif
index bea63644f76442e2d7c0772df944ce67648ce9f4..d25dcb8600845827b86e56f90322fc65dfbc9912 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>
    and Paul Janzen <pcj@primenet.com>, 1996.
@@ -390,12 +390,12 @@ pututline_file (const struct utmp *data)
     }
 
   /* Write the new data.  */
-  if (write (file_fd, data, sizeof (struct utmp)) != sizeof (struct utmp)
+  if (write (file_fd, data, sizeof (struct utmp)) != sizeof (struct utmp))
+    {
       /* If we appended a new record this is only partially written.
         Remove it.  */
-      && found < 0)
-    {
-      (void) ftruncate (file_fd, file_offset);
+      if (found < 0)
+       (void) ftruncate (file_fd, file_offset);
       pbuf = NULL;
     }
   else
index 34f894e49edca94b67aeccc8834cc03ab54966e7..c5284938019151d0f145aa4220f1a5bcb489ffc4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1992, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+# Copyright (C) 1992, 93, 94, 95, 96, 97, 98 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
@@ -149,12 +149,14 @@ realclean: distclean
 
 .PHONY: install subdir_install installdirs install-data
 install-data subdir_install: install
+ifneq ($(strip $(MAKEINFO)),)
 install: $(inst_infodir)/libc.info dir-add.info
        @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
          test -f $(inst_infodir)/dir || cp dir $(inst_infodir);\
         $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
         $(INSTALL_INFO) --info-dir=$(inst_infodir) dir-add.info;\
        else : ; fi
+endif
 # Catchall implicit rule for other installation targets from the parent.
 install-%: ;
 
index b62f3921add53c3a1b3022bebc01f3bd251c23b3..9bcd6c75630dbe1014fd00395396220d58e9fcc1 100644 (file)
@@ -1,5 +1,5 @@
 /* Define and initialize `__progname' et. al.
-   Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998 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
@@ -18,7 +18,6 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <string.h>
-#include <errno.h>
 
 char *__progname_full = (char *) "";
 char *__progname = (char *) "";
index a0e11300775be28119502cd0e392baa73f800fdc..26cac675a59323b560ea260b1db4d139ed79b0df 100644 (file)
@@ -17,6 +17,8 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA. */
 
+#include <string.h>
+#include <unistd.h>
 #include <rpcsvc/nis.h>
 #include "nis_intern.h"
 
index dab1b5e566607ec3d81e7bbd8eb2070072ee1318..ca5abc4d2c6b2daf34b275c14b1d190a2272b109 100644 (file)
@@ -263,6 +263,14 @@ getgrent_next_nis (struct group *result, ent_t *ent, char *buffer,
              ent->nis = 0;
              return NSS_STATUS_UNAVAIL;
            }
+
+         if ( buflen < ((size_t) outvallen + 1))
+           {
+             free (outval);
+             *errnop = ERANGE;
+             return NSS_STATUS_TRYAGAIN;
+           }
+
          save_oldkey = ent->oldkey;
          save_oldlen = ent->oldkeylen;
          save_nis_first = TRUE;
@@ -280,6 +288,13 @@ getgrent_next_nis (struct group *result, ent_t *ent, char *buffer,
              return NSS_STATUS_NOTFOUND;
            }
 
+         if ( buflen < ((size_t) outvallen + 1))
+           {
+             free (outval);
+             *errnop = ERANGE;
+             return NSS_STATUS_TRYAGAIN;
+           }
+
          save_oldkey = ent->oldkey;
          save_oldlen = ent->oldkeylen;
          save_nis_first = FALSE;
@@ -287,7 +302,7 @@ getgrent_next_nis (struct group *result, ent_t *ent, char *buffer,
          ent->oldkeylen = outkeylen;
        }
 
-      /* Copy the found data to our buffer  */
+      /* Copy the found data to our buffer...  */
       p = strncpy (buffer, outval, buflen);
 
       /* ...and free the data.  */
@@ -427,8 +442,17 @@ getgrnam_plusgroup (const char *name, struct group *result, char *buffer,
                    &outval, &outvallen) != YPERR_SUCCESS)
        return NSS_STATUS_NOTFOUND;
 
-      p = strncpy (buffer, outval,
-                   buflen < (size_t) outvallen ? buflen : (size_t) outvallen);
+      if (buflen < ((size_t) outvallen + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
+
+      /* Copy the found data to our buffer...  */
+      p = strncpy (buffer, outval, buflen);
+
+      /* ... and free the data.  */
       free (outval);
       while (isspace (*p))
         ++p;
@@ -758,9 +782,20 @@ getgrgid_plusgroup (gid_t gid, struct group *result, char *buffer,
          *errnop = errno;
          return NSS_STATUS_TRYAGAIN;
        }
-      p = strncpy (buffer, outval,
-                   buflen < (size_t) outvallen ? buflen : (size_t) outvallen);
+
+      if (buflen < ((size_t) outvallen + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
+
+      /* Copy the found data to our buffer...  */
+      p = strncpy (buffer, outval, buflen);
+
+      /* ... and free the data.  */
       free (outval);
+
       while (isspace (*p))
         p++;
       parse_res = _nss_files_parse_grent (p, result, data, buflen, errnop);
index 5bfff17ca5c0ba8aa0e9683e1df0cf0c6fb8d69e..eec2634f3ab1ab0d9d17ff7b377e3482d06908f0 100644 (file)
@@ -393,7 +393,7 @@ getpwent_next_nis_netgr (const char *name, struct passwd *result, ent_t *ent,
       if (domain != NULL && strcmp (ypdomain, domain) != 0)
        continue;
 
-      /* If name != NULL, we are called from getpwnam */
+      /* If name != NULL, we are called from getpwnam */
       if (name != NULL)
        if (strcmp (user, name) != 0)
          continue;
@@ -406,12 +406,21 @@ getpwent_next_nis_netgr (const char *name, struct passwd *result, ent_t *ent,
       p2len = pwd_need_buflen (&ent->pwd);
       if (p2len > buflen)
        {
+         free (outval);
          *errnop = ERANGE;
          return NSS_STATUS_TRYAGAIN;
        }
       p2 = buffer + (buflen - p2len);
       buflen -= p2len;
+
+      if (buflen < ((size_t) outvallen + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
       p = strncpy (buffer, outval, buflen);
+
       while (isspace (*p))
        p++;
       free (outval);
@@ -650,6 +659,13 @@ getpwent_next_nis (struct passwd *result, ent_t *ent, char *buffer,
              return NSS_STATUS_UNAVAIL;
            }
 
+         if (buflen < ((size_t) outvallen + 1))
+           {
+             free (outval);
+             *errnop = ERANGE;
+             return NSS_STATUS_TRYAGAIN;
+           }
+
          saved_first = TRUE;
          saved_oldkey = ent->oldkey;
          saved_oldlen = ent->oldkeylen;
@@ -668,6 +684,13 @@ getpwent_next_nis (struct passwd *result, ent_t *ent, char *buffer,
              return NSS_STATUS_NOTFOUND;
            }
 
+         if (buflen < ((size_t) outvallen + 1))
+           {
+             free (outval);
+             *errnop = ERANGE;
+             return NSS_STATUS_TRYAGAIN;
+           }
+
          saved_first = FALSE;
          saved_oldkey = ent->oldkey;
          saved_oldlen = ent->oldkeylen;
@@ -769,9 +792,13 @@ getpwnam_plususer (const char *name, struct passwd *result, char *buffer,
                    &outval, &outvallen) != YPERR_SUCCESS)
        return NSS_STATUS_NOTFOUND;
 
-      ptr = strncpy (buffer, outval, buflen < (size_t) outvallen ?
-                    buflen : (size_t) outvallen);
-      buffer[buflen < (size_t) outvallen ? buflen : (size_t) outvallen] = '\0';
+      if (buflen < ((size_t) outvallen + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
+      ptr = strncpy (buffer, outval, buflen);
       free (outval);
       while (isspace (*ptr))
        ptr++;
@@ -1259,10 +1286,17 @@ getpwuid_plususer (uid_t uid, struct passwd *result, char *buffer,
          *errnop = errno;
          return NSS_STATUS_TRYAGAIN;
        }
-      ptr = strncpy (buffer, outval, buflen < (size_t) outvallen ?
-                    buflen : (size_t) outvallen);
-      buffer[buflen < (size_t) outvallen ? buflen : (size_t) outvallen] = '\0';
+
+      if ( buflen < ((size_t) outvallen + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
+
+      ptr = strncpy (buffer, outval, buflen);
       free (outval);
+
       while (isspace (*ptr))
        ptr++;
       parse_res = _nss_files_parse_pwent (ptr, result, data, buflen, errnop);
index 816e9c1f0a705f8222ff58ba8da00d9efb8676e3..1d4216393a87d652c263df9fd4d201f8cbc3ea95 100644 (file)
@@ -359,11 +359,18 @@ getspent_next_nis_netgr (const char *name, struct spwd *result, ent_t *ent,
       p2len = spwd_need_buflen (&ent->pwd);
       if (p2len > buflen)
        {
+         free (outval);
          *errnop = ERANGE;
          return NSS_STATUS_TRYAGAIN;
        }
       p2 = buffer + (buflen - p2len);
       buflen -= p2len;
+      if (buflen < ((size_t) outval + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
       p = strncpy (buffer, outval, buflen);
       while (isspace (*p))
        p++;
@@ -601,6 +608,14 @@ getspent_next_nis (struct spwd *result, ent_t *ent,
              give_spwd_free (&ent->pwd);
              return NSS_STATUS_UNAVAIL;
            }
+
+         if (buflen < ((size_t) outvallen + 1))
+           {
+             free (outval);
+             *errnop = ERANGE;
+             return NSS_STATUS_TRYAGAIN;
+           }
+
          saved_first = TRUE;
          saved_oldkey = ent->oldkey;
          saved_oldlen = ent->oldkeylen;
@@ -619,6 +634,13 @@ getspent_next_nis (struct spwd *result, ent_t *ent,
              return NSS_STATUS_NOTFOUND;
            }
 
+         if (buflen < ((size_t) outvallen + 1))
+           {
+             free (outval);
+             *errnop = ERANGE;
+             return NSS_STATUS_TRYAGAIN;
+           }
+
          saved_first = FALSE;
          saved_oldkey = ent->oldkey;
          saved_oldlen = ent->oldkeylen;
@@ -720,9 +742,14 @@ getspnam_plususer (const char *name, struct spwd *result, char *buffer,
                    &outval, &outvallen)  != YPERR_SUCCESS)
        return NSS_STATUS_NOTFOUND;
 
-      ptr = strncpy (buffer, outval, buflen < (size_t) outvallen ?
-                    buflen : (size_t) outvallen);
-      buffer[buflen < (size_t) outvallen ? buflen : (size_t) outvallen] = '\0';
+      if (buflen < ((size_t) outvallen + 1))
+       {
+         free (outval);
+         *errnop = ERANGE;
+         return NSS_STATUS_TRYAGAIN;
+       }
+
+      ptr = strncpy (buffer, outval, buflen);
       free (outval);
       while (isspace (*ptr))
         ptr++;
index 904d3ec423bd45e13efc4f9779ccc3d5477d5d0f..e0fceee93edfa16a791366decc8766bb1e512c99 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998 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
@@ -36,6 +36,8 @@ routines              = nsswitch $(addsuffix -lookup,$(databases))
 databases              = proto service hosts network grp pwd rpc ethers \
                          spwd netgrp key alias
 
+tests                  = test-netdb
+
 include ../Makeconfig
 
 # Specify rules for the nss_* modules.  We have some services.
diff --git a/nss/test-netdb.c b/nss/test-netdb.c
new file mode 100644 (file)
index 0000000..918bbeb
--- /dev/null
@@ -0,0 +1,349 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/*
+  Testing of some network related lookup functions.
+  The system databases looked up are:
+  - /etc/services
+  - /etc/hosts
+  - /etc/networks
+  - /etc/protocols
+  - /etc/rpc
+  The tests try to be fairly generic and simple so that they work on
+  every possible setup (and might therefore not detect some possible
+  errors).
+*/
+
+#include <netdb.h>
+#include <rpc/netdb.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+
+/*
+  The following define is neccessary for glibc 2.0.6
+*/
+#ifndef INET6_ADDRSTRLEN
+# define INET6_ADDRSTRLEN 46
+#endif
+
+int error_count;
+
+void
+output_servent (const char *call, struct servent *sptr)
+{
+  char **pptr;
+
+  if (sptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s, returned: s_name: %s, s_port: %d, s_proto: %s\n",
+             call, sptr->s_name, ntohs(sptr->s_port), sptr->s_proto);
+      for (pptr = sptr->s_aliases; *pptr != NULL; pptr++)
+       printf ("  alias: %s\n", *pptr);
+    }
+}
+
+
+void
+test_services (void)
+{
+  struct servent *sptr;
+
+  sptr = getservbyname ("domain", "tcp");
+  output_servent ("getservbyname (\"domain\", \"tcp\")", sptr);
+
+  sptr = getservbyname ("domain", "udp");
+  output_servent ("getservbyname (\"domain\", \"udp\")", sptr);
+
+  sptr = getservbyname ("domain", NULL);
+  output_servent ("getservbyname (\"domain\", NULL)", sptr);
+
+  sptr = getservbyname ("not-existant", NULL);
+  output_servent ("getservbyname (\"not-existant\", NULL)", sptr);
+
+  sptr = getservbyport (htons(53), "tcp");
+  output_servent ("getservbyport (htons(53), \"tcp\")", sptr);
+
+  sptr = getservbyport (htons(53), NULL);
+  output_servent ("getservbyport (htons(53), NULL)", sptr);
+
+  sptr = getservbyport (htons(1), "udp"); /* shouldn't exist */
+  output_servent ("getservbyport (htons(1), \"udp\")", sptr);
+
+  setservent (0);
+  do
+    {
+      sptr = getservent ();
+      output_servent ("getservent ()", sptr);
+    }
+  while (sptr != NULL);
+  endservent ();
+}
+
+
+void
+output_hostent (const char *call, struct hostent *hptr)
+{
+  int i;
+  char **pptr;
+  char buf[INET6_ADDRSTRLEN];
+
+  if (hptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s returned: name: %s, addr_type: %d\n",
+             call, hptr->h_name, hptr->h_addrtype);
+      for (pptr = hptr->h_aliases; *pptr != NULL; pptr++)
+       printf ("  alias: %s\n", *pptr);
+
+      for (pptr = hptr->h_addr_list; *pptr != NULL; pptr++)
+       printf ("  ip: %s\n",
+               inet_ntop (hptr->h_addrtype, *pptr, buf, sizeof (buf)));
+    }
+}
+
+void
+test_hosts (void)
+{
+  struct hostent *hptr1, *hptr2;
+  char name[MAXHOSTNAMELEN];
+  size_t namelen = sizeof(name);
+  struct in_addr ip;
+
+  hptr1 = gethostbyname ("localhost");
+  hptr2 = gethostbyname ("LocalHost");
+  if (hptr1 != NULL || hptr2 != NULL)
+    {
+      if (hptr1 == NULL)
+       {
+         printf ("localhost not found - but LocalHost found:-(\n");
+         ++error_count;
+       }
+      else if (hptr2 == NULL)
+       {
+         printf ("LocalHost not found - but localhost found:-(\n");
+         ++error_count;
+       }
+      else if (strcmp (hptr1->h_name, hptr2->h_name) != 0)
+       {
+         printf ("localhost and LocalHost have different canoncial name\n");
+         printf ("gethostbyname (\"localhost\")->%s\n", hptr1->h_name);
+         printf ("gethostbyname (\"LocalHost\")->%s\n", hptr2->h_name);
+         ++error_count;
+       }
+      else
+       output_hostent ("gethostbyname(\"localhost\")", hptr1);
+    }
+
+
+  if (gethostname (name, namelen) == 0)
+    {
+      printf ("Hostname: %s\n", name);
+      hptr1 = gethostbyname (name);
+      output_hostent ("gethostbyname (gethostname(...))", hptr1);
+    }
+
+  ip.s_addr = htonl (INADDR_LOOPBACK);
+  hptr1 = gethostbyaddr ((char *)&ip, sizeof(ip), AF_INET);
+  if (hptr1 != NULL)
+    {
+      printf ("official name of 127.0.0.1: %s\n", hptr1->h_name);
+    }
+
+  sethostent (0);
+  do
+    {
+      hptr1 = gethostent ();
+      output_hostent ("gethostent ()", hptr1);
+    }
+  while (hptr1 != NULL);
+  endhostent ();
+
+}
+
+
+void
+output_netent (const char *call, struct netent *nptr)
+{
+  char **pptr;
+
+  if (nptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      struct in_addr ip;
+
+      ip.s_addr = htonl(nptr->n_net);
+      printf ("Call: %s, returned: n_name: %s, network_number: %s\n",
+             call, nptr->n_name, inet_ntoa (ip));
+
+      for (pptr = nptr->n_aliases; *pptr != NULL; pptr++)
+       printf ("  alias: %s\n", *pptr);
+    }
+}
+
+void
+test_network (void)
+{
+  struct netent *nptr;
+  u_int32_t ip;
+
+  /*
+    this test needs the following line in /etc/networks:
+     loopback        127.0.0.0
+  */
+  nptr = getnetbyname ("loopback");
+  output_netent ("getnetbyname (\"loopback\")",nptr);
+
+  ip = inet_network ("127.0.0.0");
+  nptr = getnetbyaddr (ip, AF_INET);
+  output_netent ("getnetbyaddr (inet_network (\"127.0.0.0\"), AF_INET)",nptr);
+
+  setnetent (0);
+  do
+    {
+      nptr = getnetent ();
+      output_netent ("getnetent ()", nptr);
+    }
+  while (nptr != NULL);
+  endnetent ();
+}
+
+
+void
+output_protoent (const char *call, struct protoent *prptr)
+{
+  char **pptr;
+
+  if (prptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s, returned: p_name: %s, p_proto: %d\n",
+             call, prptr->p_name, prptr->p_proto);
+      for (pptr = prptr->p_aliases; *pptr != NULL; pptr++)
+       printf ("  alias: %s\n", *pptr);
+    }
+}
+
+
+void
+test_protocols (void)
+{
+  struct protoent *prptr;
+
+  prptr = getprotobyname ("IP");
+  output_protoent ("getprotobyname (\"IP\")", prptr);
+
+  prptr = getprotobynumber (1);
+  output_protoent ("getprotobynumber (1)", prptr);
+
+  setprotoent (0);
+  do
+    {
+      prptr = getprotoent ();
+      output_protoent ("getprotoent ()", prptr);
+    }
+  while (prptr != NULL);
+  endprotoent ();
+}
+
+
+void
+output_rpcent (const char *call, struct rpcent *rptr)
+{
+  char **pptr;
+
+  if (rptr == NULL)
+    printf ("Call: %s returned NULL\n", call);
+  else
+    {
+      printf ("Call: %s, returned: r_name: %s, r_number: %d\n",
+               call, rptr->r_name, rptr->r_number);
+      for (pptr = rptr->r_aliases; *pptr != NULL; pptr++)
+       printf ("  alias: %s\n", *pptr);
+    }
+}
+
+void
+test_rpc (void)
+{
+  struct rpcent *rptr;
+
+  rptr = getrpcbyname ("portmap");
+  output_rpcent ("getrpcyname (\"portmap\")", rptr);
+
+  rptr = getrpcbynumber (100000);
+  output_rpcent ("getrpcbynumber (100000)", rptr);
+
+  setrpcent (0);
+  do
+    {
+      rptr = getrpcent ();
+      output_rpcent ("getrpcent ()", rptr);
+    }
+  while (rptr != NULL);
+  endrpcent ();
+}
+
+/*
+  Override /etc/nsswitch.conf for this program.
+  This is mainly useful for developers
+*/
+void
+setdb (const char *dbname)
+{
+  if (strcmp ("db", dbname))
+      {
+       /*
+         db is not implemented for hosts, networks
+       */
+       __nss_configure_lookup ("hosts", dbname);
+       __nss_configure_lookup ("networks", dbname);
+      }
+  __nss_configure_lookup ("protocols", dbname);
+  __nss_configure_lookup ("rpc", dbname);
+  __nss_configure_lookup ("services", dbname);
+}
+
+
+int
+main (void)
+{
+  /*
+    setdb ("db");
+  */
+  test_hosts ();
+  test_network ();
+  test_protocols ();
+  test_rpc ();
+  test_services ();
+
+  if (error_count)
+    printf ("\n %d errors occured!\n", error_count);
+  else
+    printf ("No visible errors occured!\n");
+
+  exit (error_count);
+}
similarity index 100%
rename from include/cpio.h
rename to posix/cpio.h
index 7699901177c48ffdae8132014c0f9e3970c3c940..1aa70bffb551fd0431382042d344e84b76e69e67 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1998 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
@@ -74,12 +74,18 @@ __fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer,
 
   do
     {
+      buffer[buflen] = '\xff';
       p = fgets (buffer, buflen, stream);
-      if (p == NULL)
+      if (p == NULL && feof (stream))
        {
          *result = NULL;
          return errno;
        }
+      if (p == NULL || buffer[buflen] != '\xff')
+       {
+         *result = NULL;
+         return errno = ERANGE;
+       }
 
       /* Skip leading blanks.  */
       while (isspace (*p))
index 864a49b6e1f33c48f046eadf2591f3e61a2cb2b8..015f0f0b93b8dce852e98d3a8c0960253aebab2b 100644 (file)
@@ -268,8 +268,8 @@ extern int sigqueue __P ((__pid_t __pid, int __sig,
 
 /* Names of the signals.  This variable exists only for compatibility.
    Use `strsignal' instead (see <string.h>).  */
-extern __const char *__const _sys_siglist[_NSIG];
-extern __const char *__const sys_siglist[_NSIG];
+extern __const char *__const _sys_siglist[_NSIG + 1];
+extern __const char *__const sys_siglist[_NSIG + 1];
 
 /* Structure passed to `sigvec'.  */
 struct sigvec
index 30f381320e1713f8d8a328c11f907e6abb39e768..036b3b4dfe04106e36a0178df6cf643b51ce7364 100644 (file)
@@ -1,5 +1,5 @@
 /* Internal header for parsing printf format strings.
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of th GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -268,6 +268,7 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
   spec->info.is_long_double = 0;
   spec->info.is_short = 0;
   spec->info.is_long = 0;
+  spec->info.is_char = 0;
 
   if (*format == L_('h') || *format == L_('l') || *format == L_('L') ||
       *format == L_('Z') || *format == L_('q'))
@@ -278,7 +279,10 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
        if (spec->info.is_short == 0)
          spec->info.is_short = 1;
        else
-         spec->info.is_short = 2;
+         {
+           spec->info.is_short = 0;
+           spec->info.is_char = 1;
+         }
        break;
       case L_('l'):
        /* int's are long int's.  */
@@ -329,6 +333,8 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
            spec->data_arg_type = PA_INT|PA_FLAG_LONG;
          else if (spec->info.is_short)
            spec->data_arg_type = PA_INT|PA_FLAG_SHORT;
+         else if (spec->info.is_char)
+           spec->data_arg_type = PA_CHAR;
          else
            spec->data_arg_type = PA_INT;
          break;
index c49172b88c0ea050b8f0ef0509985ec01e9e2532..8b3b4eb96760828a242725c241616665c4549cac 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 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
@@ -44,6 +44,7 @@ struct printf_info
   unsigned int showsign:1;     /* + flag.  */
   unsigned int group:1;                /* ' flag.  */
   unsigned int extra:1;                /* For special use.  */
+  unsigned int is_char:1;      /* hh flag.  */
   wchar_t pad;                 /* Padding character.  */
 };
 
index b13a1c254216e4ce22c5c67cd8a47bb91bf16365..aced45d5c9a8465d6aa77cb5cb06054bb87eb255 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998 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
@@ -16,7 +16,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -26,9 +26,10 @@ write_data (FILE *stream)
   int i;
   for (i=0; i<100; i++)
     fprintf (stream, "%d\n", i);
-  if (ferror (stream))  {
-    fprintf (stderr, "Output to stream failed.\n");
-    exit (1);
+  if (ferror (stream))
+    {
+      fprintf (stderr, "Output to stream failed.\n");
+      exit (1);
     }
 }
 
index 541ea43a0c34024cdfcf70f1a45e8e307d850dab..bce47665a71aa451fde8bb217197659c95d94ab9 100644 (file)
@@ -9,7 +9,7 @@ typedef struct {
   const char *format_string;
 } sprint_int_type;
 
-sprint_int_type sprint_ints[] = 
+sprint_int_type sprint_ints[] =
 {
   {__LINE__, 0x000838d2,       "838d2", "%.4x"},
   {__LINE__, 0x0063be46,       "63BE46", "%-6X"},
@@ -5022,6 +5022,9 @@ sprint_int_type sprint_ints[] =
   {__LINE__, 0000123456,       "00123456", "%#.8o"},
   {__LINE__, 0000123456,       "  00123456", "%#10.8o"},
   {__LINE__, 0x00000123,       "0x00123", "%#07x"},
+  {__LINE__, 0x00000000,       "", "%#.0d"},
+  {__LINE__, 0x00000000,       "", "%#.0x"},
+  {__LINE__, 0x00000000,       "0", "%#.0o"},
 
   {0},
 };
index 4abee7ed915e19a60f2f3f7f9d1e5be3c4895939..e6c2df25d66808737fa5ab071b3918d2d5195147 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,98 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
@@ -492,10 +492,12 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
          long int signed_number;                                             \
                                                                              \
          if (fspec == NULL)                                                  \
-           if (is_long)                                                      \
-             signed_number = va_arg (ap, long int);                          \
-           else  /* `char' and `short int' will be promoted to `int'.  */    \
-             signed_number = va_arg (ap, int);                               \
+           {                                                                 \
+             if (is_long)                                                    \
+               signed_number = va_arg (ap, long int);                        \
+             else  /* `char' and `short int' will be promoted to `int'.  */  \
+               signed_number = va_arg (ap, int);                             \
+           }                                                                 \
          else                                                                \
            if (is_long)                                                      \
              signed_number = args_value[fspec->data_arg].pa_long_int;        \
@@ -550,9 +552,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
            pad = ' ';                                                        \
                                                                              \
          /* If the precision is 0 and the number is 0 nothing has to         \
-            be written for the number.  */                                   \
+            be written for the number, except for the 'o' format in          \
+            alternate form.  */                                              \
          if (prec == 0 && number.longlong == 0)                              \
-           string = workend;                                                 \
+           {                                                                 \
+             string = workend;                                               \
+             if (base == 8 && alt)                                           \
+               *string-- = '0';                                              \
+           }                                                                 \
          else                                                                \
            {                                                                 \
              /* Put the number in WORK.  */                                  \
@@ -569,12 +576,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       else                                                                   \
        {                                                                     \
          if (fspec == NULL)                                                  \
-           if (is_long)                                                      \
-             number.word = va_arg (ap, unsigned long int);                   \
-           else if (!is_short)                                               \
-             number.word = va_arg (ap, unsigned int);                        \
-           else                                                              \
-             number.word = (unsigned short int) va_arg (ap, unsigned int);   \
+           {                                                                 \
+             if (is_long)                                                    \
+               number.word = va_arg (ap, unsigned long int);                 \
+             else if (!is_short)                                             \
+               number.word = va_arg (ap, unsigned int);                      \
+             else                                                            \
+               number.word = (unsigned short int) va_arg (ap, unsigned int); \
+           }                                                                 \
          else                                                                \
            if (is_long)                                                      \
              number.word = args_value[fspec->data_arg].pa_u_long_int;        \
@@ -597,9 +606,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
            pad = ' ';                                                        \
                                                                              \
          /* If the precision is 0 and the number is 0 nothing has to         \
-            be written for the number.  */                                   \
+            be written for the number, except for the 'o' format in          \
+            alternate form.  */                                              \
          if (prec == 0 && number.word == 0)                                  \
-           string = workend;                                                 \
+           {                                                                 \
+             string = workend;                                               \
+             if (base == 8 && alt)                                           \
+               *string-- = '0';                                              \
+           }                                                                 \
          else                                                                \
            {                                                                 \
              /* Put the number in WORK.  */                                  \
@@ -926,14 +940,16 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
     LABEL (form_number):                                                     \
       /* Answer the count of characters written.  */                         \
       if (fspec == NULL)                                                     \
-       if (is_longlong)                                                      \
-         *(long long int *) va_arg (ap, void *) = done;                      \
-       else if (is_long)                                                     \
-         *(long int *) va_arg (ap, void *) = done;                           \
-       else if (!is_short)                                                   \
-         *(int *) va_arg (ap, void *) = done;                                \
-       else                                                                  \
-         *(short int *) va_arg (ap, void *) = done;                          \
+       {                                                                     \
+         if (is_longlong)                                                    \
+           *(long long int *) va_arg (ap, void *) = done;                    \
+         else if (is_long)                                                   \
+           *(long int *) va_arg (ap, void *) = done;                         \
+         else if (!is_short)                                                 \
+           *(int *) va_arg (ap, void *) = done;                              \
+         else                                                                \
+           *(short int *) va_arg (ap, void *) = done;                        \
+       }                                                                     \
       else                                                                   \
        if (is_longlong)                                                      \
          *(long long int *) args_value[fspec->data_arg].pa_pointer = done;   \
@@ -1360,8 +1376,8 @@ do_positional:
        int showsign = specs[nspecs_done].info.showsign;
        int group = specs[nspecs_done].info.group;
        int is_long_double = specs[nspecs_done].info.is_long_double;
-       int is_short = specs[nspecs_done].info.is_short == 1;
-       int is_char = specs[nspecs_done].info.is_short == 2;
+       int is_short = specs[nspecs_done].info.is_short;
+       int is_char = specs[nspecs_done].info.is_char;
        int is_long = specs[nspecs_done].info.is_long;
        int width = specs[nspecs_done].info.width;
        int prec = specs[nspecs_done].info.prec;
index 4bf31052693478daf93223d6382d5b2e374cc870..aa7ac20c1513ae14f761138c3d8b705cddd3a79a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,98 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
@@ -720,8 +720,32 @@ extern int getsubopt __P ((char **__optionp, __const char *__const *__tokens,
 
 /* Setup DES tables according KEY.  */
 extern void setkey __P ((__const char *__key));
+
+/* X/Open pseudo terminal handling.  */
+
+/* The next four functions all take a master pseudo-tty fd and
+   perform an operation on the associated slave:  */
+
+/* Chown the slave to the calling user.  */
+extern int grantpt __P ((int __fd));
+
+/* Release an internal lock so the slave can be opened.
+   Call after grantpt().  */
+extern int unlockpt __P ((int __fd));
+
+/* Get the name of the slave.  */
+extern char *ptsname __P ((int __fd));
 #endif
 
+#ifdef __USE_GNU
+/* Reentrant version of ptsname.  */
+extern char *__ptsname_r __P ((int __fd, char *__buf, unsigned int __len));
+extern char *ptsname_r __P ((int __fd, char *__buf, unsigned int __len));
+
+/* Open a master pseudo tty and return its file descriptor.  */
+extern int __getpt __P ((void));
+extern int getpt __P ((void));
+#endif
 
 __END_DECLS
 
diff --git a/sysdeps/generic/getpt.c b/sysdeps/generic/getpt.c
new file mode 100644 (file)
index 0000000..6dee1e1
--- /dev/null
@@ -0,0 +1,34 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <stdlib.h>
+#include <errno.h>
+
+/* Open the master side of a pseudoterminal and return its file
+   descriptor, or -1 on error. */
+int
+__getpt ()
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+weak_alias (getpt, __getpt)
+
+stub_warning (getpt)
+#include <stub-tag.h>
diff --git a/sysdeps/generic/grantpt.c b/sysdeps/generic/grantpt.c
new file mode 100644 (file)
index 0000000..73c1821
--- /dev/null
@@ -0,0 +1,35 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <stdlib.h>
+#include <errno.h>
+
+/* Given a fd on a master pseudoterminal, chown the file associated
+   with the slave to the calling process, and set its group and
+   mode appropriately.  Note that this is an unprivileged operation. */
+int
+grantpt (fd)
+     int fd __attribute__ ((unused));
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (grantpt)
+#include <stub-tag.h>
index c5a74b8d2d980ff59dc3ad484eeff38c5bd804ac..9ef0e8526a6cbcc66e2fa9387a15f9776a536375 100644 (file)
@@ -1 +1 @@
-#error "This file must be written based on the data typs sizes of the target"
+#error "This file must be written based on the data type sizes of the target"
diff --git a/sysdeps/generic/ptsname.c b/sysdeps/generic/ptsname.c
new file mode 100644 (file)
index 0000000..7a442d0
--- /dev/null
@@ -0,0 +1,46 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <stdlib.h>
+#include <errno.h>
+
+/* Given the file descriptor of a master pty, return the pathname
+   of the associated slave. */
+
+char *
+ptsname (fd)
+     int fd __attribute__ ((unused));
+{
+  __set_errno (ENOSYS);
+  return 0;
+}
+
+char *
+__ptsname_r (fd, buf, len)
+     int fd __attribute__ ((unused));
+     char *buf __attribute__ ((unused));
+     unsigned int len __attribute__ ((unused));
+{
+  __set_errno (ENOSYS);
+  return 0;
+}
+weak_alias (__ptsname_r, ptsname_r)
+
+stub_warning(ptsname)
+stub_warning(ptsname_r)
diff --git a/sysdeps/generic/pty.c b/sysdeps/generic/pty.c
deleted file mode 100644 (file)
index 75c7857..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)pty.c      8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <grp.h>
-#include <pty.h>
-#include <utmp.h>
-
-#ifndef REVOKE
-# define REVOKE(Line) revoke (Line)
-#endif
-
-int
-openpty(amaster, aslave, name, termp, winp)
-       int *amaster, *aslave;
-       char *name;
-       struct termios *termp;
-       struct winsize *winp;
-{
-       char line[11];
-       register const char *cp1, *cp2;
-       register int master, slave, ttygid;
-       size_t buflen = sysconf (_SC_GETGR_R_SIZE_MAX);
-       char buffer[buflen];
-       struct group grbuffer;
-       struct group *gr;
-
-       strcpy (line, "/dev/ptyXX");
-
-       if (getgrnam_r("tty", &grbuffer, buffer, buflen, &gr) >= 0)
-               ttygid = gr->gr_gid;
-       else
-               ttygid = -1;
-
-       for (cp1 = "pqrs"; *cp1; cp1++) {
-               line[8] = *cp1;
-               for (cp2 = "0123456789abcdef"; *cp2; cp2++) {
-                       line[9] = *cp2;
-                       if ((master = open(line, O_RDWR, 0)) == -1) {
-                               if (errno == ENOENT)
-                                       return (-1);    /* out of ptys */
-                       } else {
-                               line[5] = 't';
-                               (void) chown(line, getuid(), ttygid);
-                               (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
-                               REVOKE(line);
-                               if ((slave = open(line, O_RDWR, 0)) != -1) {
-                                       *amaster = master;
-                                       *aslave = slave;
-                                       if (name)
-                                               strcpy(name, line);
-                                       if (termp)
-                                               (void) tcsetattr(slave,
-                                                       TCSAFLUSH, termp);
-                                       if (winp)
-                                               (void) ioctl(slave, TIOCSWINSZ,
-                                                       (char *)winp);
-                                       return (0);
-                               }
-                               (void) close(master);
-                               line[5] = 'p';
-                       }
-               }
-       }
-       __set_errno (ENOENT);   /* out of ptys */
-       return (-1);
-}
-
-int
-forkpty(amaster, name, termp, winp)
-       int *amaster;
-       char *name;
-       struct termios *termp;
-       struct winsize *winp;
-{
-       int master, slave, pid;
-
-       if (openpty(&master, &slave, name, termp, winp) == -1)
-               return (-1);
-       switch (pid = fork()) {
-       case -1:
-               return (-1);
-       case 0:
-               /*
-                * child
-                */
-               (void) close(master);
-               login_tty(slave);
-               return (0);
-       }
-       /*
-        * parent
-        */
-       *amaster = master;
-       (void) close(slave);
-       return (pid);
-}
diff --git a/sysdeps/generic/unlockpt.c b/sysdeps/generic/unlockpt.c
new file mode 100644 (file)
index 0000000..5ee1309
--- /dev/null
@@ -0,0 +1,35 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <stdlib.h>
+#include <errno.h>
+
+/* Given a fd on a master pseudoterminal, clear a kernel lock so that
+   the slave can be opened.  This is to avoid a race between opening the
+   master and calling grantpt() to take possession of the slave. */
+int
+unlockpt (fd)
+     int fd __attribute__ ((unused));
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (unlockpt)
+#include <stub-tag.h>
diff --git a/sysdeps/unix/bsd/getpt.c b/sysdeps/unix/bsd/getpt.c
new file mode 100644 (file)
index 0000000..cb47692
--- /dev/null
@@ -0,0 +1,60 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "pty-internal.h"
+
+/* Per the FreeBSD-3.0 manpages: pty masters are named
+   /dev/pty[p-sP-S][0-9a-v].  I hope EIO is the right
+   errno in the "already open" case; it doesn't say.  */
+static const char pn1[] = "pqrsPQRS";
+static const char pn2[] = "0123456789abcdefghijklmnopqrstuv";
+
+/* Open the master side of a pseudoterminal and return its file
+   descriptor, or -1 on error.  BSD version.  */
+int
+__getpt ()
+{
+  int fd;
+  const char *i, *j;
+  char namebuf[PTYNAMELEN];
+
+  strcpy (namebuf, "/dev/pty");
+  namebuf[10] = '\0';
+  for (i = pn1; *i; ++i)
+    {
+      namebuf[8] = *i;
+      for (j = pn2; *j; ++j)
+        {
+         namebuf[9] = *j;
+         fd = open (namebuf, O_RDWR);
+         if (fd != -1)
+           return fd;
+         if (errno != EIO)
+           return -1;
+        }
+    }
+  __set_errno (ENFILE);
+  return -1;
+}
+weak_alias (getpt, __getpt)
diff --git a/sysdeps/unix/bsd/unlockpt.c b/sysdeps/unix/bsd/unlockpt.c
new file mode 100644 (file)
index 0000000..3de46ee
--- /dev/null
@@ -0,0 +1,41 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "pty-internal.h"
+
+/* Given a fd on a master pseudoterminal, clear a kernel lock so that
+   the slave can be opened.  This is to avoid a race between opening the
+   master and calling grantpt() to take possession of the slave.
+
+   BSD doesn't have this lock, but what it does have is revoke(). */
+
+int
+unlockpt (fd)
+     int fd;
+{
+  char buf[PTYNAMELEN];
+
+  if (ptsname_r (fd, buf, PTYNAMELEN))
+    return -1;
+
+  return revoke (buf);
+}
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
new file mode 100644 (file)
index 0000000..4837a7a
--- /dev/null
@@ -0,0 +1,111 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <assert.h>
+
+#include "pty-internal.h"
+
+/* Given a fd on a master pseudoterminal, chown the file associated
+   with the slave to the calling process, and set its group and
+   mode appropriately.  Note that this is an unprivileged operation. */
+
+/* This "generic Unix" implementation works because we provide the program
+   /usr/libexec/pt_chown, and it only depends on ptsname() working. */
+static const char helper[] = LIBEXECDIR "/pt_chown";
+static const char *argv[] = { "pt_chown", NULL };
+
+int
+grantpt (fd)
+     int fd;
+{
+  struct stat st;
+  int w, pid;
+  char namebuf[PTYNAMELEN];
+
+  /* Some systems do it for us.  */
+  if (ptsname_r (fd, namebuf, PTYNAMELEN) == NULL)
+    return -1;
+  if (stat (namebuf, &st))
+    return -1;
+
+  if (st.st_uid == getuid ())
+    return 0;
+
+  /* We have to do it in user space.  */
+
+  pid = fork ();
+  if (pid == -1)
+    return -1;
+  else if (pid == 0)
+    {
+      /* Disable core dumps in the child.  */
+      struct rlimit off = { 0, 0 };
+      setrlimit (RLIMIT_CORE, &off);
+
+      /* The helper does its thing on fd PTY_FD.  */
+      if (fd != PTY_FD)
+       if (dup2 (fd, PTY_FD) == -1)
+         _exit (FAIL_EBADF);
+
+      execve (helper, (char *const *) argv, 0);
+      _exit (FAIL_EXEC);
+    }
+  else
+    {
+      if (waitpid (pid, &w, 0) == -1)
+       return -1;
+      if (!WIFEXITED (w))
+       {
+         __set_errno (ENOEXEC);
+         return -1;
+       }
+      else
+       switch (WEXITSTATUS(w))
+         {
+         case 0:
+           break;
+         case FAIL_EBADF:
+           __set_errno (EBADF);
+           return -1;
+         case FAIL_EINVAL:
+           __set_errno (EINVAL);
+           return -1;
+         case FAIL_EACCES:
+           __set_errno (EACCES);
+           return -1;
+         case FAIL_EXEC:
+           __set_errno (ENOEXEC);
+           return -1;
+
+         default:
+           assert(! "getpt: internal error: invalid exit code from pt_chown");
+         }
+    }
+
+  /* Success.  */
+  return 0;
+}
index 674379428182201d58dd463b667547af3c60fa52..c1b6ec91c2188caa566ce8815069ea446a9768fb 100644 (file)
@@ -33,6 +33,7 @@ netinet/tcp.h
 netinet/udp.h
 netipx/ipx.h
 netrom/netrom.h
+netrose/rose.h
 nfs/nfs.h
 rt_sigaction.c
 rt_sigpending.c
index 29f1566753141a27f11839cbf3b52d70f82cf6f0..a71ee439a0b90ac19c75d0a4e5c41385bde487e6 100644 (file)
@@ -79,7 +79,8 @@ ifeq ($(subdir),inet)
 sysdep_headers += netinet/in_systm.h netinet/udp.h \
                  netinet/if_fddi.h netinet/if_tr.h netinet/igmp.h \
                  netinet/ip_fw.h  netinet/ip_icmp.h netipx/ipx.h \
-                 sys/socketvar.h netax25/ax25.h netrom/netrom.h
+                 sys/socketvar.h netax25/ax25.h netrom/netrom.h \
+                 netrose/rose.h
 endif
 
 ifeq ($(subdir),posix)
index 715fda7bd3280f38b88bd6878c373d95d9de230a..5b5dca44da211386c019a3a4f077fd1ced236d88 100644 (file)
@@ -9,6 +9,7 @@ ioperm.c
 kernel_sigaction.h
 kernel_stat.h
 kernel_termios.h
+net/route.h
 sys/acct.h
 sys/io.h
 sys/procfs.h
index 738b9cc54201d9ee0e928a10338f74cf9ad76e7d..d9872854452f4ae54b47f02e3a7d4715e05dd7ed 100644 (file)
@@ -1 +1,2 @@
+bits/mman.h
 clone.S
index a89724cd71c07ed948db4d2b446e20146200c1ba..7208d3bd4f31727095be2a7f583296292eca959f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 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
 
 /* Use the definitions from the kernel header files.  */
 #include <asm/ioctls.h>
-#include <linux/sockios.h>
+
+/* Routing table calls.  */
+#define SIOCADDRT      0x890B          /* add routing table entry      */
+#define SIOCDELRT      0x890C          /* delete routing table entry   */
+#define SIOCRTMSG      0x890D          /* call to routing system       */
+
+/* Socket configuration controls. */
+#define SIOCGIFNAME    0x8910          /* get iface name               */
+#define SIOCSIFLINK    0x8911          /* set iface channel            */
+#define SIOCGIFCONF    0x8912          /* get iface list               */
+#define SIOCGIFFLAGS   0x8913          /* get flags                    */
+#define SIOCSIFFLAGS   0x8914          /* set flags                    */
+#define SIOCGIFADDR    0x8915          /* get PA address               */
+#define SIOCSIFADDR    0x8916          /* set PA address               */
+#define SIOCGIFDSTADDR 0x8917          /* get remote PA address        */
+#define SIOCSIFDSTADDR 0x8918          /* set remote PA address        */
+#define SIOCGIFBRDADDR 0x8919          /* get broadcast PA address     */
+#define SIOCSIFBRDADDR 0x891a          /* set broadcast PA address     */
+#define SIOCGIFNETMASK 0x891b          /* get network PA mask          */
+#define SIOCSIFNETMASK 0x891c          /* set network PA mask          */
+#define SIOCGIFMETRIC  0x891d          /* get metric                   */
+#define SIOCSIFMETRIC  0x891e          /* set metric                   */
+#define SIOCGIFMEM     0x891f          /* get memory address (BSD)     */
+#define SIOCSIFMEM     0x8920          /* set memory address (BSD)     */
+#define SIOCGIFMTU     0x8921          /* get MTU size                 */
+#define SIOCSIFMTU     0x8922          /* set MTU size                 */
+#define        SIOCSIFHWADDR   0x8924          /* set hardware address         */
+#define SIOCGIFENCAP   0x8925          /* get/set encapsulations       */
+#define SIOCSIFENCAP   0x8926
+#define SIOCGIFHWADDR  0x8927          /* Get hardware address         */
+#define SIOCGIFSLAVE   0x8929          /* Driver slaving support       */
+#define SIOCSIFSLAVE   0x8930
+#define SIOCADDMULTI   0x8931          /* Multicast address lists      */
+#define SIOCDELMULTI   0x8932
+#define SIOCGIFINDEX   0x8933          /* name -> if_index mapping     */
+#define SIOGIFINDEX    SIOCGIFINDEX    /* misprint compatibility :-)   */
+#define SIOCSIFPFLAGS  0x8934          /* set/get extended flags set   */
+#define SIOCGIFPFLAGS  0x8935
+#define SIOCDIFADDR    0x8936          /* delete PA address            */
+#define        SIOCSIFHWBROADCAST      0x8937  /* set hardware broadcast addr  */
+#define SIOCGIFCOUNT   0x8938          /* get number of devices */
+
+#define SIOCGIFBR      0x8940          /* Bridging support             */
+#define SIOCSIFBR      0x8941          /* Set bridging options         */
+
+#define SIOCGIFTXQLEN  0x8942          /* Get the tx queue length      */
+#define SIOCSIFTXQLEN  0x8943          /* Set the tx queue length      */
+
+
+/* ARP cache control calls. */
+                   /*  0x8950 - 0x8952  * obsolete calls, don't re-use */
+#define SIOCDARP       0x8953          /* delete ARP table entry       */
+#define SIOCGARP       0x8954          /* get ARP table entry          */
+#define SIOCSARP       0x8955          /* set ARP table entry          */
+
+/* RARP cache control calls. */
+#define SIOCDRARP      0x8960          /* delete RARP table entry      */
+#define SIOCGRARP      0x8961          /* get RARP table entry         */
+#define SIOCSRARP      0x8962          /* set RARP table entry         */
+
+/* Driver configuration calls */
+
+#define SIOCGIFMAP     0x8970          /* Get device parameters        */
+#define SIOCSIFMAP     0x8971          /* Set device parameters        */
+
+/* DLCI configuration calls */
+
+#define SIOCADDDLCI    0x8980          /* Create new DLCI device       */
+#define SIOCDELDLCI    0x8981          /* Delete DLCI device           */
+
+/* Device private ioctl calls.  */
+
+/* These 16 ioctls are available to devices via the do_ioctl() device
+   vector.  Each device should include this file and redefine these
+   names as their own. Because these are device dependent it is a good
+   idea _NOT_ to issue them to random objects and hope.  */
+
+#define SIOCDEVPRIVATE 0x89F0  /* to 89FF */
+
+/*
+ *     These 16 ioctl calls are protocol private
+ */
+
+#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */
index 68cbf8ca7d672d80ee9d6a31e57306646f052f5f..16111beed0f60f48f11c63baa74ac6f68f0e1c5f 100644 (file)
@@ -104,7 +104,7 @@ typedef struct
 typedef int __key_t;
 
 /* Used in `struct shmid_ds'.  */
-typedef short int __ipc_pid_t;
+typedef unsigned short int __ipc_pid_t;
 
 
 /* Types from the Large File Support interface.  */
diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c
new file mode 100644 (file)
index 0000000..8eea2ff
--- /dev/null
@@ -0,0 +1,76 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "pty-internal.h"
+
+/* Per Documentation/devices.txt: pty masters are /dev/pty[p-za-e][0-9a-f].
+   These strings are used also in ptsname.c. */
+const char __ptyname1[] = "pqrstuvwxyzabcde";
+const char __ptyname2[] = "0123456789abcdef";
+
+/* Open the master side of a pseudoterminal and return its file
+   descriptor, or -1 on error.  Linux version. */
+int
+__getpt ()
+{
+  int fd;
+  const char *i, *j;
+  static int have_dev_ptmx = 1;
+  char namebuf[PTYNAMELEN];
+
+  /* The new way:  */
+  if (have_dev_ptmx)
+    {
+      fd = open ("/dev/ptmx", O_RDWR);
+      if (fd != -1)
+       return fd;
+      else
+       {
+         if (errno == ENOENT || errno == ENODEV)
+           have_dev_ptmx = 0;
+         else
+           return -1;
+       }
+    }
+
+  /* The old way: */
+  strcpy (namebuf, "/dev/pty");
+  namebuf[10] = '\0';
+  for (i = __ptyname1; *i; ++i)
+    {
+      namebuf[8] = *i;
+      for (j = __ptyname2; *j; ++j)
+        {
+         namebuf[9] = *j;
+         fd = open (namebuf, O_RDWR);
+         if (fd != -1)
+           return fd;
+         if (errno != EIO)
+           return -1;
+        }
+    }
+  __set_errno (ENFILE);
+  return -1;
+}
+weak_alias (__getpt, getpt)
index 2e0bc5bf8f60ea2a07140e7ad0c59791454b1865..9d9bf0e0b244049d1034fa7de87de54d37680567 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998 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
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <net/if.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
index 1c9c095ed39fcc45adfc129aa268d4dd4d98764b..d026910ee2af83d9ae499d9b32beacbf7f80ade4 100644 (file)
@@ -16,7 +16,7 @@ sigsuspend    -       sigsuspend      1       __sigsuspend    sigsuspend
 # Socket functions; Linux/MIPS doesn't use the socketcall(2) wrapper;
 # it's provided for compatibility, though.
 #
-ccept          -       accept          3       __libc_accept   __accept accept
+accept         -       accept          3       __libc_accept   __accept accept
 bind           -       bind            3       __bind          bind
 connect                -       connect         3       __libc_connect  __connect connect
 getpeername    -       getpeername     3       __getpeername   getpeername
similarity index 73%
rename from sysdeps/unix/sysv/linux/m68k/sigreturn.S
rename to sysdeps/unix/sysv/linux/netrose/rose.h
index 34c0a91952c84896d81591c637f622447be0f7e2..c158c66bb730bd7c8968f63cd8c19d1e6b4dd90e 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Definitions for Rose packet radio address family.
+   Copyright (C) 1998 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
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <sysdep.h>
+#ifndef _NETROSE_ROSE_H
+#define _NETROSE_ROSE_H 1
 
-.text
-ENTRY (__sigreturn)
-       addq.l #4, %sp          /* Pop the return PC.  */
-       DO_CALL (#SYS_ify (sigreturn), 0)
-                               /* Do the system call; it never returns.  */
-       /* NOTREACHED */
-END (__sigreturn)
+#include <linux/rose.h>                /* Ask, and the kernel will provide.  */
 
-weak_alias (__sigreturn, sigreturn)
+#endif
diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c
new file mode 100644 (file)
index 0000000..04feadd
--- /dev/null
@@ -0,0 +1,108 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <termios.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "pty-internal.h"
+
+#include <stdio-common/_itoa.h>
+#include <sys/sysmacros.h>
+
+/* Given the file descriptor of a master pty, return the pathname
+   of the associated slave. */
+
+static char namebuf[PTYNAMELEN];
+extern const char __ptyname1[], __ptyname2[]; /* defined in getpt.c */
+
+char *
+ptsname (fd)
+     int fd;
+{
+  return __ptsname_r (fd, namebuf, PTYNAMELEN);
+}
+
+char *
+__ptsname_r (fd, buf, len)
+     int fd;
+     char *buf;
+     unsigned int len;
+{
+  char nbuf[PTYNAMELEN], idbuf[6];
+  int ptyno;
+  struct stat st;
+
+#ifdef TIOCGPTN
+  static int tiocgptn_works = 1;
+  if (tiocgptn_works)
+    {
+      if (!ioctl (fd, TIOCGPTN, &ptyno))
+       goto gotit;
+      else
+       {
+         if(errno != EINVAL)
+           return 0;
+         else
+           tiocgptn_works = 0;
+       }
+    }
+#endif
+  /* /dev/ptmx will make it into the kernel before 32 bit dev_t, so
+     this should be safe.  */
+  if (fstat (fd, &st))
+    return 0;
+
+  ptyno = minor (st.st_rdev);
+
+#ifdef TIOCGPTN
+gotit:
+#endif
+  /* Two different possible naming schemes for pty slaves:
+     the SVr4 way.  */
+
+  idbuf[5] = '\0';
+  stpcpy (stpcpy (nbuf, "/dev/pts/"),
+         _itoa_word (ptyno, &idbuf[4], 10, 0));
+  if (!stat (nbuf, &st))
+    {
+      strncpy (buf, nbuf, len);
+      return buf;
+    }
+  else
+    if (errno != ENOENT)
+      return NULL;
+
+  /* ...and the BSD way.  */
+  nbuf[7]  = 'y';
+  nbuf[8]  = __ptyname1[ptyno / 16];
+  nbuf[9]  = __ptyname2[ptyno % 16];
+  nbuf[10] = '\0';
+
+  if (stat (nbuf, &st))
+    return NULL;
+
+  strncpy (buf, nbuf, len);
+  return buf;
+}
+weak_alias (__ptsname_r, ptsname_r)
diff --git a/sysdeps/unix/sysv/linux/pty.c b/sysdeps/unix/sysv/linux/pty.c
deleted file mode 100644 (file)
index e64261c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Linux does not has the `revoke' function.  */
-#define REVOKE(Line)
-#include <sysdeps/generic/pty.c>
index 43b229fc9567e2b838f8094c776f34901b8012b9..ae5ca6b8ecae56a74346084da23073638390856d 100644 (file)
@@ -1,3 +1,21 @@
+/* Copyright (C) 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
 #include <stddef.h>
 #include <signal.h>
 
diff --git a/sysdeps/unix/sysv/linux/unlockpt.c b/sysdeps/unix/sysv/linux/unlockpt.c
new file mode 100644 (file)
index 0000000..e508b28
--- /dev/null
@@ -0,0 +1,50 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* Given a fd on a master pseudoterminal, clear a kernel lock so that
+   the slave can be opened.  This is to avoid a race between opening the
+   master and calling grantpt() to take possession of the slave.  */
+int
+unlockpt (fd)
+     int fd __attribute__ ((unused));
+{
+#ifdef TIOCSPTLCK
+  int serrno = errno;
+  int unlock = 0;
+
+  if (ioctl (fd, TIOCSPTLCK, &unlock))
+    {
+      if(errno == EINVAL)
+       {
+         __set_errno (serrno);
+         return 0;
+       }
+      else
+       return -1;
+    }
+#else
+  /* On pre-/dev/ptmx kernels this function should be a no-op.  */
+  return 0;
+#endif
+}