From d52454015072ba8f9e8118b65789aed4c622fa62 Mon Sep 17 00:00:00 2001 From: Frank Lahm Date: Mon, 21 Mar 2011 14:53:19 +0100 Subject: [PATCH] Lock volume files while reading them --- NEWS | 1 + etc/afpd/volume.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 169c8f2f..d1ed03f2 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ Changes in XXX * FIX: afpd: generate mersenne primes for DHX2 UAM once at startup, not for every login * FIX: Support for platforms that do not have the *at functions +* UPD: afpd: put POSIX write lock on volume files while reading them Changes in 2.2beta3 =================== diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index bcc2468f..a7a62e85 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1199,6 +1199,14 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int us p1->mtime = st.st_mtime; } + if ((read_lock(fd, 0, SEEK_SET, 0)) != 0) { + LOG(log_error, logtype_afpd, "readvolfile: can't lock volume file \"%s\"", path); + if ( fclose( fp ) != 0 ) { + LOG(log_error, logtype_afpd, "readvolfile: fclose: %s", strerror(errno) ); + } + return -1; + } + memset(save_options, 0, sizeof(save_options)); /* Enable some default options for all volumes */ -- 2.39.2