mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
4961c3b4af
commit
ba428469e6
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.74 -
|
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.
|
Fix dm_task_get_name_unmangled to not unmangle already unmangled name.
|
||||||
Check whether device names are properly mangled on ioctl return.
|
Check whether device names are properly mangled on ioctl return.
|
||||||
Deactivation of failed thin check on thin pool returns success.
|
Deactivation of failed thin check on thin pool returns success.
|
||||||
|
@ -1559,6 +1559,9 @@ static int _do_dm_ioctl_unmangle_name(char *name)
|
|||||||
if (mode == DM_STRING_MANGLING_NONE)
|
if (mode == DM_STRING_MANGLING_NONE)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (!check_multiple_mangled_name_allowed(mode, name))
|
||||||
|
return_0;
|
||||||
|
|
||||||
if ((r = unmangle_name(name, DM_NAME_LEN, buf, sizeof(buf),
|
if ((r = unmangle_name(name, DM_NAME_LEN, buf, sizeof(buf),
|
||||||
dm_get_name_mangling_mode())) < 0) {
|
dm_get_name_mangling_mode())) < 0) {
|
||||||
log_debug("_do_dm_ioctl_unmangle_name: failed to "
|
log_debug("_do_dm_ioctl_unmangle_name: failed to "
|
||||||
|
@ -326,6 +326,17 @@ static int _is_whitelisted_char(char c)
|
|||||||
return 0;
|
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
|
* 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.
|
* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_multiple_mangled_name_allowed(mangling_mode, name))
|
||||||
|
return_0;
|
||||||
|
|
||||||
if (mangling_mode != DM_STRING_MANGLING_NONE &&
|
if (mangling_mode != DM_STRING_MANGLING_NONE &&
|
||||||
(r = mangle_name(name, strlen(name), mangled_name,
|
(r = mangle_name(name, strlen(name), mangled_name,
|
||||||
sizeof(mangled_name), mangling_mode)) < 0) {
|
sizeof(mangled_name), mangling_mode)) < 0) {
|
||||||
@ -620,6 +634,9 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_multiple_mangled_name_allowed(mangling_mode, newname))
|
||||||
|
return_0;
|
||||||
|
|
||||||
if (mangling_mode != DM_STRING_MANGLING_NONE &&
|
if (mangling_mode != DM_STRING_MANGLING_NONE &&
|
||||||
(r = mangle_name(newname, strlen(newname), mangled_name,
|
(r = mangle_name(newname, strlen(newname), mangled_name,
|
||||||
sizeof(mangled_name), mangling_mode)) < 0) {
|
sizeof(mangled_name), mangling_mode)) < 0) {
|
||||||
|
@ -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,
|
int unmangle_name(const char *str, size_t len, char *buf,
|
||||||
size_t buf_len, dm_string_mangling_t mode);
|
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,
|
struct target *create_target(uint64_t start,
|
||||||
uint64_t len,
|
uint64_t len,
|
||||||
const char *type, const char *params);
|
const char *type, const char *params);
|
||||||
|
@ -2944,6 +2944,12 @@ static int _mangle(CMD_ARGS)
|
|||||||
target_format = _switches[MANGLENAME_ARG] ? _int_args[MANGLENAME_ARG]
|
target_format = _switches[MANGLENAME_ARG] ? _int_args[MANGLENAME_ARG]
|
||||||
: DEFAULT_DM_NAME_MANGLING;
|
: 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 (target_format == DM_STRING_MANGLING_NONE) {
|
||||||
if (!(new_name = dm_task_get_name_unmangled(dmt)))
|
if (!(new_name = dm_task_get_name_unmangled(dmt)))
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user