Bug 25413

Summary: sha*sum programs list "--color" as an option, but they don't print in color
Product: Mageia Reporter: Jeff Robins <jeffrobinsSAE>
Component: RPM PackagesAssignee: Thomas Backlund <tmb>
Status: RESOLVED OLD QA Contact:
Severity: enhancement    
Priority: Low CC: lewyssmith
Version: 7   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: coreutils CVE:
Status comment:
Attachments: sha256sum --color

Description Jeff Robins 2019-09-07 10:09:07 CEST
Description of problem:
sha*sum programs (sha256sum, sha512sum, etc) list "--color" as an option, but they don't print in color.  Additionally the man page on Mageia lists the "--color" option, but the man page on gnu.org doesn't list the "--color" option and I can't find any other mention of it.  Did we modify the source to provide the "--color" option?

Version-Release number of selected component (if applicable):
8.31

How reproducible:
Always

Steps to Reproduce:
1. Get the checksum of a file and save it to a file
2. Verify the checksum using the file and with the "--color" option
3. Notice there are no colors
4. Modify the file with the checksum to change the saved checksum
5. Verify the checksum using the file and with the "--color" option
6. Notice the verify fails and there are still no colors
Comment 1 Jeff Robins 2019-09-07 10:13:49 CEST
https://www.gnu.org/software/coreutils/sha256sum has the documentation.  

Command-line options are from the md5sum section: https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html#md5sum-invocation
Comment 2 Jani Välimaa 2019-09-07 11:59:36 CEST
Created attachment 11270 [details]
sha256sum --color

I don't have issues seeing colors in the output.
Comment 3 Jeff Robins 2019-09-07 17:34:17 CEST
Okay, so it only shows colors when generating the checksums and not when checking them?  I would have figured it would colorize the pass/fail output.  Is this something we add to the code?  I can't find reference to the colorization anywhere and that's why I didn't know this was the expected behavior.  If we do this, then I'd like to modify it so that the pass/fail gets colorized too.

This produces no colorized output:
sha256sum <input_file> > <output_file>
sha256sum --check --color <output_file> 

Also, the colorized portions are reproducible, but the widths aren't equal.  sha256sum puts the colored chunks at mostly 3-bytes long, but one of them is 6-bytes long and one is only 2-byts long.  sha512 has chunks 15-Bytes long.
Comment 4 Lewis Smith 2019-09-07 21:31:29 CEST
Trying this M7 MATE:
The man pages are imprecise about what the --color option does:
 --color    print with colors
It is a curious addition of doubtful worth, except perhaps as an aid to reading the long checksums; as stated above, GNU makes no reference to it.
I do not think we are bound to any particular behaviour; and I do think the present behaviour is sensible in the context.

 $ md5sum --color Mageia-7-rc-x86_64.iso
b3448bcf6c61e3681109a709b3291440  Mageia-7-rc-x86_64.iso
The colours were grouped 6-12-6-6-2
 $ sha1sum --color Mageia-7-rc-x86_64.iso
f274600e4655cb411f6acaa10d2176d34af23d46  Mageia-7-rc-x86_64.iso
Grouped 6-6-6-6-6-6-4
 $ sha256sum --color Mageia-7-rc-x86_64.iso
f20b223f4aedd01c5d70da35d8629a8f2d75a605caff9e0c3d5ea5e3c20647b6  Mageia-7-rc-x86_64.iso
Grouped 6-6-6-6-6-6-6-6-6-6-4
 $ sha512sum --color Mageia-7-rc-x86_64.iso
2b225ffa4d35b076d9619a24411170b97d0962442cc13d19b02f19ba41e3d9358aa0b754eeddcaf580da3cd1cf8d79b144139710b9beee38faf60a975f819554
Grouped 6-6-6-6-6-24-12-12-6-6-6-6-6-12-6-2

So the whole lot are in 6 (or multiple) byte chunks, the trailing bytes in white. The fact of having multiple-6 chunks sometimes is probably due to a random colour selection for 6 bytes landing on the same colour again.

@Jeff : This is not a bug. However:
> I'd like to modify it so that the pass/fail gets colorized too.
This is a decent offer. You need to be very precise about what you propose because these checksum commands have several several different ways of being used, and the output varies accordingly. For example, where the directory contians both the checksum and its host file:
 $ ls
DATE.txt                        Mageia-7-rc-x86_64.iso.md5
Mageia-7-beta2-x86_64.iso.sha1  Mageia-7-rc-x86_64.iso.sha3
Mageia-7-rc-x86_64.idx          Mageia-7-rc-x86_64.iso.sha512
Mageia-7-rc-x86_64.iso
 $ md5sum -c *.md5
Mageia-7-rc-x86_64.iso: OK

If you really want to do this, you can re-open the bug as an enhancement request and make your proposition.

CC: (none) => lewyssmith
Resolution: (none) => INVALID
Status: NEW => RESOLVED

Comment 5 Jeff Robins 2019-09-08 18:36:10 CEST
I request enhancing the checksum programs in the coreutils package to enable colorization of the outputs, such that:
1) Lines the print "OK" print either the entire line or just the "OK" in green
2) Lines that print "FAILED" print wither the entire line or just the "FAILED" in red
3) Lines that print "WARNING" print wither the entire line or just the "WARNING" in yellow

Resolution: INVALID => (none)
Severity: normal => enhancement
Status: RESOLVED => REOPENED

Comment 6 Jeff Robins 2019-09-08 18:37:01 CEST
The colorization would depend on the "--color" option being specified on the command line
Comment 7 Lewis Smith 2019-09-08 21:42:00 CEST
Jeff
Did I misunderstand:
> I'd like to modify it so that the pass/fail gets colorized too.
? which looks like *you* were offering to do the change; and which is why I proposed changing the bug to enhancement request. Are you?

OTOH If you meant "I would like it to be modified..." (as comments 5/6) by existing packagers, then your chances are slim. It is extremely trivial, and the same thing could be asked for ubiquitously; which is clearly not on.

Assigning to tmb anyway for 'coreutils'.

Assignee: bugsquad => tmb
Priority: Normal => Low

Comment 8 Jeff Robins 2019-09-09 04:05:43 CEST
If tmb doesn't want to or have the time to make the change and we modify this package, then I'll work on it and submit a patch to tmb and see what he wants to do.  I'll use it locally, but I don't want to modify his package and I don't have time to finish the packager training so that I can maintain it.

I haven't taken a look at the source we use or the source from gnu.org.  I would assume we aren't modifying the source of these programs except no one else seems to have any documentation on the "--color" option.  That's why my original question asked if we modified the source to add the "--color" option.
Comment 9 Aurelien Oudelet 2021-07-06 13:14:58 CEST
Mageia 7 is EOL since July 1st 2021.
There will not have any further bugfix for this release.

You are encouraged to upgrade to Mageia 8 as soon as possible.

@reporter, if this bug still apply with Mageia 8, please let us know it.

@packager, if you work on the Mageia 7 version of your package, please check the Mageia 8 package if issue is also present. In this case, please fix the Mageia 8 version instead.

This bug report will be closed OLD if there is no further notice within 1st September 2021.
Comment 10 Marja Van Waes 2021-09-07 14:10:56 CEST
Hi bug reporter and hi assignee and others involved,

Please reopen this bug report if it is still valid for Mageia 8 or 9(cauldron), and change "Version:" in the upper left of this report accordingly.

This report is being closed as OLD because it was filed against Mageia 7, for which  support ended on June 30th 2021.

Thanks,
Marja

Status: REOPENED => RESOLVED
Resolution: (none) => OLD