Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strange behaviour with binary paths depends on running context #87

Open
alexminder opened this issue Oct 22, 2024 · 2 comments
Open

strange behaviour with binary paths depends on running context #87

alexminder opened this issue Oct 22, 2024 · 2 comments

Comments

@alexminder
Copy link

# grep initrd_generator=ugrd /etc/kernel/install.conf
initrd_generator=ugrd
# emerge --config =sys-kernel/hardened-kernel-6.10.13

A binaries in result image placed in the /usr/bin

# xz -d -c /boot/xxx/6.10.13-hardened/initrd |cpio -tv|grep mount
-rwx--x--x   1 root     root        55328 Oct 22 16:24 usr/bin/mount
lrwxrwxrwx   1 root     root            9 Oct 18 09:17 usr/bin/mount.bcachefs -> bcachefs
-rwx--x--x   1 root     root        34848 Oct 22 16:24 usr/bin/umount
-rwxr-xr-x   1 root     root       449160 Oct 22 16:24 usr/lib/libmount.so.1.1.0
lrwxrwxrwx   1 root     root           27 Oct 22 16:24 usr/lib/libmount.so.1 -> /usr/lib/libmount.so.1.1.0

When I run ugrd manualy binaries placed in the /usr/sbin:

# ugrd /initrd.ugrd.img

# xz -d -c /initrd.ugrd.img |cpio -tv|grep mount
-rwxr-xr-x   1 root     root       449160 Oct 22 16:24 usr/lib/libmount.so.1.1.0
lrwxrwxrwx   1 root     root           27 Oct 22 16:24 usr/lib/libmount.so.1 -> /usr/lib/libmount.so.1.1.0
-rwx--x--x   1 root     root        55328 Oct 22 16:24 usr/sbin/mount
-rwx--x--x   1 root     root        34848 Oct 22 16:24 usr/sbin/umount
lrwxrwxrwx   1 root     root            9 Oct 18 09:17 usr/sbin/mount.bcachefs -> bcachefs

With one of case symlink module [symlinks.xxx] fails to work

ERROR    | ugrd                                       | [Errno 2] No such file or directory: '/var/tmp/portage/sys-kernel/hardened-kernel-6.10.13/temp/initramfs_build/usr/sbin/mount.bcachefs'
@desultory
Copy link
Owner

desultory commented Oct 22, 2024

# grep initrd_generator=ugrd /etc/kernel/install.conf
initrd_generator=ugrd
# emerge --config =sys-kernel/hardened-kernel-6.10.13

A binaries in result image placed in the /usr/bin

# xz -d -c /boot/xxx/6.10.13-hardened/initrd |cpio -tv|grep mount
-rwx--x--x   1 root     root        55328 Oct 22 16:24 usr/bin/mount
lrwxrwxrwx   1 root     root            9 Oct 18 09:17 usr/bin/mount.bcachefs -> bcachefs
-rwx--x--x   1 root     root        34848 Oct 22 16:24 usr/bin/umount
-rwxr-xr-x   1 root     root       449160 Oct 22 16:24 usr/lib/libmount.so.1.1.0
lrwxrwxrwx   1 root     root           27 Oct 22 16:24 usr/lib/libmount.so.1 -> /usr/lib/libmount.so.1.1.0

When I run ugrd manualy binaries placed in the /usr/sbin:

# ugrd /initrd.ugrd.img

# xz -d -c /initrd.ugrd.img |cpio -tv|grep mount
-rwxr-xr-x   1 root     root       449160 Oct 22 16:24 usr/lib/libmount.so.1.1.0
lrwxrwxrwx   1 root     root           27 Oct 22 16:24 usr/lib/libmount.so.1 -> /usr/lib/libmount.so.1.1.0
-rwx--x--x   1 root     root        55328 Oct 22 16:24 usr/sbin/mount
-rwx--x--x   1 root     root        34848 Oct 22 16:24 usr/sbin/umount
lrwxrwxrwx   1 root     root            9 Oct 18 09:17 usr/sbin/mount.bcachefs -> bcachefs

The path used in the image depends on where it is found in the environment's PATH variable.

With one of case symlink module [symlinks.xxx] fails to work

ERROR    | ugrd                                       | [Errno 2] No such file or directory: '/var/tmp/portage/sys-kernel/hardened-kernel-6.10.13/temp/initramfs_build/usr/sbin/mount.bcachefs'

If you specify a binaries entry which is a symlink, it will resolve that automatically. If you want to hardcode a symlink, you should also hardcode the path of the binary. UGRD allows this, but it's generally best to get the path from the environment's PATH.

https://github.com/desultory/ugrd/blob/main/src/ugrd/base/core.py#L39

@desultory
Copy link
Owner

Also, if you run ugrd with --print-config it should show all the internal paths used, as well as cpio contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants