Bug 255990 - when there's in environment set GREP_OPTIONS '--color=always' it breaks freebsd-update
Summary: when there's in environment set GREP_OPTIONS '--color=always' it breaks freeb...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL: https://reviews.freebsd.org/D37702
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-19 07:54 UTC by Oleg Streejak
Modified: 2023-09-19 21:48 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Streejak 2021-05-19 07:54:50 UTC
Hi all,
if i have in my shell profile set environment GREP_OPTIONS '--color=always' I always get freebsd-update error:

$ freebsd-update fetch install
src component not installed, skipped
Looking up update.FreeBSD.org mirrors... 2 mirrors found.
Fetching metadata signature for 13.0-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.

The update metadata index is correctly signed, but
failed an integrity check.
Cowardly refusing to proceed any further.

After some researching i found out that the problem is in /usr/sbin/freebsd-update at line #1293 :
  1288	# Sanity check all the lines of tINDEX.new.  Even if more metadata lines
  1289	# are added by future versions of the server, this won't cause problems,
  1290	# since the only lines which appear in tINDEX.new are the ones which we
  1291	# specifically grepped out of ${TINDEXHASH}.
  1292	fetch_metadata_index_sanity () {
  1293		if grep -qvE '^[0-9A-Z.-]+\|[0-9a-f]{64}$' tINDEX.new; then
  1294			fetch_metadata_bogus " index"
  1295			return 1
  1296		fi
  1297	}

when grep-ing tINDEX.new, there're unexpected ESC-color sequences and, obviously, it fails
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-03-01 16:04:22 UTC
A commit in branch main references this bug:

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

commit e093c61b2d69e9cca54a2332096c0e36f97bffc0
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-14 17:13:19 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-01 16:02:54 +0000

    freebsd-update: avoid effects of user's environment on grep

    A user had GREP_OPTIONS containing --color=always, which broke grep use
    in freebsd-update.  Unset this environment variable.

    PR:             255990
    Reviewed by:    kevans
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation

 usr.sbin/freebsd-update/freebsd-update.sh | 3 +++
 1 file changed, 3 insertions(+)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-03-02 18:32:00 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=24fe8a518324e291b9ea3fe4e60f2e0fb4f857c5

commit 24fe8a518324e291b9ea3fe4e60f2e0fb4f857c5
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-14 17:13:19 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-02 18:30:54 +0000

    freebsd-update: avoid effects of user's environment on grep

    A user had GREP_OPTIONS containing --color=always, which broke grep use
    in freebsd-update.  Unset this environment variable.

    PR:             255990
    Reviewed by:    kevans
    Approved by:    re (cperciva, expedited MFC)
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit e093c61b2d69e9cca54a2332096c0e36f97bffc0)

 usr.sbin/freebsd-update/freebsd-update.sh | 3 +++
 1 file changed, 3 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-03-02 20:51:27 UTC
A commit in branch releng/13.2 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=735c962a4944cf40e2315ada58f6cab8b9d16726

commit 735c962a4944cf40e2315ada58f6cab8b9d16726
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-14 17:13:19 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-02 20:50:57 +0000

    freebsd-update: avoid effects of user's environment on grep

    A user had GREP_OPTIONS containing --color=always, which broke grep use
    in freebsd-update.  Unset this environment variable.

    PR:             255990
    Reviewed by:    kevans
    Approved by:    re (cperciva)
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit e093c61b2d69e9cca54a2332096c0e36f97bffc0)
    (cherry picked from commit 24fe8a518324e291b9ea3fe4e60f2e0fb4f857c5)

 usr.sbin/freebsd-update/freebsd-update.sh | 3 +++
 1 file changed, 3 insertions(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-06-21 12:58:52 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2004a768e44c37a3d0d9602fa66bf139e86da1c4

commit 2004a768e44c37a3d0d9602fa66bf139e86da1c4
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-14 17:13:19 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-06-21 12:54:37 +0000

    freebsd-update: avoid effects of user's environment on grep

    A user had GREP_OPTIONS containing --color=always, which broke grep use
    in freebsd-update.  Unset this environment variable.

    PR:             255990
    Reviewed by:    kevans
    Approved by:    re (cperciva, expedited MFC)
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit e093c61b2d69e9cca54a2332096c0e36f97bffc0)
    (cherry picked from commit 24fe8a518324e291b9ea3fe4e60f2e0fb4f857c5)

 usr.sbin/freebsd-update/freebsd-update.sh | 3 +++
 1 file changed, 3 insertions(+)