Subject: bug#36583: 26.1; emacs 26 tries loading original user's .emacs after su to root

From: Noam Postavsky <[email-masked]>
Date: Mon, 15 Jul 2019 09:04:51 -0400

Stefan Monnier <[email-masked]> writes:

> How 'bout let the /root/.emacs file do something like:
>
>     (load (concat "~" (user-login-name) "/.emacs"))
>     
> ?
> For convenience, we could provide an ad-hoc function that would do that
> "right" (i.e. looking for .emacs, .emacs.d/init.el, and things like
> that).  We could even put it in /root/.emacs.d/early-init.el.

Wouldn't it be simpler to do this in the shell, e.g.,

    cat >>/root/.bashrc <<'EOF'
    alias emacs='emacs -u "$LOGNAME"'
    EOF

although I would personally suggest

    cat >>/root/.bashrc <<'EOF'
    alias emacs='echo Do not run emacs as root'
    EOF