2

It seems that Linux has tightened up security in /tmp in later kernels than 3.x and if /tmp has the sticky bit set another user may not modify a 0777 file.

Are there any work arounds for sharing a flock'ed file? (I cannot create the file as root ahead of time, which apparently would work since root owns /tmp)

$ ll /tmp/zzz
-rwxrwxrwx 1 games games 1 Aug 23 11:35 /tmp/zzz
$ id
uid=1000(me) gid=1000(me) groups=1000(me)
$ /usr/bin/flock /tmp/zzz  ls 
flock: cannot open lock file /tmp/zzz: Permission denied 

1 Answer 1

0

One solution is to use a directory instead:

(umask 0222 && mkdir -p /tmp/lock.foo && flock /tmp/.foo /usr/bin/whatever)

The restriction does not appear to apply to directories, and the directory doesn't seem to require to be writable by other users either.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.