James Richard Tyrer wrote:
>> While this is an obscure problem. It is a very serious bug since Bash does
>> not correctly set HOME to match the user as reported by:
>> id -un
>
> I thought that I should clarify that this ONLY happens when the LPR daemon
> (which is running as root) calls the filter script (as the user that submitted
> the job) that HOME is not correctly set to the: "passwd" file entry for the
> user.
An examination of the source code (file variables.c) shows that Bash
sets HOME only if it's not already in the environment:
/* Set $HOME to the information in the password file if we didn't get
it from the environment. */
...
static void
set_home_var ()
{
SHELL_VAR *temp_var;
temp_var = find_variable ("HOME");
if (temp_var == 0)
temp_var = bind_variable ("HOME", sh_get_home_dir ());
#if 0
VSETATTR (temp_var, att_exported);
#endif
}
Thus, it is the LPR daemon that is not changing HOME before exec'ing the
filter script.