[openssh-commits] [openssh] 02/02: Hook up flock() compat code.

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Feb 26 14:38:30 AEDT 2018


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit cd3ab57f9b388f8b1abf601dc4d78ff82d83b75e
Author: Darren Tucker <dtucker at dtucker.net>
Date:   Mon Feb 26 14:37:06 2018 +1100

    Hook up flock() compat code.
    
    Also a couple of minor changes: fail if we can't lock instead of
    silently succeeding, and apply a couple of minor style fixes.
---
 configure.ac               |  1 +
 openbsd-compat/Makefile.in |  2 +-
 openbsd-compat/bsd-flock.c | 11 ++++++++---
 openbsd-compat/bsd-misc.h  |  8 ++++++++
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index a70d4062..35e2e8d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1723,6 +1723,7 @@ AC_CHECK_FUNCS([ \
 	explicit_bzero \
 	fchmod \
 	fchown \
+	flock \
 	freeaddrinfo \
 	freezero \
 	fstatfs \
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in
index 053f2ef2..71fcdb12 100644
--- a/openbsd-compat/Makefile.in
+++ b/openbsd-compat/Makefile.in
@@ -16,7 +16,7 @@ LDFLAGS=-L. @LDFLAGS@
 
 OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt_long.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o reallocarray.o realpath.o recallocarray.o rresvport.o setenv.o setproctitle.o sha1.o sha2.o rmd160.o md5.o sigact.o strcasestr.o strlcat.o strlcpy.o strmode.o strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o bl [...]
 
-COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-getpagesize.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-malloc.o bsd-setres_id.o bsd-signal.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xcrypt.o kludge-fd_set.o
+COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-flock.o bsd-getpagesize.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-malloc.o bsd-setres_id.o bsd-signal.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xcrypt.o kludge-fd_set.o
 
 PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-net.o port-uw.o
 
diff --git a/openbsd-compat/bsd-flock.c b/openbsd-compat/bsd-flock.c
index 4a51ebe1..bf4d8a65 100644
--- a/openbsd-compat/bsd-flock.c
+++ b/openbsd-compat/bsd-flock.c
@@ -34,13 +34,15 @@
  * Otherwise, don't do locking; just pretend success.
  */
 
-#include "nbtool_config.h"
+#include "includes.h"
 
-#if !HAVE_FLOCK
+#ifndef HAVE_FLOCK
 #include <errno.h>
 #include <fcntl.h>
 
-int flock(int fd, int op) {
+int
+flock(int fd, int op)
+{
 	int rc = 0;
 
 #if defined(F_SETLK) && defined(F_SETLKW)
@@ -69,6 +71,9 @@ int flock(int fd, int op) {
 
 	if (rc && (errno == EAGAIN))
 		errno = EWOULDBLOCK;
+#else
+	rc = -1
+	errno = ENOSYS;
 #endif
 
 	return rc;
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index af2ccdae..2a73ae45 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -145,4 +145,12 @@ int raise(int);
 pid_t getsid(pid_t);
 #endif
 
+#ifndef HAVE_FLOCK
+# define LOCK_SH		0x01
+# define LOCK_EX		0x02
+# define LOCK_NB		0x04
+# define LOCK_UN		0x08
+int flock(int, int);
+#endif
+
 #endif /* _BSD_MISC_H */

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list