summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2012-03-05 12:48:12 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2012-03-05 12:48:12 +0000
commitba428469e6b8546349f6acb293535b3e805a9313 (patch)
treeed7b129909b7b36f2b8e409aea60dc9670870abc
parent4961c3b4afdf56852b3a06641845c73166d46f05 (diff)
downloadlvm2-ba428469e6b8546349f6acb293535b3e805a9313.tar.gz
lvm2-ba428469e6b8546349f6acb293535b3e805a9313.tar.xz
lvm2-ba428469e6b8546349f6acb293535b3e805a9313.zip
Check for multiple mangled names in auto mangling mode.
Auto mode can't deal with multiple mangled names. We can do that while working in hex mode, but in auto mode, this would lead to device name ambiguity.
-rw-r--r--WHATS_NEW_DM1
-rw-r--r--libdm/ioctl/libdm-iface.c3
-rw-r--r--libdm/libdm-common.c17
-rw-r--r--libdm/libdm-common.h2
-rw-r--r--tools/dmsetup.c6
5 files changed, 29 insertions, 0 deletions
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 0ba55d94..38cc1448 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.74 -
================================
+ Check for multiple mangled names in auto mangling mode.
Fix dm_task_get_name_unmangled to not unmangle already unmangled name.
Check whether device names are properly mangled on ioctl return.
Deactivation of failed thin check on thin pool returns success.
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 0e3dab5e..09116197 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -1559,6 +1559,9 @@ static int _do_dm_ioctl_unmangle_name(char *name)
if (mode == DM_STRING_MANGLING_NONE)
return 1;
+ if (!check_multiple_mangled_name_allowed(mode, name))
+ return_0;
+
if ((r = unmangle_name(name, DM_NAME_LEN, buf, sizeof(buf),
dm_get_name_mangling_mode())) < 0) {
log_debug("_do_dm_ioctl_unmangle_name: failed to "
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 843d1dde..15a6316e 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -326,6 +326,17 @@ static int _is_whitelisted_char(char c)
return 0;
}
+int check_multiple_mangled_name_allowed(dm_string_mangling_t mode, const char *name)
+{
+ if (mode == DM_STRING_MANGLING_AUTO && strstr(name, "\\x5cx")) {
+ log_error("The name \"%s\" seems to be multiple mangled. "
+ "This is not allowed in auto mode.", name);
+ return 0;
+ }
+
+ return 1;
+}
+
/*
* Mangle all characters in the input string which are not on a whitelist
* with '\xNN' format where NN is the hex value of the character.
@@ -485,6 +496,9 @@ static int _dm_task_set_name(struct dm_task *dmt, const char *name,
return 0;
}
+ if (!check_multiple_mangled_name_allowed(mangling_mode, name))
+ return_0;
+
if (mangling_mode != DM_STRING_MANGLING_NONE &&
(r = mangle_name(name, strlen(name), mangled_name,
sizeof(mangled_name), mangling_mode)) < 0) {
@@ -620,6 +634,9 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname)
return 0;
}
+ if (!check_multiple_mangled_name_allowed(mangling_mode, newname))
+ return_0;
+
if (mangling_mode != DM_STRING_MANGLING_NONE &&
(r = mangle_name(newname, strlen(newname), mangled_name,
sizeof(mangled_name), mangling_mode)) < 0) {
diff --git a/libdm/libdm-common.h b/libdm/libdm-common.h
index ce9b434f..b57bae9e 100644
--- a/libdm/libdm-common.h
+++ b/libdm/libdm-common.h
@@ -28,6 +28,8 @@ int mangle_name(const char *str, size_t len, char *buf,
int unmangle_name(const char *str, size_t len, char *buf,
size_t buf_len, dm_string_mangling_t mode);
+int check_multiple_mangled_name_allowed(dm_string_mangling_t mode, const char *name);
+
struct target *create_target(uint64_t start,
uint64_t len,
const char *type, const char *params);
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index c747e6d7..d07ebc03 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -2944,6 +2944,12 @@ static int _mangle(CMD_ARGS)
target_format = _switches[MANGLENAME_ARG] ? _int_args[MANGLENAME_ARG]
: DEFAULT_DM_NAME_MANGLING;
+ if (target_format == DM_STRING_MANGLING_AUTO && strstr(name, "\\x5cx")) {
+ log_error("The name \"%s\" seems to be multiple mangled. "
+ "Manual intervention required to rename the device.", name);
+ goto out;
+ }
+
if (target_format == DM_STRING_MANGLING_NONE) {
if (!(new_name = dm_task_get_name_unmangled(dmt)))
goto out;