alpinelinux / alpine-chroot-install

Install Alpine Linux in chroot with a breeze. Build ARM on Travis CI or any other x86_64 CI.
MIT License
290 stars 59 forks source link

`-d` option has unexpected (and potentially dangerous) behavior #43

Open afontenot opened 1 year ago

afontenot commented 1 year ago
  1. Make a temporary directory and cd into it.

  2. sudo alpine-chroot-install -d alpine

Observe that the chroot is not placed in alpine, but it alpine/alpine.

  1. Destroy the chroot with ./alpine/alpine/destroy --remove.

[Here is where I made an error in reasoning - assuming that alpine-chroot-install always creates a new directory called alpine below whatever is specified in -d.]

  1. sudo alpine-chroot-install -d .

Observe that the chroot is placed in the current directory!

  1. In frustration, hit the up key twice (in most terminals) to go back to ./alpine/alpine/destroy --remove.

alpine-chroot-install blows away the (hopefully empty!) temporary directory you created in step 1.

In fact I lost data because of this. It was a stupid error on my part, I guess, to not realize that the destroy command would also destroy the non-empty directory I created the chroot in (step 4). But there's clearly some weird behavior happening here that should probably be fixed.

  1. The program should always (?) use the specified directory to create the chroot, and not sometimes (?) create a secondary subdirectory named alpine. (Yes, I checked that ./alpine did not already exist in step 2.)

  2. The program should loudly warn or better yet fail when asked to create a chroot in a non-empty directory, given that it expects to be able to take over the directory completely.