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