290f8b
diff -up lockdev-scm-2011-10-07/src/lockdev.c.access lockdev-scm-2011-10-07/src/lockdev.c
290f8b
--- lockdev-scm-2011-10-07/src/lockdev.c.access	2011-07-22 09:37:10.000000000 +0200
290f8b
+++ lockdev-scm-2011-10-07/src/lockdev.c	2013-12-05 11:56:57.836961642 +0100
290f8b
@@ -95,6 +95,10 @@
290f8b
  *
290f8b
  */
290f8b
 
290f8b
+#ifndef _GNU_SOURCE
290f8b
+   #define _GNU_SOURCE
290f8b
+#endif
290f8b
+
290f8b
 #include <errno.h>
290f8b
 #include <signal.h>
290f8b
 #include <stdio.h>
290f8b
@@ -125,6 +125,10 @@
290f8b
 #include "lockdev.h"
290f8b
 #include "ttylock.h"
290f8b
 
290f8b
+#ifndef LOCKDEV_ACCESS
290f8b
+#define LOCKDEV_ACCESS  euidaccess
290f8b
+#endif
290f8b
+
290f8b
 #define	LOCKDEV_PATH	SBINDIR "/lockdev"
290f8b
 
290f8b
 /*
290f8b
@@ -616,7 +620,10 @@ dev_lock (const char *devname)
290f8b
 	if ( stat( device, &statbuf) == -1 ) {
290f8b
 		close_n_return(-errno);
290f8b
 	}
290f8b
-	if ( access( device, W_OK ) == -1 ) {
290f8b
+	/* check that the caller has write permission to the device
290f8b
+	 * to prevent denial-of-service attack by unauthorized users
290f8b
+	 */
290f8b
+	if ( LOCKDEV_ACCESS( device, W_OK ) == -1 ) {
290f8b
 		close_n_return(-errno);
290f8b
 	}
290f8b
 
290f8b
@@ -780,7 +787,10 @@ dev_relock (const char  *devname,
290f8b
 	if ( stat( device, &statbuf) == -1 ) {
290f8b
 		close_n_return(-errno);
290f8b
 	}
290f8b
-	if ( access( device, W_OK ) == -1 ) {
290f8b
+	/* check that the caller has write permission to the device
290f8b
+	 * to prevent denial-of-service attack by unauthorized users
290f8b
+	 */
290f8b
+	if ( LOCKDEV_ACCESS( device, W_OK ) == -1 ) {
290f8b
 		close_n_return(-errno);
290f8b
 	}
290f8b
 
290f8b
@@ -870,7 +880,10 @@ dev_unlock (const char *devname,
290f8b
 	if ( stat( device, &statbuf) == -1 ) {
290f8b
 		close_n_return(-errno);
290f8b
 	}
290f8b
-	if ( access( device, W_OK ) == -1 ) {
290f8b
+	/* check that the caller has write permission to the device
290f8b
+	 * to prevent denial-of-service attack by unauthorized users
290f8b
+	 */
290f8b
+	if ( LOCKDEV_ACCESS( device, W_OK ) == -1 ) {
290f8b
 		close_n_return(-errno);
290f8b
 	}
290f8b
 
290f8b
diff -ru lockdev-save/src/Makefile.am lockdev-scm-2011-10-07/src/Makefile.am
290f8b
--- lockdev-save/src/Makefile.am	2014-09-18 13:42:00.363741658 +0200
290f8b
+++ lockdev-scm-2011-10-07/src/Makefile.am	2014-09-18 13:52:10.307868154 +0200
290f8b
@@ -6,7 +6,6 @@
290f8b
 AM_CPPFLAGS = -include $(top_builddir)/config.h -DSBINDIR=\"$(sbindir)\"
290f8b
 
290f8b
 lockdev_SOURCES = sample.c
290f8b
-lockdev_LDADD = liblockdev.la
290f8b
 
290f8b
 baudboy_SOURCES = baudboy_test.c
290f8b
 baudboy_LDADD = liblockdev.la
290f8b
Solo in lockdev-scm-2011-10-07/src: Makefile.in
290f8b
diff -ru lockdev-save/src/sample.c lockdev-scm-2011-10-07/src/sample.c
290f8b
--- lockdev-save/src/sample.c	2014-09-18 13:42:00.363741658 +0200
290f8b
+++ lockdev-scm-2011-10-07/src/sample.c	2014-09-18 14:06:03.769023380 +0200
290f8b
@@ -6,6 +6,13 @@
290f8b
 #include <fcntl.h>
290f8b
 #include "lockdev.h"
290f8b
 
290f8b
+/* ttylock functions swap the real/effective uid/gid for us, so
290f8b
+ * use access instead of euidaccess.
290f8b
+ */
290f8b
+#define LOCKDEV_ACCESS access
290f8b
+#undef TTYLOCK_USE_HELPER
290f8b
+#include "lockdev.c"
290f8b
+
290f8b
 void
290f8b
 usage (void)
290f8b
 {
290f8b
Solo in lockdev-scm-2011-10-07: VERSION