From nobody Wed Dec 1 01:08:21 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5DF3018AE121; Wed, 1 Dec 2021 01:08:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J3gv96Dbrz3sxT; Wed, 1 Dec 2021 01:08:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B1B022065C; Wed, 1 Dec 2021 01:08:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B118LoN035669; Wed, 1 Dec 2021 01:08:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B118LxO035668; Wed, 1 Dec 2021 01:08:21 GMT (envelope-from git) Date: Wed, 1 Dec 2021 01:08:21 GMT Message-Id: <202112010108.1B118LxO035668@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 00558493b73c - stable/13 - ldconfig: start of cleanup List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 00558493b73c27d88556d8e41c0db5276e995b32 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638320901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/NZogFe4TO7DTlGR5YuuTRDzArHUyRASZY/7sgoqT3A=; b=O7Vcar7xO+E4s5FtSdmIfGJtqI13Qgte98BxzIWeWhu/+/1fcsxGg0iHILIfqXn31d+G1X mpTBlLUrwjW5m4L8VUG3iTy/qUUAtg332Yhj18gI9wmNe9fAU10AmIdK5OBv903jGHcFuF 2lP3IYWBpkqJHbfP1tdNIruNK3xVZhAgr/FXNEdYEC05fqacUl39l+ETEXpMpXZbX7VR0Y CT7J2C8IKmbPVocnuxNJEowSsRluTbspUpZV1Ao5ZQgqkfDXx0190SysZDunSOjyeQnABz IR4qQa2/VDW5BZLGqhbIU2KrZVKM2oD478CW1RXyrzMS7Hh54op7cIfhNMd5GA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638320901; a=rsa-sha256; cv=none; b=stTjIGB5pB9r7WwfLplog/wcZrF0/R6ximIwZHGIiw+jZ8AAWiIK4pJmzNuhWweLM5d7ZT Rjn2+8rg6+i2sOJztX9HsCdpDApPxQ+Yhk0Rwcin5VdyK8etAzSPweAFgtI/k0/2vyUQgz VVqdSNw3SEalQE0DVtHXhGWAD4Rc0xcBiqiBZNSEsEdMzNZ89546Tjpt42rqGsUSN8RGvF DN+cfqOFlL/BlB090QnnoCtUlafLNcHCJT9WwmaQkI83HwwFRY3cs8BqKfyKDbcSc3H2jR 6W6Nbn3wzBKptxdgnPZeTNCeyWwyzUgBwwA1x7gfX6j0Ti3NqQJkU1FHh5z1oA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=00558493b73c27d88556d8e41c0db5276e995b32 commit 00558493b73c27d88556d8e41c0db5276e995b32 Author: Konstantin Belousov AuthorDate: 2021-11-19 03:35:50 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-01 01:07:19 +0000 ldconfig: start of cleanup (cherry picked from commit 3f2c6f5598410b7233b0acd1c804a0473fa1e9fa) --- sbin/ldconfig/elfhints.c | 19 ++++++++--------- sbin/ldconfig/ldconfig.c | 55 +++++++++++++++++------------------------------- sbin/ldconfig/ldconfig.h | 5 +++-- 3 files changed, 31 insertions(+), 48 deletions(-) diff --git a/sbin/ldconfig/elfhints.c b/sbin/ldconfig/elfhints.c index bbedac64b3ff..81236feec5ca 100644 --- 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 @@ read_dirs_from_file(const char *hintsfile, const char *listfile) } 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 @@ read_elf_hints(const char *hintsfile, int must_exist) } 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.c b/sbin/ldconfig/ldconfig.c index 389cbb6101b5..3f623d6f38b1 100644 --- 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,6 +41,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -53,34 +49,20 @@ static const char rcsid[] = #include "ldconfig.h" -#if DEBUG -/* test */ -#undef _PATH_ELF_HINTS -#define _PATH_ELF_HINTS "./ld-elf.so.hints" -#endif - #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, nostd, rescan, verbose; + + is_32 = is_soft = justread = merge = nostd = rescan = verbose = false; while (argc > 1) { if (strcmp(argv[1], "-aout") == 0) { @@ -89,11 +71,11 @@ main(int argc, char **argv) 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 { @@ -108,29 +90,29 @@ main(int argc, char **argv) else hints_file = _PATH_ELF_HINTS; if (argc == 1) - rescan = 1; + rescan = true; else 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; + nostd = true; break; case 'v': - verbose = 1; + verbose = true; break; default: usage(); @@ -143,13 +125,14 @@ main(int argc, char **argv) else update_elf_hints(hints_file, argc - optind, argv + optind, merge || rescan); - return 0; + exit(0); } static void usage(void) { fprintf(stderr, - "usage: ldconfig [-32] [-elf] [-Rimrsv] [-f hints_file] [directory | file ...]\n"); + "usage: ldconfig [-32] [-elf] [-Rimrsv] [-f hints_file] " + "[directory | file ...]\n"); exit(1); } diff --git a/sbin/ldconfig/ldconfig.h b/sbin/ldconfig/ldconfig.h index 9b278255ac07..8aff4e6a5ef2 100644 --- 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