Bug 606757 - chattr and lsattr always return 0
chattr and lsattr always return 0
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: e2fsprogs (Show other bugs)
5.5
All Linux
low Severity medium
: rc
: ---
Assigned To: Eric Sandeen
BaseOS QE - Apps
patch exists upstream
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-22 08:31 EDT by Jaroslav Kortus
Modified: 2011-07-21 08:38 EDT (History)
3 users (show)

See Also:
Fixed In Version: e2fsprogs-1.39-28.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-07-21 05:07:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1080 normal SHIPPED_LIVE e2fsprogs bug fix and enhancement update 2011-07-21 05:04:54 EDT

  None (edit)
Description Jaroslav Kortus 2010-06-22 08:31:02 EDT
Description of problem:
chattr and lsattr always return 0 even if they haven't done anything because of errors.

Version-Release number of selected component (if applicable):
e2fsprogs-1.39-23.el5


How reproducible:
100%

Steps to Reproduce:
[root@a1 ~]# lsattr /non/existent/file; echo $?
lsattr: No such file or directory while trying to stat /non/existent/file
0
[root@a1 ~]# chattr +a /non/existent/file; echo $?
chattr: No such file or directory while trying to stat /non/existent/file
0

Actual results:
error code = 0. This makes using in scripts very difficult wrt error checking

Expected results:
EC=0 means that operation was completed successfully. Any failure must result in error code > 0.

Additional info:
Comment 1 Eric Sandeen 2010-06-22 11:13:50 EDT
I have a patch upstream for this:

commit e68594d2376afd10e03b440b4bc288508ad13aa2
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Mon Oct 22 08:51:39 2007 -0400

    chattr: provide an exit code in case of failure and add -f flag
    
    Fix chattr so that if there are errors, it will report it via a
    non-zero exit code.  It will now explicitly give errors when
    attempting to set files that are not files or directories (which are
    currently not supported under Linux).  The -f flag will suppress error
    messages from being printed, although the exit status will still be
    non-zero.
    
    Addresses-Red-Hat-Bugzilla: #180596
    
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
    Signed-off-by: Eric Sandeen <sandeen@redhat.com>

which should resolve the issue.
Comment 4 RHEL Product and Program Management 2010-08-09 15:16:01 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 5 Ric Wheeler 2011-02-01 13:07:15 EST
Eric, did this get pulled into RHEL5 for ext4 or ext3?

Thanks!
Comment 6 Eric Sandeen 2011-02-01 13:16:36 EST
It is in RHEL6 via upstream.  I plan to push it for RHEL5.7.  The fix will be in e2fsprogs' chattr, and will work fine for any filesystem.

-Eric
Comment 7 Eric Sandeen 2011-02-01 17:10:06 EST
Built & tagged in e2fsprogs-1.39-28.el5
Comment 10 errata-xmlrpc 2011-07-21 05:07:46 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1080.html
Comment 11 errata-xmlrpc 2011-07-21 08:38:43 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1080.html

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