[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r9337 - in /fsf/trunk/libc: ./ csu/ include/ localedata/ localedata/locales/ login/programs/ nptl/ stdlib/ sysdeps/unix/ sys...
- To: commits@xxxxxxxxxx
- Subject: [commits] r9337 - in /fsf/trunk/libc: ./ csu/ include/ localedata/ localedata/locales/ login/programs/ nptl/ stdlib/ sysdeps/unix/ sys...
- From: eglibc@xxxxxxxxxx
- Date: Wed, 25 Nov 2009 08:05:50 -0000
Author: eglibc
Date: Wed Nov 25 00:05:49 2009
New Revision: 9337
Log:
Import glibc-mainline for 2009-11-25
Added:
fsf/trunk/libc/nptl/tst-sem13.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/grantpt.c
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/csu/elf-init.c
fsf/trunk/libc/csu/libc-start.c
fsf/trunk/libc/include/stdlib.h
fsf/trunk/libc/localedata/ChangeLog
fsf/trunk/libc/localedata/locales/hsb_DE
fsf/trunk/libc/login/programs/pt_chown.c
fsf/trunk/libc/nptl/ChangeLog
fsf/trunk/libc/nptl/Makefile
fsf/trunk/libc/stdlib/random_r.c
fsf/trunk/libc/sysdeps/unix/grantpt.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/ptsname.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Wed Nov 25 00:05:49 2009
@@ -1,3 +1,33 @@
+2009-11-24 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ [BZ #3662]
+ * stdlib/random_r.c: Fix comments for __initstate_r and __setstate_r.
+ Patch by Christopher Neufeld <glibcbugs0000@xxxxxxxxxxx>.
+
+ * sysdeps/unix/grantpt.c (pts_name): Take additional parameter,
+ pass it on to __ptsname_internal.
+ (grantpt): Pass stat64 pointer to pts_name. Remove stat call here.
+ * sysdeps/unix/sysv/linux/ptsname.c (__ptsname_internal): New function.
+ All the code from __ptsname_r but take additional parameter. Use that
+ instead of pointer to local stat64 variable.
+ (__ptsname_r): Call __ptsname_internal with pointer to local stat64
+ variable.
+ * include/stdlib.h: Declare __ptsname_internal.
+
+ * sysdeps/unix/grantpt.c (grantpt): Use CLOSE_ALL_FDS is available
+ before the exec.
+ * sysdeps/unix/sysv/linux/grantpt.c: New file.
+ * login/programs/pt_chown.c (main): Don't print message on errors
+ when doing real work.
+
+ * sysdeps/unix/grantpt.c (grantpt): Only get tty group information
+ once.
+
+ * csu/elf-init.c (__libc_csu_irel): New function. Code to perform
+ irel relocations split out from...
+ (__libc_csu_init): ...here.
+ * csu/libc-start.c [!SHARED]: Call __libc_csu_irel early.
+
2009-11-23 Andreas Schwab <schwab@xxxxxxxxxx>
* sysdeps/unix/sysv/linux/x86_64/bits/stat.h: Use struct timespec
Modified: fsf/trunk/libc/csu/elf-init.c
==============================================================================
--- fsf/trunk/libc/csu/elf-init.c (original)
+++ fsf/trunk/libc/csu/elf-init.c Wed Nov 25 00:05:49 2009
@@ -72,15 +72,14 @@
/* These functions are passed to __libc_start_main by the startup code.
These get statically linked into each program. For dynamically linked
programs, this module will come from libc_nonshared.a and differs from
- the libc.a module in that it doesn't call the preinit array. */
+ the libc.a module in that it doesn't call the preinit array and performs
+ explicit IREL{,A} relocations. */
-void
-__libc_csu_init (int argc, char **argv, char **envp)
-{
- /* For dynamically linked executables the preinit array is executed by
- the dynamic linker (before initializing any shared object. */
#ifndef LIBC_NONSHARED
+void
+__libc_csu_irel (void)
+{
# ifdef USE_MULTIARCH
# ifdef ELF_MACHINE_IRELA
{
@@ -98,7 +97,17 @@
}
# endif
# endif
+}
+#endif
+
+void
+__libc_csu_init (int argc, char **argv, char **envp)
+{
+ /* For dynamically linked executables the preinit array is executed by
+ the dynamic linker (before initializing any shared object. */
+
+#ifndef LIBC_NONSHARED
/* For static executables, preinit happens right before init. */
{
const size_t size = __preinit_array_end - __preinit_array_start;
Modified: fsf/trunk/libc/csu/libc-start.c
==============================================================================
--- fsf/trunk/libc/csu/libc-start.c (original)
+++ fsf/trunk/libc/csu/libc-start.c Wed Nov 25 00:05:49 2009
@@ -24,6 +24,9 @@
#include <bp-sym.h>
extern void __libc_init_first (int argc, char **argv, char **envp);
+#ifndef SHARED
+extern void __libc_csu_irel (void);
+#endif
extern int __libc_multiple_libcs;
@@ -134,6 +137,9 @@
}
# endif
+ /* Performe IREL{,A} relocations. */
+ __libc_csu_irel ();
+
/* Initialize the thread library at least a bit since the libgcc
functions are using thread functions if these are available and
we need to setup errno. */
Modified: fsf/trunk/libc/include/stdlib.h
==============================================================================
--- fsf/trunk/libc/include/stdlib.h (original)
+++ fsf/trunk/libc/include/stdlib.h Wed Nov 25 00:05:49 2009
@@ -9,6 +9,7 @@
/* Now define the internal interfaces. */
#ifndef __Need_M_And_C
+# include <sys/stat.h>
__BEGIN_DECLS
@@ -77,6 +78,8 @@
extern char *__canonicalize_file_name (__const char *__name);
extern char *__realpath (__const char *__name, char *__resolved);
extern int __ptsname_r (int __fd, char *__buf, size_t __buflen);
+extern int __ptsname_internal (int fd, char *buf, size_t buflen,
+ struct stat64 *stp);
extern int __getpt (void);
extern int __posix_openpt (int __oflag);
Modified: fsf/trunk/libc/localedata/ChangeLog
==============================================================================
--- fsf/trunk/libc/localedata/ChangeLog (original)
+++ fsf/trunk/libc/localedata/ChangeLog Wed Nov 25 00:05:49 2009
@@ -1,3 +1,7 @@
+2009-11-24 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * locales/hsb_DE: Define week, first_weekday, and first_workday.
+
2009-11-23 Ulrich Drepper <drepper@xxxxxxxxxx>
* locales/en_DK: Define week, first_weekday, and first_workday.
Modified: fsf/trunk/libc/localedata/locales/hsb_DE
==============================================================================
--- fsf/trunk/libc/localedata/locales/hsb_DE (original)
+++ fsf/trunk/libc/localedata/locales/hsb_DE Wed Nov 25 00:05:49 2009
@@ -197,7 +197,7 @@
% letter;accent;case;specials
order_start forward;backward/
- ;forward;position
+ ;forward;position
% <CAPITAL> or <SMALL> letters first:
@@ -2136,16 +2136,16 @@
LC_TIME
abday "<U004E><U006A>";"<U0050><U00F3>";/
- "<U0057><U0075>";"<U0053><U0072>";/
- "<U0160><U0074>";"<U0050><U006A>";/
- "<U0053><U006F>"
+ "<U0057><U0075>";"<U0053><U0072>";/
+ "<U0160><U0074>";"<U0050><U006A>";/
+ "<U0053><U006F>"
day "<U004E><U006A><U0065><U0064><U017A><U0065><U006C><U0061>";/
- "<U0050><U00F3><U006E><U0064><U017A><U0065><U006C><U0061>";/
- "<U0057><U0075><U0074><U006F><U0072><U0061>";/
- "<U0053><U0072><U006A><U0065><U0064><U0061>";/
- "<U0160><U0074><U0076><U00F3><U0072><U0074><U006B>";/
- "<U0050><U006A><U0061><U0074><U006B>";/
- "<U0053><U006F><U0062><U006F><U0074><U0061>"
+ "<U0050><U00F3><U006E><U0064><U017A><U0065><U006C><U0061>";/
+ "<U0057><U0075><U0074><U006F><U0072><U0061>";/
+ "<U0053><U0072><U006A><U0065><U0064><U0061>";/
+ "<U0160><U0074><U0076><U00F3><U0072><U0074><U006B>";/
+ "<U0050><U006A><U0061><U0074><U006B>";/
+ "<U0053><U006F><U0062><U006F><U0074><U0061>"
abmon "<U004A><U0061><U006E>";"<U0046><U0065><U0062>";/
"<U004D><U011B><U0072>";"<U0041><U0070><U0072>";/
"<U004D><U0065><U006A>";"<U004A><U0075><U006E>";/
@@ -2172,6 +2172,10 @@
date_fmt "<U0025><U0061><U0020><U0025><U0062><U0020><U0025><U0065>/
<U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/
<U0025><U005A><U0020><U0025><U0059>"
+
+week 7;19971130;4
+first_weekday 2
+first_workday 2
END LC_TIME
LC_PAPER
Modified: fsf/trunk/libc/login/programs/pt_chown.c
==============================================================================
--- fsf/trunk/libc/login/programs/pt_chown.c (original)
+++ fsf/trunk/libc/login/programs/pt_chown.c Wed Nov 25 00:05:49 2009
@@ -154,8 +154,7 @@
# define ncap_list (sizeof (cap_list) / sizeof (cap_list[0]))
cap_t caps = cap_init ();
if (caps == NULL)
- error (FAIL_ENOMEM, errno,
- _("Failed to initialize drop of capabilities"));
+ return FAIL_ENOMEM;
/* There is no reason why these should not work. */
cap_set_flag (caps, CAP_PERMITTED, ncap_list, cap_list, CAP_SET);
@@ -166,7 +165,7 @@
cap_free (caps);
if (__builtin_expect (res != 0, 0))
- error (FAIL_EXEC, errno, _("cap_set_proc failed"));
+ return FAIL_EXEC;
}
#endif
Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Wed Nov 25 00:05:49 2009
@@ -1,3 +1,8 @@
+2009-11-24 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * tst-sem13.c: New file.
+ * Makefile (tests): Add tst-sem13.
+
2009-11-22 Roland McGrath <roland@xxxxxxxxxx>
* sysdeps/unix/sysv/linux/i386/dl-sysdep.h: # include "i686/dl-sysdep.h"
Modified: fsf/trunk/libc/nptl/Makefile
==============================================================================
--- fsf/trunk/libc/nptl/Makefile (original)
+++ fsf/trunk/libc/nptl/Makefile Wed Nov 25 00:05:49 2009
@@ -216,7 +216,7 @@
tst-once1 tst-once2 tst-once3 tst-once4 \
tst-key1 tst-key2 tst-key3 tst-key4 \
tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
- tst-sem8 tst-sem9 tst-sem10 tst-sem11 tst-sem12 \
+ tst-sem8 tst-sem9 tst-sem10 tst-sem11 tst-sem12 tst-sem13 \
tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
tst-align tst-align2 tst-align3 \
tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
Added: fsf/trunk/libc/nptl/tst-sem13.c
==============================================================================
--- fsf/trunk/libc/nptl/tst-sem13.c (added)
+++ fsf/trunk/libc/nptl/tst-sem13.c Wed Nov 25 00:05:49 2009
@@ -1,0 +1,46 @@
+#include <errno.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <internaltypes.h>
+
+
+static int
+do_test (void)
+{
+ union
+ {
+ sem_t s;
+ struct new_sem ns;
+ } u;
+
+ if (sem_init (&u.s, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ return 1;
+ }
+
+ struct timespec ts = { 0, 1000000001 }; /* Invalid. */
+ errno = 0;
+ if (sem_timedwait (&u.s, &ts) >= 0)
+ {
+ puts ("sem_timedwait did not fail");
+ return 1;
+ }
+ if (errno != EINVAL)
+ {
+ puts ("sem_timedwait did not fail with EINVAL");
+ return 1;
+ }
+ if (u.ns.nwaiters != 0)
+ {
+ puts ("nwaiters modified");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Modified: fsf/trunk/libc/stdlib/random_r.c
==============================================================================
--- fsf/trunk/libc/stdlib/random_r.c (original)
+++ fsf/trunk/libc/stdlib/random_r.c Wed Nov 25 00:05:49 2009
@@ -228,7 +228,7 @@
lose this information and will be able to restart with setstate.
Note: The first thing we do is save the current state, if any, just like
setstate so that it doesn't matter when initstate is called.
- Returns a pointer to the old state. */
+ Returns 0 on success, non-zero on failure. */
int
__initstate_r (seed, arg_state, n, buf)
unsigned int seed;
@@ -296,7 +296,7 @@
location into the zeroth word of the state information. Note that due
to the order in which things are done, it is OK to call setstate with the
same state as the current state
- Returns a pointer to the old state information. */
+ Returns 0 on success, non-zero on failure. */
int
__setstate_r (arg_state, buf)
char *arg_state;
Modified: fsf/trunk/libc/sysdeps/unix/grantpt.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/grantpt.c (original)
+++ fsf/trunk/libc/sysdeps/unix/grantpt.c Wed Nov 25 00:05:49 2009
@@ -38,7 +38,7 @@
this buffer, a sufficiently long buffer is allocated using malloc,
and returned in PTS. 0 is returned upon success, -1 otherwise. */
static int
-pts_name (int fd, char **pts, size_t buf_len)
+pts_name (int fd, char **pts, size_t buf_len, struct stat64 *stp)
{
int rv;
char *buf = *pts;
@@ -49,7 +49,7 @@
if (buf_len)
{
- rv = __ptsname_r (fd, buf, buf_len);
+ rv = __ptsname_internal (fd, buf, buf_len, stp);
if (rv != 0)
{
if (rv == ENOTTY)
@@ -108,15 +108,8 @@
#endif
char *buf = _buf;
struct stat64 st;
- char *grtmpbuf;
- struct group grbuf;
- size_t grbuflen = __sysconf (_SC_GETGR_R_SIZE_MAX);
- struct group *p;
- uid_t uid;
- gid_t gid;
- pid_t pid;
-
- if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf)), 0))
+
+ if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf), &st), 0))
{
int save_errno = errno;
@@ -126,34 +119,42 @@
return -1;
/* If the filedescriptor is no TTY, grantpt has to set errno
- to EINVAL. */
+ to EINVAL. */
if (save_errno == ENOTTY)
- __set_errno (EINVAL);
+ __set_errno (EINVAL);
else
__set_errno (save_errno);
return -1;
}
- if (__xstat64 (_STAT_VER, buf, &st) < 0)
- goto cleanup;
-
/* Make sure that we own the device. */
- uid = __getuid ();
+ uid_t uid = __getuid ();
if (st.st_uid != uid)
{
if (__chown (buf, uid, st.st_gid) < 0)
goto helper;
}
- /* Get the group ID of the special `tty' group. */
- if (grbuflen == (size_t) -1L)
- /* `sysconf' does not support _SC_GETGR_R_SIZE_MAX.
- Try a moderate value. */
- grbuflen = 1024;
- grtmpbuf = (char *) __alloca (grbuflen);
- __getgrnam_r (TTY_GROUP, &grbuf, grtmpbuf, grbuflen, &p);
- gid = p ? p->gr_gid : __getgid ();
+ static int tty_gid = -1;
+ if (__builtin_expect (tty_gid == -1, 0))
+ {
+ char *grtmpbuf;
+ struct group grbuf;
+ size_t grbuflen = __sysconf (_SC_GETGR_R_SIZE_MAX);
+ struct group *p;
+
+ /* Get the group ID of the special `tty' group. */
+ if (grbuflen == (size_t) -1L)
+ /* `sysconf' does not support _SC_GETGR_R_SIZE_MAX.
+ Try a moderate value. */
+ grbuflen = 1024;
+ grtmpbuf = (char *) __alloca (grbuflen);
+ __getgrnam_r (TTY_GROUP, &grbuf, grtmpbuf, grbuflen, &p);
+ if (p != NULL)
+ tty_gid = p->gr_gid;
+ }
+ gid_t gid = tty_gid == -1 ? __getgid () : tty_gid;
/* Make sure the group of the device is that special group. */
if (st.st_gid != gid)
@@ -174,9 +175,9 @@
goto cleanup;
/* We have to use the helper program. */
- helper:
-
- pid = __fork ();
+ helper:;
+
+ pid_t pid = __fork ();
if (pid == -1)
goto cleanup;
else if (pid == 0)
@@ -189,6 +190,10 @@
if (fd != PTY_FILENO)
if (__dup2 (fd, PTY_FILENO) < 0)
_exit (FAIL_EBADF);
+
+#ifdef CLOSE_ALL_FDS
+ CLOSE_ALL_FDS ();
+#endif
execle (_PATH_PT_CHOWN, basename (_PATH_PT_CHOWN), NULL, NULL);
_exit (FAIL_EXEC);
Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/grantpt.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/grantpt.c (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/grantpt.c Wed Nov 25 00:05:49 2009
@@ -1,0 +1,42 @@
+#include <assert.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "not-cancel.h"
+#include "pty-private.h"
+
+
+/* Close all file descriptors except the one specified. */
+static void
+close_all_fds (void)
+{
+ DIR *dir = __opendir ("/proc/self/fd");
+ if (dir != NULL)
+ {
+ struct dirent64 *d;
+ while ((d = __readdir64 (dir)) != NULL)
+ if (isdigit (d->d_name[0]))
+ {
+ char *endp;
+ long int fd = strtol (d->d_name, &endp, 10);
+ if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir))
+ close_not_cancel_no_status (fd);
+ }
+
+ __closedir (dir);
+
+ int nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_RDONLY);
+ assert (nullfd == STDIN_FILENO);
+ nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_WRONLY);
+ assert (nullfd == STDOUT_FILENO);
+ __dup2 (STDOUT_FILENO, STDERR_FILENO);
+ }
+}
+#define CLOSE_ALL_FDS() close_all_fds()
+
+#include <sysdeps/unix/grantpt.c>
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/ptsname.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/ptsname.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/ptsname.c Wed Nov 25 00:05:49 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Zack Weinberg <zack@xxxxxxxxxxxxxxxxxxxxxx>, 1998.
@@ -67,14 +67,10 @@
}
-/* Store at most BUFLEN characters of the pathname of the slave pseudo
- terminal associated with the master FD is open on in BUF.
- Return 0 on success, otherwise an error number. */
int
-__ptsname_r (int fd, char *buf, size_t buflen)
+__ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
{
int save_errno = errno;
- struct stat64 st;
unsigned int ptyno;
if (buf == NULL)
@@ -93,7 +89,7 @@
if (__ioctl (fd, TIOCGPTN, &ptyno) == 0)
{
/* Buffer we use to print the number in. For a maximum size for
- `int' of 8 bytes we never need more than 20 digits. */
+ `int' of 8 bytes we never need more than 20 digits. */
char numbuf[21];
const char *devpts = _PATH_DEVPTS;
const size_t devptslen = strlen (_PATH_DEVPTS);
@@ -121,20 +117,20 @@
return ERANGE;
}
- if (__fxstat64 (_STAT_VER, fd, &st) < 0)
+ if (__fxstat64 (_STAT_VER, fd, stp) < 0)
return errno;
/* Check if FD really is a master pseudo terminal. */
- if (! MASTER_P (st.st_rdev))
+ if (! MASTER_P (stp->st_rdev))
{
__set_errno (ENOTTY);
return ENOTTY;
}
- ptyno = minor (st.st_rdev);
+ ptyno = minor (stp->st_rdev);
/* This is for the old BSD pseudo terminals. As of Linux
- 2.1.115 these are no longer supported. */
- if (major (st.st_rdev) == 4)
+ 2.1.115 these are no longer supported. */
+ if (major (stp->st_rdev) == 4)
ptyno -= 128;
if (ptyno / 16 >= strlen (__libc_ptyname1))
@@ -149,12 +145,12 @@
p[2] = '\0';
}
- if (__xstat64 (_STAT_VER, buf, &st) < 0)
+ if (__xstat64 (_STAT_VER, buf, stp) < 0)
return errno;
/* Check if the name we're about to return really corresponds to a
slave pseudo terminal. */
- if (! S_ISCHR (st.st_mode) || ! SLAVE_P (st.st_rdev))
+ if (! S_ISCHR (stp->st_mode) || ! SLAVE_P (stp->st_rdev))
{
/* This really is a configuration problem. */
__set_errno (ENOTTY);
@@ -164,4 +160,15 @@
__set_errno (save_errno);
return 0;
}
+
+
+/* Store at most BUFLEN characters of the pathname of the slave pseudo
+ terminal associated with the master FD is open on in BUF.
+ Return 0 on success, otherwise an error number. */
+int
+__ptsname_r (int fd, char *buf, size_t buflen)
+{
+ struct stat64 st;
+ return __ptsname_internal (fd, buf, buflen, &st);
+}
weak_alias (__ptsname_r, ptsname_r)