diff --git a/libexec/rtld-elf/rtld_paths.h b/libexec/rtld-elf/rtld_paths.h --- a/libexec/rtld-elf/rtld_paths.h +++ b/libexec/rtld-elf/rtld_paths.h @@ -35,8 +35,12 @@ #define _COMPAT32_BASENAME_RTLD "ld-elf32.so.1" #endif +#ifndef _PATH_ELF32_HINTS +#define _PATH_ELF32_HINTS "/var/run/ld-elf32.so.hints" +#endif + #ifdef COMPAT_32BIT -#define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints" +#define _PATH_ELF_HINTS _PATH_ELF32_HINTS #define _PATH_LIBMAP_CONF "/etc/libmap32.conf" #define _BASENAME_RTLD _COMPAT32_BASENAME_RTLD #define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32" diff --git a/sbin/ldconfig/Makefile b/sbin/ldconfig/Makefile --- a/sbin/ldconfig/Makefile +++ b/sbin/ldconfig/Makefile @@ -3,6 +3,7 @@ PACKAGE=runtime PROG= ldconfig SRCS= elfhints.c ldconfig.c +CFLAGS+= -I${SRCTOP}/libexec/rtld-elf MAN= ldconfig.8 .include diff --git a/sbin/ldconfig/elfhints.c b/sbin/ldconfig/elfhints.c --- a/sbin/ldconfig/elfhints.c +++ b/sbin/ldconfig/elfhints.c @@ -48,17 +48,17 @@ #define MAXDIRS 1024 /* Maximum directories in path */ #define MAXFILESIZE (16*1024) /* Maximum hints file size */ -static void add_dir(const char *, const char *, int); +static void add_dir(const char *, const char *, bool); static void read_dirs_from_file(const char *, const char *); -static void read_elf_hints(const char *, int); +static void read_elf_hints(const char *, bool); static void write_elf_hints(const char *); static const char *dirs[MAXDIRS]; static int ndirs; -int insecure; +bool insecure; static void -add_dir(const char *hintsfile, const char *name, int trusted) +add_dir(const char *hintsfile, const char *name, bool trusted) { struct stat stbuf; int i; @@ -186,7 +186,7 @@ } static void -read_elf_hints(const char *hintsfile, int must_exist) +read_elf_hints(const char *hintsfile, bool must_exist) { int fd; struct stat s; @@ -231,15 +231,14 @@ } void -update_elf_hints(const char *hintsfile, int argc, char **argv, int merge) +update_elf_hints(const char *hintsfile, int argc, char **argv, bool merge) { - int i; + struct stat s; + int i; if (merge) - read_elf_hints(hintsfile, 0); + read_elf_hints(hintsfile, false); for (i = 0; i < argc; i++) { - struct stat s; - if (stat(argv[i], &s) == -1) warn("warning: %s", argv[i]); else if (S_ISREG(s.st_mode)) diff --git a/sbin/ldconfig/ldconfig.h b/sbin/ldconfig/ldconfig.h --- a/sbin/ldconfig/ldconfig.h +++ b/sbin/ldconfig/ldconfig.h @@ -32,12 +32,13 @@ #define LDCONFIG_H 1 #include +#include -extern int insecure; /* -i flag, needed here for elfhints.c */ +extern bool insecure; /* -i flag, needed here for elfhints.c */ __BEGIN_DECLS void list_elf_hints(const char *); -void update_elf_hints(const char *, int, char **, int); +void update_elf_hints(const char *, int, char **, bool); __END_DECLS #endif diff --git a/sbin/ldconfig/ldconfig.8 b/sbin/ldconfig/ldconfig.8 --- a/sbin/ldconfig/ldconfig.8 +++ b/sbin/ldconfig/ldconfig.8 @@ -43,7 +43,7 @@ .Sh SYNOPSIS .Nm .Op Fl 32 -.Op Fl Rimrsv +.Op Fl Rimrv .Op Fl f Ar hints_file .Op Ar directory | Ar .Sh DESCRIPTION @@ -128,10 +128,6 @@ The hints file is not modified. .Pp Scan and print all libraries found on the directories list. -.It Fl s -Do not scan the built-in system directory -.Pq Dq /usr/lib -for shared libraries. .It Fl v Switch on verbose mode. .El diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c --- a/sbin/ldconfig/ldconfig.c +++ b/sbin/ldconfig/ldconfig.c @@ -30,11 +30,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ - #include #include #include @@ -46,41 +41,29 @@ #include #include #include +#include #include #include #include #include #include "ldconfig.h" - -#if DEBUG -/* test */ -#undef _PATH_ELF_HINTS -#define _PATH_ELF_HINTS "./ld-elf.so.hints" -#endif +#include "rtld_paths.h" #define _PATH_LD32_HINTS "/var/run/ld32.so.hints" #define _PATH_ELF32_HINTS "/var/run/ld-elf32.so.hints" #define _PATH_ELFSOFT_HINTS "/var/run/ld-elf-soft.so.hints" -#undef major -#undef minor - -static int verbose; -static int nostd; -static int justread; -static int merge; -static int rescan; -static const char *hints_file; - -static void usage(void); +static void usage(void); int main(int argc, char **argv) { - int c; - int is_32 = 0; - int is_soft = 0; + const char *hints_file; + int c; + bool is_32, is_soft, justread, merge, rescan, verbose; + + is_32 = is_soft = justread = merge = rescan = verbose = false; while (argc > 1) { if (strcmp(argv[1], "-aout") == 0) { @@ -89,11 +72,11 @@ argc--; argv++; } else if (strcmp(argv[1], "-32") == 0) { - is_32 = 1; + is_32 = true; argc--; argv++; } else if (strcmp(argv[1], "-soft") == 0) { - is_soft = 1; + is_soft = true; argc--; argv++; } else { @@ -102,35 +85,34 @@ } if (is_soft) - hints_file = _PATH_ELFSOFT_HINTS; /* Never will have a.out softfloat */ + /* Never will have a.out softfloat */ + hints_file = _PATH_SOFT_ELF_HINTS; else if (is_32) hints_file = _PATH_ELF32_HINTS; else hints_file = _PATH_ELF_HINTS; - if (argc == 1) - rescan = 1; - else while((c = getopt(argc, argv, "Rf:imrsv")) != -1) { + while((c = getopt(argc, argv, "Rf:imrsv")) != -1) { switch (c) { case 'R': - rescan = 1; + rescan = true; break; case 'f': hints_file = optarg; break; case 'i': - insecure = 1; + insecure = true; break; case 'm': - merge = 1; + merge = true; break; case 'r': - justread = 1; + justread = true; break; case 's': - nostd = 1; + /* was nostd */ break; case 'v': - verbose = 1; + verbose = true; break; default: usage(); @@ -138,18 +120,20 @@ } } - if (justread) + if (justread) { list_elf_hints(hints_file); - else + } else { update_elf_hints(hints_file, argc - optind, - argv + optind, merge || rescan); - return 0; + argv + optind, merge || rescan || (argc == optind)); + } + exit(0); } static void usage(void) { fprintf(stderr, - "usage: ldconfig [-32] [-elf] [-Rimrsv] [-f hints_file] [directory | file ...]\n"); + "usage: ldconfig [-32] [-elf] [-Rimrv] [-f hints_file] " + "[directory | file ...]\n"); exit(1); }