From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Steinar Bang <sb@dod.no>, 36583@debbugs.gnu.org
Subject: bug#36583: 26.1; emacs 26 tries loading original user's .emacs after su to root
Date: Thu, 11 Jul 2019 20:38:55 -0400 [thread overview]
Message-ID: <jwvv9w8xfjw.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <m37e8op3em.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 12 Jul 2019 01:17:21 +0200")
>> 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@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
next prev parent reply other threads:[~2019-07-12 0:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 20:20 bug#36583: 26.1; emacs 26 tries loading original user's .emacs after su to root Steinar Bang
2019-07-10 20:50 ` Glenn Morris
2019-07-11 22:58 ` Stefan Monnier
2019-07-11 23:17 ` Lars Ingebrigtsen
2019-07-12 0:38 ` Stefan Monnier [this message]
2019-07-12 14:34 ` Lars Ingebrigtsen
2019-07-12 23:39 ` Richard Stallman
2019-07-13 9:21 ` Andreas Schwab
2019-07-13 9:34 ` Stefan Kangas
2019-07-13 23:02 ` Richard Stallman
2019-07-13 23:16 ` Andreas Schwab
2019-07-13 13:09 ` Stefan Monnier
2019-07-13 23:05 ` Richard Stallman
2019-07-15 12:49 ` Stefan Monnier
2019-07-15 13:04 ` Noam Postavsky
2019-07-15 14:42 ` Stefan Monnier
2019-07-23 13:53 ` Steinar Bang
2019-07-23 14:30 ` Stefan Monnier
2019-08-04 10:57 ` Steinar Bang
2019-07-12 6:37 ` Eli Zaretskii
2019-07-12 14:46 ` Stefan Monnier
2019-07-12 14:53 ` Eli Zaretskii
2019-07-12 15:00 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvv9w8xfjw.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=36583@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=sb@dod.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.