0

I have a kernel file located inside a cpio archive and I would like to calculate it's sha256sum. For that I redirected the archive output to the standard output and piped through sha256sum. I get the sum by using awk.

KERNEL_CHECKSUM=$(cpio --to-stdout -i kernel.fat16 < archive.cpio | sha256sum | awk '{print $1}')

This command works when it runs on a terminal. When run as a script, the checksum is not correctly calculated.

I suspect something related with the standard output but was unable to find the issue.

Jerome H
  • 36
  • 2
  • 1
    what shell are you using? If its `sh`, is it a symlink to something? How do you call the shell-script? Has the script a proper shebang? Please show the script. – Fredrik Pihl Aug 22 '17 at 13:53
  • Hi Fredrik, The shell is shIt's an `sh`, linked from `sh -> /bin/busybox.nosuid` and the script is called by the system() command. I figured out that the wrong sha256sum is always the same, it's actually the hash of an empty array of bytes : `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855` – Jerome H Aug 22 '17 at 14:00
  • Do you set absolute path for `archive.cpio`? You can log `stderr` of `cpio` to check what wrong. – Dmitry Ershov Aug 23 '17 at 11:57

0 Answers0