GNU bug report logs -
#36583
26.1; emacs 26 tries loading original user's .emacs after su to root
Previous Next
Full log
View this message in rfc822 format
>> BTW, thinking about "dangerous" above, I guess the behavior might make
>> sense when you're `su`ing *from* root rather than the other way around.
> By default, /root on many systems isn't readable by anybody but root, so
> I don't think it makes much sense in any situation...
Good point.
> I think Emacs shouldn't do this at all. When was this introduced, and
> what was the reasoning behind it?
The Texinfo says:
[...]
@xref{Entering Emacs,,, emacs, The GNU Emacs Manual}. If neither
option is specified, Emacs uses the @env{LOGNAME} environment
variable, or the @env{USER} (most systems) or @env{USERNAME} (MS
systems) variable, to find your home directory and thus your init
file; this way, even if you have su'd, Emacs still loads your own init
file. If those environment variables are absent, though, Emacs uses
your user-id to find your home directory.
and it's at least as old as 2007 probably long before.
I still haven't found the corresponding code, so I can't confirm
the origin.
[...hhhmmm...] Ha! Found it!
commit a726e0d12ccb1c49ca1f3e1fbe64addea9b7d3b4
Author: Jim Blandy <jimb <at> redhat.com>
Date: Thu Jul 11 23:17:40 1991 +0000
Initial revision
diff --git a/lisp/startup.el b/lisp/startup.el
--- /dev/null
+++ b/lisp/startup.el
@@ -0,0 +160,6 @@
+ ;; Figure out which user's init file to load,
+ ;; either from the environment or from the options.
+ (setq init-file-user (if noninteractive nil (user-login-name)))
+ ;; If user has not done su, use current $HOME to find .emacs.
+ (and init-file-user (string= init-file-user (user-real-login-name))
+ (setq init-file-user ""))
So yes, goes back pretty far.
Stefan
This bug report was last modified 123 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.