3
0
forked from pool/util-linux
OBS User unknown 2007-03-01 20:08:53 +00:00 committed by Git OBS Bridge
parent d34689d58b
commit 8a9d3be9ea
4 changed files with 107 additions and 8 deletions

View File

@ -159,7 +159,15 @@ Index: util-linux-2.12r/mount/lomount.c
loopFileName = (char *)file; loopFileName = (char *)file;
multiKeyMode = 0; multiKeyMode = 0;
@@ -848,8 +872,8 @@ set_loop(const char *device, const char @@ -802,6 +826,7 @@ set_loop(const char *device, const char
}
if ((fd = open(device, mode)) < 0) {
perror (device);
+ ret = 1;
goto close_ffd_return1;
}
*loopro = (mode == O_RDONLY);
@@ -848,8 +873,8 @@ set_loop(const char *device, const char
loopinfo.lo_encrypt_key_size = 0; loopinfo.lo_encrypt_key_size = 0;
break; break;
case LO_CRYPT_XOR: case LO_CRYPT_XOR:
@ -170,7 +178,7 @@ Index: util-linux-2.12r/mount/lomount.c
xstrncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); xstrncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE);
loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key); loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key);
break; break;
@@ -886,6 +910,7 @@ set_loop(const char *device, const char @@ -886,6 +911,7 @@ set_loop(const char *device, const char
/* This is not compatible with gpgkey= mount option */ /* This is not compatible with gpgkey= mount option */
if(rd_wr_retry(atoi(passFDnumber), (char *)&loopinfo.lo_encrypt_key[0], LO_KEY_SIZE, 0) < 1) { if(rd_wr_retry(atoi(passFDnumber), (char *)&loopinfo.lo_encrypt_key[0], LO_KEY_SIZE, 0) < 1) {
fprintf(stderr, _("Error: couldn't read binary key\n")); fprintf(stderr, _("Error: couldn't read binary key\n"));
@ -178,7 +186,7 @@ Index: util-linux-2.12r/mount/lomount.c
goto close_fd_ffd_return1; goto close_fd_ffd_return1;
} }
break; /* out of switch(loopinfo.lo_encrypt_type) */ break; /* out of switch(loopinfo.lo_encrypt_type) */
@@ -894,6 +919,7 @@ set_loop(const char *device, const char @@ -894,6 +920,7 @@ set_loop(const char *device, const char
/* WARNING! DO NOT USE RANDOM HASH TYPE ON PARTITION WITH EXISTING */ /* WARNING! DO NOT USE RANDOM HASH TYPE ON PARTITION WITH EXISTING */
/* IMPORTANT DATA ON IT. RANDOM HASH TYPE WILL DESTROY YOUR DATA. */ /* IMPORTANT DATA ON IT. RANDOM HASH TYPE WILL DESTROY YOUR DATA. */
if(loop_create_random_keys((char*)file, *loopro, &multiKeyBits[0][0])) { if(loop_create_random_keys((char*)file, *loopro, &multiKeyBits[0][0])) {
@ -186,7 +194,7 @@ Index: util-linux-2.12r/mount/lomount.c
goto close_fd_ffd_return1; goto close_fd_ffd_return1;
} }
memcpy(&loopinfo.lo_encrypt_key[0], &multiKeyBits[0][0], sizeof(loopinfo.lo_encrypt_key)); memcpy(&loopinfo.lo_encrypt_key[0], &multiKeyBits[0][0], sizeof(loopinfo.lo_encrypt_key));
@@ -901,8 +927,8 @@ set_loop(const char *device, const char @@ -901,8 +928,8 @@ set_loop(const char *device, const char
break; /* out of switch(loopinfo.lo_encrypt_type) */ break; /* out of switch(loopinfo.lo_encrypt_type) */
} }
} }
@ -197,7 +205,7 @@ Index: util-linux-2.12r/mount/lomount.c
i = strlen(pass); i = strlen(pass);
if(hashFunc == unhashed1_key_setup) { if(hashFunc == unhashed1_key_setup) {
/* this is for compatibility with historic loop-AES version */ /* this is for compatibility with historic loop-AES version */
@@ -966,6 +992,7 @@ set_loop(const char *device, const char @@ -966,6 +993,7 @@ set_loop(const char *device, const char
break; break;
default: default:
fprintf (stderr, _("Error: don't know how to get key for encryption system %d\n"), loopinfo.lo_encrypt_type); fprintf (stderr, _("Error: don't know how to get key for encryption system %d\n"), loopinfo.lo_encrypt_type);
@ -205,7 +213,7 @@ Index: util-linux-2.12r/mount/lomount.c
goto close_fd_ffd_return1; goto close_fd_ffd_return1;
} }
@@ -985,7 +1012,7 @@ close_fd_ffd_return1: @@ -985,7 +1013,7 @@ close_fd_ffd_return1:
close (fd); close (fd);
close_ffd_return1: close_ffd_return1:
close (ffd); close (ffd);
@ -214,6 +222,14 @@ Index: util-linux-2.12r/mount/lomount.c
} }
/* type 18 == LO_CRYPT_CRYPTOAPI */ /* type 18 == LO_CRYPT_CRYPTOAPI */
@@ -995,6 +1023,7 @@ close_ffd_return1:
fprintf(stderr, _("ioctl: LOOP_SET_STATUS: %s, requested cipher or key length (%d bits) not supported by kernel\n"), strerror(errno), loopinfo.lo_encrypt_key_size << 3);
loop_clr_fd_out:
(void) ioctl (fd, LOOP_CLR_FD, 0);
+ ret = 1;
goto keyclean_close_fd_ffd_return1;
}
}
Index: util-linux-2.12r/mount/losetup.8 Index: util-linux-2.12r/mount/losetup.8
=================================================================== ===================================================================
--- util-linux-2.12r.orig/mount/losetup.8 --- util-linux-2.12r.orig/mount/losetup.8

View File

@ -0,0 +1,70 @@
Index: util-linux-2.12r/mount/lomount.c
===================================================================
--- util-linux-2.12r.orig/mount/lomount.c
+++ util-linux-2.12r/mount/lomount.c
@@ -1005,7 +1005,17 @@ set_loop(const char *device, const char
}
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- perror("ioctl: LOOP_SET_FD");
+ switch (errno) {
+ case EBUSY:
+ ret = 2;
+ if (verbose)
+ perror("ioctl: LOOP_SET_FD");
+ break;
+ default:
+ ret = 1;
+ perror("ioctl: LOOP_SET_FD");
+ break;
+ }
keyclean_close_fd_ffd_return1:
memset(loopinfo.lo_encrypt_key, 0, sizeof(loopinfo.lo_encrypt_key));
memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits));
Index: util-linux-2.12r/mount/mount.c
===================================================================
--- util-linux-2.12r.orig/mount/mount.c
+++ util-linux-2.12r/mount/mount.c
@@ -653,18 +653,32 @@ loop_check(const char **spec, const char
printf(_("mount: skipping the setup of a loop device\n"));
} else {
int loopro = (*flags & MS_RDONLY);
+ int res;
- if (!*loopdev || !**loopdev)
- *loopdev = find_unused_loop_device();
- if (!*loopdev)
- return EX_SYSERR; /* no more loop devices */
- if (verbose)
- printf(_("mount: going to use the loop device %s\n"), *loopdev);
- if (set_loop (*loopdev, *loopfile, &loopro, type, AutoChmodPtr)) {
+ do {
+ if (!*loopdev || !**loopdev)
+ *loopdev = find_unused_loop_device();
+ if (!*loopdev)
+ return EX_SYSERR; /* no more loop devices */
if (verbose)
- printf(_("mount: failed setting up loop device\n"));
- return EX_FAIL;
- }
+ printf(_("mount: going to use the loop device %s\n"), *loopdev);
+ if (res = set_loop (*loopdev, *loopfile, &loopro, type, AutoChmodPtr)) {
+ switch(res) {
+ case 2:
+ /* loop dev has been grabbed by some other process,
+ try again */
+ if (verbose)
+ printf("mount: stolen loop=%s ...trying again\n", *loopdev);
+ *loopdev = NULL;
+ continue;
+ default:
+ if (verbose)
+ printf(_("mount: failed setting up loop device\n"));
+ return EX_FAIL;
+ }
+ }
+ } while (!*loopdev);
+
if (verbose > 1)
printf(_("mount: setup loop device successfully\n"));
*spec = *loopdev;

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Feb 27 10:58:46 CET 2007 - mkoenig@suse.de
- fix missing return code in
util-linux-2.12r-losetup_password.patch
- mount: fix race condition in mount -o loop [#242750]
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Feb 12 17:22:45 CET 2007 - mkoenig@suse.de Mon Feb 12 17:22:45 CET 2007 - mkoenig@suse.de

View File

@ -20,7 +20,7 @@ License: BSD License and BSD-like, GNU General Public License (GPL)
Group: System/Base Group: System/Base
Autoreqprov: on Autoreqprov: on
Version: 2.12r Version: 2.12r
Release: 73 Release: 76
Summary: A collection of basic system utilities Summary: A collection of basic system utilities
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-%version.tar.bz2 Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-%version.tar.bz2
Source2: nologin.c Source2: nologin.c
@ -110,6 +110,7 @@ Patch108: util-linux-2.12r-nfs_remount_options.patch
Patch109: util-linux-2.12r-losetup_password.patch Patch109: util-linux-2.12r-losetup_password.patch
Patch110: util-linux-2.12r-mkfs_open_exclusive.patch Patch110: util-linux-2.12r-mkfs_open_exclusive.patch
Patch111: util-linux-2.12r-fdisk_remove_bogus_warnings.patch Patch111: util-linux-2.12r-fdisk_remove_bogus_warnings.patch
Patch112: util-linux-2.12r-mount_racy_loop.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
PreReq: %insserv_prereq %fillup_prereq /bin/sed PreReq: %insserv_prereq %fillup_prereq /bin/sed
@ -185,6 +186,7 @@ cd -
%patch109 -p1 %patch109 -p1
%patch110 -p1 %patch110 -p1
%patch111 -p1 %patch111 -p1
%patch112 -p1
# setctsid # setctsid
cp %{S:22} %{S:23} . cp %{S:22} %{S:23} .
# nologin and guessfstype # nologin and guessfstype
@ -617,7 +619,11 @@ fi
%{_mandir}/man8/tunelp.8.gz %{_mandir}/man8/tunelp.8.gz
%endif %endif
%changelog -n util-linux %changelog
* Tue Feb 27 2007 - mkoenig@suse.de
- fix missing return code in
util-linux-2.12r-losetup_password.patch
- mount: fix race condition in mount -o loop [#242750]
* Mon Feb 12 2007 - mkoenig@suse.de * Mon Feb 12 2007 - mkoenig@suse.de
- remove legacy warnings from fdisk [#241372] - remove legacy warnings from fdisk [#241372]
* Fri Feb 02 2007 - mkoenig@suse.de * Fri Feb 02 2007 - mkoenig@suse.de