binpash / try

Inspect a command's effects before modifying your live system
MIT License
5.17k stars 64 forks source link

Creation of overlay directories can fail #162

Closed gschwaer closed 3 weeks ago

gschwaer commented 1 month ago

In my system findmnt returns

$ findmnt --real -r -o target -n
/
/sys/kernel/tracing
/boot/efi
/home/gschwaer
/run/user/1000/doc

Note: /sys/kernel/tracing

The issue is that find / -maxdepth 1 also contains /sys:

$ find / -maxdepth 1 | grep sys
/sys

/sys has permissions 555 (no write):

$ stat -c %a /sys
555

Now in https://github.com/binpash/try/blob/62cdacd7f40377c0636adc5b87c941790b01c9a7/try#L119, when try creates the overlay folder for /sys/kernel/tracing, /sys already exists and is not writable. So it fails with

mkdir: cannot create directory ‘/tmp/tmp.u4suDM7r4h/upperdir//sys/kernel’: Permission denied

I assume the solution would be one of:

  1. create all folders with 700 permissions first and then loop over them again and set the file permissions (after all folders have been created)
  2. create the folders in order of descending path length and if a folder already exists only update the permissions
  3. catch this specific case by ignoring the folder: change findmnt --real -r -o target -n to findmnt --real -r -o target -n | grep -v '/sys/kernel/tracing' (I did this locally to get rid of this error)

Thoughts?

ezrizhu commented 1 month ago

I feel like findmnt --real shouldn't return the tracefs here, I'll look into whether findmnt's behavior is correct here. cc @mgree

ezrizhu commented 1 month ago

@gschwaer on my machine findmnt --real does not return /sys/kernel/tracing, could you send me the output of findmnt -V please, and also what your distro is. For context, I have findmnt from util-linux 2.40.1

gschwaer commented 3 weeks ago

Hi @ezrizhu, sorry for the delay, here's the output:

$ findmnt -V
findmnt from util-linux 2.34

$ cat /etc/os-release 
NAME="Linux Mint"
VERSION="20.3 (Una)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 20.3"
VERSION_ID="20.3"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=una
UBUNTU_CODENAME=focal
ezrizhu commented 3 weeks ago

Hi, it seems like your version of util-linux did not cover tracefs, whereas newer util-linux did cover tracefs. The problem should be fixed by you updating util-linux.

I propose we close this issue. cc @mgree

mgree commented 3 weeks ago

Closing (but feel free to reopen if this doesn't fix it!).