From e11a58ddc64b58f7e2a82f1d772c407fb18007d3 Mon Sep 17 00:00:00 2001 From: jdp Date: Thu, 10 Oct 1996 23:14:23 +0000 Subject: Add a new option "-f hints_file" to specify an alternate file instead of "/var/run/ld.so.hints". Delete an incorrect statement about LD_LIBRARY_PATH from the manual page. --- sbin/ldconfig/ldconfig.8 | 21 ++++++++----------- sbin/ldconfig/ldconfig.c | 53 +++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 37 deletions(-) (limited to 'sbin/ldconfig') diff --git a/sbin/ldconfig/ldconfig.8 b/sbin/ldconfig/ldconfig.8 index 8f055c0..3ad223b 100644 --- a/sbin/ldconfig/ldconfig.8 +++ b/sbin/ldconfig/ldconfig.8 @@ -27,7 +27,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: ldconfig.8,v 1.7 1995/06/24 10:08:43 asami Exp $ +.\" $Id: ldconfig.8,v 1.8 1996/04/08 04:17:33 mpp Exp $ .\" .Dd October 3, 1993 .Dt LDCONFIG 8 @@ -38,6 +38,7 @@ .Sh SYNOPSIS .Nm ldconfig .Op Fl mrsv +.Op Fl f Ar hints_file .Op Ar directory Ar ... .Sh DESCRIPTION .Nm @@ -82,15 +83,17 @@ is typically run as part of the boot sequence. The following options recognized by .Nm ldconfig: .Bl -tag -width indent +.It Fl f Ar hints_file +Read and/or update the specified hints file, instead of +.Pa /var/run/ld.so.hints . +This option is provided primarily for testing. .It Fl m -Instead of replacing the contents of -.Pa ld.so.hints +Instead of replacing the contents of the hints file with those found in the directories specified, .Dq merge in new entries. .It Fl r -Lists the current contents of -.Pa ld.so.hints +Lists the current contents of the hints file on the standard output. The hints file will not be modified. .It Fl s Do not scan the built-in system directory @@ -104,8 +107,7 @@ space of .Ev set-user-Id programs. Whenever such a program is run, .Nm ld.so -will only load shared libraries from the -.Pa ld.so.hints +will only load shared libraries from the hints file. In particular, the .Ev LD_LIBRARY_PATH is not used to search for libraries. Thus, the role of ldconfig is dual. In @@ -114,11 +116,6 @@ specify the trusted collection of directories from which shared objects can be safely loaded. It is presumed that the set of directories specified to .Nm ldconfig are under control of the system's administrator. -.Nm ld.so -further assists set-user-Id programs by erasing the -.Ev LD_LIBRARY_PATH -from the environment. - .Sh FILES .Pa /var/run/ld.so.hints .Sh SEE ALSO diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c index f65b58f..87cbfaf 100644 --- a/sbin/ldconfig/ldconfig.c +++ b/sbin/ldconfig/ldconfig.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ldconfig.c,v 1.13 1996/07/12 19:08:34 jkh Exp $ + * $Id: ldconfig.c,v 1.14 1996/10/01 01:31:51 peter Exp $ */ #include @@ -57,6 +57,11 @@ #include "shlib.h" #include "support.h" +#if DEBUG +/* test */ +#undef _PATH_LD_HINTS +#define _PATH_LD_HINTS "./ld.so.hints" +#endif #undef major #undef minor @@ -67,6 +72,7 @@ static int verbose; static int nostd; static int justread; static int merge; +static char *hints_file = _PATH_LD_HINTS; struct shlib_list { /* Internal list of shared libraries found */ @@ -96,8 +102,11 @@ char *argv[]; int i, c; int rval = 0; - while ((c = getopt(argc, argv, "mrsv")) != EOF) { + while ((c = getopt(argc, argv, "f:mrsv")) != EOF) { switch (c) { + case 'f': + hints_file = optarg; + break; case 'm': merge = 1; break; @@ -111,7 +120,7 @@ char *argv[]; verbose = 1; break; default: - errx(1, "Usage: %s [-mrsv] [dir ...]", + errx(1, "Usage: %s [-mrsv] [-f hints_file] [dir ...]", __progname); break; } @@ -254,12 +263,6 @@ int dewey[], ndewey; } -#if DEBUG -/* test */ -#undef _PATH_LD_HINTS -#define _PATH_LD_HINTS "./ld.so.hints" -#endif - int hinthash(cp, vmajor) char *cp; @@ -366,7 +369,7 @@ buildhints() errx(1, "str_index(%d) != strtab_sz(%d)", str_index, strtab_sz); } - tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", ""); + tmpfile = concat(hints_file, ".XXXXXX", ""); if ((tmpfile = mktemp(tmpfile)) == NULL) { warn("%s", tmpfile); return -1; @@ -374,37 +377,37 @@ buildhints() umask(0); /* Create with exact permissions */ if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0444)) == -1) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } if (write(fd, &hdr, sizeof(struct hints_header)) != sizeof(struct hints_header)) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } if (write(fd, blist, hdr.hh_nbucket * sizeof(struct hints_bucket)) != hdr.hh_nbucket * sizeof(struct hints_bucket)) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } if (write(fd, strtab, strtab_sz) != strtab_sz) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } if (close(fd) != 0) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } /* Install it */ - if (unlink(_PATH_LD_HINTS) != 0 && errno != ENOENT) { - warn("%s", _PATH_LD_HINTS); + if (unlink(hints_file) != 0 && errno != ENOENT) { + warn("%s", hints_file); return -1; } - if (rename(tmpfile, _PATH_LD_HINTS) != 0) { - warn("%s", _PATH_LD_HINTS); + if (rename(tmpfile, hints_file) != 0) { + warn("%s", hints_file); return -1; } @@ -423,8 +426,8 @@ readhints() struct shlib_list *shp; int i; - if ((fd = open(_PATH_LD_HINTS, O_RDONLY, 0)) == -1) { - warn("%s", _PATH_LD_HINTS); + if ((fd = open(hints_file, O_RDONLY, 0)) == -1) { + warn("%s", hints_file); return -1; } @@ -432,14 +435,14 @@ readhints() addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0); if (addr == (caddr_t)-1) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } hdr = (struct hints_header *)addr; if (HH_BADMAG(*hdr)) { warnx("%s: Bad magic: %o", - _PATH_LD_HINTS, hdr->hh_magic); + hints_file, hdr->hh_magic); return -1; } @@ -454,7 +457,7 @@ readhints() PROT_READ, MAP_COPY|MAP_FIXED, fd, msize) != (caddr_t)(addr+msize)) { - warn("%s", _PATH_LD_HINTS); + warn("%s", hints_file); return -1; } } @@ -499,7 +502,7 @@ listhints() struct shlib_list *shp; int i; - printf("%s:\n", _PATH_LD_HINTS); + printf("%s:\n", hints_file); printf("\tsearch directories: %s\n", dir_list); for (i = 0, shp = shlib_head; shp; i++, shp = shp->next) -- cgit v1.1