Closed ceridwen closed 3 years ago
Hm. That could be a problem. I will look into it.
Do you know if there is a way to detect if you are using sudo under emacs?
Perhaps on most unix systems, if /etc/sudoers
is writable, you will have sudo access. I am unsure about this, since I don't currently have access to a linux system where I have sudo access.
I don't know about emacs in particular, but there are a number of methods to check for sudo specifically or whether you have root privileges in general, with varying degrees of robustness. sudo is not part of the POSIX standard to my knowledge so implementations may vary. On my Ubuntu system, the environment variables SUDO_COMMAND, SUDO_USER, SUDO_UID, and SUDO_GID are set when I'm running a command with sudo. These could be faked, but for this purpose, I'm not sure that matters. You can use geteuid and getuid to detect whether a user has switched user ids after logging in, though this will catch non-sudo uses too. You can use sudo to run a command as a different user, not root, too, but that could still potentially modify .emacs to be owned by another user depending on what permissions are set on the original user's .emacs.
Reopen if you have issues on the new github version
When I use sudo with my user account to use emacs to edit system configuration files, afterwards .emacs will be owned by root and ergoemacs mode will start throwing errors because it can't write to it. I'm guessing this happens because ergoemacs mode writes to .emacs on close, even if I didn't make any configuration changes.