coteditor / CotEditor

Lightweight Plain-Text Editor for macOS
https://coteditor.com
Other
6.22k stars 425 forks source link

Unable to edit `/etc/sudoers` file due to a permission issue #1657

Closed dralshehri closed 1 week ago

dralshehri commented 1 week ago

Description

When trying to edit the sudoers file /etc/sudoers using CotEditor, I get the following message:

The document “sudoers.tmp” could not be opened. You don’t have permission.

To Reproduce

Run the following command:

EDITOR="cot -w" sudo visudo

Expected behavior

The sudoers temporary file /etc/sudoers.tmp should open in CotEditor and be edited normally.

CotEditor version

CotEditor: 4.8.6 (655)

macOS version

macOS Version 14.5 (Build 23F79)

Additional context

Another issue that may be related is editing config files using chezmoi. When I try to edit a file using a command like EDITOR="cot -w" chezmoi edit ~/.zshrc, the file opens as a temporary file in a chezmoi-* directory under $TMPDIR, however, when I try to save the changes, I get this message:

The document “.zshrc” could not be saved. The file is locked.

and when I hit "Save Anyway", I get this message:

You don’t have permission to save the file “.zshrc” in the folder “chezmoi-edit566696390”.
1024jp commented 1 week ago

CotEditor cannot overwrite the files that don't have permission even with sudo. This action is restricted by Apple as long as CotEditor is sandboxed.