Use sudo if required to read or stat a file#4141
Open
SollyBunny wants to merge 2 commits into
Open
Conversation
a3b6f48 to
e702f28
Compare
Author
|
Everything seems to work, here's what I have tested For every file: make an edit and save it sudo rm -rf /tmp/microtest
mkdir /tmp/microtest && cd /tmp/microtest
touch file
touch readonly
sudo chown root:root readonly
sudo chmod 444 readonly
touch writeonly
sudo chown root:root writeonly
sudo chmod 222 writeonly
touch root
sudo chown root:root
sudo chmod 777 writeonly
mkdir dir
mkdir rootdir
sudo chown root:root rootdir
sudo chmod 000 rootdir
sudo touch rootdir/file
sudo mkdir rootdir/dir
micro file
micro dir
micro readonly # new behaviour
micro writeonly # new behaviour
micro root # new behaviour
micro noexist
micro rootdir
micro rootdir/file # save doesnt support sudo inside unstatable yet
micro rootdir/dir # save doesnt support sudo inside unstatable yet
# micro rootdir/noexist/a # mkparents doesnt use sudo yet |
Author
|
Now that loading is async, the tests need to wait for the buffers to be available. |
Andriamanitra
left a comment
Contributor
There was a problem hiding this comment.
I'm not convinced this feature is a good idea:
- no other editor I know of does it (I checked nano, nvim, emacs, helix)
- the implementation is fiddly and the sudo feature for writing files is already a common source of issues in micro (especially on Windows)
- you should probably be using
sudo -e/sudoedit(or equivalent) if you want to edit something that requires superuser privileges 1
Footnotes
| } | ||
|
|
||
| func findBuffer(file string) *buffer.Buffer { | ||
| time.Sleep(time.Second / 10) // TODO wait for open command to be done instead of waiting |
Contributor
There was a problem hiding this comment.
I really do not like this line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If trying to modify a file which requires elevated permissions you have to make micro elevated which
Draft because tests are failing and I would like to add more for this as there are lots of cases
First time doing anything proper with go