SuperCuber / dotter

A dotfile manager and templater written in rust 🦀
The Unlicense
882 stars 46 forks source link

[BUG] Dotter doesn't elevate if it can't read a directory #103

Open Amir-Ahmad opened 2 years ago

Amir-Ahmad commented 2 years ago

Environment

Description

When specifying a target directory that dotter can't read, dotter fails to create symlinks or templates, even when owner is specified as root.

Reproduction

#Global.toml
[system.files.test]
owner = "root"
target = "/tmp/nonreadable/test"
type = "template"

#local.toml
packages = ["system"]

Create directory user can't read.

sudo mkdir /tmp/nonreadable
sudo chmod 700 /tmp/nonreadable

Expected behavior

I expected dotter to elevate before checking the state of the file/dir as I had specified the "owner" field. Or perhaps elevate if it gets a permission denied.

Actual behavior

Dotter fails with a permission denied.

$ ▶ dotter -v
[ INFO] [+] template "test" -> "/tmp/nonreadable/test"
[ERROR] Failed to create template "test" -> "/tmp/nonreadable/test"
Caused by:
    detect templated file's current state
    get state of target
    read contents of file that isn't symbolic or directory
    Permission denied (os error 13)
stratosgear commented 1 year ago

I verify that this still fails for me on latest Arch and at dotter 0.12.15