Bug 155373 - Incorrect error message on failed output redirection
Incorrect error message on failed output redirection
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: bash (Show other bugs)
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2005-04-19 13:38 EDT by Steve Bonds
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-04-20 04:19:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Steve Bonds 2005-04-19 13:38:28 EDT
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):

How reproducible:

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 04:19:13 EDT
This was caused by AFS support.  A fix has been committed to CVS for Fedora
development.  Thanks for the report.

Note You need to log in before you can comment on or make changes to this bug.