From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87ims94p6p.fsf@dod.no> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="215832"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Steinar Bang , 36583@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 12 02:40:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hljbf-000txr-TD for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2019 02:40:12 +0200 Original-Received: from localhost ([::1]:45998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hljbZ-0004IY-HO for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jul 2019 20:40:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44625) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hljbW-0004IF-VQ for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 20:40:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hljbV-0000Uu-R3 for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 20:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hljbV-0000Ua-NO for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 20:40:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hljbV-0002vm-JU for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2019 20:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jul 2019 00:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36583 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug wontfix Original-Received: via spool by 36583-submit@debbugs.gnu.org id=B36583.156289194811198 (code B ref 36583); Fri, 12 Jul 2019 00:40:01 +0000 Original-Received: (at 36583) by debbugs.gnu.org; 12 Jul 2019 00:39:08 +0000 Original-Received: from localhost ([127.0.0.1]:39068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hljad-0002uY-LB for submit@debbugs.gnu.org; Thu, 11 Jul 2019 20:39:07 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hljab-0002tn-G3 for 36583@debbugs.gnu.org; Thu, 11 Jul 2019 20:39:06 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CBE0C80E46; Thu, 11 Jul 2019 20:38:59 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0406080AB2; Thu, 11 Jul 2019 20:38:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1562891938; bh=7XatUBowAo8p1d41V6EoDw6JivHm2b+tigrSwanC32Y=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=eJsb6dn11ZMm2ZDQjhWyhBbJajdFWymNFQMZuhi5AsUdrdeen594AH9OFRpB9Lj6q 0rSN6nlNCaXP/hA2ozqV9xkBLgh+knTnV+fANzrxHhgYUPnvgAeoaI47iw8TFJ9sG3 Ui80U3jlqEsBvvZp8XMbsTfrxHoYo1ZtHb8Up27u9jZ48R2u2K99KRHGwls86TtG30 69GG650yhdsixokZH/tzEXfgJ6V9XqpoFokjprxNmRE6ipAyw6IbKhqBHca14Dk0t5 IMVAxPTPN3U/4hszPN6VMV3F5e4ubh+O8xsDKz8FiEUaTwysb0gG/agaZXJ4J+CU8J 4uIezfUp08auQ== Original-Received: from milanesa (104-222-123-229.cpe.teksavvy.com [104.222.123.229]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B54821207A4; Thu, 11 Jul 2019 20:38:57 -0400 (EDT) In-Reply-To: (Lars Ingebrigtsen's message of "Fri, 12 Jul 2019 01:17:21 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162746 Archived-At: >> 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 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