Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1195314

Summary: at creates empty job file when filesystem is full
Product: Red Hat Enterprise Linux 6 Reporter: Bonnie King <misterbonnie>
Component: atAssignee: Tomas Mraz <tmraz>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6CC: csieh, jcpunk
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-23 15:17:24 UTC Type: Bug
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
call fflush() before checking ferror() on job file descriptor none

Description Bonnie King 2015-02-23 15:12:32 UTC
Created attachment 994408 [details]
call fflush() before checking ferror() on job file descriptor

Description of problem:

at does not properly call fflush() before checking ferror on job file. 

If filesystem (/var) is full or almost full when setting at job is attempted, a 0byte or truncated file is created.

This causes a spew of 

File <filename> is in wrong format - aborting 

to syslog which can fill up /var again very quickly.

Version-Release number of selected component (if applicable):

3.1.10

How reproducible:

Happens if filesystem containing /var/spool/at is full.

Steps to Reproduce:
1. Fill up /var
2. set a small job with `at`
3. observe that the file created is 0bytes long
4. wait for the scheduled time

Actual results:

at does not properly remove at file when write error to the file occurs. This leaves behind a 0byte or potentially truncated job file.

0byte job files are created and when scheduled time is reached, atd complains profusely with:

File <filename> is in wrong format - aborting

If written to /var/log/messages (which is default), file grows rapidly until jobs are removed with atrm.

If /var is already full, and messages is cleared out without cleaning up the bad at jobs, /var fills up again very soon.

Expected results:

at should reach 

    fprintf(fp, "\n");
    if (ferror(fp))
        panic("Output error");

so panic() cleans up the malformed atfile. 

Need to fflush() before checking ferror() in case the write() returns an error.

Additional info:

Patch attached, built against 3.1.10 and tested on Scientific Linux 6.6.

Comment 1 Tomas Mraz 2015-02-23 15:17:24 UTC

*** This bug has been marked as a duplicate of bug 1166882 ***