help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set init-file-user via whoami shell command? Prevent load of USER or


From: Kevin Rodgers
Subject: Re: Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file
Date: Fri, 18 Apr 2003 12:20:25 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Mark Mynsted wrote:

I want emacs to load the init file for the effective user, i.e. when
I su to a different user I wan that user's init file to load.

The documentation says:
"
How Emacs Finds Your Init File
------------------------------

   Normally Emacs uses the environment variable `HOME' to find
`.emacs'; that's what `~' means in a file name.  But if you run Emacs
from a shell started by `su', Emacs tries to find your own `.emacs',
not that of the user you are currently pretending to be.  The idea is
that you should get your own editor customizations even if you are
running as the super user.

   More precisely, Emacs first determines which user's init file to use.
It gets the user name from the environment variables `LOGNAME' and
`USER'; if neither of those exists, it uses effective user-ID.  If that
user name matches the real user-ID, then Emacs uses `HOME'; otherwise,
it looks up the home directory corresponding to that user name in the
system's data base of users.
"


That node's parent (Init File) says:

|    When Emacs is started, it normally loads a Lisp program from the file
| `.emacs' in your home directory.  We call this file your "init file"
| because it specifies how to initialize Emacs for you.  You can use the
| command line switches `-q' and `-u' to tell Emacs whether to load an
| init file, and which one (*note Entering Emacs::.).

That reference isn't very useful, though.  The relevant information is in
the "Initial Options" node:

| `-u USER'
| `--user=USER'
|      Load USER's Emacs init file `~USER/.emacs' instead of your own.


This is precisely the behavior I do not want.  I think that if I can
somehow set the value of init-file-user to the effective user in the
site init file, then I would be fine.
How can I get the value of the effective user?

The following shell-command function loads the correct value, but puts
it in the buffer, not in a result that I know how to use.
(shell-command "whoami" 1)

How can I get the value something like the following to work?
(set-variable 'init-file-user (shell-command "whoami" 1))

emacs -u `whoami`

emacs --user=`whoami`

--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]