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

makeImage.sh with a wrong DEVICE variable value causes error #89

Open
c0mix opened this Issue Sep 17, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@c0mix
Contributor

c0mix commented Sep 17, 2018

Inside firmadyne.config, the below assumption is not always correct.

get_device () {
    echo "/dev/mapper/loop0p1"
}

This wrong assumption causes a failure during the mounting phase of makeImage.sh because get_device it is called by the script to set DEVICE variable (line 51).

DEVICE=`get_device`

To avoid this issue, a simple workaround could be applied inside makeImage.sh file, specifically, it is possible to use the output of the kpartx command to infer the correct device name and set DEVICE variable.

echo "----Mounting QEMU Image----"
output=$(kpartx -a -s -v "${IMAGE}")
foo=$(echo "$output" | cut -d ' ' -f 3)
DEVICE="/dev/mapper/$foo"
echo $DEVICE # for debug purpose (can be removed)
sleep 1

The fixed makeImage.sh should look like this:
https://gist.github.com/c0mix/085a350df0b78290d3b3fb175a5c5555
Note: Tested on ubuntu 18.04 with 4.15.0-34-generic

@ddcc

This comment has been minimized.

Show comment
Hide comment
@ddcc

ddcc Sep 18, 2018

Collaborator

Thanks for the feedback. Can you submit it as a pull request? My only concern is that other scripts such as mount.sh also utilize this functionality, so it'd be better to move the parsing into the firmadyne.config script, and have get_device take the output of kpartx as an input argument.

Collaborator

ddcc commented Sep 18, 2018

Thanks for the feedback. Can you submit it as a pull request? My only concern is that other scripts such as mount.sh also utilize this functionality, so it'd be better to move the parsing into the firmadyne.config script, and have get_device take the output of kpartx as an input argument.

c0mix added a commit to c0mix/firmadyne that referenced this issue Sep 18, 2018

@c0mix

This comment has been minimized.

Show comment
Hide comment
@c0mix

c0mix Sep 18, 2018

Contributor

As suggested I've opened a pull request here #90 moving the parsing into firmadyne.config
I hope that this will help you to improve your fantastic tool :)

Contributor

c0mix commented Sep 18, 2018

As suggested I've opened a pull request here #90 moving the parsing into firmadyne.config
I hope that this will help you to improve your fantastic tool :)

ddcc added a commit that referenced this issue Oct 5, 2018

bugfix for #89 issue (#90)
* bugfix to issue 89

#89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment