Skip to content
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

fix: use Lchown to prevent erroring on broken symlinks #434

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

strike
Copy link
Contributor

@strike strike commented Dec 10, 2024

It's better to use Lchown instead Chown because:

  1. there are dummy/broken symlinks may use in repository. For example, we use dummy/broken symlinks for tests.
  2. some software create dummy symlinks in users home. For example, nix with options --no-channel-add create broken symlinks:
root ➜ / $ ls -l /home/vscode/.nix-defexpr/channels_root
lrwxrwxrwx 1 root root 44 Dec  3 15:34 /home/vscode/.nix-defexpr/channels_root -> /nix/var/nix/profiles/per-user/root/channels
root ➜ / $  ls -l  /nix/var/nix/profiles/per-user/root/channels
ls: cannot access '/nix/var/nix/profiles/per-user/root/channels': No such file or directory

Without this PR envbuilder fails with error:

chown "/home/vscode": chown /home/vscode/.nix-defexpr/channels_root: no such file or directory

@matifali matifali requested a review from mafredri December 12, 2024 07:38
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@mafredri mafredri changed the title fix: Do not fail chown on dummy symlinks fix: use Lchown to prevent erroring on broken symlinks Dec 12, 2024
@mafredri mafredri merged commit 440ac5c into coder:main Dec 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants