SHA256
1
0
forked from pool/glibc

Accepting request 73973 from Base:System

Various cleanups

OBS-URL: https://build.opensuse.org/request/show/73973
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/glibc?expand=0&rev=49
This commit is contained in:
Sascha Peilicke 2011-06-17 09:13:35 +00:00 committed by Git OBS Bridge
parent 2a2a7be7ab
commit 170d79deda
4 changed files with 424 additions and 22 deletions

View File

@ -13,7 +13,16 @@ Index: sysdeps/posix/getaddrinfo.c
{
const struct gaih_typeproto *tp = gaih_inet_typeproto;
struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv;
@@ -766,7 +766,7 @@ gaih_inet (const char *name, const struc
@@ -706,7 +706,7 @@ gaih_inet (const char *name, const struc
no_data = 0;
nss_gethostbyname4_r fct4
= __nss_lookup_function (nip, "gethostbyname4_r");
- if (fct4 != NULL)
+ if (fct4 != NULL && usable_ipv6)
{
int herrno;
@@ -763,7 +763,7 @@ gaih_inet (const char *name, const struc
if (fct != NULL)
{
if (req->ai_family == AF_INET6
@ -22,7 +31,7 @@ Index: sysdeps/posix/getaddrinfo.c
{
gethosts (AF_INET6, struct in6_addr);
no_inet6_data = no_data;
@@ -2157,7 +2157,7 @@ getaddrinfo (const char *name, const cha
@@ -2156,7 +2156,7 @@ getaddrinfo (const char *name, const cha
if (hints->ai_family == AF_UNSPEC || hints->ai_family == AF_INET
|| hints->ai_family == AF_INET6)
{

320
glibc-2.13-dl-load.patch Normal file
View File

@ -0,0 +1,320 @@
2011-05-11 Ulrich Drepper <drepper@gmail.com>
[BZ #12393]
* elf/dl-load.c (is_trusted_path): Remove unnecessary test.
(is_trusted_path_normalize): Skip initial colon. Append slash
to empty buffer. Duplicate is_trusted_path code but allow
constructed patch to be prefix.
(is_dst): Allow $ORIGIN followed by /.
(_dl_dst_substitute): Correct clearing of check_for_trusted.
Correct testing of result of is_trusted_path_normalize
(decompose_rpath): Fix warning.
2011-05-07 Petr Baudis <pasky@suse.cz>
Ulrich Drepper <drepper@gmail.com>
[BZ #12393]
* elf/dl-load.c (fillin_rpath): Move trusted path check...
(is_trusted_path): ...to here.
(is_trusted_path_normalize): Wrapper for /../ and /./ normalization.
(_dl_dst_substitute): Verify expanded $ORIGIN path elements
using is_trusted_path_normalize() in setuid scripts.
2011-03-14 Andreas Schwab <schwab@redhat.com>
* elf/dl-load.c (_dl_dst_substitute): When skipping the first
rpath element also skip the following colon.
(expand_dynamic_string_token): Add is_path parameter and pass
down to DL_DST_REQUIRED and _dl_dst_substitute.
(decompose_rpath): Call expand_dynamic_string_token with
non-zero is_path. Ignore empty rpaths.
(_dl_map_object_from_fd): Call expand_dynamic_string_token
with zero is_path.
2011-03-06 Ulrich Drepper <drepper@gmail.com>
* elf/dl-load.c (_dl_map_object): If we are looking for the first
to-be-loaded object along a path to loader is ld.so.
--- glibc-2.13/elf/dl-load.c 2011-05-20 21:53:43.766426054 +0200
+++ glibc-2.14/elf/dl-load.c 2011-05-31 09:59:16.781617374 +0200
@@ -1,5 +1,5 @@
/* Map in a shared object's segments from the file.
- Copyright (C) 1995-2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1995-2007, 2009, 2010, 2011 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
@@ -168,6 +168,87 @@ local_strdup (const char *s)
}
+static bool
+is_trusted_path (const char *path, size_t len)
+{
+ const char *trun = system_dirs;
+
+ for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
+ {
+ if (len == system_dirs_len[idx] && memcmp (trun, path, len) == 0)
+ /* Found it. */
+ return true;
+
+ trun += system_dirs_len[idx] + 1;
+ }
+
+ return false;
+}
+
+
+static bool
+is_trusted_path_normalize (const char *path, size_t len)
+{
+ if (len == 0)
+ return false;
+
+ if (*path == ':')
+ {
+ ++path;
+ --len;
+ }
+
+ char *npath = (char *) alloca (len + 2);
+ char *wnp = npath;
+ while (*path != '\0')
+ {
+ if (path[0] == '/')
+ {
+ if (path[1] == '.')
+ {
+ if (path[2] == '.' && (path[3] == '/' || path[3] == '\0'))
+ {
+ while (wnp > npath && *--wnp != '/')
+ ;
+ path += 3;
+ continue;
+ }
+ else if (path[2] == '/' || path[2] == '\0')
+ {
+ path += 2;
+ continue;
+ }
+ }
+
+ if (wnp > npath && wnp[-1] == '/')
+ {
+ ++path;
+ continue;
+ }
+ }
+
+ *wnp++ = *path++;
+ }
+
+ if (wnp == npath || wnp[-1] != '/')
+ *wnp++ = '/';
+
+ const char *trun = system_dirs;
+
+ for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
+ {
+ if (wnp - npath >= system_dirs_len[idx]
+ && memcmp (trun, npath, system_dirs_len[idx]) == 0)
+ /* Found it. */
+ return true;
+
+ trun += system_dirs_len[idx] + 1;
+ }
+
+ return false;
+}
+
+
static size_t
is_dst (const char *start, const char *name, const char *str,
int is_path, int secure)
@@ -200,7 +281,8 @@ is_dst (const char *start, const char *n
return 0;
if (__builtin_expect (secure, 0)
- && ((name[len] != '\0' && (!is_path || name[len] != ':'))
+ && ((name[len] != '\0' && name[len] != '/'
+ && (!is_path || name[len] != ':'))
|| (name != start + 1 && (!is_path || name[-2] != ':'))))
return 0;
@@ -240,13 +322,14 @@ _dl_dst_substitute (struct link_map *l,
int is_path)
{
const char *const start = name;
- char *last_elem, *wp;
/* Now fill the result path. While copying over the string we keep
track of the start of the last path element. When we come accross
a DST we copy over the value or (if the value is not available)
leave the entire path element out. */
- last_elem = wp = result;
+ char *wp = result;
+ char *last_elem = result;
+ bool check_for_trusted = false;
do
{
@@ -265,6 +348,9 @@ _dl_dst_substitute (struct link_map *l,
else
#endif
repl = l->l_origin;
+
+ check_for_trusted = (INTUSE(__libc_enable_secure)
+ && l->l_type == lt_executable);
}
else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
repl = GLRO(dl_platform);
@@ -284,6 +370,10 @@ _dl_dst_substitute (struct link_map *l,
name += len;
while (*name != '\0' && (!is_path || *name != ':'))
++name;
+ /* Also skip following colon if this is the first rpath
+ element, but keep an empty element at the end. */
+ if (wp == result && is_path && *name == ':' && name[1] != '\0')
+ ++name;
}
else
/* No DST we recognize. */
@@ -293,11 +383,28 @@ _dl_dst_substitute (struct link_map *l,
{
*wp++ = *name++;
if (is_path && *name == ':')
- last_elem = wp;
+ {
+ /* In SUID/SGID programs, after $ORIGIN expansion the
+ normalized path must be rooted in one of the trusted
+ directories. */
+ if (__builtin_expect (check_for_trusted, false)
+ && !is_trusted_path_normalize (last_elem, wp - last_elem))
+ wp = last_elem;
+ else
+ last_elem = wp;
+
+ check_for_trusted = false;
+ }
}
}
while (*name != '\0');
+ /* In SUID/SGID programs, after $ORIGIN expansion the normalized
+ path must be rooted in one of the trusted directories. */
+ if (__builtin_expect (check_for_trusted, false)
+ && !is_trusted_path_normalize (last_elem, wp - last_elem))
+ wp = last_elem;
+
*wp = '\0';
return result;
@@ -310,7 +417,7 @@ _dl_dst_substitute (struct link_map *l,
belonging to the map is loaded. In this case the path element
containing $ORIGIN is left out. */
static char *
-expand_dynamic_string_token (struct link_map *l, const char *s)
+expand_dynamic_string_token (struct link_map *l, const char *s, int is_path)
{
/* We make two runs over the string. First we determine how large the
resulting string is and then we copy it over. Since this is no
@@ -321,7 +428,7 @@ expand_dynamic_string_token (struct link
char *result;
/* Determine the number of DST elements. */
- cnt = DL_DST_COUNT (s, 1);
+ cnt = DL_DST_COUNT (s, is_path);
/* If we do not have to replace anything simply copy the string. */
if (__builtin_expect (cnt, 0) == 0)
@@ -335,7 +442,7 @@ expand_dynamic_string_token (struct link
if (result == NULL)
return NULL;
- return _dl_dst_substitute (l, s, result, 1);
+ return _dl_dst_substitute (l, s, result, is_path);
}
@@ -407,33 +514,8 @@ fillin_rpath (char *rpath, struct r_sear
cp[len++] = '/';
/* Make sure we don't use untrusted directories if we run SUID. */
- if (__builtin_expect (check_trusted, 0))
- {
- const char *trun = system_dirs;
- size_t idx;
- int unsecure = 1;
-
- /* All trusted directories must be complete names. */
- if (cp[0] == '/')
- {
- for (idx = 0; idx < nsystem_dirs_len; ++idx)
- {
- if (len == system_dirs_len[idx]
- && memcmp (trun, cp, len) == 0)
- {
- /* Found it. */
- unsecure = 0;
- break;
- }
-
- trun += system_dirs_len[idx] + 1;
- }
- }
-
- if (unsecure)
- /* Simply drop this directory. */
- continue;
- }
+ if (__builtin_expect (check_trusted, 0) && !is_trusted_path (cp, len))
+ continue;
/* See if this directory is already known. */
for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)
@@ -551,13 +633,21 @@ decompose_rpath (struct r_search_path_st
/* Make a writable copy. At the same time expand possible dynamic
string tokens. */
- copy = expand_dynamic_string_token (l, rpath);
+ copy = expand_dynamic_string_token (l, rpath, 1);
if (copy == NULL)
{
errstring = N_("cannot create RUNPATH/RPATH copy");
goto signal_error;
}
+ /* Ignore empty rpaths. */
+ if (*copy == 0)
+ {
+ free (copy);
+ sps->dirs = (struct r_search_path_elem **) -1;
+ return false;
+ }
+
/* Count the number of necessary elements in the result array. */
nelems = 0;
for (cp = copy; *cp != '\0'; ++cp)
@@ -2109,7 +2201,9 @@ _dl_map_object (struct link_map *loader,
{
#ifdef SHARED
// XXX Correct to unconditionally default to namespace 0?
- l = loader ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+ l = (loader
+ ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded
+ ?: &GL(dl_rtld_map));
#else
l = loader;
#endif
@@ -2175,7 +2269,7 @@ _dl_map_object (struct link_map *loader,
{
/* The path may contain dynamic string tokens. */
realname = (loader
- ? expand_dynamic_string_token (loader, name)
+ ? expand_dynamic_string_token (loader, name, 0)
: local_strdup (name));
if (realname == NULL)
fd = -1;

View File

@ -1,3 +1,25 @@
-------------------------------------------------------------------
Fri Jun 17 07:07:37 UTC 2011 - aj@suse.de
- Do not package memusage and memusagestat since they require
lib-gd and that grows the build cycle.
-------------------------------------------------------------------
Thu Jun 16 18:37:19 UTC 2011 - aj@suse.de
- Fix handling of shared library preloading.
-------------------------------------------------------------------
Thu Jun 16 13:33:23 UTC 2011 - aj@suse.de
- Fix getaddrinfo IPv6 code (bnc#684534).
- Split up glibc-devel-static subpackage (bnc#655261).
-------------------------------------------------------------------
Thu Jun 16 12:23:32 UTC 2011 - aj@suse.de
- Reorder ld.so.conf library list (bnc#671725).
-------------------------------------------------------------------
Wed Jun 15 07:08:35 UTC 2011 - aj@suse.de

View File

@ -19,11 +19,8 @@
Name: glibc
BuildRequires: gcc-c++
BuildRequires: gd-devel
BuildRequires: libpng-devel
BuildRequires: libselinux-devel
BuildRequires: libstdc++-devel
BuildRequires: zlib-devel
%define _filter_GLIBC_PRIVATE 1
%define build_locales 1
%define run_testsuite 0
@ -149,7 +146,7 @@ Patch27: glibc-2.6-configure.diff
Patch28: glibc-2.2-sunrpc.diff
# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch29: glibc-2.8-getconf.diff
# PATCH-FIX-OPENSUSE only use ipv6 if real ipv6 address exists bnc#361697
# PATCH-FIX-OPENSUSE only use ipv6 if real ipv6 address exists bnc#361697, bnc#684534
Patch30: getaddrinfo-ipv6-sanity.diff
# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch31: ppc-atomic.diff
@ -199,6 +196,8 @@ Patch55: glibc-bso-12454.diff
Patch56: glibc-static-memcpy.diff
# FIX-OPENSUSE compile some files with -fno-strict-aliasing
Patch58: glibc-strict-aliasing.diff
# PATCH-FIX-UPSTREAM fix preloading of shared libs aj@suse.de
Patch59: glibc-2.13-dl-load.patch
# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch500: ARM_glibc-2.10.1-local-eabi-wchar.diff
# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines
@ -208,6 +207,7 @@ Patch502: ARM_glibc-2.10.1-local-lowlevellock.diff
# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines
Patch503: ARM_glibc-2.10.1-local-no-hwcap.diff
%description
The GNU C Library provides the most important standard libraries used
by nearly all programs: the standard C library, the standard math
@ -220,6 +220,7 @@ Summary: Info Files for the GNU C Library
Group: Documentation/Other
PreReq: %{install_info_prereq}
%description info
This package contains the documentation for the GNU C library stored as
info files. Due to a lack of resources, this documentation is not
@ -230,6 +231,7 @@ License: GPLv2+ ; LGPLv2.1+
Summary: HTML Documentation for the GNU C Library
Group: Documentation/HTML
%description html
This package contains the HTML documentation for the GNU C library. Due
to a lack of resources, this documentation is not complete and is
@ -240,6 +242,7 @@ License: LGPLv2.1+
Summary: Database Sources for 'locale'
Group: System/Libraries
%description i18ndata
This package contains the data needed to build the locale data files to
use the internationalization features of the GNU libc. It is normally
@ -260,6 +263,7 @@ Obsoletes: glibc-locale-64bit
Obsoletes: glibc-locale-32bit
%endif
%description locale
Locale data for the internationalisation features of the GNU C library.
@ -271,6 +275,7 @@ Provides: aaa_base:/etc/init.d/nscd
Provides: glibc:/usr/sbin/nscd
PreReq: %insserv_prereq
%description -n nscd
Nscd caches name service lookups and can dramatically improve
performance with NIS, NIS+, and LDAP.
@ -288,6 +293,7 @@ Obsoletes: glibc-profile-64bit
Obsoletes: glibc-profile-32bit
%endif
%description profile
This package contains special versions of the GNU C library which are
necessary for profiling and debugging.
@ -308,16 +314,31 @@ Obsoletes: glibc-devel-32bit
PreReq: /bin/rm
Requires: glibc = %{version}, linux-kernel-headers
%description devel
These libraries are needed to develop programs which use the standard C
library.
%package devel-static
Summary: C library static libraries for -static linking
Group: Development/Libraries/C and C++
Requires: %{name}-devel = %{version}
%description devel-static
The glibc-devel-static package contains the C library static libraries
for -static linking. You don't need these, unless you link statically,
which is highly discouraged.
%package utils
License: BSD3c(or similar) ; GPLv2+ ; LGPLv2.1+
Summary: Development utilities from GNU C library
Group: Development/Languages/C and C++
Requires: glibc = %{version}
%description utils
The glibc-utils package contains memusage, a memory usage profiler,
mtrace, a memory leak tracer and xtrace, a function call tracer
@ -327,12 +348,14 @@ If you are unsure if you need this, don't install this package.
%ifarch %ix86
%package obsolete
License: BSD3c(or similar) ; GPLv2+ ; LGPLv2.1+
Summary: Obsolete Shared Libraries from the GNU C Library
Group: System/Libraries
Requires: glibc = %{version}
%description obsolete
This package provides some old libraries from the GNU C Library which
are no longer supported. Additional it provides a compatibility library
@ -345,6 +368,7 @@ versions of your software.
%endif
%prep
%ifarch %arm armv5tel armv7l
# add glibc-ports for arm
@ -418,6 +442,7 @@ rm nscd/s-stamp
%patch55 -p1
%patch56 -p1
%patch58
%patch59 -p1
%ifarch %arm armv5tel armv7l
%patch500
%patch501
@ -450,6 +475,7 @@ find . -name configure | xargs touch
###
#######################################################################
%build
if [ -x /bin/uname.bin ]; then
/bin/uname.bin -a
@ -625,6 +651,7 @@ $BuildCC -static $RPM_OPT_FLAGS -Os $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glib
###
#######################################################################
%check
%if %{run_testsuite}
# Increase timeout
@ -647,6 +674,7 @@ make -C cc-base check-abi || echo check-abi failed
###
#######################################################################
%install
# We don't want to strip the .symtab from our libraries in find-debuginfo.sh,
# certainly not from libpthread.so.* because it is used by libthread_db to find
@ -772,12 +800,8 @@ touch $RPM_BUILD_ROOT/var/run/nscd/{socket,nscd.pid}
#
cat > $RPM_BUILD_ROOT/etc/ld.so.conf <<EOF
%ifarch s390x sparc64 x86_64 ppc64 ppc
#/usr/X11R6/lib64/Xaw3d
#/usr/X11R6/lib64
/usr/lib64/Xaw3d
%endif
#/usr/X11R6/lib/Xaw3d
#/usr/X11R6/lib
/usr/lib/Xaw3d
%ifarch %x86
/usr/i586-suse-linux/lib
@ -789,16 +813,16 @@ cat > $RPM_BUILD_ROOT/etc/ld.so.conf <<EOF
/usr/$RPM_ARCH-suse-linux/lib
%endif
%endif
/usr/local/lib
/opt/kde3/lib
%ifarch s390x sparc64 x86_64 ppc64 ppc
/lib64
/lib
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/opt/kde3/lib64
%endif
/opt/kde3/lib
include /etc/ld.so.conf.d/*.conf
EOF
# Add ldconfig cache directory for directory ownership
@ -834,6 +858,7 @@ done
###
#######################################################################
%clean
rm -rf $RPM_BUILD_ROOT
@ -841,10 +866,13 @@ rm -rf $RPM_BUILD_ROOT
# %set_permissions %{_libdir}/pt_chown
# since we cannot do it in our own post section
%post -p %{_sbindir}/glibc_post_upgrade
%postun -p /sbin/ldconfig
%post locale
for l in /usr/share/locale/locale.alias %{_libdir}/gconv/gconv-modules; do
[ -d "$l.d" ] || continue
@ -853,19 +881,24 @@ for l in /usr/share/locale/locale.alias %{_libdir}/gconv/gconv-modules; do
done
/usr/sbin/iconvconfig
%post info
%install_info --info-dir=%{_infodir} %{_infodir}/libc.info.gz
%postun info
%install_info_delete --info-dir=%{_infodir} %{_infodir}/libc.info.gz
%preun -n nscd
%stop_on_removal nscd
%post -n nscd
%{insserv_force_if_yast nscd}
mkdir -p /var/run/nscd
%postun -n nscd
%restart_on_update nscd
%insserv_cleanup
@ -882,6 +915,7 @@ exit 0
# glibc
%files
%defattr(-,root,root)
%doc LICENSES
@ -1009,6 +1043,7 @@ exit 0
%ifarch %ix86
%files obsolete
%defattr (755,root,root,755)
%dir /%{_lib}/obsolete/
@ -1017,6 +1052,7 @@ exit 0
/%{_lib}/obsolete/noversion/libNoVersion.so.1
%endif
%files locale -f libc.lang
%defattr(-,root,root)
/usr/share/locale/locale.alias
@ -1025,6 +1061,7 @@ exit 0
%endif
%{_libdir}/gconv
%files devel
%defattr(-,root,root)
%doc COPYING COPYING.LIB FAQ INSTALL NEWS NOTES README BUGS CONFORMANCE
@ -1038,43 +1075,52 @@ exit 0
%{_prefix}/include/*
%{_libdir}/*.o
%{_libdir}/*.so
%{_libdir}/libBrokenLocale.a
%{_libdir}/libanl.a
# These static libraries are needed even for shared builds
%{_libdir}/libbsd-compat.a
%{_libdir}/libc.a
%{_libdir}/libc_nonshared.a
%{_libdir}/libcrypt.a
%{_libdir}/libdl.a
%{_libdir}/libg.a
%{_libdir}/libieee.a
%ifarch ppc ppc64 s390 s390x sparc sparcv8 sparcv9 sparcv9v
# This is not built on sparc64.
%{_libdir}/libnldbl_nonshared.a
%endif
%{_libdir}/libm.a
%{_libdir}/libmcheck.a
%{_libdir}/libpthread_nonshared.a
%{_libdir}/librpcsvc.a
%files devel-static
%defattr(-,root,root)
%{_libdir}/libBrokenLocale.a
%{_libdir}/libanl.a
%{_libdir}/libc.a
%{_libdir}/libcrypt.a
%{_libdir}/libdl.a
%{_libdir}/libm.a
%{_libdir}/libnsl.a
%{_libdir}/libpthread.a
%{_libdir}/libpthread_nonshared.a
%{_libdir}/libresolv.a
%{_libdir}/librpcsvc.a
%{_libdir}/librt.a
%{_libdir}/libutil.a
%files info
%defattr(-,root,root)
%doc %{_infodir}/libc.info.gz
%doc %{_infodir}/libc.info-?.gz
%doc %{_infodir}/libc.info-??.gz
%files html
%defattr(-,root,root)
%doc %{_prefix}/share/doc/glibc
%files i18ndata
%defattr(-,root,root)
%{_prefix}/share/i18n
%files -n nscd
%defattr(-,root,root)
%config(noreplace) /etc/nscd.conf
@ -1090,6 +1136,7 @@ exit 0
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/group
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/run/nscd/hosts
%files profile
%defattr(-,root,root)
%{_libdir}/libc_p.a
@ -1105,14 +1152,18 @@ exit 0
%{_libdir}/libutil_p.a
%{_libdir}/libdl_p.a
%files utils
%defattr(-,root,root)
/%{_lib}/libmemusage.so
/%{_lib}/libpcprofile.so
%{_bindir}/memusage
%{_bindir}/memusagestat
# These need gd-devel for building
#%{_bindir}/memusage
#%{_bindir}/memusagestat
%{_bindir}/mtrace
%{_bindir}/pcprofiledump
%{_bindir}/xtrace
%changelog