gitbls / sdm

Raspberry Pi SD Card Image Manager
MIT License
471 stars 48 forks source link

copyfile source file collision #196

Closed tim-oe closed 7 months ago

tim-oe commented 7 months ago

just installed the latest version using 2024-03-15-raspios-bookworm-arm64-lite.img building image on same version launched on a pi 3b+

tried with both the following:

separate plugins --plugin copyfile:"from=/mnt/clones/data/home/tcronin/.ssh/authorized_keys|to=/home/tcronin/.ssh|runphase=postinstall|chown=tcronin:tcronin|chmod=600" \ --plugin copyfile:"from=/mnt/clones/data/home/ansible/.ssh/authorized_keys|to=/home/ansible/.ssh|runphase=postinstall|chown=ansible:ansible|chmod=600" \

and filelist --plugin copyfile:"filelist=./filelist" \ filelist content from=/mnt/clones/data/home/ansible/.ssh/authorized_keys|to=/home/ansible/.ssh|chown=ansible:ansible|chmod=600|mkdirif|runphase=postinstall from=/mnt/clones/data/home/tcronin/.ssh/authorized_keys|to=/home/tcronin/.ssh|chown=tcronin:tcronin|chmod=600|mkdirif|runphase=postinstall both instances would copy the first from to each to target even verified reordering the files also the filelist command required adding the mkdirif even with a preceding mkdir plugin creating the target dir.

full customize command: sudo sdm --customize \ --plugin user:"adduser=tcronin|password=$TEC_PWD" \ --plugin mkdir:"dir=/home/tcronin/.ssh|chown=tcronin:tcronin|chmod=700" \ --plugin copyfile:"from=/mnt/clones/data/home/tcronin/.ssh/authorized_keys|to=/home/tcronin/.ssh|runphase=postinstall|chown=tcronin:tcronin|chmod=600" \ --plugin user:"adduser=ansible|password=$ANS_PWD" \ --plugin mkdir:"dir=/home/ansible/.ssh|chown=ansible:ansible|chmod=700" \ --plugin copyfile:"from=/mnt/clones/data/home/ansible/.ssh/authorized_keys|to=/home/ansible/.ssh|runphase=postinstall|chown=ansible:ansible|chmod=600" \ --plugin user:"deluser=pi" \ --plugin L10n:"keymap=us|locale=en_US.UTF-8|timezone=America/Chicago" \ --regen-ssh-host-keys \ --plugin network:"netman=nm|wifissid=tec-wan|wifipassword=$WIFI_PWD|wificountry=US" \ --restart img/bookworm.img

gitbls commented 7 months ago

Investigating...

gitbls commented 7 months ago

Please provide the redacted-as-necessary /etc/sdm/history from the IMG or console output from the customize command. Thx

tim-oe commented 7 months ago

I think i found the issue from command output: first copy: `> Run Plugin 'copyfile' (/usr/local/sdm/plugins/copyfile) Phase 1 with arguments: 'from=/mnt/clones/data/home/tcronin/.ssh/authorized_keys|to=/home/tcronin/.ssh|runphase=postinst all|chown=tcronin:tcronin|chmod=600'

second copy: `> Run Plugin 'copyfile' (/usr/local/sdm/plugins/copyfile) Phase 1 with arguments: 'from=/mnt/clones/data/home/tcronin/.ssh/authorized_keys|to=/home/tcronin/.ssh|runphase=postinst all|chown=tcronin:tcronin|chmod=600'

key being: Copy 'authorized_keys' from /etc/sdm/assets/copyfile

below is the full redacted output:

tcronin@tec-pi-mgr:~/src/piImage $ src/sdm/image.sh

gitbls commented 7 months ago

Thanks! Will correct this for next release.

gitbls commented 7 months ago

This is fixed in v11.7. Please test/verify. Thx

tim-oe commented 7 months ago

works! thanks for the quick turn around.

gitbls commented 7 months ago

Perfect. And thanks for finding this rather nasty bug. Using the same source filename in two different directories never occurred to me. 😵