bug-bash
[Top][All Lists]
Advanced

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

[PATCH] Fix hang if $OLDPWD points to inaccessible directory


From: Mikulas Patocka
Subject: [PATCH] Fix hang if $OLDPWD points to inaccessible directory
Date: Thu, 28 Sep 2017 11:44:02 +0200 (CEST)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)

Bash attempts to execute the stat syscall on the $OLDPWD variable on every 
startup. This results in hard to diagnose hangs if the $OLDPWD variable 
points to a directory on network filesystem that is inaccessible (for 
example sshfs or nfs).

How to reproduce the hang:

- mount an sshfs directory
/usr/src/git/bash# sshfs user@host:/ /mnt/test -o cache=no,reconnect

- go to the mounted directory
/usr/src/git/bash# cd /mnt/test

- go back
/mnt/test# cd -

- disconnect the network cable (or shut down the remote host)

- execute some command or script via bash
/usr/src/git/bash# bash -c 'echo Hello World'

- bash hangs, because it tries to execute stat("/mnt/test")

Mikulas


---
 variables.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: bash/variables.c
===================================================================
--- bash.orig/variables.c
+++ 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);
       VSETATTR (temp_var, (att_exported | att_invisible));



reply via email to

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