From 57cdd87cc52bf47037374bf7435f1f519e796ae7 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Thu, 18 Sep 2014 14:39:31 +0200 Subject: [PATCH] better euidaccess.patch from Paolo Bonzini (#600636#c33) --- lockdev-euidaccess.patch | 47 +++++++++++++++++++++++++++++++++++++--- lockdev.spec | 7 ++++-- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/lockdev-euidaccess.patch b/lockdev-euidaccess.patch index 2b7bcc7..2ed5cee 100644 --- a/lockdev-euidaccess.patch +++ b/lockdev-euidaccess.patch @@ -12,6 +12,17 @@ diff -up lockdev-scm-2011-10-07/src/lockdev.c.access lockdev-scm-2011-10-07/src/ #include #include #include +@@ -125,6 +125,10 @@ + #include "lockdev.h" + #include "ttylock.h" + ++#ifndef LOCKDEV_ACCESS ++#define LOCKDEV_ACCESS euidaccess ++#endif ++ + #define LOCKDEV_PATH SBINDIR "/lockdev" + + /* @@ -616,7 +620,10 @@ dev_lock (const char *devname) if ( stat( device, &statbuf) == -1 ) { close_n_return(-errno); @@ -20,7 +31,7 @@ diff -up lockdev-scm-2011-10-07/src/lockdev.c.access lockdev-scm-2011-10-07/src/ + /* 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 ) { ++ if ( LOCKDEV_ACCESS( device, W_OK ) == -1 ) { close_n_return(-errno); } @@ -32,7 +43,7 @@ diff -up lockdev-scm-2011-10-07/src/lockdev.c.access lockdev-scm-2011-10-07/src/ + /* 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 ) { ++ if ( LOCKDEV_ACCESS( device, W_OK ) == -1 ) { close_n_return(-errno); } @@ -44,7 +55,37 @@ diff -up lockdev-scm-2011-10-07/src/lockdev.c.access lockdev-scm-2011-10-07/src/ + /* 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 ) { ++ if ( LOCKDEV_ACCESS( device, W_OK ) == -1 ) { close_n_return(-errno); } +diff -ru lockdev-save/src/Makefile.am lockdev-scm-2011-10-07/src/Makefile.am +--- lockdev-save/src/Makefile.am 2014-09-18 13:42:00.363741658 +0200 ++++ lockdev-scm-2011-10-07/src/Makefile.am 2014-09-18 13:52:10.307868154 +0200 +@@ -6,7 +6,6 @@ + AM_CPPFLAGS = -include $(top_builddir)/config.h -DSBINDIR=\"$(sbindir)\" + + lockdev_SOURCES = sample.c +-lockdev_LDADD = liblockdev.la + + baudboy_SOURCES = baudboy_test.c + baudboy_LDADD = liblockdev.la +Solo in lockdev-scm-2011-10-07/src: Makefile.in +diff -ru lockdev-save/src/sample.c lockdev-scm-2011-10-07/src/sample.c +--- lockdev-save/src/sample.c 2014-09-18 13:42:00.363741658 +0200 ++++ lockdev-scm-2011-10-07/src/sample.c 2014-09-18 14:06:03.769023380 +0200 +@@ -6,6 +6,13 @@ + #include + #include "lockdev.h" + ++/* ttylock functions swap the real/effective uid/gid for us, so ++ * use access instead of euidaccess. ++ */ ++#define LOCKDEV_ACCESS access ++#undef TTYLOCK_USE_HELPER ++#include "lockdev.c" ++ + void + usage (void) + { +Solo in lockdev-scm-2011-10-07: VERSION diff --git a/lockdev.spec b/lockdev.spec index 046f53d..42bee18 100644 --- a/lockdev.spec +++ b/lockdev.spec @@ -10,7 +10,7 @@ Summary: A library for locking devices Name: lockdev Version: 1.0.4 -Release: 0.17.%{checkout}%{?dist} +Release: 0.18.%{checkout}%{?dist} License: LGPLv2 Group: System Environment/Libraries URL: https://alioth.debian.org/projects/lockdev/ @@ -51,7 +51,7 @@ package contains the development headers. %prep %setup -q -n lockdev-scm-%{co_date} -# Replace access() calls with euidaccess() (600636#c9) +# Replace access() calls with euidaccess() (600636#c33) %patch1 -p1 -b .access %build @@ -105,6 +105,9 @@ fi %{_includedir}/* %changelog +* Thu Sep 18 2014 Jiri Popelka - 1.0.4-0.18.20111007git +- better euidaccess.patch from Paolo Bonzini (#600636#c33) + * Sun Aug 17 2014 Fedora Release Engineering - 1.0.4-0.17.20111007git - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild