Bug 974716

Summary: psacct.service fails to start if accounting file already exists
Product: [Fedora] Fedora Reporter: Alexander Demenshin <aldem-fedora>
Component: psacctAssignee: Jaromír Cápík <jcapik>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 19CC: ignatenko, jcapik, ovasik
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: psacct-6.6.1-3.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-06-29 18:48:04 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:

Description Alexander Demenshin 2013-06-14 23:52:22 UTC
Description of problem:

Service psacct.service fails to start if accounting file already exists (= after it was started at least once).

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

psacct-6.6.1-2.fc19.x86_64

How reproducible:

Always after first successful run.

Steps to Reproduce:
1. run "systemctl start psacct"
2. if it is started (it should when run first time after installation), stop it and try to start again
3. check the result

Actual results:

Job for psacct.service failed. See 'systemctl status psacct.service' and 'journalctl -xn' for details.

And from systemctl status:

# systemctl status psacct.service
psacct.service - Kernel process accounting
   Loaded: loaded (/usr/lib/systemd/system/psacct.service; enabled)
   Active: failed (Result: exit-code) since Sat 2013-06-15 01:32:57 CEST; 6s ago
  Process: 1664 ExecStop=/usr/sbin/accton off (code=exited, status=0/SUCCESS)
  Process: 1654 ExecStart=/usr/sbin/accton /var/account/pacct (code=exited, status=0/SUCCESS)
  Process: 1669 ExecStartPre=/usr/libexec/psacct/accton-create (code=exited, status=1/FAILURE)

Jun 15 01:32:57 localhost.localdomain systemd[1]: psacct.service: control process exited, code=exited status=1
Jun 15 01:32:57 localhost.localdomain systemd[1]: Failed to start Kernel process accounting.
Jun 15 01:32:57 localhost.localdomain systemd[1]: Unit psacct.service entered failed state.

Expected results:

Process accounting is started.

Additional info:

It seems that the problem is in /usr/libexec/psacct/accton-create script:

--snip--
#!/bin/sh
ACCTFILE=/var/account/pacct
[ ! -r $ACCTFILE ] && touch $ACCTFILE && chmod 600 $ACCTFILE
--snip--

Obviously, when accounting file already exists, the script will exit with non-zero status, which is propagated to systemd, thus reporting (incorrectly) failure.

Actually, "[ ! -r $ACCTFILE ] && " is not needed at all, as touch will try to create file if it doesn't exist, and chmod won't hurt in any case.

Comment 1 Jaromír Cápík 2013-06-17 12:44:42 UTC
Hello Alexander.

You're right. I blindly copied the line from the psacct initscript. The condition is mandatory, since we don't want to overwrite possibly customized permissions each time the service is started. There are two solutions for the issue:
1.) add 'exit 0' at the end
2.) use the 'if then fi' style condition

I'm gonna decide and fix that.

Thanks for the report.

Regards,
Jaromir.

Comment 2 Jaromír Cápík 2013-06-17 12:57:42 UTC
The second option seems to be more correct. It returns failure when the creation or the permission change fails. In that case it's reasonable to return non-zero.
The change is committed, pushed and the package is going to be rebuilt in few minutes.

Comment 3 Fedora Update System 2013-06-17 13:28:08 UTC
psacct-6.6.1-3.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/psacct-6.6.1-3.fc19

Comment 4 Fedora Update System 2013-06-17 17:02:16 UTC
Package psacct-6.6.1-3.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing psacct-6.6.1-3.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-11051/psacct-6.6.1-3.fc19
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2013-06-29 18:48:04 UTC
psacct-6.6.1-3.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.