[357] in Kerberos-V5-bugs
Re: POSIX_FILE_LOCKS in Kerberos V
daemon@ATHENA.MIT.EDU (Theodore Ts'o)
Tue Sep 21 22:31:34 1993
Date: Tue, 21 Sep 93 22:30:58 EDT
From: tytso@MIT.EDU (Theodore Ts'o)
To: "Hugh C. Lauer" <lauer@merl.com>
Cc: krb5-bugs@MIT.EDU, lauer@merl.com
In-Reply-To: "[350] in Kerberos-V5-bugs"
Date: Sat, 18 Sep 93 19:38:40 -0400
From: "Hugh C. Lauer" <lauer@merl.com>
The file slave/kprop.c does not compile in the presence of the switch
POSIX_FILE_LOCKS
The function lockf is called with incorrect arguments. Here is a context
diff to make it compile correctly, according to the HP-UX 9.0 man page
description of the lockf call.
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",