On 11/3/07, Kyle Moffett <[EMAIL PROTECTED]> wrote: > On Nov 03, 2007, at 12:43:06, Ahmed S. Darwish wrote: > > Bashv3 builtin "echo" behaves very strangely to -EINVAL. It sends > > all the buffers that causes -EINVAL again in subsequent echo > > invocations. > > > > i.e. > > echo "Invalid Rule" > /smack/load # -EINVAL returned > > echo "Valid Rule" > /smack/load > > > > In seconod iteration, echo sends the first invalid buffer again > > then sends the new one. This causes a "Invalid Rule\nValid Rule" > > buffer sent to write(). > > > > IMHO, this is a bug in builtin echo. The external /bin/echo doesn't > > cause such strange behaviour. > > Actually, what causes problems here is something between a bug and a > feature in libc's buffering. Basically the -EINVAL error causes libc > to leave its data in the file-output buffer despite the file being > closed and reopened. Since a standalone echo just exits that buffer > is discarded, but for the bash builtin it hangs around in the buffer > for a while and ends up getting prepended to the following echo > statement. There's actually multiple ways to make this fail; this is > just the simplest. >
Thanks a lot for such a useful info. Is there a way from my side to make subsequent echo invocations not affected by previous failed ones ? Regards, -- Ahmed S. Darwish Homepage: http://darwish.07.googlepages.com Blog: http://darwish-07.blogspot.com - To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html