Date: Monday, July 28, 2014 @ 19:24:00
  Author: thomas
Revision: 218252

upgpkg: cryptsetup 1.6.5-2

Added:
  
cryptsetup/trunk/0001-Move-safe-table-params-wipe-into-function-which-allo.patch
  cryptsetup/trunk/0002-Re-check-flags-after-DM-device-creations.patch
  
cryptsetup/trunk/0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch
Modified:
  cryptsetup/trunk/PKGBUILD

-----------------------------------------------------------------+
 0001-Move-safe-table-params-wipe-into-function-which-allo.patch |   37 ++++
 0002-Re-check-flags-after-DM-device-creations.patch             |   62 ++++++
 0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch |   92 
++++++++++
 PKGBUILD                                                        |   22 +-
 4 files changed, 209 insertions(+), 4 deletions(-)

Added: 0001-Move-safe-table-params-wipe-into-function-which-allo.patch
===================================================================
--- 0001-Move-safe-table-params-wipe-into-function-which-allo.patch             
                (rev 0)
+++ 0001-Move-safe-table-params-wipe-into-function-which-allo.patch     
2014-07-28 17:24:00 UTC (rev 218252)
@@ -0,0 +1,37 @@
+From 2250d5f71f9dd66112d5c63367169f4e6af8ad70 Mon Sep 17 00:00:00 2001
+From: Milan Broz <[email protected]>
+Date: Thu, 24 Jul 2014 11:37:24 +0200
+Subject: [PATCH 1/3] Move safe table params wipe into function which allocates
+ it.
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+---
+ lib/libdevmapper.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c
+index 3ed87c0..8e5a696 100644
+--- a/lib/libdevmapper.c
++++ b/lib/libdevmapper.c
+@@ -642,8 +642,6 @@ out_no_removal:
+       if (cookie && _dm_use_udev())
+               (void)_dm_udev_wait(cookie);
+ 
+-      if (params)
+-              crypt_safe_free(params);
+       if (dmt)
+               dm_task_destroy(dmt);
+ 
+@@ -674,6 +672,8 @@ int dm_create_device(struct crypt_device *cd, const char 
*name,
+               r = _dm_create_device(name, type, dmd->data_device,
+                                     dmd->flags, dmd->uuid, dmd->size,
+                                     table_params, reload);
++
++      crypt_safe_free(table_params);
+       dm_exit_context();
+       return r;
+ }
+-- 
+2.0.1
+

Added: 0002-Re-check-flags-after-DM-device-creations.patch
===================================================================
--- 0002-Re-check-flags-after-DM-device-creations.patch                         
(rev 0)
+++ 0002-Re-check-flags-after-DM-device-creations.patch 2014-07-28 17:24:00 UTC 
(rev 218252)
@@ -0,0 +1,62 @@
+From 3640eaa726b7a9d761f1c67cd8620153d791688e Mon Sep 17 00:00:00 2001
+From: Milan Broz <[email protected]>
+Date: Thu, 24 Jul 2014 11:52:58 +0200
+Subject: [PATCH 2/3] Re-check flags after DM device creations.
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+---
+ lib/libdevmapper.c | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c
+index 8e5a696..6138a6b 100644
+--- a/lib/libdevmapper.c
++++ b/lib/libdevmapper.c
+@@ -566,6 +566,9 @@ static int _dm_create_device(const char *name, const char 
*type,
+       uint32_t cookie = 0;
+       uint16_t udev_flags = 0;
+ 
++      if (!params)
++              return -EINVAL;
++
+       if (flags & CRYPT_ACTIVATE_PRIVATE)
+               udev_flags = CRYPT_TEMP_UDEV_FLAGS;
+ 
+@@ -646,6 +649,10 @@ out_no_removal:
+               dm_task_destroy(dmt);
+ 
+       dm_task_update_nodes();
++
++      /* If code just loaded target module, update versions */
++      _dm_check_versions();
++
+       return r;
+ }
+ 
+@@ -655,7 +662,7 @@ int dm_create_device(struct crypt_device *cd, const char 
*name,
+                    int reload)
+ {
+       char *table_params = NULL;
+-      int r = -EINVAL;
++      int r;
+ 
+       if (!type)
+               return -EINVAL;
+@@ -668,10 +675,9 @@ int dm_create_device(struct crypt_device *cd, const char 
*name,
+       else if (dmd->target == DM_VERITY)
+               table_params = get_dm_verity_params(dmd->u.verity.vp, dmd);
+ 
+-      if (table_params)
+-              r = _dm_create_device(name, type, dmd->data_device,
+-                                    dmd->flags, dmd->uuid, dmd->size,
+-                                    table_params, reload);
++      r = _dm_create_device(name, type, dmd->data_device,
++                            dmd->flags, dmd->uuid, dmd->size,
++                            table_params, reload);
+ 
+       crypt_safe_free(table_params);
+       dm_exit_context();
+-- 
+2.0.1
+

Added: 0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch
===================================================================
--- 0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch             
                (rev 0)
+++ 0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch     
2014-07-28 17:24:00 UTC (rev 218252)
@@ -0,0 +1,92 @@
+From 59fdf2a6bb461a39e6db6b7d515873419f8a8ada Mon Sep 17 00:00:00 2001
+From: Milan Broz <[email protected]>
+Date: Thu, 24 Jul 2014 22:11:58 +0200
+Subject: [PATCH 3/3] Properly allow activation of discard even if dm_crypt
+ module is not yet loaded.
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The dm_flags() call cannot be used if dmcrypt module is not present.
+
+Better try to activate volume with dicard flags and if it is not possible,
+try to activate device without the discard flag.
+---
+ lib/libdevmapper.c | 37 ++++++++++++++++++++++++-------------
+ 1 file changed, 24 insertions(+), 13 deletions(-)
+
+diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c
+index 6138a6b..dcc54fd 100644
+--- a/lib/libdevmapper.c
++++ b/lib/libdevmapper.c
+@@ -306,22 +306,19 @@ static void hex_key(char *hexkey, size_t key_size, const 
char *key)
+ }
+ 
+ /* http://code.google.com/p/cryptsetup/wiki/DMCrypt */
+-static char *get_dm_crypt_params(struct crypt_dm_active_device *dmd)
++static char *get_dm_crypt_params(struct crypt_dm_active_device *dmd, uint32_t 
flags)
+ {
+       int r, max_size, null_cipher = 0;
+       char *params, *hexkey;
+-      const char *features = "";
++      const char *features;
+ 
+       if (!dmd)
+               return NULL;
+ 
+-      if (dmd->flags & CRYPT_ACTIVATE_ALLOW_DISCARDS) {
+-              if (dm_flags() & DM_DISCARDS_SUPPORTED) {
+-                      features = " 1 allow_discards";
+-                      log_dbg("Discard/TRIM is allowed.");
+-              } else
+-                      log_dbg("Discard/TRIM is not supported by the kernel.");
+-      }
++      if (flags & CRYPT_ACTIVATE_ALLOW_DISCARDS)
++              features = " 1 allow_discards";
++      else
++              features = "";
+ 
+       if (!strncmp(dmd->u.crypt.cipher, "cipher_null-", 12))
+               null_cipher = 1;
+@@ -662,6 +659,7 @@ int dm_create_device(struct crypt_device *cd, const char 
*name,
+                    int reload)
+ {
+       char *table_params = NULL;
++      uint32_t dmd_flags;
+       int r;
+ 
+       if (!type)
+@@ -670,14 +668,27 @@ int dm_create_device(struct crypt_device *cd, const char 
*name,
+       if (dm_init_context(cd))
+               return -ENOTSUP;
+ 
++      dmd_flags = dmd->flags;
++
+       if (dmd->target == DM_CRYPT)
+-              table_params = get_dm_crypt_params(dmd);
++              table_params = get_dm_crypt_params(dmd, dmd_flags);
+       else if (dmd->target == DM_VERITY)
+               table_params = get_dm_verity_params(dmd->u.verity.vp, dmd);
+ 
+-      r = _dm_create_device(name, type, dmd->data_device,
+-                            dmd->flags, dmd->uuid, dmd->size,
+-                            table_params, reload);
++      r = _dm_create_device(name, type, dmd->data_device, dmd_flags,
++                            dmd->uuid, dmd->size, table_params, reload);
++
++      /* If discard not supported try to load without discard */
++      if (!reload && r && dmd->target == DM_CRYPT &&
++          (dmd->flags & CRYPT_ACTIVATE_ALLOW_DISCARDS) &&
++          !(dm_flags() & DM_DISCARDS_SUPPORTED)) {
++              log_dbg("Discard/TRIM is not supported, retrying activation.");
++              dmd_flags = dmd_flags & ~CRYPT_ACTIVATE_ALLOW_DISCARDS;
++              crypt_safe_free(table_params);
++              table_params = get_dm_crypt_params(dmd, dmd_flags);
++              r = _dm_create_device(name, type, dmd->data_device, dmd_flags,
++                                    dmd->uuid, dmd->size, table_params, 
reload);
++      }
+ 
+       crypt_safe_free(table_params);
+       dm_exit_context();
+-- 
+2.0.1
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2014-07-28 16:10:39 UTC (rev 218251)
+++ PKGBUILD    2014-07-28 17:24:00 UTC (rev 218252)
@@ -2,24 +2,38 @@
 # Maintainer: Thomas Bächler <[email protected]>
 pkgname=cryptsetup
 pkgver=1.6.5
-pkgrel=1
+pkgrel=2
 pkgdesc="Userspace setup tool for transparent encryption of block devices 
using dm-crypt"
 arch=(i686 x86_64)
 license=('GPL')
 url="http://code.google.com/p/cryptsetup/";
 groups=('base')
-depends=('device-mapper' 'libgcrypt' 'popt' 'util-linux')
+depends=('device-mapper' 'libgcrypt' 'popt' 'libutil-linux')
+makedepends=('util-linux')
 options=('!emptydirs')
 
source=(https://www.kernel.org/pub/linux/utils/cryptsetup/v1.6/${pkgname}-${pkgver}.tar.xz
         
#https://www.kernel.org/pub/linux/utils/cryptsetup/v1.6/${pkgname}-${pkgver}.tar.sign
         encrypt_hook
         encrypt_install
-        sd-encrypt)
+        sd-encrypt
+        0001-Move-safe-table-params-wipe-into-function-which-allo.patch
+        0002-Re-check-flags-after-DM-device-creations.patch
+        0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch)
 sha256sums=('267973f20be43f9d685f7193aa23954b60768c74a1d330243114d4b8bc17ca9a'
             '4406f8dc83f4f1b408e49d557515f721d91b358355c71fbe51f74ab27e5c84ff'
             'cfe465bdad3d958bb2332a05e04f2e1e884422a5714dfd1a0a3b9b74bf7dc6ae'
-            'd442304e6a78b3513ebc53be3fe2f1276a7df470c8da701b3ece971d59979bdd')
+            'd442304e6a78b3513ebc53be3fe2f1276a7df470c8da701b3ece971d59979bdd'
+            '54895ebba0cf1df27da7a53b6a256b7826f9b2d4cff577f840ab457dc32b5c49'
+            'd022e43fa96ee60e295cf6041a8b9e15225eeb03b713f32675061c4063c17ea5'
+            '16d55306a5dde637db16cb219834095432bc8579528789ee52aa975df12284d4')
 
+prepare() {
+  cd "${srcdir}"/$pkgname-${pkgver}
+  patch -p1 -i 
"${srcdir}"/0001-Move-safe-table-params-wipe-into-function-which-allo.patch
+  patch -p1 -i "${srcdir}"/0002-Re-check-flags-after-DM-device-creations.patch
+  patch -p1 -i 
"${srcdir}"/0003-Properly-allow-activation-of-discard-even-if-dm_cryp.patch
+}
+
 build() {
   cd "${srcdir}"/$pkgname-${pkgver}
   ./configure --prefix=/usr --sbindir=/usr/bin --disable-static 
--enable-cryptsetup-reencrypt

Reply via email to