[360] in Kerberos-V5-bugs
Re: POSIX_FILE_LOCKS in Kerberos V
daemon@ATHENA.MIT.EDU (Hugh C. Lauer)
Mon Sep 27 09:03:21 1993
To: tytso@MIT.EDU (Theodore Ts'o)
Cc: "Hugh C. Lauer" <lauer@merl.com>, krb5-bugs@MIT.EDU
In-Reply-To: Your message of "Tue, 21 Sep 93 22:30:58 EDT."
Date: Mon, 27 Sep 93 09:02:55 -0400
From: "Hugh C. Lauer" <lauer@merl.com>
For reasons unexplained, the following patches would not install in the
beta version of Kerberos V. I had to install them by hand. Just thought
you'd like to know.
/Hugh
>
> Actually, the real problem is that lockf() isn't the correct posix
> locking function. It should have been using fcntl instead. So
> something like this is the correct fix.
>
> - Ted
>
> *** kprop.c 1993/09/01 03:20:14 5.9
> --- kprop.c 1993/09/22 02:28:31
> ***************
> *** 38,43 ****
> --- 38,46 ----
> #include <krb5/los-proto.h>
> #include <com_err.h>
> #include <errno.h>
> + #ifdef POSIX_FILE_LOCKS
> + #include <fcntl.h>
> + #endif
>
> #include <stdio.h>
> #include <ctype.h>
> ***************
> *** 409,414 ****
> --- 412,420 ----
> struct stat stbuf, stbuf_ok;
> char *data_ok_fn;
> static char ok[] = ".dump_ok";
> + #ifdef POSIX_FILE_LOCKS
> + struct flock lock_arg;
> + #endif
>
> if ((fd = open(data_fn, O_RDONLY)) < 0) {
> com_err(progname, errno, "while trying to open %s",
> ***************
> *** 417,424 ****
> }
>
> #ifdef POSIX_FILE_LOCKS
> ! if (lockf(fd, LOCK_SH | LOCK_NB, 0) < 0) {
> ! if (errno == EWOULDBLOCK || errno == EAGAIN)
> com_err(progname, 0, "database locked");
> else
> com_err(progname, errno, "while trying to flock %s",
> --- 423,433 ----
> }
>
> #ifdef POSIX_FILE_LOCKS
> ! lock_arg.l_whence = 0;
> ! lock_arg.l_start = 0;
> ! lock_arg.l_len = 0;
> ! if (fcntl(fd, F_SETLK, &lock_arg) == -1) {
> ! if (errno == EACCES || errno == EAGAIN)
> com_err(progname, 0, "database locked");
> else
> com_err(progname, errno, "while trying to flock %s",