FS#65006 - [mkinitpcio] running as non-root creates non-root files in the cpio
            Attached to Project:
            Arch Linux
            
Opened by Damjan Georgievski (damjan) - Wednesday, 01 January 2020, 20:35 GMT
Last edited by Antonio Rojas (arojas) - Monday, 27 December 2021, 14:45 GMT
          Opened by Damjan Georgievski (damjan) - Wednesday, 01 January 2020, 20:35 GMT
Last edited by Antonio Rojas (arojas) - Monday, 27 December 2021, 14:45 GMT
| 
 | Details
                    When you run mkinitcpio by a non-root user, the files in the
                    archive are also owned by the said non-root user. Steps to reproduce: $ id uid=1000... $ mkinitcpio -g /tmp/test.img ... $ lsinitpcio -v -l /tmp/test.img ... shows the files in the archive owned by the 1000 user ... Looking at the mkinitcpio code, it seems to try to avoid this by enforcing the uid/gid to 0, but for some reason, it needs those options in both invocations of bsdtar. I've attached a patch that fixes the issue for me. | 
              This task depends upon
              
              
            
            
          
            Closed by  Antonio Rojas (arojas)
Monday, 27 December 2021, 14:45 GMT
Reason for closing: Fixed
Additional comments about closing: Reason for request: this has been fixed in 31
          
          
        Monday, 27 December 2021, 14:45 GMT
Reason for closing: Fixed
Additional comments about closing: Reason for request: this has been fixed in 31
 
                       mkinitcpio.patch
                         mkinitcpio.patch
                    
yes, the use case is to make sure the cpio/initramfs has the proper uid/gid even if created by non-root users.
I personally do create initramfs for tools like firecracker/crosvm, but also I don't see the reason for mkinitcpio to depend on being run as root.