retitle 586736 dash: Can't open read-only scripts merge 586807 586736 thanks
Krzysztof A. Sobiecki wrote: > sob...@solis:/tmp$ ./a.sh > /bin/sh: Can't open ./a.sh > > During the boot-up process / partition is read-only and because of that > dash is unable to execute /etc/init.d/rcS and /etc/init.d/rc scripts. > > Apparently problem lies inside patch: > 0006--INPUT-exit-127-if-command_file-is-given-but-doesn-t.diff [...] > > - if ((fd = open(fname, O_RDONLY)) < 0) { > + if ((fd = open(fname, O_RDWR)) < 0) { > > After changing it back to O_RDONLY dash properly executes read-only scripts. Thanks for the triage. Here’s a pointer for the interested: http://thread.gmane.org/gmane.comp.shells.dash/291/focus=295 > Why would anyone want to open script in read-write mode? Based on open(2), I am guessing it is a hack to force EISDIR when fname refers to a directory. That is, I am guessing the intended effect is something like this: static int isdir_hack(int fd) { struct stat64 st; if (fstat64(fd, &st) < 0) return -1; if (S_ISDIR(st.st_mode)) { errno = EISDIR; return -1; } return 0; } ... if ((fd = open(fname, O_RDONLY)) < 0 || isdir_hack(fd) < 0) { Please take that with a grain of salt, since I am not familiar with this code. Cheers, Jonathan -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org