SOURCES (AC-branch): util-linux-dm_crypt.patch - added support for...
kosmo
kosmo at pld-linux.org
Fri May 25 13:00:55 CEST 2007
Author: kosmo Date: Fri May 25 11:00:53 2007 GMT
Module: SOURCES Tag: AC-branch
---- Log message:
- added support for ESSIV
---- Files affected:
SOURCES:
util-linux-dm_crypt.patch (1.2 -> 1.2.2.1)
---- Diffs:
================================================================
Index: SOURCES/util-linux-dm_crypt.patch
diff -u SOURCES/util-linux-dm_crypt.patch:1.2 SOURCES/util-linux-dm_crypt.patch:1.2.2.1
--- SOURCES/util-linux-dm_crypt.patch:1.2 Sun Feb 27 20:09:11 2005
+++ SOURCES/util-linux-dm_crypt.patch Fri May 25 13:00:48 2007
@@ -1,7 +1,220 @@
+diff -urN util-linux-2.12q.org/mount/cryptsetup.h util-linux-2.12q/mount/cryptsetup.h
+--- util-linux-2.12q.org/mount/cryptsetup.h 1970-01-01 01:00:00.000000000 +0100
++++ util-linux-2.12q/mount/cryptsetup.h 2005-02-27 19:26:34.000000000 +0100
+@@ -0,0 +1,4 @@
++extern int verbose;
++extern int set_crypt(char **, const char *, int, char **,
++ int, int *);
++extern int del_crypt(const char *);
+diff -urN util-linux-2.12q.org/mount/Makefile util-linux-2.12q/mount/Makefile
+--- util-linux-2.12q.org/mount/Makefile 2005-02-27 19:25:37.000000000 +0100
++++ util-linux-2.12q/mount/Makefile 2005-02-27 19:27:21.000000000 +0100
+@@ -30,6 +30,7 @@
+ MAYBE = pivot_root swapoff
+
+ LO_OBJS = lomount.o $(LIB)/xstrncpy.o
++CRYPT_OBJS = cryptsetup.o -lcryptsetup
+ NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o
+ GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c
+
+@@ -49,12 +50,12 @@
+
+ mount: mount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o version.o \
+ get_label_uuid.o mount_by_label.o mount_blkid.o mount_guess_fstype.o \
+- getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS)
++ getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS) $(CRYPT_OBJS)
+ $(LINK) $^ -o $@ $(BLKID_LIB)
+
+ umount: umount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o \
+ getusername.o get_label_uuid.o mount_by_label.o mount_blkid.o \
+- version.o $(LIB)/env.o $(LO_OBJS)
++ version.o $(LIB)/env.o $(LO_OBJS) $(CRYPT_OBJS)
+ $(LINK) $^ -o $@ $(BLKID_LIB)
+
+ swapon: swapon.o version.o xmalloc.o \
+diff -urN util-linux-2.12q.org/mount/mount.c util-linux-2.12q/mount/mount.c
+--- util-linux-2.12q.org/mount/mount.c 2004-12-21 23:00:36.000000000 +0100
++++ util-linux-2.12q/mount/mount.c 2005-02-27 19:29:40.000000000 +0100
+@@ -28,6 +28,7 @@
+ #include "mntent.h"
+ #include "fstab.h"
+ #include "lomount.h"
++#include "cryptsetup.h"
+ #include "loop.h"
+ #include "linux_fs.h" /* for BLKGETSIZE */
+ #include "mount_guess_rootdev.h"
+@@ -98,6 +99,7 @@
+ #define MS_USER 0x20000000
+ #define MS_OWNER 0x10000000
+ #define MS_GROUP 0x08000000
++#define MS_CRYPT 0x00040000
+ #define MS_COMMENT 0x00020000
+ #define MS_LOOP 0x00010000
+
+@@ -607,7 +609,7 @@
+ *type = opt_vfstype;
+ }
+
+- *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption);
++ *loop = ((*flags & MS_LOOP) || *loopdev || (opt_offset && !opt_encryption));
+ *loopfile = *spec;
+
+ if (*loop) {
+@@ -626,7 +628,7 @@
+ printf(_("mount: going to use the loop device %s\n"), *loopdev);
+ offset = opt_offset ? strtoull(opt_offset, NULL, 0) : 0;
+ if (set_loop(*loopdev, *loopfile, offset,
+- opt_encryption, pfd, &loopro)) {
++ NULL /* opt_encryption */, pfd, &loopro)) {
+ if (verbose)
+ printf(_("mount: failed setting up loop device\n"));
+ return EX_FAIL;
+@@ -636,6 +638,42 @@
+ *spec = *loopdev;
+ if (loopro)
+ *flags |= MS_RDONLY;
++ /* set offset to 0 so that crypto setup doesn't add an offset too */
++ opt_offset = 0;
++ }
++ }
++
++ return 0;
++}
++
++static int
++crypt_check(char **spec, char **type, int *flags,
++ int *crypt, char **cryptdev, char **realdev) {
++ int offset;
++
++ *crypt = ((*flags & MS_CRYPT) || opt_encryption);
++ *realdev = *spec;
++
++ if (*crypt) {
++ *flags |= MS_CRYPT;
++ if (fake) {
++ if (verbose)
++ printf(_("mount: skipping the setup of an encrypted device\n"));
++ } else {
++ int cryptro = (*flags & MS_RDONLY);
++
++ offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0;
++ if (set_crypt(cryptdev, *realdev, offset,
++ &opt_encryption, pfd, &cryptro)) {
++ if (verbose)
++ printf(_("mount: failed setting up encrypted device\n"));
++ return EX_FAIL;
++ }
++ if (verbose > 1)
++ printf(_("mount: setup crypt device successfully\n"));
++ *spec = *cryptdev;
++ if (cryptro)
++ *flags |= MS_RDONLY;
+ }
+ }
+
+@@ -788,7 +826,9 @@
+ const char *opts, *spec, *node, *types;
+ char *user = 0;
+ int loop = 0;
++ int crypt = 0;
+ const char *loopdev = 0, *loopfile = 0;
++ char *cryptdev = 0, *realdev = 0;
+ struct stat statbuf;
+ int nfs_mount_version = 0; /* any version */
+
+@@ -823,6 +863,10 @@
+ res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
+ if (res)
+ goto out;
++
++ res = crypt_check(&spec, &types, &flags, &crypt, &cryptdev, &realdev);
++ if (res)
++ goto out;
+ }
+
+ /*
+@@ -863,8 +907,13 @@
+ /* Mount succeeded, report this (if verbose) and write mtab entry. */
+ if (loop)
+ opt_loopdev = loopdev;
++ if (crypt) {
++ char *tmp = xmalloc(strlen(cryptdev) + strlen(opt_encryption) + 3);
++ sprintf(tmp, "@%s:%s", cryptdev, opt_encryption);
++ opt_encryption = tmp;
++ }
+
+- update_mtab_entry(loop ? loopfile : spec,
++ update_mtab_entry(loop ? loopfile : crypt ? realdev : spec,
+ node,
+ types ? types : "unknown",
+ fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user),
+@@ -879,6 +928,8 @@
+
+ mnt_err = errno;
+
++ if (crypt)
++ del_crypt(spec);
+ if (loop)
+ del_loop(spec);
+
+diff -urN util-linux-2.12q.org/mount/umount.c util-linux-2.12q/mount/umount.c
+--- util-linux-2.12q.org/mount/umount.c 2004-12-20 23:03:45.000000000 +0100
++++ util-linux-2.12q/mount/umount.c 2005-02-27 19:26:34.000000000 +0100
+@@ -15,6 +15,7 @@
+ #include "sundries.h"
+ #include "getusername.h"
+ #include "lomount.h"
++#include "cryptsetup.h"
+ #include "loop.h"
+ #include "fstab.h"
+ #include "env.h"
+@@ -274,6 +275,7 @@
+ int res;
+ int status;
+ const char *loopdev;
++ const char *cryptdev;
+
+ /* Special case for root. As of 0.99pl10 we can (almost) unmount root;
+ the kernel will remount it readonly so that we can carry on running
+@@ -365,12 +367,33 @@
+ }
+ }
+
+- loopdev = 0;
+ if (res >= 0) {
+ /* Umount succeeded */
+ if (verbose)
+ printf (_("%s umounted\n"), spec);
++ }
++
++ cryptdev = 0;
++ if (res >= 0) {
++ /* Free any encrypted devices that we allocated ourselves */
++ if (mc) {
++ char *optl;
++
++ optl = mc->m.mnt_opts ? xstrdup(mc->m.mnt_opts) : "";
++ for (optl = strtok (optl, ","); optl;
++ optl = strtok (NULL, ",")) {
++ if (!strncmp(optl, "encryption=", 11)) {
++ cryptdev = optl+11;
++ break;
++ }
++ }
++ }
++ }
++ if (cryptdev)
++ del_crypt(cryptdev);
+
++ loopdev = 0;
++ if (res >= 0) {
+ /* Free any loop devices that we allocated ourselves */
+ if (mc) {
+ char *optl;
diff -urN util-linux-2.12q.org/mount/cryptsetup.c util-linux-2.12q/mount/cryptsetup.c
--- util-linux-2.12q.org/mount/cryptsetup.c 1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.12q/mount/cryptsetup.c 2005-02-27 19:26:34.000000000 +0100
-@@ -0,0 +1,216 @@
+@@ -0,0 +1,217 @@
+/*
+ * cryptsetup.c - setup and control encrypted devices
+ */
@@ -100,6 +313,7 @@
+ options.name = name;
+ options.device = realdev;
+ options.cipher = xstrtok(p, ':');
++ q = options.cipher; while(*q) { if (*q == '@') { *q = ':'; } q++; } /* for <cipher>-cbc-essiv@<hash> */
+ q = xstrtok(NULL, ':');
+ options.key_size = q ? strtoul(q, NULL, 0) : 0;
+ if (!options.key_size)
@@ -218,216 +432,3 @@
+}
+
+#endif
-diff -urN util-linux-2.12q.org/mount/cryptsetup.h util-linux-2.12q/mount/cryptsetup.h
---- util-linux-2.12q.org/mount/cryptsetup.h 1970-01-01 01:00:00.000000000 +0100
-+++ util-linux-2.12q/mount/cryptsetup.h 2005-02-27 19:26:34.000000000 +0100
-@@ -0,0 +1,4 @@
-+extern int verbose;
-+extern int set_crypt(char **, const char *, int, char **,
-+ int, int *);
-+extern int del_crypt(const char *);
-diff -urN util-linux-2.12q.org/mount/Makefile util-linux-2.12q/mount/Makefile
---- util-linux-2.12q.org/mount/Makefile 2005-02-27 19:25:37.000000000 +0100
-+++ util-linux-2.12q/mount/Makefile 2005-02-27 19:27:21.000000000 +0100
-@@ -30,6 +30,7 @@
- MAYBE = pivot_root swapoff
-
- LO_OBJS = lomount.o $(LIB)/xstrncpy.o
-+CRYPT_OBJS = cryptsetup.o -lcryptsetup
- NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o
- GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c
-
-@@ -49,12 +50,12 @@
-
- mount: mount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o version.o \
- get_label_uuid.o mount_by_label.o mount_blkid.o mount_guess_fstype.o \
-- getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS)
-+ getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS) $(CRYPT_OBJS)
- $(LINK) $^ -o $@ $(BLKID_LIB)
-
- umount: umount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o \
- getusername.o get_label_uuid.o mount_by_label.o mount_blkid.o \
-- version.o $(LIB)/env.o $(LO_OBJS)
-+ version.o $(LIB)/env.o $(LO_OBJS) $(CRYPT_OBJS)
- $(LINK) $^ -o $@ $(BLKID_LIB)
-
- swapon: swapon.o version.o xmalloc.o \
-diff -urN util-linux-2.12q.org/mount/mount.c util-linux-2.12q/mount/mount.c
---- util-linux-2.12q.org/mount/mount.c 2004-12-21 23:00:36.000000000 +0100
-+++ util-linux-2.12q/mount/mount.c 2005-02-27 19:29:40.000000000 +0100
-@@ -28,6 +28,7 @@
- #include "mntent.h"
- #include "fstab.h"
- #include "lomount.h"
-+#include "cryptsetup.h"
- #include "loop.h"
- #include "linux_fs.h" /* for BLKGETSIZE */
- #include "mount_guess_rootdev.h"
-@@ -98,6 +99,7 @@
- #define MS_USER 0x20000000
- #define MS_OWNER 0x10000000
- #define MS_GROUP 0x08000000
-+#define MS_CRYPT 0x00040000
- #define MS_COMMENT 0x00020000
- #define MS_LOOP 0x00010000
-
-@@ -607,7 +609,7 @@
- *type = opt_vfstype;
- }
-
-- *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption);
-+ *loop = ((*flags & MS_LOOP) || *loopdev || (opt_offset && !opt_encryption));
- *loopfile = *spec;
-
- if (*loop) {
-@@ -626,7 +628,7 @@
- printf(_("mount: going to use the loop device %s\n"), *loopdev);
- offset = opt_offset ? strtoull(opt_offset, NULL, 0) : 0;
- if (set_loop(*loopdev, *loopfile, offset,
-- opt_encryption, pfd, &loopro)) {
-+ NULL /* opt_encryption */, pfd, &loopro)) {
- if (verbose)
- printf(_("mount: failed setting up loop device\n"));
- return EX_FAIL;
-@@ -636,6 +638,42 @@
- *spec = *loopdev;
- if (loopro)
- *flags |= MS_RDONLY;
-+ /* set offset to 0 so that crypto setup doesn't add an offset too */
-+ opt_offset = 0;
-+ }
-+ }
-+
-+ return 0;
-+}
-+
-+static int
-+crypt_check(char **spec, char **type, int *flags,
-+ int *crypt, char **cryptdev, char **realdev) {
-+ int offset;
-+
-+ *crypt = ((*flags & MS_CRYPT) || opt_encryption);
-+ *realdev = *spec;
-+
-+ if (*crypt) {
-+ *flags |= MS_CRYPT;
-+ if (fake) {
-+ if (verbose)
-+ printf(_("mount: skipping the setup of an encrypted device\n"));
-+ } else {
-+ int cryptro = (*flags & MS_RDONLY);
-+
-+ offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0;
-+ if (set_crypt(cryptdev, *realdev, offset,
-+ &opt_encryption, pfd, &cryptro)) {
-+ if (verbose)
-+ printf(_("mount: failed setting up encrypted device\n"));
-+ return EX_FAIL;
-+ }
-+ if (verbose > 1)
-+ printf(_("mount: setup crypt device successfully\n"));
-+ *spec = *cryptdev;
-+ if (cryptro)
-+ *flags |= MS_RDONLY;
- }
- }
-
-@@ -788,7 +826,9 @@
- const char *opts, *spec, *node, *types;
- char *user = 0;
- int loop = 0;
-+ int crypt = 0;
- const char *loopdev = 0, *loopfile = 0;
-+ char *cryptdev = 0, *realdev = 0;
- struct stat statbuf;
- int nfs_mount_version = 0; /* any version */
-
-@@ -823,6 +863,10 @@
- res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
- if (res)
- goto out;
-+
-+ res = crypt_check(&spec, &types, &flags, &crypt, &cryptdev, &realdev);
-+ if (res)
-+ goto out;
- }
-
- /*
-@@ -863,8 +907,13 @@
- /* Mount succeeded, report this (if verbose) and write mtab entry. */
- if (loop)
- opt_loopdev = loopdev;
-+ if (crypt) {
-+ char *tmp = xmalloc(strlen(cryptdev) + strlen(opt_encryption) + 3);
-+ sprintf(tmp, "@%s:%s", cryptdev, opt_encryption);
-+ opt_encryption = tmp;
-+ }
-
-- update_mtab_entry(loop ? loopfile : spec,
-+ update_mtab_entry(loop ? loopfile : crypt ? realdev : spec,
- node,
- types ? types : "unknown",
- fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user),
-@@ -879,6 +928,8 @@
-
- mnt_err = errno;
-
-+ if (crypt)
-+ del_crypt(spec);
- if (loop)
- del_loop(spec);
-
-diff -urN util-linux-2.12q.org/mount/umount.c util-linux-2.12q/mount/umount.c
---- util-linux-2.12q.org/mount/umount.c 2004-12-20 23:03:45.000000000 +0100
-+++ util-linux-2.12q/mount/umount.c 2005-02-27 19:26:34.000000000 +0100
-@@ -15,6 +15,7 @@
- #include "sundries.h"
- #include "getusername.h"
- #include "lomount.h"
-+#include "cryptsetup.h"
- #include "loop.h"
- #include "fstab.h"
- #include "env.h"
-@@ -274,6 +275,7 @@
- int res;
- int status;
- const char *loopdev;
-+ const char *cryptdev;
-
- /* Special case for root. As of 0.99pl10 we can (almost) unmount root;
- the kernel will remount it readonly so that we can carry on running
-@@ -365,12 +367,33 @@
- }
- }
-
-- loopdev = 0;
- if (res >= 0) {
- /* Umount succeeded */
- if (verbose)
- printf (_("%s umounted\n"), spec);
-+ }
-+
-+ cryptdev = 0;
-+ if (res >= 0) {
-+ /* Free any encrypted devices that we allocated ourselves */
-+ if (mc) {
-+ char *optl;
-+
-+ optl = mc->m.mnt_opts ? xstrdup(mc->m.mnt_opts) : "";
-+ for (optl = strtok (optl, ","); optl;
-+ optl = strtok (NULL, ",")) {
-+ if (!strncmp(optl, "encryption=", 11)) {
-+ cryptdev = optl+11;
-+ break;
-+ }
-+ }
-+ }
-+ }
-+ if (cryptdev)
-+ del_crypt(cryptdev);
-
-+ loopdev = 0;
-+ if (res >= 0) {
- /* Free any loop devices that we allocated ourselves */
- if (mc) {
- char *optl;
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/util-linux-dm_crypt.patch?r1=1.2&r2=1.2.2.1&f=u
More information about the pld-cvs-commit
mailing list