Bug 155373

Summary: Incorrect error message on failed output redirection
Product: Red Hat Enterprise Linux 4 Reporter: Steve Bonds <ij2fdc402>
Component: bashAssignee: Tim Waugh <twaugh>
Status: CLOSED RAWHIDE QA Contact: Ben Levenson <benl>
Severity: low Docs Contact:
Priority: medium    
Version: 4.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-04-20 08:19:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Steve Bonds 2005-04-19 17:38:28 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20041003 Firefox/0.10

Description of problem:
When I redirect output to a location where I would expect to get "permission denied", I instead get "No such file or directory".

Version-Release number of selected component (if applicable):
bash-3.0-19.2

How reproducible:
Always

Steps to Reproduce:
1. log in as a user that can't write to /
2. run the command ">/tempfile"


  

Actual Results:  The shell returns the error "-bash: /tempfile: No such file or directory"

Expected Results:  The shell should have returned the error "bash: /tempfile: Permission denied"  (This is the Red Hat Enterprise 3 behavior.)

Additional info:

An "strace" of the improper behavior (strace sh -c ">/tempfile") shows:

-----
open("/tempfile", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Permission denied)
open("/tempfile", O_WRONLY|O_TRUNC|O_LARGEFILE) = -1 ENOENT (No such file or directory)
-----

It seems that the failure of the first open() is not being detected and the errno from the second open() without O_CREAT is the one getting passed back to the error handler.  In Red Hat Enterprise 3, there is only one open():

-----
open("/tempfile", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 EACCES (Permission denied)
-----

Comment 1 Tim Waugh 2005-04-20 08:19:13 UTC
This was caused by AFS support.  A fix has been committed to CVS for Fedora
development.  Thanks for the report.