[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: read-write to stdin-stdout or to a file?



On Fri, Jul 20, 2001 at 08:28:54AM -0300, Pedro Zorzenon Neto wrote:
>    I could use some options like this:
> 
>       $ avrprog -i input.data -o output.data
> 
>    But I chose to use stdin/stdout instead.
> 
>       $ avrprog < input.data > output.data
> 
>    Than I don't need to check if the user has permission to read/write that file, don't need to check for symlink... because the shell will do this for me.

To be accurate, the kernel does it for you. The unprivileged shell does the open
calls and the kernel validates them.

>    Is this right? Did I make the right option when I decided to use
>    stdin/stdout.

It should be safe.

On Fri, Jul 20, 2001 at 04:42:16AM -0700, Vladislav wrote:
> I think, the better way is to use freopen() function
> to reassign stdin, stdout and stderr.
> This is more secure and shell-independant desision...

No, that would defeat the entire point of using stdin/stdout, which was to avoid
the privileged process having to open anything.

-- 
Colin Phipps         PGP 0x689E463E     http://www.netcraft.com/



Reply to: