Make sure USER variable is correct. Needed when using the su command.

darcs-hash:20051023102232-ac50b-4ed7c9de75ece8a1d9ba7ec5c086bde146436db9.gz
This commit is contained in:
axel 2005-10-23 20:22:32 +10:00
parent fc5e0ab367
commit ba6ad5025e
2 changed files with 21 additions and 9 deletions

View File

@ -503,7 +503,7 @@ inherited by any commands started by fish. It is convention that
exported variables are in uppercase and unexported variables are in
lowercase.
Variables can be explicitly set to be exportes with the \c -x or \c
Variables can be explicitly set to be exported with the \c -x or \c
--export switch, or not exported with the \c -u or \c --unexport
switch. The exporting rules when creating or updating a variable are
identical to the scoping rules for variables:
@ -557,7 +557,7 @@ echo $smurf
\subsection variables-special Special variables
The user can change the settings of \c fish by changing the values of
certain environment variables.These are:
certain environment variables.
- \c BROWSER, which is the users preferred web browser. If this variable is set, fish will use the specified browser instead of the system default browser to display the fish documentation.
- \c CDPATH, which is an array of directories in which to search for the new directory for the \c cd builtin.
@ -569,12 +569,15 @@ values of certain environment variables. The user can not change the values of t
- \c _, which is the name of the currently running command.
- \c history, which is an array containing the last commands that where entered
- \c HOME, which is the users home directory. This variable can be changed by the root user.
- \c HOME, which is the users home directory. This variable can only be changed by the root user.
- \c PWD, which is the current working directory.
- \c status, which is the exit status of the last foreground job to exit. If a job contains pipelines, the status of the last command in the pipeline is the status for the job.
- \c USER, which is the username. This variable can only be changed by the root user.
\c fish also uses several variables internally. Such variables are
prefixed with the string __FISH or __fish. These should be ignored by the user.
Variables whose name are in uppercase are exported to the commands
started by fish. \c fish also uses several variables internally. Such
variables are prefixed with the string __FISH or __fish. These should
be ignored by the user.
\section builtin-overview Builtins

11
env.c
View File

@ -234,6 +234,8 @@ static void universal_callback( int type,
void env_init()
{
char **p;
struct passwd *pw;
wchar_t *uname;
sb_init( &dyn_var );
@ -253,11 +255,14 @@ void env_init()
hash_put( &env_read_only, L"PWD", L"" );
/*
HOME should be writeable by root, since this is often a
HOME and USER should be writeable by root, since this can be a
convenient way to install software.
*/
if( getuid() != 0 )
{
hash_put( &env_read_only, L"HOME", L"" );
hash_put( &env_read_only, L"USER", L"" );
}
top = malloc( sizeof(env_node_t) );
top->next = 0;
@ -302,6 +307,10 @@ void env_init()
free(key);
}
pw = getpwuid( getuid() );
uname = str2wcs( pw->pw_name );
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
env_universal_init( env_get( L"FISHD_SOKET_DIR"),
env_get( L"USER" ),
&start_fishd,