Sat Jul 27 02:58:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>

* elf/rtld.c (dl_main): Take new option --verify when run directly.
	In verify mode, exit with status zero iff the argument object's
	PT_INTERP matches argv[0].
	* elf/ldd.sh.in: Use ${RTLD} --verify and only run the program if it
	exits with zero status.  This makes `ldd' secure again.

Fri Jul 26 22:49:58 1996  Ulrich Drepper  <drepper@cygnus.com>

	* elf/rtld.c (dl_main): Implement LD_TRACE_LOADED_OBJECTS
	environment variable handling.  This makes the dynamic linker
	only print loaded libraries and quit.

	* elf/ldd.sh.in: Don't use `rtld --list' but instead
	LD_TRACE_LOADED_OBJECTS environment variable to print needed
	objects.

Sat Jul 27 02:03:26 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

	* db/makedb.c (main): Print version on stdout, not stderr.  Don't exit
	after printing version until after doing usage for --help.
	(long_options, main, usage): Rename -l/--lowercase option to
	-f/--fold-case (-f matches sort).

Sat Jul 27 04:32:31 1996  Ulrich Drepper  <drepper@cygnus.com>

	* db/makedb.c: New file.  Implement program to create simple <db.h>
	database from textual input.  This will be used for nss_db.

Sat Jul 27 01:24:05 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

	* sunrpc/rpc/auth_unix.h: Fix misapplied patches in last changes.
	* sunrpc/rpc/pmap_clnt.h: Likewise.
	* sunrpc/rpc/auth.h: Likewise.
	* sunrpc/rpc/pmap_rmt.h: Likewise.
	* sunrpc/rpc/rpc_msg.h: Likewise.

Sat Jul 27 04:37:34 1996  Ulrich Drepper  <drepper@cygnus.com>

	* string/string.h (strndupa): Change to use return value of
	`memcpy' for more performance.
	* string/strndup.c: Likewise.

	* string/string.h (strdupa): Don't call __builtin_alloca in argument.
	This might lead to problems.
	(strndupa): Likewise.
This commit is contained in:
Roland McGrath 1996-07-27 07:29:13 +00:00
parent fc933e284e
commit 61965e9b17
3 changed files with 79 additions and 6 deletions

View File

@ -1,3 +1,51 @@
Sat Jul 27 02:58:49 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* elf/rtld.c (dl_main): Take new option --verify when run directly.
In verify mode, exit with status zero iff the argument object's
PT_INTERP matches argv[0].
* elf/ldd.sh.in: Use ${RTLD} --verify and only run the program if it
exits with zero status. This makes `ldd' secure again.
Fri Jul 26 22:49:58 1996 Ulrich Drepper <drepper@cygnus.com>
* elf/rtld.c (dl_main): Implement LD_TRACE_LOADED_OBJECTS
environment variable handling. This makes the dynamic linker
only print loaded libraries and quit.
* elf/ldd.sh.in: Don't use `rtld --list' but instead
LD_TRACE_LOADED_OBJECTS environment variable to print needed
objects.
Sat Jul 27 02:03:26 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* db/makedb.c (main): Print version on stdout, not stderr. Don't exit
after printing version until after doing usage for --help.
(long_options, main, usage): Rename -l/--lowercase option to
-f/--fold-case (-f matches sort).
Sat Jul 27 04:32:31 1996 Ulrich Drepper <drepper@cygnus.com>
* db/makedb.c: New file. Implement program to create simple <db.h>
database from textual input. This will be used for nss_db.
Sat Jul 27 01:24:05 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* sunrpc/rpc/auth_unix.h: Fix misapplied patches in last changes.
* sunrpc/rpc/pmap_clnt.h: Likewise.
* sunrpc/rpc/auth.h: Likewise.
* sunrpc/rpc/pmap_rmt.h: Likewise.
* sunrpc/rpc/rpc_msg.h: Likewise.
Sat Jul 27 04:37:34 1996 Ulrich Drepper <drepper@cygnus.com>
* string/string.h (strndupa): Change to use return value of
`memcpy' for more performance.
* string/strndup.c: Likewise.
* string/string.h (strdupa): Don't call __builtin_alloca in argument.
This might lead to problems.
(strndupa): Likewise.
Fri Jul 26 15:24:25 1996 Ulrich Drepper <drepper@cygnus.com> Fri Jul 26 15:24:25 1996 Ulrich Drepper <drepper@cygnus.com>
* sunrpc/rpc/auth.h: Add protection against multiple inclusion * sunrpc/rpc/auth.h: Add protection against multiple inclusion

View File

@ -17,7 +17,11 @@ case $# in
/*) file="$1" ;; /*) file="$1" ;;
*) file="./$1" ;; *) file="./$1" ;;
esac esac
exec ${RTLD} --list "$file" && exit 1 if ${RTLD} --verify "$file"; then
LD_TRACE_LOADED_OBJECTS=1 exec "$file" && exit 1
else
echo ' not a dynamic executable'
fi
exit ;; exit ;;
*) *)
set -e # Bail out immediately if ${RTLD} loses on any argument. set -e # Bail out immediately if ${RTLD} loses on any argument.
@ -27,7 +31,11 @@ case $# in
/*) file="$file" ;; /*) file="$file" ;;
*) file="./$file" ;; *) file="./$file" ;;
esac esac
${RTLD} --list "$file" if ${RTLD} --verify "$file"; then
LD_TRACE_LOADED_OBJECTS=1 "$file"
else
echo ' not a dynamic executable'
fi
done done
esac esac

View File

@ -127,7 +127,7 @@ dl_main (const ElfW(Phdr) *phdr,
const ElfW(Phdr) *ph; const ElfW(Phdr) *ph;
struct link_map *l; struct link_map *l;
int lazy; int lazy;
int list_only = 0; enum { normal, list, verify } mode = normal;
struct link_map **preloads; struct link_map **preloads;
unsigned int npreloads; unsigned int npreloads;
@ -150,7 +150,7 @@ dl_main (const ElfW(Phdr) *phdr,
installing it. */ installing it. */
if (_dl_argc < 2) if (_dl_argc < 2)
_dl_sysdep_fatal ("\ _dl_sysdep_fatal ("\
Usage: ld.so [--list] EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\ Usage: ld.so [--list|--verify] EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\
You have invoked `ld.so', the helper program for shared library executables.\n\ You have invoked `ld.so', the helper program for shared library executables.\n\
This program usually lives in the file `/lib/ld.so', and special directives\n\ This program usually lives in the file `/lib/ld.so', and special directives\n\
in executable files using ELF shared libraries tell the system's program\n\ in executable files using ELF shared libraries tell the system's program\n\
@ -169,7 +169,15 @@ of this helper program; chances are you did not intend to run this program.\n",
if (! strcmp (_dl_argv[1], "--list")) if (! strcmp (_dl_argv[1], "--list"))
{ {
list_only = 1; mode = list;
++_dl_skip_args;
--_dl_argc;
++_dl_argv;
}
else if (! strcmp (_dl_argv[1], "--verify"))
{
mode = verify;
++_dl_skip_args; ++_dl_skip_args;
--_dl_argc; --_dl_argc;
@ -235,6 +243,12 @@ of this helper program; chances are you did not intend to run this program.\n",
else else
assert (_dl_rtld_map.l_libname); /* How else did we get here? */ assert (_dl_rtld_map.l_libname); /* How else did we get here? */
if (mode == verify)
/* We were called just to verify that this is a dynamic executable
using us as the program interpreter. */
_exit (strcmp (_dl_rtld_map.l_libname, _dl_rtld_map.l_name)
? EXIT_FAILURE : EXIT_SUCCESS);
/* Extract the contents of the dynamic section for easy access. */ /* Extract the contents of the dynamic section for easy access. */
elf_get_dynamic_info (l->l_ld, l->l_info); elf_get_dynamic_info (l->l_ld, l->l_info);
if (l->l_info[DT_HASH]) if (l->l_info[DT_HASH])
@ -326,7 +340,10 @@ of this helper program; chances are you did not intend to run this program.\n",
} }
} }
if (list_only) if (mode == normal && getenv ("LD_TRACE_LOADED_OBJECTS") != NULL)
mode = list;
if (mode != normal)
{ {
/* We were run just to list the shared libraries. It is /* We were run just to list the shared libraries. It is
important that we do this before real relocation, because the important that we do this before real relocation, because the