Bug 465438 - builtins do not report errors on failed file operations
builtins do not report errors on failed file operations
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: ksh (Show other bugs)
5.1
All Linux
high Severity medium
: rc
: ---
Assigned To: Michal Hlavinka
BaseOS QE
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-10-03 06:49 EDT by Tomas Smetana
Modified: 2010-10-23 00:55 EDT (History)
5 users (show)

See Also:
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 05:11:01 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)
patch against ksh-20080202 (2.98 KB, patch)
2008-10-15 12:18 EDT, Michal Hlavinka
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:1256 normal SHIPPED_LIVE ksh bug fix update 2009-09-01 05:05:54 EDT

  None (edit)
Description Tomas Smetana 2008-10-03 06:49:06 EDT
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 12:18:42 EDT
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 13:51:24 EST
(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-20 23:58:12 EDT
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 05:11:01 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-2009-1256.html

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