bug-bash
[Top][All Lists]
Advanced

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

Re: [Fwd: Obscure problem with Bash when printing]


From: James Richard Tyrer
Subject: Re: [Fwd: Obscure problem with Bash when printing]
Date: Tue, 05 Aug 2003 12:22:41 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.4) Gecko/20030624

Francis Litterio wrote:
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.

I have changed the filter script to a login script, which is necessary for it 
to set the
GS environment strings and it sets HOME to "/".

I think that this is the relevant code in: "shell.c":

void
get_current_user_info()
{
  struct passwd *entry;

  /* Don't fetch this more than once. */
  if(current_user.user_name == 0)
    {
      entry = getpwuid(current_user.uid);
      if(entry)
        {
          current_user.user_name = savestring(entry->pw_name);
          current_user.shell = (entry->pw_shell && entry->pw_shell[0])
                                ? savestring(entry->pw_shell)
                                : savestring("/bin/sh");
          current_user.home_dir = savestring(entry->pw_dir);
        }
      else
        {
          current_user.user_name = savestring("I have no name!");
          current_user.shell = savestring("/bin/sh");
          current_user.home_dir = savestring("/");
        }
      endpwent();
    }
}

I can't see how this doesn't work. :-\

It won't help for LPR to set HOME, because the login will change it.

--
JRT







reply via email to

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