Bug 465438

Summary: builtins do not report errors on failed file operations
Product: Red Hat Enterprise Linux 5 Reporter: Tomas Smetana <tsmetana>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED ERRATA QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: high    
Version: 5.1CC: jplans, kvolny, mfabry, rvokal, tao
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
The ksh builtins fail to report errors on failed file operations, for example, they would not report an error if they were unable to write to a file because of no space on a disk. This could result in data loss, because a user would have no warning that data was not saved. Builtins now provide a proper return code and present an error message to the user if they are unable to complete a file operation. This prevents the user from incorrectly assuming that the file operation has completed correctly in cases where it has not.
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-02 09:11:01 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:
Attachments:
Description Flags
patch against ksh-20080202 none

Description Tomas Smetana 2008-10-03 10:49:06 UTC
The ksh builtins fail to report errors on failed file operations, e.g.:

echo "something" > /mnt/filesystem/file.txt

Will not report an error and would have zero return code even if "/mnt/filesystem" was full and the file.txt could not be written to.

This problem seems to be present even in the latest upstream version and is caused by not checking the return codes of sfsync/sfwrite/sfclose functions. Excerpt from src/cmd/ksh93/bltins/print.c:

342     else if(n&SF_SHARE)
343     {
344         sfset(outfile,SF_SHARE|SF_PUBLIC,1);
345         sfsync(outfile);
346     }
347     return(exitval);

Note the line 345: if sfsync fails, the builtins print printf or echo would still return no error which may lead to data loss.  The return codes of sfsync/sfclose or sfwrite should not be ignored and any error should be indicated to the user with a proper return code of the command and an error message.

Comment 1 Michal Hlavinka 2008-10-15 16:18:42 UTC
Created attachment 320455 [details]
patch against ksh-20080202

patch against ksh-20080202 (rebased version in oncoming RHEL 5.3)

Comment 2 David Aquilina 2008-11-17 18:51:24 UTC
(In reply to comment #1)
> Created an attachment (id=320455) [details]
> patch against ksh-20080202
> 
> patch against ksh-20080202 (rebased version in oncoming RHEL 5.3)

Customer tested this patch and confirmed that it fixes their problems.

Comment 12 Ruediger Landmann 2009-05-21 03:58:12 UTC
Release note added. If any revisions are required, please set the 
"requires_release_notes" flag to "?" and edit the "Release Notes" field accordingly.
All revisions will be proofread by the Engineering Content Services team.

New Contents:
The ksh builtins fail to report errors on failed file operations, for example, they would not report an error if they were unable to write to a file because of no space on a disk. This could result in data loss, because a user would have no warning that data was not saved. Builtins now provide a proper return code and present an error message to the user if they are unable to complete a file operation. This prevents the user from incorrectly assuming that the file operation has completed correctly in cases where it has not.

Comment 15 errata-xmlrpc 2009-09-02 09:11:01 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-2009-1256.html