2.1.15-patch[12]

Ion Badulescu (ionut@moisil.wal.rhno.columbia.edu)
Wed, 18 Dec 1996 02:00:55 -0500 (EST)


Hi,

The modification to locks.c in Alan's patches breaks sendmail, and
possibly other applications as well. The author of the patch had good
intentions (avoid random users locking files they cannot open in writing),
however there is too much broken software out there which assumes that
flock will work with a r/o file descriptor.

The following patch does pretty much the same thing, but in a more
conservative way.

Ionut

--
  It is better to keep your mouth shut and be thought a fool,
            than to open it and remove all doubt.

--- linux/fs/locks.c.old Wed Dec 4 23:16:57 1996 +++ linux/fs/locks.c Wed Dec 4 23:14:25 1996 @@ -242,9 +242,14 @@ { struct file_lock file_lock; struct file *filp; + int err; if ((fd >= NR_OPEN) || !(filp = current->files->fd[fd])) return (-EBADF); + + err = permission(filp->f_inode, S_IWOTH); + if (err) + return err; if (!flock_make_lock(filp, &file_lock, cmd)) return (-EINVAL);