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

Fixed the readlink in init script #110

Closed
wants to merge 1 commit into from
Closed

Conversation

stesrn
Copy link

@stesrn stesrn commented Nov 16, 2023

Init script 'S50-dropbear' updated 'dropbear_key_dir' variable to read the target location of the symlink using 'readlink'.
But the result was not the target of the link. Now fixed it with removing the switch '-f' for 'readlink'

Because of this issue, host keys are not generated and as a result unable to SSH in to cirros VMs

This is what seen with cirros 0.5.2
$ readlink -f /etc/dropbear
/etc/dropbear
$ readlink /etc/dropbear
/var/run/dropbear

Init script had a logic to read the target location of the
symlink using 'readlink'. But the result was not the
target of the link. Now fixed it with removing the
switch '-f' for 'readlink'

This is what seen with cirros 0.5.2
$ readlink -f /etc/dropbear
/etc/dropbear
$ readlink  /etc/dropbear
/var/run/dropbear
@osfrickler
Copy link
Contributor

Can you add more detail about how to reproduce the issue? Also note that 0.5.2 has been superceded by 0.5.3 or even the 0.6.x train, do you also see the issue there?

@smoser
Copy link
Member

smoser commented Nov 17, 2023

I'm confused. I just looked at 0.5.2 and /etc/dropbear is a regular directory, not a symlink at all.

$ sudo mount-image-callback disk1.img --read-only --cd -- stat etc/dropbear
  File: etc/dropbear
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 2b01h/11009d	Inode: 802         Links: 2
Access: (0700/drwx------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-11-17 09:28:21.000000000 -0500
Modify: 2023-11-17 09:28:01.000000000 -0500
Change: 2023-11-17 09:28:01.000000000 -0500
 Birth: -
$ sudo mount-image-callback disk1.img --read-only --cd -- ls -ld etc/dropbear
drwx------ 2 root root 4096 Nov 17 09:28 etc/dropbear
$ sudo mount-image-callback disk1.img --read-only --cd -- cat etc/cirros/version
0.5.2
$ sudo mount-image-callback disk1.img --read-only --cd -- chroot .
chroot: failed to run command ‘/bin/bash’: No such file or directory
$ sudo mount-image-callback disk1.img --read-only --cd -- chroot /bin/sh
chroot: cannot change root directory to '/bin/sh': Not a directory
$ sudo mount-image-callback disk1.img --read-only --cd -- chroot . /bin/sh
/ # readlink /etc/dropbear
/ # readlink -f /etc/dropbear
/etc/dropbear

@smoser smoser closed this Nov 17, 2023
@smoser
Copy link
Member

smoser commented Nov 17, 2023

I'm confused. I just looked at 0.5.2 and /etc/dropbear is a regular directory, not a symlink at all.

Also, it seems that 'readlink' without -f on a non-link returns empty output, with -f it will give the actual path. see below.

$ sudo mount-image-callback disk1.img --read-only --cd -- cat etc/cirros/version
0.5.2

$ sudo mount-image-callback disk1.img --read-only --cd -- stat etc/dropbear
  File: etc/dropbear
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 2b01h/11009d	Inode: 802         Links: 2
Access: (0700/drwx------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-11-17 09:28:21.000000000 -0500
Modify: 2023-11-17 09:28:01.000000000 -0500
Change: 2023-11-17 09:28:01.000000000 -0500
 Birth: -

$ sudo mount-image-callback disk1.img --read-only --cd -- ls -ld etc/dropbear
drwx------ 2 root root 4096 Nov 17 09:28 etc/dropbear

$ sudo mount-image-callback disk1.img --read-only --cd -- chroot /bin/sh
chroot: cannot change root directory to '/bin/sh': Not a directory
$ sudo mount-image-callback disk1.img --read-only --cd -- chroot . /bin/sh
/ # readlink /etc/dropbear
/ # readlink -f /etc/dropbear
/etc/dropbear

@smoser smoser reopened this Nov 17, 2023
@stesrn
Copy link
Author

stesrn commented Nov 20, 2023

I am seeing the same issue with cirros-0.5.3, but haven't tested it with 0.6.z

@smoser I used the same cirros 0.5.2 and created VM out of it.


$ sudo mount-image-callback --read-only cirros-0.5.2-x86_64-disk.img -C -m /home/sas/test-cirros/tmp -- cat /home/sas/test-cirros/tmp/etc/cirros/version
0.5.2

$ sudo mount-image-callback --read-only cirros-0.5.2-x86_64-disk.img -C -m /home/sas/test-cirros/tmp -- ls /home/sas/test-cirros/tmp/etc/dropbear -l
lrwxrwxrwx. 1 root root 17 Nov 20 12:47 /home/sas/test-cirros/tmp/etc/dropbear -> /var/run/dropbear

$ sudo mount-image-callback --read-only cirros-0.5.2-x86_64-disk.img -C -m /home/sas/test-cirros/tmp -- ls /home/sas/test-cirros/tmp/var/run/dropbear
ls: cannot access '/home/sas/test-cirros/tmp/var/run/dropbear': No such file or directory`

$ sudo mount-image-callback --read-only cirros-0.5.2-x86_64-disk.img -C -m /home/sas/test-cirros/tmp -- readlink /home/sas/test-cirros/tmp/etc/dropbear
/var/run/dropbear

Here the problem is that /etc/dropbear links to /var/run/dropbear. But this directory /var/run/dropbear is not available.

@smoser
Copy link
Member

smoser commented Nov 20, 2023

I am seeing the same issue with cirros-0.5.3, but haven't tested it with 0.6.z

@smoser I used the same cirros 0.5.2 and created VM out of it.

You are right... i dont know what I was doing. I'll look at this further.

@stesrn
Copy link
Author

stesrn commented Jan 25, 2024

@smoser Hi. This issue is not yet addressed. What is the plan to fix this issue with cirros ?

@osfrickler
Copy link
Contributor

For the next release this will be fixed by #118, I don't think we will support older releases.

@osfrickler osfrickler closed this Sep 11, 2024
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

Successfully merging this pull request may close these issues.

3 participants