Re: [PATCH] [INPUT] exit 127 if command_file is given but doesn't exist

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

 



On Mon, Jun 14, 2010 at 09:54:51AM +0000, Gerrit Pape wrote:
>
> @@ -405,11 +406,13 @@ setinputfile(const char *fname, int flags)
>  	int fd;
>  
>  	INTOFF;
> -	if ((fd = open(fname, O_RDONLY)) < 0) {
> +	if ((fd = open(fname, O_RDWR)) < 0) {

Why should the file be writeable?

Please do not mix multiple changes in one patch.

>  		if (flags & INPUT_NOFILE_OK)
>  			goto out;
> -		sh_error("Can't open %s", fname);
> +		exitstatus = 127;
> +		exerror(EXIFILE, "Can't open %s", fname);
>  	}
> +	fcntl(fd, F_SETFL, O_RDONLY);

This is wrong.  You're creating exactly the problem that Jilles
was talking about where dot(1) is returning 127.  This code should
be moved to procargs, which runs only for the "sh script" case.

Thanks,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux