Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix $PWD breakage on fork; cd; exec (rhbz#1168611)
This applies the following Red Hat patch: https://src.fedoraproject.org/rpms/ksh/blob/642af4d6/f/ksh-20120801-cdfork.patch The associated bug report is public, but nearly all info (such as a reproducer) has been wiped: https://bugzilla.redhat.com/1168611 However, the errata blurb is mildly informative: "Previously, ksh sometimes incorrectly initialized a variable holding the path of the working directory. If a program changed the working directory between forking and ksh execution, then ksh could contain an incorrect value in the working directory variable. With this update, initialization of the working directory variable has been corrected, and ksh now contains the correct value in the aforementioned situation." Also, the patch makes a lot of sense on the face of it. It removes an optimisation in path_pwd() that checks for the directory defined by e_crondir[] in data/msg.c, which is: const char e_crondir[] = "/usr/spool/cron/atjobs"; Of /usr/spool not existed on any system for decades as it is common to mount usr as read-only, so all the writable stuff was moved to /var. So that would never check out. And if 'flag' is nonzero, the optimizing 'count++' is executed regardless of whether that directory exists, ensuring that it never gets the real PWD and defaults to returning ".". src/cmd/ksh93/sh/path.c: - Apply patch as described. - Mark 'flag' variable as NOT_USED to suppress compiler warning. Keep it for backwards compat, as some programs that link with libshell might use this function (though it's undocumented). src/cmd/ksh93/include/path.h, src/cmd/ksh93/data/msg.c: - Remove now-unused e_crondir[].
- Loading branch information