Commit fb920cc9 authored by stskeeps's avatar stskeeps

For SB2-OBS integration: glibc-2.14.1-elf-rtld.c.1.diff

glibc-2.14.1-ldso-nodefaultdirs-option.5.diff
glibc-2.14.1-ldso-rpath-prefix-option.2.diff
glibc-2.14.1-nscd-socket-location.4.diff
glibc-2.14.1-nsswitchconf-location.3.diff
Signed-off-by: stskeeps's avatarCarsten Munk <carsten.munk@gmail.com>
parent 608b5c93
diff -ur glibc-2.14.1-orig/elf/rtld.c glibc-2.14.1/elf/rtld.c
--- glibc-2.14.1-orig/elf/rtld.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/elf/rtld.c 2011-11-16 17:00:19.000000000 +0200
@@ -930,6 +930,7 @@
if (*user_entry == (ElfW(Addr)) ENTRY_POINT)
{
+ const char *forced_argv0 = NULL;
/* Ho ho. We are not the program interpreter! We are the program
itself! This means someone ran ld.so as a command. Well, that
might be convenient to do sometimes. We support it by
@@ -994,6 +995,14 @@
_dl_argc -= 2;
INTUSE(_dl_argv) += 2;
}
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--argv0") && _dl_argc > 2)
+ {
+ forced_argv0 = INTUSE(_dl_argv)[2];
+
+ _dl_skip_args += 2;
+ _dl_argc -= 2;
+ INTUSE(_dl_argv) += 2;
+ }
else
break;
@@ -1021,6 +1030,7 @@
variable LD_LIBRARY_PATH\n\
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
in LIST\n\
+ --argv0 STRING use STRING as argv[0]\n\
--audit LIST use objects named in LIST as auditors\n");
++_dl_skip_args;
@@ -1073,6 +1083,8 @@
HP_TIMING_DIFF (load_time, start, stop);
}
+ if (forced_argv0 != NULL) _dl_argv[0] = forced_argv0;
+
/* Now the map for the main executable is available. */
main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
diff -ur glibc-2.14.1+p4/elf/dl-load.c glibc-2.14.1/elf/dl-load.c
--- glibc-2.14.1+p4/elf/dl-load.c 2011-11-16 17:07:07.000000000 +0200
+++ glibc-2.14.1/elf/dl-load.c 2011-11-16 17:26:58.000000000 +0200
@@ -2252,7 +2252,8 @@
/* 'l' is always != NULL for dynamically linked objects. */
l != NULL &&
#endif
- __builtin_expect (l->l_flags_1 & DF_1_NODEFLIB, 0))
+ __builtin_expect (((l->l_flags_1 & DF_1_NODEFLIB) ||
+ GLRO(dl_no_default_dirs)), 0))
{
const char *dirp = system_dirs;
unsigned int cnt = 0;
@@ -2293,7 +2294,8 @@
/* Finally, try the default path. */
if (fd == -1
&& ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
- || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
+ || __builtin_expect (!((l->l_flags_1 & DF_1_NODEFLIB) ||
+ GLRO(dl_no_default_dirs)), 1))
&& rtld_search_dirs.dirs != (void *) -1)
fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs,
&realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
@@ -2459,7 +2461,7 @@
a way to indicate that in the results for Dl_serinfo. */
/* Finally, try the default path. */
- if (!(loader->l_flags_1 & DF_1_NODEFLIB))
+ if (!((loader->l_flags_1 & DF_1_NODEFLIB) || GLRO(dl_no_default_dirs)))
add_path (&rtld_search_dirs, XXX_default);
if (counting)
diff -ur glibc-2.14.1+p4/elf/dl-support.c glibc-2.14.1/elf/dl-support.c
--- glibc-2.14.1+p4/elf/dl-support.c 2011-11-16 17:07:07.000000000 +0200
+++ glibc-2.14.1/elf/dl-support.c 2011-11-16 17:26:58.000000000 +0200
@@ -60,6 +60,9 @@
/* prefix to be added to all RUNPATHs and RPATHs */
const char *_dl_rpath_prefix = NULL;
+/* flag: don't search default directories if set. */
+int _dl_no_default_dirs = 0;
+
/* The map for the object we will profile. */
struct link_map *_dl_profile_map;
diff -ur glibc-2.14.1+p4/elf/rtld.c glibc-2.14.1/elf/rtld.c
--- glibc-2.14.1+p4/elf/rtld.c 2011-11-16 17:08:18.000000000 +0200
+++ glibc-2.14.1/elf/rtld.c 2011-11-16 17:28:14.000000000 +0200
@@ -969,6 +969,15 @@
--_dl_argc;
++INTUSE(_dl_argv);
}
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--nodefaultdirs")
+ && _dl_argc > 2)
+ {
+ GLRO(dl_no_default_dirs) = 1;
+
+ ++_dl_skip_args;
+ --_dl_argc;
+ ++INTUSE(_dl_argv);
+ }
else if (! strcmp (INTUSE(_dl_argv)[1], "--library-path")
&& _dl_argc > 2)
{
@@ -1035,6 +1044,7 @@
--list list all dependencies and how they are resolved\n\
--verify verify that given object really is a dynamically linked\n\
object we can handle\n\
+ --nodefaultdirs Do not search from default directories or cache\n\
--library-path PATH use given PATH instead of content of the environment\n\
variable LD_LIBRARY_PATH\n\
--rpath-prefix PREFIX add PREFIX to every RUNPATH and RPATH component\n\
diff -ur glibc-2.14.1+p4/sysdeps/generic/ldsodefs.h glibc-2.14.1/sysdeps/generic/ldsodefs.h
--- glibc-2.14.1+p4/sysdeps/generic/ldsodefs.h 2011-11-16 17:07:07.000000000 +0200
+++ glibc-2.14.1/sysdeps/generic/ldsodefs.h 2011-11-16 17:26:58.000000000 +0200
@@ -692,6 +692,8 @@
/* prefix for RPATH + RUNPATH components. */
EXTERN const char *_dl_rpath_prefix;
+ EXTERN int _dl_no_default_dirs;
+
#ifdef SHARED
};
# define __rtld_global_attribute__
diff -ur glibc-2.14.1+p1/elf/dl-load.c glibc-2.14.1/elf/dl-load.c
--- glibc-2.14.1+p1/elf/dl-load.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/elf/dl-load.c 2011-11-16 17:07:07.000000000 +0200
@@ -487,7 +487,8 @@
static struct r_search_path_elem **
fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
- int check_trusted, const char *what, const char *where)
+ int check_trusted, const char *what, const char *where,
+ const char *rpath_prefix)
{
char *cp;
size_t nelems = 0;
@@ -518,9 +519,23 @@
continue;
/* See if this directory is already known. */
- for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)
- if (dirp->dirnamelen == len && memcmp (cp, dirp->dirname, len) == 0)
- break;
+ if (__builtin_expect (rpath_prefix != NULL, 0))
+ {
+ /* has rpath_prefix */
+ size_t rpath_prefix_len = strlen (rpath_prefix);
+
+ for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)
+ if (dirp->dirnamelen == (rpath_prefix_len+len) &&
+ (memcmp (cp, rpath_prefix, rpath_prefix_len) == 0) &&
+ (memcmp (cp+rpath_prefix_len, dirp->dirname, len) == 0))
+ break;
+ }
+ else
+ {
+ for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)
+ if (dirp->dirnamelen == len && memcmp (cp, dirp->dirname, len) == 0)
+ break;
+ }
if (dirp != NULL)
{
@@ -538,22 +553,43 @@
size_t cnt;
enum r_dir_status init_val;
size_t where_len = where ? strlen (where) + 1 : 0;
+ size_t rpath_prefix_len = 0;
+
+ if (__builtin_expect (rpath_prefix != NULL, 0)
+ && !INTUSE(__libc_enable_secure))
+ {
+ rpath_prefix_len = strlen (rpath_prefix);
+ if (*cp != '/') rpath_prefix_len++; /* need to add a '/' */
+ }
/* It's a new directory. Create an entry and add it. */
dirp = (struct r_search_path_elem *)
malloc (sizeof (*dirp) + ncapstr * sizeof (enum r_dir_status)
- + where_len + len + 1);
+ + where_len + rpath_prefix_len + len + 1);
if (dirp == NULL)
_dl_signal_error (ENOMEM, NULL, NULL,
N_("cannot create cache for search path"));
dirp->dirname = ((char *) dirp + sizeof (*dirp)
+ ncapstr * sizeof (enum r_dir_status));
- *((char *) __mempcpy ((char *) dirp->dirname, cp, len)) = '\0';
- dirp->dirnamelen = len;
+ if (rpath_prefix_len == 0)
+ {
+ *((char *) __mempcpy ((char *) dirp->dirname, cp, len)) = '\0';
+ }
+ else
+ {
+ char *prefixend;
+
+ prefixend = (char *) __mempcpy ((char *) dirp->dirname,
+ rpath_prefix, rpath_prefix_len);
+ if (*cp != '/')
+ prefixend[-1] = '/'; /* replace \0 */
+ *((char *) __mempcpy (prefixend, cp, len)) = '\0';
+ }
+ dirp->dirnamelen = len + rpath_prefix_len;
- if (len > max_dirnamelen)
- max_dirnamelen = len;
+ if ((len + rpath_prefix_len) > max_dirnamelen)
+ max_dirnamelen = len + rpath_prefix_len;
/* We have to make sure all the relative directories are
never ignored. The current directory might change and
@@ -564,7 +600,8 @@
dirp->what = what;
if (__builtin_expect (where != NULL, 1))
- dirp->where = memcpy ((char *) dirp + sizeof (*dirp) + len + 1
+ dirp->where = memcpy ((char *) dirp + sizeof (*dirp)
+ + rpath_prefix_len + len + 1
+ (ncapstr * sizeof (enum r_dir_status)),
where, where_len);
else
@@ -666,7 +703,7 @@
_dl_signal_error (ENOMEM, NULL, NULL, errstring);
}
- fillin_rpath (copy, result, ":", 0, what, where);
+ fillin_rpath (copy, result, ":", 0, what, where, GLRO(dl_rpath_prefix));
/* Free the copied RPATH string. `fillin_rpath' make own copies if
necessary. */
@@ -865,7 +902,7 @@
(void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;",
INTUSE(__libc_enable_secure), "LD_LIBRARY_PATH",
- NULL);
+ NULL, NULL/*no prefix*/);
if (env_path_list.dirs[0] == NULL)
{
diff -ur glibc-2.14.1+p1/elf/dl-support.c glibc-2.14.1/elf/dl-support.c
--- glibc-2.14.1+p1/elf/dl-support.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/elf/dl-support.c 2011-11-16 17:07:07.000000000 +0200
@@ -57,6 +57,9 @@
ignored. */
const char *_dl_inhibit_rpath;
+/* prefix to be added to all RUNPATHs and RPATHs */
+const char *_dl_rpath_prefix = NULL;
+
/* The map for the object we will profile. */
struct link_map *_dl_profile_map;
diff -ur glibc-2.14.1+p1/elf/rtld.c glibc-2.14.1/elf/rtld.c
--- glibc-2.14.1+p1/elf/rtld.c 2011-11-16 17:00:19.000000000 +0200
+++ glibc-2.14.1/elf/rtld.c 2011-11-16 17:08:18.000000000 +0200
@@ -987,6 +987,15 @@
_dl_argc -= 2;
INTUSE(_dl_argv) += 2;
}
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--rpath-prefix")
+ && _dl_argc > 2)
+ {
+ GLRO(dl_rpath_prefix) = INTUSE(_dl_argv)[2];
+
+ _dl_skip_args += 2;
+ _dl_argc -= 2;
+ INTUSE(_dl_argv) += 2;
+ }
else if (! strcmp (INTUSE(_dl_argv)[1], "--audit") && _dl_argc > 2)
{
process_dl_audit (INTUSE(_dl_argv)[2]);
@@ -1028,6 +1037,7 @@
object we can handle\n\
--library-path PATH use given PATH instead of content of the environment\n\
variable LD_LIBRARY_PATH\n\
+ --rpath-prefix PREFIX add PREFIX to every RUNPATH and RPATH component\n\
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
in LIST\n\
--argv0 STRING use STRING as argv[0]\n\
diff -ur glibc-2.14.1+p1/sysdeps/generic/ldsodefs.h glibc-2.14.1/sysdeps/generic/ldsodefs.h
--- glibc-2.14.1+p1/sysdeps/generic/ldsodefs.h 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/sysdeps/generic/ldsodefs.h 2011-11-16 17:07:07.000000000 +0200
@@ -687,6 +687,12 @@
/* 0 if internal pointer values should not be guarded, 1 if they should. */
EXTERN int _dl_pointer_guard;
+#endif
+
+ /* prefix for RPATH + RUNPATH components. */
+ EXTERN const char *_dl_rpath_prefix;
+
+#ifdef SHARED
};
# define __rtld_global_attribute__
# ifdef IS_IN_rtld
diff -ur glibc-2.14.1+p3/nscd/connections.c glibc-2.14.1/nscd/connections.c
--- glibc-2.14.1+p3/nscd/connections.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/nscd/connections.c 2011-11-16 17:22:40.000000000 +0200
@@ -502,6 +502,20 @@
return 0;
}
+int __nscd_get_socket_path(char *buf, size_t bufsiz)
+{
+ const char *ext_nscd_socket_path = getenv ("NSCD_SOCKET_PATH");
+ if (ext_nscd_socket_path) {
+ int len = strlen(ext_nscd_socket_path);
+ strncpy (buf, ext_nscd_socket_path, bufsiz);
+ if (len >= bufsiz) return -1;
+ return 0;
+ }
+ strncpy (buf, _PATH_NSCDSOCKET, bufsiz);
+ if (sizeof(_PATH_NSCDSOCKET) >= bufsiz) return -1;
+ return 0;
+}
+
#ifdef O_CLOEXEC
# define EXTRA_O_FLAGS O_CLOEXEC
@@ -900,10 +914,15 @@
/* Bind a name to the socket. */
struct sockaddr_un sock_addr;
sock_addr.sun_family = AF_UNIX;
- strcpy (sock_addr.sun_path, _PATH_NSCDSOCKET);
+ if (__nscd_get_socket_path (sock_addr.sun_path, sizeof(sock_addr.sun_path)) < 0)
+ {
+ dbg_log ("Path to nscd socket is too long");
+ exit (1);
+ }
+
if (bind (sock, (struct sockaddr *) &sock_addr, sizeof (sock_addr)) < 0)
{
- dbg_log ("%s: %s", _PATH_NSCDSOCKET, strerror (errno));
+ dbg_log ("%s: %s", sock_addr.sun_path, strerror (errno));
exit (errno == EACCES ? 4 : 1);
}
@@ -930,7 +949,7 @@
#endif
/* Set permissions for the socket. */
- chmod (_PATH_NSCDSOCKET, DEFFILEMODE);
+ chmod (sock_addr.sun_path, DEFFILEMODE);
/* Set the socket up to accept connections. */
if (listen (sock, SOMAXCONN) < 0)
diff -ur glibc-2.14.1+p3/nscd/nscd.c glibc-2.14.1/nscd/nscd.c
--- glibc-2.14.1+p3/nscd/nscd.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/nscd/nscd.c 2011-11-16 17:22:40.000000000 +0200
@@ -126,6 +126,8 @@
/* True if only statistics are requested. */
static bool get_stats;
+extern int __nscd_get_socket_path(char *buf, size_t bufsiz);
+
int
main (int argc, char **argv)
{
@@ -270,7 +272,11 @@
signal (SIGPIPE, SIG_IGN);
/* Cleanup files created by a previous 'bind'. */
- unlink (_PATH_NSCDSOCKET);
+ {
+ struct sockaddr_un addr;
+ if (__nscd_get_socket_path (addr.sun_path, sizeof(addr.sun_path)) >= 0)
+ unlink (addr.sun_path);
+ }
/* Make sure we do not get recursive calls. */
__nss_disable_nscd ();
@@ -448,8 +454,12 @@
return -1;
addr.sun_family = AF_UNIX;
- assert (sizeof (addr.sun_path) >= sizeof (_PATH_NSCDSOCKET));
- strcpy (addr.sun_path, _PATH_NSCDSOCKET);
+ if (__nscd_get_socket_path (addr.sun_path, sizeof(addr.sun_path)) < 0)
+ {
+ close (sock);
+ return -1;
+ }
+
if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
{
close (sock);
@@ -464,10 +474,13 @@
void
termination_handler (int signum)
{
+ struct sockaddr_un addr;
+
close_sockets ();
/* Clean up the file created by 'bind'. */
- unlink (_PATH_NSCDSOCKET);
+ if (__nscd_get_socket_path (addr.sun_path, sizeof(addr.sun_path)) >= 0)
+ unlink (addr.sun_path);
/* Clean up pid file. */
unlink (_PATH_NSCDPID);
diff -ur glibc-2.14.1+p3/nscd/nscd_helper.c glibc-2.14.1/nscd/nscd_helper.c
--- glibc-2.14.1+p3/nscd/nscd_helper.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/nscd/nscd_helper.c 2011-11-16 17:22:40.000000000 +0200
@@ -159,6 +159,19 @@
return ret;
}
+static int nscd_get_socket_path(char *buf, size_t bufsiz)
+{
+ const char *ext_nscd_socket_path = getenv ("NSCD_SOCKET_PATH");
+ if (ext_nscd_socket_path) {
+ int len = strlen(ext_nscd_socket_path);
+ strncpy (buf, ext_nscd_socket_path, bufsiz);
+ if (len >= bufsiz) return -1;
+ return 0;
+ }
+ strncpy (buf, _PATH_NSCDSOCKET, bufsiz);
+ if (sizeof(_PATH_NSCDSOCKET) >= bufsiz) return -1;
+ return 0;
+}
static int
open_socket (request_type type, const char *key, size_t keylen)
@@ -203,7 +216,8 @@
struct sockaddr_un sun;
sun.sun_family = AF_UNIX;
- strcpy (sun.sun_path, _PATH_NSCDSOCKET);
+ if (nscd_get_socket_path (sun.sun_path, sizeof(sun.sun_path)) < 0) goto out;
+
if (__connect (sock, (struct sockaddr *) &sun, sizeof (sun)) < 0
&& errno != EINPROGRESS)
goto out;
diff -ur glibc-2.14.1+p2/nss/nsswitch.c glibc-2.14.1/nss/nsswitch.c
--- glibc-2.14.1+p2/nss/nsswitch.c 2011-10-07 12:48:55.000000000 +0300
+++ glibc-2.14.1/nss/nsswitch.c 2011-11-16 17:21:16.000000000 +0200
@@ -41,6 +41,8 @@
#include "nsswitch.h"
#include "../nscd/nscd_proto.h"
+#include <unistd.h> /* __libc_enable_secure */
+
/* Prototypes for the local functions. */
static name_database *nss_parse_file (const char *fname) internal_function;
static name_database_entry *nss_getline (char *line) internal_function;
@@ -105,8 +107,16 @@
/* Are we initialized yet? */
if (service_table == NULL)
- /* Read config file. */
- service_table = nss_parse_file (_PATH_NSSWITCH_CONF);
+ {
+ const char *ext_nss_config_file = NULL;
+ if (__libc_enable_secure == 0)
+ {
+ ext_nss_config_file = getenv ("NSSWITCH_CONF_PATH");
+ }
+ /* Read config file. */
+ service_table = nss_parse_file (ext_nss_config_file ?
+ ext_nss_config_file : _PATH_NSSWITCH_CONF);
+ }
/* Test whether configuration data is available. */
if (service_table != NULL)
* Fri Jan 06 2012 Carsten Munk <carsten@merproject.org> - 2.14
- For SB2-OBS integration:
glibc-2.14.1-elf-rtld.c.1.diff
glibc-2.14.1-ldso-nodefaultdirs-option.5.diff
glibc-2.14.1-ldso-rpath-prefix-option.2.diff
glibc-2.14.1-nscd-socket-location.4.diff
glibc-2.14.1-nsswitchconf-location.3.diff
* Fri Nov 25 2011 Carsten Munk <carsten@merproject.org> - 2.13
- Add glibc-2.13-onlyenus.patch, we're only interested in en_US locales
right now. For integrators, you can use localedef in your %post
......
......@@ -41,6 +41,12 @@ Patch9: glibc-arm-atomics-disable-qemu.patch
Patch10: glibc-2.13-no-timestamping.patch
Patch11: glibc-2.13-onlyenus.patch
Patch12: glibc-2.14.1-elf-rtld.c.1.diff
Patch13: glibc-2.14.1-ldso-rpath-prefix-option.2.diff
Patch14: glibc-2.14.1-nsswitchconf-location.3.diff
Patch15: glibc-2.14.1-nscd-socket-location.4.diff
Patch16: glibc-2.14.1-ldso-nodefaultdirs-option.5.diff
Provides: ldconfig
# The dynamic linker supports DT_GNU_HASH
Provides: rtld(GNU_HASH)
......@@ -197,6 +203,11 @@ mv glibc-ports-2.13 ports
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
cat > find_provides.sh <<EOF
#!/bin/sh
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment