Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking File Checksum In Alpine

I got this curious problem with Alpine. I want to check the checksum of a file inside a bash console. It works under CentOS but not under Alpine. Where is the error?

Under CentOS

$ sha1sum /bin/tini
fa23d1e20732501c3bb8eeeca423c89ac80ed452  /bin/tini
$ echo "fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini" | sha1sum -c -
/bin/tini: OK

Under Alpine

$ sha1sum /bin/tini
fa23d1e20732501c3bb8eeeca423c89ac80ed452  /bin/tini
$ echo "fa23d1e20732501c3bb8eeeca423c89ac80ed452 /bin/tini" | sha1sum -c -
sha1sum: WARNING: 1 of 1 computed checksums did NOT match
like image 468
blacklabelops Avatar asked May 27 '16 16:05

blacklabelops


1 Answers

Could you try adding 1 space (total 2) between the checksum and the path:

$ echo "fa23d1e20732501c3bb8eeeca423c89ac80ed452  /bin/tini" | sha1sum -c -

I've tried with /bin/busybox:

# sha1sum /bin/busybox
71bdaf6e52759f7f277c89b694c494f472ca2dfb  /bin/busybox
# echo '71bdaf6e52759f7f277c89b694c494f472ca2dfb /bin/busybox' | sha1sum -c -
sha1sum: WARNING: 1 of 1 computed checksums did NOT match
# echo '71bdaf6e52759f7f277c89b694c494f472ca2dfb  /bin/busybox' | sha1sum -c -
/bin/busybox: OK

The error is because sha1sum expects its own output as input when called with -c and its output uses 2 spaces.

like image 72
Javier Segura Avatar answered Oct 06 '22 06:10

Javier Segura