Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 548450 - the file command returns zero exit code even in case of unexisting file being tested
the file command returns zero exit code even in case of unexisting file being...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: file (Show other bugs)
5.4
All Linux
low Severity medium
: rc
: ---
Assigned To: Jan Kaluža
BaseOS QE Security Team
:
Depends On:
Blocks: 580046 608686
  Show dependency treegraph
 
Reported: 2009-12-17 08:52 EST by Martin Cermak
Modified: 2012-10-29 08:59 EDT (History)
3 users (show)

See Also:
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 00:46:06 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
a patch (1.26 KB, patch)
2010-04-08 05:34 EDT, Daniel Novotny
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0201 normal SHIPPED_LIVE file bug fix update 2012-02-20 09:53:52 EST

  None (edit)
Description Martin Cermak 2009-12-17 08:52:40 EST
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 Product and Program Management 2009-12-21 10:20:27 EST
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 05:34:38 EDT
Created attachment 405246 [details]
a patch

a patch to return non-zero status when error occurs
Comment 4 Daniel Novotny 2010-04-14 09:29:26 EDT
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 10:17:26 EDT
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 Product and Program Management 2011-01-11 15:38:28 EST
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 Product and Program Management 2011-01-11 17:34:11 EST
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 Product and Program Management 2011-05-31 09:28:13 EDT
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 07:15:53 EST
    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 00:46:06 EST
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 09:11:15 EDT
    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.

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