2013-06-03 10:37:32 +00:00
|
|
|
diff -up lockdev-scm-2011-10-07/src/lockdev.c.access lockdev-scm-2011-10-07/src/lockdev.c
|
|
|
|
--- lockdev-scm-2011-10-07/src/lockdev.c.access 2011-07-22 09:37:10.000000000 +0200
|
2013-12-05 11:00:07 +00:00
|
|
|
+++ lockdev-scm-2011-10-07/src/lockdev.c 2013-12-05 11:56:57.836961642 +0100
|
|
|
|
@@ -95,6 +95,10 @@
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
+#ifndef _GNU_SOURCE
|
|
|
|
+ #define _GNU_SOURCE
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
@@ -616,7 +620,10 @@ dev_lock (const char *devname)
|
2013-06-03 10:37:32 +00:00
|
|
|
if ( stat( device, &statbuf) == -1 ) {
|
|
|
|
close_n_return(-errno);
|
|
|
|
}
|
|
|
|
- if ( access( device, W_OK ) == -1 ) {
|
|
|
|
+ /* check that the caller has write permission to the device
|
|
|
|
+ * to prevent denial-of-service attack by unauthorized users
|
|
|
|
+ */
|
|
|
|
+ if ( euidaccess( device, W_OK ) == -1 ) {
|
|
|
|
close_n_return(-errno);
|
|
|
|
}
|
|
|
|
|
2013-12-05 11:00:07 +00:00
|
|
|
@@ -780,7 +787,10 @@ dev_relock (const char *devname,
|
2013-06-03 10:37:32 +00:00
|
|
|
if ( stat( device, &statbuf) == -1 ) {
|
|
|
|
close_n_return(-errno);
|
|
|
|
}
|
|
|
|
- if ( access( device, W_OK ) == -1 ) {
|
|
|
|
+ /* check that the caller has write permission to the device
|
|
|
|
+ * to prevent denial-of-service attack by unauthorized users
|
|
|
|
+ */
|
|
|
|
+ if ( euidaccess( device, W_OK ) == -1 ) {
|
|
|
|
close_n_return(-errno);
|
|
|
|
}
|
|
|
|
|
2013-12-05 11:00:07 +00:00
|
|
|
@@ -870,7 +880,10 @@ dev_unlock (const char *devname,
|
2013-06-03 10:37:32 +00:00
|
|
|
if ( stat( device, &statbuf) == -1 ) {
|
|
|
|
close_n_return(-errno);
|
|
|
|
}
|
|
|
|
- if ( access( device, W_OK ) == -1 ) {
|
|
|
|
+ /* check that the caller has write permission to the device
|
|
|
|
+ * to prevent denial-of-service attack by unauthorized users
|
|
|
|
+ */
|
|
|
|
+ if ( euidaccess( device, W_OK ) == -1 ) {
|
|
|
|
close_n_return(-errno);
|
|
|
|
}
|
|
|
|
|