all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file
@ 2003-04-18 16:36 Mark Mynsted
  2003-04-18 18:20 ` Kevin Rodgers
  2003-04-18 18:48 ` Kai Großjohann
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Mynsted @ 2003-04-18 16:36 UTC (permalink / raw)


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.
"

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))

This is clearly not going to work but there must be a way to grab the
output of a shell command without creating an new buffer, writing the
value to the new buffer, then deleting the buffer . . .

Any ideas?  Anybody do this already?

-- 
-MM
I rarely read email from this address          /"\
because of spam.                               \ /     ASCII Ribbon Campaign
I MAY see it if you put #NOTSPAM#               X      Against HTML Mail
in the subject line.                           / \

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file
  2003-04-18 16:36 Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file Mark Mynsted
@ 2003-04-18 18:20 ` Kevin Rodgers
  2003-04-18 20:07   ` Mark Mynsted
  2003-04-18 18:48 ` Kai Großjohann
  1 sibling, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2003-04-18 18:20 UTC (permalink / raw)


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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file
  2003-04-18 16:36 Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file Mark Mynsted
  2003-04-18 18:20 ` Kevin Rodgers
@ 2003-04-18 18:48 ` Kai Großjohann
  2003-04-18 20:10   ` Mark Mynsted
  1 sibling, 1 reply; 5+ messages in thread
From: Kai Großjohann @ 2003-04-18 18:48 UTC (permalink / raw)


Mark Mynsted <mmynsted_news@gbronline.com> writes:

> 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.

Does it help to use "su - otheruser" instead of "su otheruser"?

-- 
file-error; Data: (Opening input file no such file or directory ~/.signature)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file
  2003-04-18 18:20 ` Kevin Rodgers
@ 2003-04-18 20:07   ` Mark Mynsted
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Mynsted @ 2003-04-18 20:07 UTC (permalink / raw)


>>>>> "Kevin" == Kevin Rodgers <ihs_4664@yahoo.com> writes:

Kevin> 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:

Kevin> emacs -u `whoami`
Kevin> emacs --user=`whoami`

Good solution.  I can make an alias for emacs and that will set
the behavior specifically for my account.

Thank you.

-- 
-MM
I rarely read email from this address          /"\
because of spam.                               \ /     ASCII Ribbon Campaign
I MAY see it if you put #NOTSPAM#               X      Against HTML Mail
in the subject line.                           / \

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file
  2003-04-18 18:48 ` Kai Großjohann
@ 2003-04-18 20:10   ` Mark Mynsted
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Mynsted @ 2003-04-18 20:10 UTC (permalink / raw)


Kai> Mark Mynsted <mmynsted_news@gbronline.com> writes:
>> 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.

Kai> Does it help to use "su - otheruser" instead of "su otheruser"?

Yes.  This is a good solution. This way I can get benefits to
other applications in addition to emacs.

Thank you.

-- 
-MM
I rarely read email from this address          /"\
because of spam.                               \ /     ASCII Ribbon Campaign
I MAY see it if you put #NOTSPAM#               X      Against HTML Mail
in the subject line.                           / \

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-04-18 20:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-18 16:36 Set init-file-user via whoami shell command? Prevent load of USER or LOGIN init file Mark Mynsted
2003-04-18 18:20 ` Kevin Rodgers
2003-04-18 20:07   ` Mark Mynsted
2003-04-18 18:48 ` Kai Großjohann
2003-04-18 20:10   ` Mark Mynsted

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.