FarManager icon indicating copy to clipboard operation
FarManager copied to clipboard

Far fails to save file after elevate to administrator

Open leg0 opened this issue 3 years ago • 7 comments

When editing an existing file that I don't have permissions to write to, on save Far prompts me to elevate to administrator in order to save the file. After elevating to administrator, instead of saving the file, I get an error message telling me that The system cannot find the file:

far-error

I tried different versions and found that this error started happening between versions v3.0.5411.1023 and v3.0.5410.1019. Still fails with v3.0.5709.1854.

leg0 avatar Nov 27 '20 14:11 leg0

Looks like the bug was introduced in this commit: 9c47236cb9b1a0d608b5b0cc9157c1be52e56f60

leg0 avatar Nov 27 '20 14:11 leg0

Is that a network mapped drive?

bitraid avatar Nov 27 '20 14:11 bitraid

@bitraid No, It's a physical disk. I also noticed that there are FARnnnn.tmp (nnnn being sequence of 4 hex digits) files created next to the file I am trying to edit. They look like copies of the original file.

leg0 avatar Nov 27 '20 15:11 leg0

@leg0 if you set Editor.SaveSafely to false in far:config the previous behavior (direct write) will be used and (probably) your issue will disappear.

However, can you provide more details please:

  • Is P: a subst disk?
  • what does icacls p:\bla.bat say?

alabuzhev avatar Nov 27 '20 18:11 alabuzhev

Thanks, @alabuzhev, setting Editor.SaveSafely=false solved my problem.

I think the error message should be a bit more clear about the failure and maybe give a hint how to solve it.

No, P is not a subst disk. It is a physical disk that has been assigned letter P.

P:\>icacls p:\bla.bat   
p:\bla.bat NT AUTHORITY\SYSTEM:(I)(F)
my_username:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)
Mandatory Label\High Mandatory Level:(I)(NW) 

leg0 avatar Nov 30 '20 07:11 leg0

FWIW, I periodically see this problem. I do usually use Far elevated but I cannot tell if this is related.

I think in my case the problem happens more often when I open VS or VSCode in the same folder. I'll try using the old Editor.SaveSafely=false, thanks for reminding.

nightroman avatar Nov 30 '20 10:11 nightroman

I get the same issue when trying to edit the C:\Windows\System32\drivers\etc\hosts file.

C:\Windows\System32\drivers\etc>icacls.exe hosts 
hosts Everyone:(F)
      NT AUTHORITY\SYSTEM:(I)(F)
      BUILTIN\Administrators:(I)(F)
      BUILTIN\Users:(I)(RX)
      APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(I)(RX)
      APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES:(I)(RX)

Note that the file is allowed to be edited by anyone (for compatibility with some old software), which in my understanding means that I should not get an elevation request in the first place.

Setting Editor.SaveSafely=false via far:config seems to resolve the issue for now, thanks.

SergeyBiryukov avatar Feb 01 '22 18:02 SergeyBiryukov