Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 548450

Summary: the file command returns zero exit code even in case of unexisting file being tested
Product: Red Hat Enterprise Linux 5 Reporter: Martin Cermak <mcermak>
Component: fileAssignee: Jan Kaluža <jkaluza>
Status: CLOSED ERRATA QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: low    
Version: 5.4CC: ksrot, mmalik, ovasik
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: file-4.17-18 Doc Type: Bug Fix
Doc Text:
The file utility can exit with the 0 exit code even if some input files have not been found. This behavior is correct; refer to the file(1) man page for more information.
Story Points: ---
Clone Of:
: 580046 608686 (view as bug list) Environment:
Last Closed: 2012-02-21 05:46:06 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:
Bug Depends On:    
Bug Blocks: 580046, 608686    
Attachments:
Description Flags
a patch none

Description Martin Cermak 2009-12-17 13:52:40 UTC
Description of problem:

   %SUMMARY

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

   file-4.17-15.el5_3.1

How reproducible:

   Always

Steps to Reproduce:

[root@localhost ~]# file this_file_does_not_exist
this_file_does_not_exist: ERROR: cannot open `this_file_does_not_exist' (No such file or directory)
[root@localhost ~]# echo $?
0
[root@localhost ~]#
  
Actual results:

  Returns zero exitcode.

Expected results:

  Should IMHO return some non-zero exitcode.

Additional info:

Comment 1 RHEL Program Management 2009-12-21 15:20:27 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".

Comment 2 Daniel Novotny 2010-04-08 09:34:38 UTC
Created attachment 405246 [details]
a patch

a patch to return non-zero status when error occurs

Comment 4 Daniel Novotny 2010-04-14 13:29:26 UTC
got this answer from upstream while submitting patch:

---------
Imagine the scenario where we have to classify many files. What should
happen if one of them does not exist/cannot be read?

According to: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html

    If file does not exist, cannot be read, or its file status could
    not be determined, the output shall indicate that the file was
    processed, but that its type could not be determined.

So it is reallly not an error if something went wrong dealing with a particular
file. "The output" means stdout to me.
----------

does this mean we are supposed to not use the patch and treat the whole thing as NOTABUG?

Comment 5 Martin Cermak 2010-04-14 14:17:26 UTC
We should IMHO distinguish between situation when file does not exist or cannot be read, which should end up with a non-zero exitcode. Another thing is situation where the file utility can't determine the file type - in this case I would expect a "can not determine file type" message at stdout and zero exitcode.

Comment 10 RHEL Program Management 2011-01-11 20:38:28 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 11 RHEL Program Management 2011-01-11 22:34:11 UTC
This request was erroneously denied for the current release of
Red Hat Enterprise Linux.  The error has been fixed and this
request has been re-proposed for the current release.

Comment 12 RHEL Program Management 2011-05-31 13:28:13 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 17 Jan Kaluža 2012-01-05 12:15:53 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: File exits with 0 exit code even some input files were not found.

This behaviour is OK according to POSIX specification and have been documented in file man page.

Comment 18 errata-xmlrpc 2012-02-21 05:46:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0201.html

Comment 19 Eliska Slobodova 2012-08-27 13:11:15 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,3 +1 @@
-Cause: File exits with 0 exit code even some input files were not found.
+The file utility can exit with the 0 exit code even if some input files have not been found. This behavior is correct; refer to the file(1) man page for more information.-
-This behaviour is OK according to POSIX specification and have been documented in file man page.