site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com int rc = system("date >/usr/tmp/tmp.kPCvVa"); If fails with rc == 256 and errno == 0 and prints this to stderr: sh: line 1: 1: Bad file descriptor the shell handles the redirection and creates the output file so its not really an indicator that your path is ok. its a bad idea to just call 'date' and not give the full path since some user program called date (and someone somwhere has probably done this) would interfere with proper behavior. The system() library routine operates by doing a: execl( "/bin/sh", "-c", "date >/usr/tmp/tmp.kPCvVa", NULL); _exit(127); /* not reached normally */ -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Jul 6, 2007, at 12:08 PM, chas williams - CONTRACTOR wrote: In message <75D481373A76D311A5790090274F2B5C09289B39@mailsrv1.gemstone.com
,Nor
m Green writes: I know the path is OK because the file /usr/tmp/tmp.kPCvVa *IS* created, but it has a size of zero. For this particular case, you are most likely correct, and it's the raw "date" that's not being correctly interpreted in his code. Since he is getting back what he is getting back (256 - btw, the correct way to decode this is using the macros used by waitpid() - see the man page), then it's most likely a bad fd. I expect that either "date" is not in the default shell path, or he is invoking this as root (in which case, security dictates that his path be cleaned out on him by the shell program), or his default path is bogus, or he has built and replaced /bin/sh with his own code, or linked it to another sell program, other than the MacOS X default, which is a specifically modified "bash". Probably setting the "date" to "/bin/date" instead would fix this: The bad fd the shell is complaining about is likely the fd in the fread() of the popen() of the date command, built into the shell, and the difference is whether or not stack pages contain "bad garbage" or "good garbage" in the shell itself (as Justin Walker pointed out might be the case). Note that if he is running this program as root, and there are local accounts, it would be rather trivial to get root on the machine as an ordinary unprivileged user account using this program as is... This email sent to site_archiver@lists.apple.com