Hasty Briefsbeta

Bilingual

Deep Down the Rabbit Hole: Bash, OverlayFS, and a 30-Year-Old Surprise

10 months ago
  • #OverlayFS
  • #Bash
  • #Debugging
  • A customer reported OpenSSH scp failure after switching to OverlayFS, with an error from Bash about retrieving the current directory.
  • Bash was using its own getcwd() implementation due to a cross-compilation issue, not the glibc version.
  • The issue stemmed from Bash's fallback getcwd() implementation, which made assumptions incompatible with OverlayFS's behavior.
  • OverlayFS's design means inode numbers from readdir() may not match those from stat(), breaking Bash's directory traversal logic.
  • Bash's getcwd() implementation also mishandled errno, leading to misleading error messages like ENOTTY.
  • The problem was resolved by adjusting the build configuration to prevent Bash from using its fallback getcwd().
  • The investigation revealed deeper issues with portability assumptions and legacy code in Bash.