Hans-Albert Schneider <Hans-Albert.Schneider@mchp.siemens.de> writes:
"Carsten" == Carsten Karkola <carsten.karkola@mailbox.tu-dresden.de> writes: ... Carsten> thanks for your help, now I ended up with Carsten> ... Carsten> + 4<& 0 Carsten> + ../src/setid root Carsten> + 0< install.sh2 Carsten> /bin/sh[11]: 4: 0403-007 Generated or received a Carsten> file descriptor number that is not valid. Carsten> + exit 1 ... ... Yes, that sounds like sh and ksh have a problem with the "exec 4<& 0" in install.sh.
Actually, I don't think its the "exec 4<&0" that's the problem...
Hmm, that means "open a new file descriptor (fd) number 4 and connect it to fd 0". I can imagine that having two fds reading from the same stream confuses the shell, especially if one of them is stdin (fd 0). Maybe it even cannot process this special variant of the exec instruction.
If that was true, then the n<&m redirection format would be completely useless. That's certainly not true for ksh. Checking a copy of the manpage for the newest ksh from AT&T Labs, I see that redirections to file descriptors greater than 2 are set to be close-on-exec. That would explain it because then the shell invoked by setid would find fd 4 closed.
Does anyone know the reason for this input redirection, BTW?
The install.sh2 script needs the original stdin, while setid takes the script to be invoked as the other user on its stdin. Carsten, can you try changing the install.sh file around the setid invocations from: exec 4<&0 case $installerid in [0-9]*) . ./install.sh2 ;; *) $setid $installerid <install.sh2 || exit 1;; esac $setid $listid $target <install.sh3 || exit 64 exec 4<&- to: case $installerid in [0-9]*) . ./install.sh2 4<&0 ;; *) $setid $installerid 4<&0 <install.sh2 || exit 1;; esac $setid $listid $target 4<&0 <install.sh3 || exit 64 and then try it again under AIX or with ksh, whichever shell made it fail before? Philip Guenther