helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
34.02k stars 2.51k forks source link

Writing changes file ownership #11988

Open kirawi opened 3 weeks ago

kirawi commented 3 weeks ago

Summary

Writing a file may change the file's ownership when writing.

Reproduction Steps

$ touch abc
$ ls -la abc
-rw-r--r-- 1 m00n m00n 0 Oct 28 23:03 abc
$ sudo helix abc
( Write the file with any content )
$ ls -la
-rw-r--r-- 1 root m00n 4 Oct 28 23:03 abc

Helix log

No response

Platform

All

Terminal Emulator

N/a

Installation Method

release

Helix Version

helix 24.7

poliorcetics commented 3 weeks ago

I think the issue is https://github.com/helix-editor/helix/blob/b53dafe326d51b7f64a1c52379e3d4150cd2991e/helix-view/src/document.rs#L973, where the file is created with the access rights, owner and group of the running helix process, not that of the target file

kirawi commented 2 weeks ago

I don't think so. I believe it would open with the same file permissions if it already exists, and for backup files we already copy metadata on https://github.com/helix-editor/helix/blob/b53dafe326d51b7f64a1c52379e3d4150cd2991e/helix-view/src/document.rs#L1008-L1014

kirawi commented 2 weeks ago

Actually you might have been right. This seems to be fixed by https://github.com/helix-editor/helix/pull/11374