2017-11-27 15:37:16 +00:00
|
|
|
/*-
|
|
|
|
* SPDX-License-Identifier: BSD-4-Clause
|
|
|
|
*
|
1996-02-26 02:22:33 +00:00
|
|
|
* Copyright (c) 1993,1995 Paul Kranenburg
|
1993-11-03 23:41:59 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Paul Kranenburg.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
1994-02-13 20:43:13 +00:00
|
|
|
* derived from this software without specific prior written permission
|
1993-11-03 23:41:59 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/mman.h>
|
1998-07-06 07:02:26 +00:00
|
|
|
#include <a.out.h>
|
|
|
|
#include <ctype.h>
|
1994-06-15 22:41:19 +00:00
|
|
|
#include <dirent.h>
|
2001-05-02 23:56:21 +00:00
|
|
|
#include <elf-hints.h>
|
1996-07-12 19:08:36 +00:00
|
|
|
#include <err.h>
|
1998-07-06 07:02:26 +00:00
|
|
|
#include <errno.h>
|
1994-06-15 22:41:19 +00:00
|
|
|
#include <fcntl.h>
|
2021-11-19 03:35:50 +00:00
|
|
|
#include <stdbool.h>
|
1994-06-15 22:41:19 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1993-11-03 23:41:59 +00:00
|
|
|
#include <string.h>
|
1994-06-15 22:41:19 +00:00
|
|
|
#include <unistd.h>
|
1993-11-03 23:41:59 +00:00
|
|
|
|
1998-09-05 03:31:00 +00:00
|
|
|
#include "ldconfig.h"
|
1996-10-01 01:31:51 +00:00
|
|
|
|
2004-03-21 01:21:26 +00:00
|
|
|
#define _PATH_LD32_HINTS "/var/run/ld32.so.hints"
|
|
|
|
#define _PATH_ELF32_HINTS "/var/run/ld-elf32.so.hints"
|
2016-01-18 21:40:18 +00:00
|
|
|
#define _PATH_ELFSOFT_HINTS "/var/run/ld-elf-soft.so.hints"
|
2004-03-21 01:21:26 +00:00
|
|
|
|
2021-11-19 03:35:50 +00:00
|
|
|
static void usage(void);
|
1993-11-03 23:41:59 +00:00
|
|
|
|
|
|
|
int
|
2005-01-14 12:22:57 +00:00
|
|
|
main(int argc, char **argv)
|
1993-11-03 23:41:59 +00:00
|
|
|
{
|
2021-11-19 03:35:50 +00:00
|
|
|
const char *hints_file;
|
|
|
|
int c;
|
|
|
|
bool is_32, is_soft, justread, merge, nostd, rescan, verbose;
|
|
|
|
|
|
|
|
is_32 = is_soft = justread = merge = nostd = rescan = verbose = false;
|
2004-03-21 01:21:26 +00:00
|
|
|
|
|
|
|
while (argc > 1) {
|
|
|
|
if (strcmp(argv[1], "-aout") == 0) {
|
2020-12-31 15:29:08 +00:00
|
|
|
errx(1, "aout is not supported");
|
2004-03-21 01:21:26 +00:00
|
|
|
} else if (strcmp(argv[1], "-elf") == 0) {
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
} else if (strcmp(argv[1], "-32") == 0) {
|
2021-11-19 03:35:50 +00:00
|
|
|
is_32 = true;
|
2004-03-21 01:21:26 +00:00
|
|
|
argc--;
|
|
|
|
argv++;
|
2016-01-18 21:40:18 +00:00
|
|
|
} else if (strcmp(argv[1], "-soft") == 0) {
|
2021-11-19 03:35:50 +00:00
|
|
|
is_soft = true;
|
2016-01-18 21:40:18 +00:00
|
|
|
argc--;
|
|
|
|
argv++;
|
2004-03-21 01:21:26 +00:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2002-09-17 01:49:00 +00:00
|
|
|
}
|
1998-09-09 01:21:25 +00:00
|
|
|
|
2016-01-18 21:40:18 +00:00
|
|
|
if (is_soft)
|
2021-11-24 20:44:20 +00:00
|
|
|
hints_file = _PATH_ELFSOFT_HINTS;
|
2016-01-18 21:40:18 +00:00
|
|
|
else if (is_32)
|
2020-12-31 15:29:08 +00:00
|
|
|
hints_file = _PATH_ELF32_HINTS;
|
2004-03-21 01:21:26 +00:00
|
|
|
else
|
2020-12-31 15:29:08 +00:00
|
|
|
hints_file = _PATH_ELF_HINTS;
|
2000-07-09 19:12:49 +00:00
|
|
|
if (argc == 1)
|
2021-11-19 03:35:50 +00:00
|
|
|
rescan = true;
|
2000-08-07 19:12:04 +00:00
|
|
|
else while((c = getopt(argc, argv, "Rf:imrsv")) != -1) {
|
1993-11-03 23:41:59 +00:00
|
|
|
switch (c) {
|
1997-08-22 04:42:12 +00:00
|
|
|
case 'R':
|
2021-11-19 03:35:50 +00:00
|
|
|
rescan = true;
|
1997-08-22 04:42:12 +00:00
|
|
|
break;
|
1996-10-10 23:14:23 +00:00
|
|
|
case 'f':
|
|
|
|
hints_file = optarg;
|
|
|
|
break;
|
2000-08-07 19:12:04 +00:00
|
|
|
case 'i':
|
2021-11-19 03:35:50 +00:00
|
|
|
insecure = true;
|
2000-08-07 19:12:04 +00:00
|
|
|
break;
|
1995-06-24 10:08:44 +00:00
|
|
|
case 'm':
|
2021-11-19 03:35:50 +00:00
|
|
|
merge = true;
|
1995-06-24 10:08:44 +00:00
|
|
|
break;
|
|
|
|
case 'r':
|
2021-11-19 03:35:50 +00:00
|
|
|
justread = true;
|
1993-11-03 23:41:59 +00:00
|
|
|
break;
|
|
|
|
case 's':
|
2021-11-19 03:35:50 +00:00
|
|
|
nostd = true;
|
1993-11-03 23:41:59 +00:00
|
|
|
break;
|
1995-06-24 10:08:44 +00:00
|
|
|
case 'v':
|
2021-11-19 03:35:50 +00:00
|
|
|
verbose = true;
|
1993-11-03 23:41:59 +00:00
|
|
|
break;
|
|
|
|
default:
|
1998-07-06 07:02:26 +00:00
|
|
|
usage();
|
1993-11-03 23:41:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-31 15:29:08 +00:00
|
|
|
if (justread)
|
|
|
|
list_elf_hints(hints_file);
|
|
|
|
else
|
|
|
|
update_elf_hints(hints_file, argc - optind,
|
|
|
|
argv + optind, merge || rescan);
|
2021-11-19 03:35:50 +00:00
|
|
|
exit(0);
|
1993-11-03 23:41:59 +00:00
|
|
|
}
|
|
|
|
|
1998-07-06 07:02:26 +00:00
|
|
|
static void
|
2009-12-29 21:07:17 +00:00
|
|
|
usage(void)
|
1998-07-06 07:02:26 +00:00
|
|
|
{
|
|
|
|
fprintf(stderr,
|
2021-11-19 03:35:50 +00:00
|
|
|
"usage: ldconfig [-32] [-elf] [-Rimrsv] [-f hints_file] "
|
|
|
|
"[directory | file ...]\n");
|
1998-07-06 07:02:26 +00:00
|
|
|
exit(1);
|
|
|
|
}
|