Bug 271240 - periodic(8) output mangles in e-mails/uses non-portable/-neutral date formats
Summary: periodic(8) output mangles in e-mails/uses non-portable/-neutral date formats
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.4-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-04 11:19 UTC by Michael Osipov
Modified: 2023-05-19 08:20 UTC (History)
2 users (show)

See Also:


Attachments
Git-formatted patch (head) (1.70 KB, patch)
2023-05-04 12:43 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (stable/12) (1.70 KB, patch)
2023-05-04 12:44 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (stable/13) (1.70 KB, patch)
2023-05-04 12:44 UTC, Michael Osipov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2023-05-04 11:19:09 UTC
This is basically a re-report of https://github.com/freebsd/pkg/issues/2126 for the base system.

Here is the diff from the setuid script (/var/log/setuid.today):
+    865 -r-sr-xr-x  1 root  wheel       6600 30 Nov. 07:24:56 2022 /usr/local/bastille/jails/deblndw013x10j/root/usr/libexec/ulog-helper
+ 231654 -rwsr-xr-x  1 root  wheel      54096 28 März 14:17:14 2023 /usr/local/bastille/jails/deblndw013x10j/root/usr/local/bin/ksu
+  15861 -r-sr-sr-x  2 root  authpf     39608 30 Nov. 07:29:24 2022 /usr/local/bastille/jails/deblndw013x10j/root/usr/sbin/authpf

März is mangled because the sender (periodic(8)) cannot set the content encoding on the e-mail. So, basically dependending on the locale the output can be mangled completely or readable if plain ASCII is used.

The source of error comes from:
root@deblndw011x2j:/etc/periodic
# grep -r "exec ls " .
./security/100.chksetuid:           \( -perm -u+s -or -perm -g+s \) -exec ls -liTd \{\} \+ |
./security/110.neggrpperm:          -exec ls -liTd \{\} \+ | tee /dev/stderr | wc -l)

After a patch it looks decent and neutral:
# ./security/110.neggrpperm

Checking negative group permissions:
525974 -------rw-  1 root  wheel  0 2023-05-04T13:02:50 /tmp/you

One needs to switch '-T' with:
 57         -exec ls -lid -D "%FT%T" \{\} \+ | tee /dev/stderr | wc -l)

Thus with '-D "%FT%T"'.

Willing to provide a Git-formatted patch for both scripts.
Comment 1 Baptiste Daroussin freebsd_committer freebsd_triage 2023-05-04 11:51:37 UTC
thanks a lot,

please provide the git-formatted patches I will push them!
Comment 2 Michael Osipov 2023-05-04 12:43:55 UTC
Created attachment 241967 [details]
Git-formatted patch (head)
Comment 3 Michael Osipov 2023-05-04 12:44:15 UTC
Created attachment 241968 [details]
Git-formatted patch (stable/12)
Comment 4 Michael Osipov 2023-05-04 12:44:46 UTC
Created attachment 241969 [details]
Git-formatted patch (stable/13)
Comment 5 Michael Osipov 2023-05-04 12:45:24 UTC
Here are the patches, first applied head and then cherry-picked from.
Comment 6 Baptiste Daroussin freebsd_committer freebsd_triage 2023-05-15 07:27:55 UTC
thank you added to head, will be merged in a couple of days in stable branches.
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-05-15 07:28:15 UTC
A commit in branch main references this bug:

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

commit d2b4753f06dcabc090080b8c8c91bda00fc8dac3
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-05-04 12:35:59 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2023-05-15 07:26:48 +0000

    periodic: Use locale-agnostic (ISO 8601) timestamp format

    Instead of reyling on locale-sensitive output which can be mangled when e-mailed
    use consistently ISO 8601 format which contains the same information as '-T'.

    PR:             271240
    MFC After:      3 days

 usr.sbin/periodic/etc/security/100.chksetuid  | 2 +-
 usr.sbin/periodic/etc/security/110.neggrpperm | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Comment 8 Michael Osipov 2023-05-15 07:48:06 UTC
(In reply to Baptiste Daroussin from comment #6)

Merci!
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-05-19 08:11:14 UTC
A commit in branch stable/13 references this bug:

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

commit e31fbe0dff0ca49670fc97eb931f8864f86d2def
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-05-04 12:35:59 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2023-05-19 08:10:08 +0000

    periodic: Use locale-agnostic (ISO 8601) timestamp format

    Instead of reyling on locale-sensitive output which can be mangled when e-mailed
    use consistently ISO 8601 format which contains the same information as '-T'.

    PR:             271240
    MFC After:      3 days

    (cherry picked from commit d2b4753f06dcabc090080b8c8c91bda00fc8dac3)

 usr.sbin/periodic/etc/security/100.chksetuid  | 2 +-
 usr.sbin/periodic/etc/security/110.neggrpperm | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-05-19 08:20:21 UTC
A commit in branch stable/12 references this bug:

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

commit 0cf997acbf0c68988470efcba691f87c38014872
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-05-04 12:35:59 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2023-05-19 08:19:55 +0000

    periodic: Use locale-agnostic (ISO 8601) timestamp format

    Instead of reyling on locale-sensitive output which can be mangled when e-mailed
    use consistently ISO 8601 format which contains the same information as '-T'.

    PR:             271240
    MFC After:      3 days

    (cherry picked from commit d2b4753f06dcabc090080b8c8c91bda00fc8dac3)

 usr.sbin/periodic/etc/security/100.chksetuid  | 2 +-
 usr.sbin/periodic/etc/security/110.neggrpperm | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)