Control: forwarded -1 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32413
On 2018-08-10 01:09:13 -0500, Rob Browning wrote: > Vincent Lefevre <vinc...@vinc17.net> writes: > > "su -l" is not a solution as it reset the current working directory. > > And one should still be able to run X applications after su. > > Hmm, is that true? -, -l, --login Start the shell as a login shell with an environment similar to a real login: o clears all the environment variables except TERM o initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH o changes to the target user's home directory ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ o sets argv[0] of the shell to '-' in order to make the shell a login shell The fact that it clears all the environment variables except TERM. The fact that the LC_* environment variables are cleared may be annoying too. BTW, there is no guarantee that TERM will still work if TERMINFO is cleared! I sometimes use a user-defined TERM, so that keeping TERMINFO is important in that case. > I don't actually know, but the suggestion I'd often > heard is to generally avoid running X applications much as root, but if > I were going to, I'd use "su -", which (now that I look) does appear to > handle at least XAUTHORITY -- though I'd still be wary. As you can see above, XAUTHORITY is cleared too. I also avoid running X applications, except Emacs. > > But in any case, emacs shouldn't create files/directories if the > > user hasn't explicitly asked it to do that. > > I'd expect emacs to create various files via gtk, dbus, and other > subsystems it uses, and it's certainly going to create bits like > ~/.emacs and ~/.emacs.d if it needs to (for M-x customize, etc.). I don't use M-x customize, certainly not as root. If the user doesn't modify his configuration, there is no need to create such files. Anyway, for ~/.emacs and ~/.emacs.d, there are no problems since HOME is set to one for the target user, e.g. to "/root" (unless -m or -p is used, but I've said that I do not use them). > Whether or not it's doing it correctly is another question, but I'm not > at all surprised that plain "su" with an X-based emacs frame (i.e. not > "emacs -nw") has trouble. Historically, there had never been any problem. AFAIK, it was assumed that the only files that could be created automatically (e.g. caches) would be under $HOME, but HOME is set to one for the target user, avoiding issues. The same bug was reported here against Fedora 25: https://bugzilla.redhat.com/show_bug.cgi?id=921689 and was closed a few years later due to Fedora 25 EOL. I've also just seen https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732209 but this may be different as this is related to desktop environments (potentially a more complex case to decide what to do). > If you want to pursue this, I suspect you should pursue it upstream, > or I'll plan to forward it later if you prefer. I've just reported a bug upstream: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32413 -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)