opencomputeproject / onie

Open Network Install Environment
https://opencomputeproject.github.io/onie
Other
606 stars 377 forks source link

Machine directory path length seems to have an effect on secure build #986

Closed foobazjo closed 2 years ago

foobazjo commented 2 years ago

After analyzing the error below, it looks like _/home/silvercro/sandbox/onie/build/images/asrockrack/ was not created for some reason.

==== Create ONIE Tools tarball ====
Building ONIE tools archive ....... Done.
Success:  ONIE tools tar archive is ready: /home/silvercro/sandbox/onie/build/asrock_rack/asrock_rack_e3c246d2i-r0/onie-tools.tar.xz
122059 blocks
bash: /home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.initrd: No such file or directory
make: *** [make/images.make:343: /home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.initrd] Error 1
make: *** Waiting for unfinished jobs....
  MKPIGGY arch/x86/boot/compressed/piggy.S
  AS      arch/x86/boot/compressed/piggy.o
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  OBJCOPY arch/x86/boot/vmlinux.bin
  AS      arch/x86/boot/header.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  BUILD   arch/x86/boot/bzImage
Setup is 16124 bytes (padded to 16384 bytes).
System is 4817 kB
CRC 65b97b21
Kernel: arch/x86/boot/bzImage is ready  (#1)
make[1]: Leaving directory '/home/silvercro/sandbox/onie/build/asrock_rack/asrock_rack_e3c246d2i-r0/kernel/linux-5.4.86'
silvercro@due-onie-build-debian-10:~/sandbox/onie/build-config$ ll /home/silvercro/sandbox/onie/build/images/                                            
total 8
drwxr-xr-x 2 silvercro silvercro 4096 Jan 25 21:54 ./
drwxrwxr-x 8 silvercro silvercro 4096 Jan 25 21:54 ../

Just for debuging the issue I went ahead and created it: silvercro@due-onie-build-debian-10:~/sandbox/onie/build-config$ mkdir -p /home/silvercro/sandbox/onie/build/images/asrock_rack/

Resumed building:

silvercro@due-onie-build-debian-10:~/sandbox/onie/build-config$ make -j1 MACHINE=asrock_rack/asrock_rack_e3c246d2i all demo
==== Copy vmlinuz to /home/silvercro/sandbox/onie/build/images ====
'/home/silvercro/sandbox/onie/build/asrock_rack/asrock_rack_e3c246d2i-r0/kernel/linux/arch/x86/boot/bzImage' -> '/home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.vmlinuz'
====  Signing kernel secure boot image ====
'/home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.vmlinuz' -> '/home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.vmlinuz.unsigned'
Signing Unsigned original image
==== GPG sign vmlinuz ====
ERROR!
Directory base absolute path [ /home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.vmlinuz ] has [ 87 ] characters.
 This exceeds the 80 character limit for a gpg homedir, and will cause the
  the gpg-agent to fail to start.
 You'll get the error message: gpg: can't connect to the agent: IPC connect call failed.
Exiting.
make: *** [make/kernel.make:152: /home/silvercro/sandbox/onie/build/asrock_rack/asrock_rack_e3c246d2i-r0/stamp/kernel-vmlinuz-install] Error 1

Note that my machine directory is a sub-directory (like other vendors with multiple models):

silvercro@due-onie-build-debian-10:~/sandbox/onie/build-config$  ll ../machine/asrock_rack/
total 12
drwxrwxr-x  3 silvercro silvercro 4096 Jan 25 20:39 ./
drwxrwxr-x 34 silvercro silvercro 4096 Jan 25 20:37 ../
drwxrwxr-x  9 silvercro silvercro 4096 Jan 25 20:39 asrock_rack_e3c246d2i/

Directory base absolute path [ /home/silvercro/sandbox/onie/build/images/asrock_rack/asrock_rack_e3c246d2i-r0.vmlinuz ] has [ 87 ] characters.

Looks like my machine path is too long and gpg is not happy. Was there anything in the build process that prevented creating my directory in the first place with a silent error and it's only visible at the end of the build process when it's trying to move things in the images directory?

asrock_rack/asrock_rack_e3c246d2i is a machine I created by copying kvm_x86_64.

foobazjo commented 2 years ago

UPDATE: I've renamed my machine from asrock_rack/asrock_rack_e3c246d2i to asrock_rack/e3c246d2i, I'm no longer having the gpg path len issue but all those build/images folder are not being created for me.

I'm using the ONIE Debian 10 build env from DUE and tag 2021.11. Not sure what I'm doing wrong.

UPDATE2: It's working fine now, it was all related to not using (and knowing) about MACHINEROOT=../machine/asrock_rack, initially using MACHINE=asrock_rack/asrock_rack_e3c246d2i, was working until the part in the Makefiles that was removing and mkdir -p the various image folders.