On Fri, 29 Sep 2017, Mikulas Patocka wrote:
> > > On Thu, 28 Sep 2017, Eduardo A. Bustamante López wrote: > > > On Thu, Sep 28, 2017 at 11:44:02AM +0200, Mikulas Patocka wrote: > > [...] > > > +++ bash/variables.c > > > @@ -899,7 +899,7 @@ set_pwd () > > > don't find OLDPWD in the environment, or it doesn't name a > > > directory, > > > make a dummy invisible variable for OLDPWD, and mark it as > > > exported. */ > > > temp_var = find_variable ("OLDPWD"); > > > - if (temp_var == 0 || value_cell (temp_var) == 0 || file_isdir > > > (value_cell (temp_var)) == 0) > > > + if (temp_var == 0 || value_cell (temp_var) == 0) > > > { > > > temp_var = bind_variable ("OLDPWD", (char *)NULL, 0); > > > > This patch would revert the change introduced in: > > > > http://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=e6f5e0c858b7c0839d346d7d55e56894648c5a33 > > This patch doesn't revert the above change. It only removes a test if > $OLDPWD is a directory. With this patch, if $OLDPWD points to a directory, > there will be no change, and if $OLDPWD points to non-directory, it will > not be cleared. > > > Which was prompted by the following bug report from John Wiersba: > > https://lists.gnu.org/archive/html/bug-bash/2015-11/msg00115.html > > > > Correct me if I'm wrong, but a hanged sshfs mount will cause many more > > issues, not only with OLDPWD. > > Hung mount shouldn't cause problems unless someone is accessing it. > > What happened to me - I use the autofs filesystem to automatically mount > filesystems on various machines. I was on some autofs-mounted directory, I > moved to the home directory (which is not on autofs) and I typed startx. > Some times after that I shut down the remote machine that provided the > autofs mount. > > The whole X session started to severely mibehave, starting various > programs caused hangs, I couldn't even start an xterm with the shell, I > couldn't even start the chome browser - the reason for the hangs was, that > the OLDPWD variable pointing to the autofs directory ended up being > propagated to the Xserver, to the desktop environment and to any program > that was running within the X session. I caused serious trouble and I > think it should be fixed. > > If I started Xwindow on the non-functioning autofs directory, it would be > expected that I get hangs. However, I started Xwindow in the home > directory that has nothing to do with autofs - and I got hangs. > > Mikulas Another problem is that various daemons change the working directory to "/", so that they don't keep the directory they were started from open - however they don't clear the $OLDPWD environment variable. So the $OLDPWD variable in a daemon could contain arbitrary garbage. If the $OLDPWD variable points to some network directory that is currently inaccessible, the daemon won't be able to start any bash scripts. Mikulas