Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1064099 - apcupsd uses /etc/apcupsd as its lock dir, even though /var/lock exists
Summary: apcupsd uses /etc/apcupsd as its lock dir, even though /var/lock exists
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: apcupsd
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
Assignee: Michal Hlavinka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1070961 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-02-12 02:30 UTC by Garry T. Williams
Modified: 2014-04-14 22:36 UTC (History)
7 users (show)

Fixed In Version: apcupsd-3.14.12-1.fc19
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-04-14 22:32:45 UTC


Attachments (Terms of Use)
AVC (deleted)
2014-02-12 02:30 UTC, Garry T. Williams
no flags Details


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1047535 None None None Never

Internal Links: 1047535

Description Garry T. Williams 2014-02-12 02:30:42 UTC
Created attachment 862092 [details]
AVC

Description of problem:
After update to apcupsd-3.14.10-14.fc20.x86_64 from updates-testing, I receive the AVC.  Downgrade to the -13 release fixes the problem.


Version-Release number of selected component (if applicable):
apcupsd-3.14.10-14.fc20.x86_64


How reproducible: always


Steps to Reproduce:
1. install the package
2. start (or restart) the daemon
3.

Actual results:
AVC


Expected results:
No AVC


Additional info:
My APC unit uses USB, so serial lock files do not make sense here anyway.

Comment 1 Garry T. Williams 2014-02-19 02:59:34 UTC
Tried apcupsd-3.14.11-1.fc20.x86_64 with same result. :-(

From system log:

Feb 18 21:51:53 vfr systemd[1]: Starting APC UPS Power Control Daemon for Linux...
Feb 18 21:51:53 vfr systemd[1]: Started APC UPS Power Control Daemon for Linux.
Feb 18 21:51:53 vfr apcupsd[5368]: Cannot create /etc/apcupsd/LCK.. serial port lock file: ERR=Permission denied
Feb 18 21:51:53 vfr apcupsd[5368]: apcupsd FATAL ERROR in apcupsd.c at line 281
                                   Unable to create UPS lock file.
                                     If apcupsd or apctest is already running,
                                     please stop it and run this program again.
Feb 18 21:51:53 vfr apcupsd[5368]: apcupsd error shutdown completed
Feb 18 21:51:53 vfr dbus[656]: [system] Activating service name='org.fedoraproject.Setroubleshootd' (using servicehelper)
Feb 18 21:51:53 vfr apcupsd[5368]: apcupsd FATAL ERROR in apcupsd.c at line 281
Feb 18 21:51:53 vfr apcupsd[5368]: Unable to create UPS lock file.
Feb 18 21:51:53 vfr apcupsd[5368]: If apcupsd or apctest is already running,
Feb 18 21:51:53 vfr apcupsd[5368]: please stop it and run this program again.

UPS is APC Backup UPS ES 750, which has USB -- not serial.

Comment 2 Adam Williamson 2014-02-21 17:49:09 UTC
I have this on Rawhide:

Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: Lock file data error:
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: apcupsd FATAL ERROR in apcupsd.c at line 281
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: Unable to create UPS lock file.
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: If apcupsd or apctest is already running,
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: please stop it and run this program again.
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: apcupsd FATAL ERROR in apcupsd.c at line 281
                                                        If apcupsd or apctest is already running,
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: [23B blob data]
Feb 21 01:54:37 adam.happyassassin.net apcupsd[1723]: apcupsd error shutdown completed
Feb 21 01:54:37 adam.happyassassin.net systemd[1]: apcupsd.service: main process exited, code=exited, status=1/FAILURE

oddly, no "Cannot create /etc/apcupsd/LCK.. serial port lock file: ERR=Permission denied" line, but otherwise the same.

Comment 3 Daniel Walsh 2014-02-21 20:38:45 UTC
Why is it creating a LCK file in /etc?

Comment 4 Adam Williamson 2014-02-21 20:39:35 UTC
I've no idea. https://bugzilla.redhat.com/show_bug.cgi?id=1047535 may be somehow relevant.

Comment 5 Daniel Walsh 2014-02-21 20:43:54 UTC
Probably the same problem.  Should move the LCK file to the /var/lib directory also.

Comment 6 Adam Williamson 2014-02-26 01:53:03 UTC
So something possibly interesting in relation to this, though I'm not sure how: my system is an old, old install, dating back to pre-/usr move. I did the F16->f17 (usr move) upgrade with yum, and did the /usr move manually. It looks like I never turned /var/lock into a symlink to /run/lock , as it's supposed to be now. And I have a /var/lock/LCK.. file.

That seems like it may possibly be relevant to this, but I'm not 100% sure. I'll have to see if the AVC stops happening if I fix up /var/lock .

Comment 7 Adam Williamson 2014-02-27 19:26:05 UTC
OK, so the problem here is that somehow, apcupsd's build process decides to use /etc/apcupsd as LOCKDIR.

What apcupsd does is this:

# set the default serial port lock director
for LOCKDIR in "/var/lock" "/var/spool/locks" "/etc/apcupsd"
do
   if test -d $LOCKDIR
   then
      break;
   fi
done

so somehow, 'test -d /var/lock' is failing in our build environment. It works on EPEL 6, but fails on F19, F20 and Rawhide.

This could be to do with /var/lock being a symlink to /run/lock now, but I don't think it's quite that simple:

[adamw@adam kernel-asoc]$ ls -dl /var/lock
lrwxrwxrwx. 1 root root 9 Feb 26 18:25 /var/lock -> /run/lock
[adamw@adam kernel-asoc]$ test -d /var/lock
[adamw@adam kernel-asoc]$ echo $?
0
[adamw@adam kernel-asoc]$ 

so I think perhaps the symlink really doesn't exist in the build environment. I guess we either need to fix that, patch apcupsd to look for and use /run/lock directly, or just hardwire /var/lock on the basis we know that's what we want.

Comment 8 Miroslav Grepl 2014-02-28 12:37:40 UTC
*** Bug 1070961 has been marked as a duplicate of this bug. ***

Comment 9 Daniel Walsh 2014-02-28 22:29:12 UTC
If we change the check to 

for LOCKDIR in "/run/lock" "/var/lock" "/var/spool/locks" "/etc/apcupsd"
do
   if test -d $LOCKDIR
   then
      break;
   fi
done

Does it fix it forever?

Comment 10 Adam Williamson 2014-02-28 22:45:51 UTC
my crystal ball is on the blink at the moment...

I don't know, I haven't even tested that it fixes it *now*. Like I said, test -d does work with a symlink, so I don't think the problem is just that /var/lock is a symlink, I think it may just not exist in the build environment. I'm *presuming* at least /run/lock does, but I haven't checked, yet.

Comment 11 Mark Schlegel 2014-03-30 06:33:27 UTC
This problem is still there even with apcupsd-3.14.11-1.fc20.x86_64
I just got from updates-testing.
My workaround was to simply comment out the "LOCKFILE" line in the conf file:

# LOCKFILE <path to lockfile>
#   Path for device lock file. Not used on Win32.
#LOCKFILE /etc/apcupsd


since I have a USB apc and it doesn't need a lock

Comment 12 Fedora Update System 2014-04-01 11:03:08 UTC
apcupsd-3.14.12-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/FEDORA-2014-2662/apcupsd-3.14.12-1.fc20

Comment 13 Fedora Update System 2014-04-01 11:06:19 UTC
apcupsd-3.14.12-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/FEDORA-2014-2685/apcupsd-3.14.12-1.fc19

Comment 14 Garry T. Williams 2014-04-01 13:38:17 UTC
This version of apcupsd-3.14.12-1.fc20 fixes the AVC for me.

Comment 15 Fedora Update System 2014-04-02 09:07:12 UTC
Package apcupsd-3.14.12-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing apcupsd-3.14.12-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-2662/apcupsd-3.14.12-1.fc20
then log in and leave karma (feedback).

Comment 16 Fedora Update System 2014-04-14 22:32:45 UTC
apcupsd-3.14.12-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2014-04-14 22:36:30 UTC
apcupsd-3.14.12-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


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