PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Hosts File Editor Does Not Clear/Reinstate Read Only Status

Open whawn1 opened this issue 2 years ago • 2 comments

Microsoft PowerToys version

0.67.0

Installation method

PowerToys auto-update

Running as admin

Yes

Area(s) with issue?

Hosts File Editor

Steps to reproduce

  1. open hosts file editor
  2. make entry
  3. receive error msg (in pink box at bottom) to the effect that hosts was not saved.
  4. say, "hmmm, why not?"
  5. investigate and discover that the read only status was not changed to allow the file to be written to.
  6. remove read only status manually.
  7. repeat steps 1 & 2
  8. file saved as is ought to be
  9. check file properties, discover read-only status not reinstated
  10. reinstate read-only status manually

✔️ Expected Behavior

Things to work as they ought.
Editor app should remove read-only, save file, reapply read-only.
Should be done automatically, without operator intervention, but perhaps with notice.
If overly cautious, could be done by opening the file property box so change can be made manually -- but why go through that, when you can do it as well or better with notepad+++?

❌ Actual Behavior

As detailed in 'Steps...' The pink error msg box should be much more evident, maybe across the text area. I missed it the first time it showed.

BTW, attempted to generate bug report log. Power toys refused and is now frozen. I take that back -- has just crashed. Restarted it, now have two bug report logs. Here they are: PowerToysReport_2023-02-02-16-42-40.zip PowerToysReport_2023-02-02-16-46-34.zip

Other Software

No response

whawn1 avatar Feb 02 '23 23:02 whawn1

Hi @whawn1 , hosts file is not "Read Only" by default on Windows. If it was set as read only, I assume it was changed. From the point of view of an editor, this is intended behavior (don't write files that are marked as read only). Looks like it's intended behavior. /needinfo

jaimecbernardo avatar Feb 03 '23 12:02 jaimecbernardo

If it is not read-only by default, now, it once was. It ought to be still. That file is vulnerable to all sorts of shenanigans. The editor should take that into account, perhaps with a check box : "allow editing" or some such, and should automatically place it back to read-only.

whawn1 avatar Feb 03 '23 15:02 whawn1