Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crux-find-alternate-file-as-root called on local files #20

Closed
gperaza opened this issue Feb 12, 2016 · 3 comments
Closed

crux-find-alternate-file-as-root called on local files #20

gperaza opened this issue Feb 12, 2016 · 3 comments

Comments

@gperaza
Copy link

gperaza commented Feb 12, 2016

When attempting to open a new file crux-reopen-as-root always calls crux-find-alternate-file-as-root and prompts for password.
I had to remove the hook for find-file.

@bbatsov
Copy link
Owner

bbatsov commented Feb 14, 2016

I'm guessing something's off with the permissions of those local files.

@dgtized
Copy link
Contributor

dgtized commented Feb 14, 2016

Hmm. I might be wrong, but have recently noticed that whenever I use M-. to jump to system installed elisp, the first load fails due to an attempt to re-open as root.

After a brief investigation I can confirm it with the following sequence:

(xref-find-definitions 'find-file) ;; asks for sudo root privileges
(kill-buffer "files.el.gz") ;; close buffer so find file will trigger again
(remove-hook 'find-file-hook 'crux-reopen-as-root)
(xref-find-definitions 'find-file) ;; jumps directly to files.el.gz with no password prompt
(kill-buffer "files.el.gz") ;; close buffer again
(add-hook 'find-file-hook 'crux-reopen-as-root) ;; re-add offending hook
(xref-find-definitions 'find-file) ;; prompts for sudo root again

I don't believe the hook should be that aggressive about re-opening as root.

@Wilfred
Copy link
Contributor

Wilfred commented Mar 29, 2016

I've bumped into this too. I fixed it with:

(remove-hook 'find-file-hook #'crux-reopen-as-root)

Currently, opening any file that is read-only and not owned by the current user triggers a root login prompt. This occurs for viewing system files (e.g /etc/fstab), built-in elisp libraries (e.g. simple.el.gz) and simply viewing files owned by other users on a shared system.

This is assuming that the user wants to open the file, as root, and edit it. This isn't always true. If I don't have root on that box, it's pointless. If I just want to view an important system file, it's hazardous to open it as root as I might accidentally make changes that break things.

Changing the default behaviour of find-file like this caught me by surprise. @bbatsov what's the original intent of this feature? Could we make this opt-in, the same way crux keybindings are opt-in?

Wilfred added a commit to Wilfred/crux that referenced this issue Apr 5, 2016
Currently, opening any file that is read-only and not owned by the
current user triggers a root login prompt. This occurs for viewing
system files (e.g /etc/fstab), built-in elisp
libraries (e.g. simple.el.gz) and simply viewing files owned by other
users on a shared system.

We can't assume that this is the behaviour users want, and changing
built-in functions without asking is surprising.

Fixes bbatsov#20.
Wilfred added a commit to Wilfred/.emacs.d that referenced this issue Apr 10, 2016
Wilfred added a commit to Wilfred/crux that referenced this issue Apr 30, 2016
Rather than changing the default find-file behavior, providing a minor
mode enables users to opt-in or toggle the behavior.

Fixes bbatsov#20.
Wilfred added a commit to Wilfred/crux that referenced this issue Apr 30, 2016
Rather than changing the default find-file behavior, providing a minor
mode enables users to opt-in or toggle the behavior.

Fixes bbatsov#20.
Wilfred added a commit to Wilfred/crux that referenced this issue Apr 30, 2016
Rather than changing the default find-file behavior, providing a minor
mode enables users to opt-in or toggle the behavior.

Fixes bbatsov#20.
bbatsov pushed a commit that referenced this issue Apr 30, 2016
Rather than changing the default find-file behavior, providing a minor
mode enables users to opt-in or toggle the behavior.

Fixes #20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants