rpms/cryptsetup-luks/devel cryptsetup-fix-activate-null.patch, NONE, 1.1 cryptsetup-fix-alignment-ioctl.patch, NONE, 1.1 cryptsetup-luks.spec, 1.82, 1.83

Milan Broz mbroz at fedoraproject.org
Mon Jun 7 07:41:20 UTC 2010


Author: mbroz

Update of /cvs/pkgs/rpms/cryptsetup-luks/devel
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv24685

Modified Files:
	cryptsetup-luks.spec 
Added Files:
	cryptsetup-fix-activate-null.patch 
	cryptsetup-fix-alignment-ioctl.patch 
Log Message:
Fix alignment ioctl use.
Fix API activation calls to handle NULL device name.



cryptsetup-fix-activate-null.patch:
 ChangeLog   |    1 +
 lib/setup.c |   11 ++++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

--- NEW FILE cryptsetup-fix-activate-null.patch ---
--- cryptsetup-1.1.2.old/ChangeLog	2010-06-07 09:34:04.000000000 +0200
+++ cryptsetup-1.1.2/ChangeLog	2010-06-07 09:34:49.000000000 +0200
@@ -1,5 +1,6 @@
 2010-06-01  Milan Broz  <mbroz at redhat.com>
 	* Fix device alignment ioctl calls parameters.
+	* Fix activate_by_* API calls to handle NULL device name as documented.
 
 2010-05-30  Milan Broz  <mbroz at redhat.com>
 	* Version 1.1.2.
--- cryptsetup-1.1.2.old/lib/setup.c	2010-05-29 17:30:48.000000000 +0200
+++ cryptsetup-1.1.2/lib/setup.c	2010-06-07 09:34:49.000000000 +0200
@@ -355,6 +355,9 @@ static int create_device_helper(struct c
 	char *processed_key = NULL;
 	int r;
 
+	if (!name)
+		return -EINVAL;
+
 	ci = crypt_status(cd, name);
 	if (ci == CRYPT_INVALID)
 		return -EINVAL;
@@ -1656,9 +1659,6 @@ int crypt_activate_by_passphrase(struct
 		name ? "Activating" : "Checking", name ?: "",
 		keyslot, passphrase ? "" : "[none] ");
 
-	if (!name)
-		return -EINVAL;
-
 	/* plain, use hashed passphrase */
 	if (isPLAIN(cd->type))
 		return create_device_helper(cd, name, cd->plain_hdr.hash,
@@ -1712,7 +1712,7 @@ int crypt_activate_by_keyfile(struct cry
 	int r;
 
 	log_dbg("Activating volume %s [keyslot %d] using keyfile %s.",
-		name, keyslot, keyfile ?: "[none]");
+		name ?: "", keyslot, keyfile ?: "[none]");
 
 	if (!isLUKS(cd->type)) {
 		log_err(cd, _("This operation is supported only for LUKS device.\n"));
@@ -1744,7 +1744,8 @@ int crypt_activate_by_keyfile(struct cry
 
 	if (r >= 0) {
 		keyslot = r;
-		r = open_from_hdr_and_mk(cd, mk, name, flags);
+		if (name)
+			r = open_from_hdr_and_mk(cd, mk, name, flags);
 	}
 
 	LUKS_dealloc_masterkey(mk);

cryptsetup-fix-alignment-ioctl.patch:
 ChangeLog   |    3 +++
 lib/utils.c |   16 ++++++++--------
 2 files changed, 11 insertions(+), 8 deletions(-)

--- NEW FILE cryptsetup-fix-alignment-ioctl.patch ---
--- cryptsetup-1.1.2.old/ChangeLog	2010-06-07 09:31:25.000000000 +0200
+++ cryptsetup-1.1.2/ChangeLog	2010-06-07 09:31:39.000000000 +0200
@@ -1,3 +1,6 @@
+2010-06-01  Milan Broz  <mbroz at redhat.com>
+	* Fix device alignment ioctl calls parameters.
+
 2010-05-30  Milan Broz  <mbroz at redhat.com>
 	* Version 1.1.2.
 
--- cryptsetup-1.1.2.old/lib/utils.c	2010-05-27 18:02:06.000000000 +0200
+++ cryptsetup-1.1.2/lib/utils.c	2010-06-07 09:31:39.000000000 +0200
@@ -690,8 +690,8 @@ void get_topology_alignment(const char *
 			    unsigned long *alignment_offset,   /* bytes */
 			    unsigned long default_alignment)
 {
-	unsigned int dev_alignment_offset = 0;
-	unsigned long min_io_size = 0, opt_io_size = 0;
+	int dev_alignment_offset = 0;
+	unsigned int min_io_size = 0, opt_io_size = 0;
 	int fd;
 
 	*required_alignment = default_alignment;
@@ -713,18 +713,18 @@ void get_topology_alignment(const char *
 		opt_io_size = min_io_size;
 
 	/* alignment offset, bogus -1 means misaligned/unknown */
-	if (ioctl(fd, BLKALIGNOFF, &dev_alignment_offset) == -1 || (int)dev_alignment_offset < 0)
+	if (ioctl(fd, BLKALIGNOFF, &dev_alignment_offset) == -1 || dev_alignment_offset < 0)
 		dev_alignment_offset = 0;
 
-	if (*required_alignment < min_io_size)
-		*required_alignment = min_io_size;
+	if (*required_alignment < (unsigned long)min_io_size)
+		*required_alignment = (unsigned long)min_io_size;
 
-	if (*required_alignment < opt_io_size)
-		*required_alignment = opt_io_size;
+	if (*required_alignment < (unsigned long)opt_io_size)
+		*required_alignment = (unsigned long)opt_io_size;
 
 	*alignment_offset = (unsigned long)dev_alignment_offset;
 
-	log_dbg("Topology: IO (%lu/%lu), offset = %lu; Required alignment is %lu bytes.",
+	log_dbg("Topology: IO (%u/%u), offset = %lu; Required alignment is %lu bytes.",
 		min_io_size, opt_io_size, *alignment_offset, *required_alignment);
 out:
 	(void)close(fd);


Index: cryptsetup-luks.spec
===================================================================
RCS file: /cvs/pkgs/rpms/cryptsetup-luks/devel/cryptsetup-luks.spec,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -p -r1.82 -r1.83
--- cryptsetup-luks.spec	30 May 2010 17:56:46 -0000	1.82
+++ cryptsetup-luks.spec	7 Jun 2010 07:41:20 -0000	1.83
@@ -1,7 +1,7 @@
 Summary: A utility for setting up encrypted filesystems
 Name: cryptsetup-luks
 Version: 1.1.2
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2
 Group: Applications/System
 URL: http://cryptsetup.googlecode.com/
@@ -16,6 +16,8 @@ Requires: cryptsetup-luks-libs = %{versi
 %define _root_sbindir /sbin
 %define upstream_version %{version}
 Source0: http://cryptsetup.googlecode.com/files/cryptsetup-%{upstream_version}.tar.bz2
+Patch0: cryptsetup-fix-alignment-ioctl.patch
+Patch1: cryptsetup-fix-activate-null.patch
 
 %description
 This package contains cryptsetup, a utility for setting up
@@ -41,6 +43,8 @@ This package contains the cryptsetup sha
 
 %prep
 %setup -q -n cryptsetup-%{upstream_version}
+%patch0 -p1 -b align
+%patch1 -p1 -b activate
 
 iconv -f latin1 -t utf8 ChangeLog > ChangeLog.new
 mv -f ChangeLog.new ChangeLog
@@ -90,6 +94,10 @@ popd 
 rm -rf $RPM_BUILD_ROOT
 
 %changelog
+* Mon Jun 07 2010 Milan Broz <mbroz at redhat.com> - 1.1.2-2
+- Fix alignment ioctl use.
+- Fix API activation calls to handle NULL device name.
+
 * Sun May 30 2010 Milan Broz <mbroz at redhat.com> - 1.1.2-1
 - Update to cryptsetup 1.1.2
 - Fix luksOpen handling of new line char on stdin.



More information about the scm-commits mailing list