Bug 606757 - chattr and lsattr always return 0
Summary: chattr and lsattr always return 0
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: e2fsprogs
Version: 5.5
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Eric Sandeen
QA Contact: BaseOS QE - Apps
URL:
Whiteboard: patch exists upstream
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-22 12:31 UTC by Jaroslav Kortus
Modified: 2011-07-21 12:38 UTC (History)
3 users (show)

Fixed In Version: e2fsprogs-1.39-28.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-21 09:07:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1080 0 normal SHIPPED_LIVE e2fsprogs bug fix and enhancement update 2011-07-21 09:04:54 UTC

Description Jaroslav Kortus 2010-06-22 12:31:02 UTC
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 15:13:50 UTC
I have a patch upstream for this:

commit e68594d2376afd10e03b440b4bc288508ad13aa2
Author: Theodore Ts'o <tytso>
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>
    Signed-off-by: Eric Sandeen <sandeen>

which should resolve the issue.

Comment 4 RHEL Program Management 2010-08-09 19:16:01 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 5 Ric Wheeler 2011-02-01 18:07:15 UTC
Eric, did this get pulled into RHEL5 for ext4 or ext3?

Thanks!

Comment 6 Eric Sandeen 2011-02-01 18:16:36 UTC
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 22:10:06 UTC
Built & tagged in e2fsprogs-1.39-28.el5

Comment 10 errata-xmlrpc 2011-07-21 09:07:46 UTC
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 12:38:43 UTC
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.