/var/lock/

I notice that the group for /var/lock/ on SUSE 11.2 is root, not uucp as usual. How are file locks supposed to work with this?

What lock do you need to create? You could make a subdirectory owned by the account and write in that.

I’m trying to write a portable serial program, that’s Linux Filesystem Hierarchy compliant. As far as I can tell, the lock is mandated to go in /var/lock.

So, I was wondering what was the thinking behind the change in group.

Probably because locks are not just for uucp or other serial programs any more. What does the FHS say about /var/lock/subsys?

Well, I’m going on this document, which I dodn’t think is the latest, but I can’t find any other.

Linux Filesystem Hierarchy

This gives:

"Many programs follow a convention to create a lock file in /var/lock to indicate that they are using a particular device or file. This directory holds those lock files (for some devices) and hopefully other programs will notice the lock file and won’t attempt to use the device or file.

Lock files should be stored within the /var/lock directory structure. Lock files for devices and other resources shared by multiple applications, such as the serial device lock files that were originally found in either /usr/spool/locks or /usr/spool/uucp, must now be stored in /var/lock. The naming convention which must be used is LCK… followed by the base name of the device file. For example, to lock /dev/ttyS0 the file LCK…ttyS0 would be created. The format used for the contents of such lock files must be the HDB UUCP lock file format."

So it doesn’t mention /var/lock/subsys/

I’m trying to stick with whatever the standard is, so I’m not sure if the standard has changed, or SUSE 11.2 is doing something non-compliant.

Well it says within the /var/lock directory structure so it can be somewhere underneath. Historically /var/lock was used by serial devices but then all sorts of programs needed locks so the group ownership by uucp is a bit of anachronism.

To keep it portable you could try both methods, either a subdirectory called /var/lock/subsys/myserialprogram owned by the account, or /var/lock for older distros.

I think I might make the lock optional, on /var/lock/.

I can’t see the point on a /var/lock/subsys/myserialprogram lock, as it would only be my program that would use it, which kind of defeats the object of a lock file.

Thanks for your help.

If only your program uses then it would be to guard against multiple instances so it wouldn’t matter that the path is specific to your program. It’s only when it’s a common device that various programs have to agree on a path.

But I am trying to use a common device: the serial port: /dev/ttyS0

What do the existing programs (minicom, uucp) do then? See what they do and emulate them.

Yes, good idea, I’ll go and hunt round some code.

Cheers.

Hi

Have the same problem with minicom on opensuse 11.2
You cannot use minicom as normal user because “bad” group of /var/lock.
Minicom creates the lock file
** /var/lock/LCK…ttyS0
**In opensuse 10.3 the directory /var/lock belonged to group uucp and all useres which wanted to use minicom have to belong to this group.
Now if the group is root, every program to write to this directory must be either root or the prog must be suid.
I think this is a bad idea…
Nevertheless if the group of this directory must belong to root the maintainer of minicom should change the package that it is working…
And there is no docu (/usr/share/doc/packages/minicom) about how to use if locking must be configured elsewhere .

Is this already reported as bug?

Yes, a search at bugzilla found it:

https://bugzilla.novell.com/show_bug.cgi?id=552095

Ah, excellent. This results in this in 11.3:

https://features.opensuse.org/308360

A decent work-around is to use the acl features of the filesystem.

If you type (as root) “setfacl -m g:uucp:rwX /var/lock” , it will add the uucp group to /var/lock just like the good ol’ days. Minicom should work now. This will not change the main permissions on /var/lock, so it will behave as intended for other programs.

To verify it took, use “getfacl”. This fix will not work if the filesystem /var is on does not support the acl features.

Hi, great solution. But I have a question. How can I set this on boot without to make a separated script on opensuse 12.1?

On Wed, 09 Nov 2011 08:16:02 +0000, cingulingu wrote:

> Hi, great solution. But I have a question. How can I set this on boot
> without to make a separated script on opensuse 12.1?

12.1 isn’t released yet, so you might ask this over in the prerelease/
beta forum.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Thanks, For the replay. :slight_smile:
I already made a decision to will this couple of days for the official release. Hopefully this bug is already fixed. Will see.

No. it is not fix. Do somebody have an idea how to run a script with this workaround as an root? Thanks.

How is this ‘fixed’ for 11.3, but not fixed for 12.1? How does something like this regress?

To use the Arduino application, the user needs access to /var/lock. Even after adding the user to the lock, uucp, and dialout groups per the instructions, the program still throws error messages complaining that it can’t create the lock files necessary because /var/lock is still owner/group root/root.