From nobody Fri Jul 1 21:20:04 2022 X-Original-To: dev-commits-ports-all@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 33CDC8717F7; Fri, 1 Jul 2022 21:20:05 +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 4LZSlT0jJ4z4Rg2; Fri, 1 Jul 2022 21:20:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656710405; 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=QUUllW3x8WamXJi1oFC/E/f3t81qFzAgKBc04Arhr30=; b=HcJ9AtyeVlUEikRdUNMqFF2Srw2ouQCZ2Bzyfh3bf/g7+zWkM8yohNxPVg2no0TCcffBro USjz7hP+TPWT/qOM968Od0PuTluEXF3j6zP6BuowrfM5OFAmdU2GIklWthFBmaIpRCk5Ok XkVFTnXzYnl6eOSYBueyZ6B1FcV4onxXfqcxizbTcmAZeHZUUUSTyeoi19S2GYRxSO4klQ 4dCx4DJf2C+O5083m0eruO6V8oc5PsfqlEwpeura9ADaAP0fL2Up0M+UvASS1Bh4LP6eSl r14WMWXDf2z08rxdhIv8+T03jakGq1kRZwi6yUZrD/uixcZ+mOaH4Q2Nw3jduA== 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 ED21C22AD2; Fri, 1 Jul 2022 21:20:04 +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 261LK4xk075810; Fri, 1 Jul 2022 21:20:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 261LK44H075807; Fri, 1 Jul 2022 21:20:04 GMT (envelope-from git) Date: Fri, 1 Jul 2022 21:20:04 GMT Message-Id: <202207012120.261LK44H075807@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Craig Leres Subject: git: b8b4094a465f - main - security/zeek: Patch to provide tail -F semantics for input framework MODE_STREAM List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: leres X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b8b4094a465f9fcc646b4d1f01871f8f220cfc92 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656710405; 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=QUUllW3x8WamXJi1oFC/E/f3t81qFzAgKBc04Arhr30=; b=qRSSUwD4/rTNeUAuV/lBwC12W+KNAOxUV0KnQKvIwabo6gdC91q3qaz4Osg62JPPGziSZ0 6enI00nzApWzQYAKuDRJSVcpupEM4bAMxsiEyG3J2b5j+NyvpZCxeMgxxaWSfMlmu3SwMr xTgDVVPgUxvcSOxpQY5OUo36X7ePCsYOy9Os/9Yr9uu3LxQ/hwKhIr4SjRs05vd30L8+uV t0WCnAQmNVuI03Y/FHvDshT6ywr3R2wcbGLm9EYsCGwlpdqWfBqxFlmFKTk/Of5FUzoDSj dbZC9y1gkEaBgXBwxp5Gn3jLQpniPga6h5hwevV5FRbAqHqN2dWpoA4eeoFcXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656710405; a=rsa-sha256; cv=none; b=NPiQeEtIy/x0Wf2LSpCqJu8geHyt4R+TO+ld9kij87t6VvAEneylO4gYOLoIvjJgVWcqHg ZzTTENooTzM6oogX0pOn/OaUwTKUfOXcRGC8KqVYwdQ3sdQ+s+tcpFpHWzANwy8ssoFptB k5suyBbGNod4bXO1woFt9UYsqWH4wqyQGrrthZhYv8BuA3PdTBfslqaVA2q79ddveDngjs CVVs+Nwy6i4VwIoVvff869jpqxOVD6bmFM/GK2cmqY6Dcbmlz6nlTWgqPvdl2QjEgzpB0z h7UcHzC00/tm1p9fjVc17Z5JtOzie1cJYxhHf9EPiRDN1/MU2ydKHn1BWOEM/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by leres: URL: https://cgit.FreeBSD.org/ports/commit/?id=b8b4094a465f9fcc646b4d1f01871f8f220cfc92 commit b8b4094a465f9fcc646b4d1f01871f8f220cfc92 Author: Craig Leres AuthorDate: 2022-07-01 21:19:09 +0000 Commit: Craig Leres CommitDate: 2022-07-01 21:19:09 +0000 security/zeek: Patch to provide tail -F semantics for input framework MODE_STREAM This is a backport of this github pull request: https://github.com/zeek/zeek/pull/2097 --- security/zeek/Makefile | 1 + .../zeek/files/patch-src_input_readers_raw_Raw.cc | 117 +++++++++++++++++++++ .../zeek/files/patch-src_input_readers_raw_Raw.h | 10 ++ 3 files changed, 128 insertions(+) diff --git a/security/zeek/Makefile b/security/zeek/Makefile index b7291f9d8155..8c32993625ae 100644 --- a/security/zeek/Makefile +++ b/security/zeek/Makefile @@ -2,6 +2,7 @@ PORTNAME= zeek PORTVERSION= 4.0.7 +PORTREVISION= 1 CATEGORIES= security MASTER_SITES= https://download.zeek.org/ DISTFILES= ${DISTNAME}${EXTRACT_SUFX} diff --git a/security/zeek/files/patch-src_input_readers_raw_Raw.cc b/security/zeek/files/patch-src_input_readers_raw_Raw.cc new file mode 100644 index 000000000000..ac3198ce5f04 --- /dev/null +++ b/security/zeek/files/patch-src_input_readers_raw_Raw.cc @@ -0,0 +1,117 @@ +--- src/input/readers/raw/Raw.cc.orig 2022-07-01 19:51:26 UTC ++++ src/input/readers/raw/Raw.cc +@@ -34,6 +34,7 @@ Raw::Raw(ReaderFrontend *frontend) : ReaderBackend(fro + firstrun = true; + mtime = 0; + ino = 0; ++ dev = 0; + forcekill = false; + offset = 0; + separator.assign( (const char*) BifConst::InputRaw::record_separator->Bytes(), +@@ -278,12 +279,32 @@ bool Raw::OpenInput() + else + { + file = std::unique_ptr(fopen(fname.c_str(), "r"), fclose); ++ if ( ! file && Info().mode == MODE_STREAM ) ++ { ++ // Watch /dev/null until the file appears ++ file = std::unique_ptr(fopen("/dev/null", "r"), fclose); ++ } ++ + if ( ! file ) + { + Error(Fmt("Init: cannot open %s", fname.c_str())); + return false; + } + ++ if ( Info().mode == MODE_STREAM ) ++ { ++ struct stat sb; ++ if ( fstat(fileno(file.get()), &sb) == -1 ) ++ { ++ // This is unlikely to fail ++ Error(Fmt("Could not get fstat for %s", fname.c_str())); ++ return false; ++ } ++ ino = sb.st_ino; ++ dev = sb.st_dev; ++ } ++ ++ + if ( ! SetFDFlags(fileno(file.get()), F_SETFD, FD_CLOEXEC) ) + Warning(Fmt("Init: cannot set close-on-exec for %s", fname.c_str())); + } +@@ -345,6 +366,7 @@ bool Raw::DoInit(const ReaderInfo& info, int num_field + fname = info.source; + mtime = 0; + ino = 0; ++ dev = 0; + execute = false; + firstrun = true; + int want_fields = 1; +@@ -565,24 +587,58 @@ bool Raw::DoUpdate() + + mtime = sb.st_mtime; + ino = sb.st_ino; ++ dev = sb.st_dev; + // file changed. reread. + // + // fallthrough + } + + case MODE_MANUAL: +- case MODE_STREAM: +- if ( Info().mode == MODE_STREAM && file ) +- { +- clearerr(file.get()); // remove end of file evil bits +- break; +- } +- + CloseInput(); + if ( ! OpenInput() ) + return false; + + break; ++ ++ case MODE_STREAM: ++ // Clear possible EOF condition ++ if ( file ) ++ clearerr(file.get()); ++ ++ // Done if reading from a pipe ++ if ( execute ) ++ break; ++ ++ // Check if the file has changed ++ struct stat sb; ++ if ( stat(fname.c_str(), &sb) == -1 ) ++ // File was removed ++ break; ++ ++ // Is it the same file? ++ if ( sb.st_ino == ino && sb.st_dev == dev ) ++ break; ++ ++ // File was replaced ++ FILE* tfile; ++ tfile = fopen(fname.c_str(), "r"); ++ if ( ! tfile ) ++ break; ++ ++ // Stat newly opened file ++ if ( fstat(fileno(tfile), &sb) == -1 ) ++ { ++ // This is unlikely to fail ++ Error(Fmt("Could not fstat %s", fname.c_str())); ++ return false; ++ } ++ file.reset(nullptr); ++ file = std::unique_ptr(tfile, fclose); ++ ino = sb.st_ino; ++ dev = sb.st_dev; ++ offset = 0; ++ bufpos = 0; ++ break; + + default: + assert(false); diff --git a/security/zeek/files/patch-src_input_readers_raw_Raw.h b/security/zeek/files/patch-src_input_readers_raw_Raw.h new file mode 100644 index 000000000000..2dacf9bb7baa --- /dev/null +++ b/security/zeek/files/patch-src_input_readers_raw_Raw.h @@ -0,0 +1,10 @@ +--- src/input/readers/raw/Raw.h.orig 2022-07-01 20:33:23 UTC ++++ src/input/readers/raw/Raw.h +@@ -52,6 +52,7 @@ class Raw : public ReaderBackend { (private) + bool firstrun; + time_t mtime; + ino_t ino; ++ dev_t dev; + + // options set from the script-level. + std::string separator;