Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jul 2026 09:34:20 +0000
From:      Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Aleksandr Rybalko <ray@FreeBSD.org>
Subject:   git: 25e66327126d - stable/14 - install: add -z <max_cmp_size> option
Message-ID:  <6a68779c.1c67b.36fd6c7f@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=25e66327126deb92f95fc2d65c8c7d51c4862e2b

commit 25e66327126deb92f95fc2d65c8c7d51c4862e2b
Author:     Aleksandr Rybalko <ray@FreeBSD.org>
AuthorDate: 2026-05-25 07:53:20 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-07-28 09:31:15 +0000

    install: add -z <max_cmp_size> option
    
    Introduces the -z <max_cmp_size> flag, enabling users to set a custom file
    size limit for pre-installation change checks and avoiding future hard-coded
    limit modifications.
    
    Reviewed by:    glebius
    Approved by:    glebius (mentor)
    Obtained from:  Fudo Security
    MFC after:      2 weeks
    Sponsored by:   Fudo Security
    Differential Revision:  https://reviews.freebsd.org/D57230
    
    (cherry picked from commit 97cad013a50a4012328e11424ed2350c1efc036c)
---
 usr.bin/xinstall/Makefile   |  2 +-
 usr.bin/xinstall/install.1  | 13 +++++++++++--
 usr.bin/xinstall/xinstall.c | 18 ++++++++++++++----
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile
index 9e91b8b210a0..588a2baca5c4 100644
--- a/usr.bin/xinstall/Makefile
+++ b/usr.bin/xinstall/Makefile
@@ -13,7 +13,7 @@ MAN=		install.1
 CFLAGS+=	-I${SRCTOP}/contrib/mtree
 CFLAGS+=	-I${SRCTOP}/lib/libnetbsd
 
-LIBADD=		md
+LIBADD=		md util
 CFLAGS+=	-DWITH_MD5 -DWITH_RIPEMD160
 
 .ifdef BOOTSTRAPPING
diff --git a/usr.bin/xinstall/install.1 b/usr.bin/xinstall/install.1
index 193892c4a2b9..7c7b6f1b2651 100644
--- a/usr.bin/xinstall/install.1
+++ b/usr.bin/xinstall/install.1
@@ -35,7 +35,7 @@
 .Nd install binaries
 .Sh SYNOPSIS
 .Nm
-.Op Fl bCcpSsUv
+.Op Fl bCcpSsUvz
 .Op Fl B Ar suffix
 .Op Fl D Ar destdir
 .Op Fl f Ar flags
@@ -47,9 +47,10 @@
 .Op Fl N Ar dbdir
 .Op Fl o Ar owner
 .Op Fl T Ar tags
+.Op Fl z Ar size
 .Ar file1 file2
 .Nm
-.Op Fl bCcpSsUv
+.Op Fl bCcpSsUvz
 .Op Fl B Ar suffix
 .Op Fl D Ar destdir
 .Op Fl f Ar flags
@@ -61,6 +62,7 @@
 .Op Fl N Ar dbdir
 .Op Fl o Ar owner
 .Op Fl T Ar tags
+.Op Fl z Ar size
 .Ar file1 ... fileN directory
 .Nm
 .Fl d
@@ -266,6 +268,13 @@ Cause
 .Nm
 to be verbose,
 showing files as they are installed or backed up.
+.It Fl z Ar maxsize
+Limit the comparison feature of
+.Fl C
+to files no larger than
+.Ar maxsize .
+Files exceeding this limit bypass the comparison step and are directly overwritten.
+The default maximum size is 128MiB.
 .El
 .Pp
 By default,
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index d9e48ddada03..7bb9ad15fc45 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -70,6 +70,7 @@ static char sccsid[] = "@(#)xinstall.c	8.1 (Berkeley) 7/21/93";
 #include <string.h>
 #include <sysexits.h>
 #include <unistd.h>
+#include <util.h>
 #include <vis.h>
 
 #include "mtree.h"
@@ -150,6 +151,7 @@ static FILE *metafp;
 static const char *group, *owner;
 static const char *suffix = BACKUP_SUFFIX;
 static char *destdir, *digest, *fflags, *metafile, *tags;
+static size_t max_compare_size = MAX_CMP_SIZE;
 
 static int	compare(int, const char *, size_t, int, const char *, size_t,
 		    char **);
@@ -181,12 +183,13 @@ main(int argc, char *argv[])
 	u_int iflags;
 	char *p;
 	const char *to_name;
+	uint64_t num;
 
 	fset = 0;
 	iflags = 0;
 	set = NULL;
 	group = owner = NULL;
-	while ((ch = getopt(argc, argv, "B:bCcD:df:g:h:l:M:m:N:o:pSsT:Uv")) !=
+	while ((ch = getopt(argc, argv, "B:bCcD:df:g:h:l:M:m:N:o:pSsT:Uvz:")) !=
 	     -1)
 		switch((char)ch) {
 		case 'B':
@@ -283,6 +286,13 @@ main(int argc, char *argv[])
 		case 'v':
 			verbose = 1;
 			break;
+		case 'z':
+			if (expand_number(optarg, &num) != 0 || num == 0) {
+				errx(EX_USAGE, "invalid max compare filesize:"
+				    " %s", optarg);
+			}
+			max_compare_size = num;
+			break;
 		case '?':
 		default:
 			usage();
@@ -1105,7 +1115,7 @@ compare(int from_fd, const char *from_name __unused, size_t from_len,
 
 	do_digest = (digesttype != DIGEST_NONE && dresp != NULL &&
 	    *dresp == NULL);
-	if (from_len <= MAX_CMP_SIZE) {
+	if (from_len <= max_compare_size) {
 		static char *buf, *buf1, *buf2;
 		static size_t bufsize;
 		int n1, n2;
@@ -1497,11 +1507,11 @@ usage(void)
 {
 	(void)fprintf(stderr,
 "usage: install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]\n"
-"               [-M log] [-D dest] [-h hash] [-T tags]\n"
+"               [-M log] [-D dest] [-h hash] [-T tags] [-z maxcmpsize]\n"
 "               [-B suffix] [-l linkflags] [-N dbdir]\n"
 "               file1 file2\n"
 "       install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]\n"
-"               [-M log] [-D dest] [-h hash] [-T tags]\n"
+"               [-M log] [-D dest] [-h hash] [-T tags] [-z maxcmpsize]\n"
 "               [-B suffix] [-l linkflags] [-N dbdir]\n"
 "               file1 ... fileN directory\n"
 "       install -dU [-vU] [-g group] [-m mode] [-N dbdir] [-o owner]\n"


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a68779c.1c67b.36fd6c7f>