* [PATCH] libdm: add "|" to _is_whitelisted_char()
@ 2012-11-27 19:11 Michael Shigorin
2012-11-28 12:04 ` Peter Rajnoha
0 siblings, 1 reply; 3+ messages in thread
From: Michael Shigorin @ 2012-11-27 19:11 UTC (permalink / raw)
To: dm-devel; +Cc: Sergey Vlasov, Dmitry V. Levin
[-- Attachment #1.1.1: Type: text/plain, Size: 558 bytes --]
Hello,
please find attached a silly one-liner that was mentioned
on #device-mapper yesterday and discussed with asalor today.
It adds "|" to a whitelist of chars allowed in devnode names
for the sake of legacy compatibility with EVMS2 LVM plugin
which uses to name the nodes like "lvm2|vg|lv".
I'm going to add it to ALT Linux lvm2 package for that matter
but would definitely prefer not to fork even a single byte
for no good reason.
TIA
--
---- WBR, Michael Shigorin <mike@altlinux.ru>
------ Linux.Kiev http://www.linux.kiev.ua/
[-- Attachment #1.1.2: 0001-libdm-add-to-_is_whitelisted_char.patch --]
[-- Type: text/plain, Size: 1431 bytes --]
From 6c36767acfbc6f72ad7ffed298200088b9bb123b Mon Sep 17 00:00:00 2001
From: Michael Shigorin <mike@altlinux.org>
Date: Fri, 23 Nov 2012 17:21:33 +0200
Subject: [PATCH] libdm: add "|" to _is_whitelisted_char()
The issue is that EVMS' lvm2 plugin would yield names like
"/dev/mapper/lvm2|vg|lv" and the current libdevmapper will
turn these down; this makes migrating legacy environments
involving devmapper-aware tools in the target configuration
a somewhat harder task than it might be.
There's a potential security consideration with any faulty
scripts which wouldn't get device names quoted as noted by
asalor on #device-mapper; this is rather mitigated by the
fact that one needs to have EVMS activated for the devices
in question, even if these are USB flash ones. Speaking of
such scripts, these are prone to misbehave upon "=" either.
---
libdm/libdm-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index afdac89..e715629 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -320,7 +320,7 @@ static int _is_whitelisted_char(char c)
if ((c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
- strchr("#+-.:=@_", c) != NULL)
+ strchr("#+-.:=@_|", c) != NULL)
return 1;
return 0;
--
1.7.12.4
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libdm: add "|" to _is_whitelisted_char()
2012-11-27 19:11 [PATCH] libdm: add "|" to _is_whitelisted_char() Michael Shigorin
@ 2012-11-28 12:04 ` Peter Rajnoha
2012-11-28 12:50 ` Peter Rajnoha
0 siblings, 1 reply; 3+ messages in thread
From: Peter Rajnoha @ 2012-11-28 12:04 UTC (permalink / raw)
To: device-mapper development
Cc: Sergey Vlasov, Michael Shigorin, Dmitry V. Levin
On 11/27/2012 08:11 PM, Michael Shigorin wrote:
> Hello,
> please find attached a silly one-liner that was mentioned
> on #device-mapper yesterday and discussed with asalor today.
>
> It adds "|" to a whitelist of chars allowed in devnode names
> for the sake of legacy compatibility with EVMS2 LVM plugin
> which uses to name the nodes like "lvm2|vg|lv".
Actually, that whitelist is taken from udev and any extra
character not on the current whitelist is automatically mangled
to a form that udev understands by default (which is \xNN,
NN being a hex value of the character). So it's all done to
conform with udev. Otherwise, if such mangling was not used,
udev would replace any blacklisted character with an underscore "_".
Now, if you *really* intend to bypass this mangling and udev,
you can use:
dmsetup <dm_command> --manglename none ...
If you have your libdevmapper *compiled with udev support*
(configure --enable-udev_sync), then you also need to use
extra --noudevrules (to bypass udev rules) and --verifyudev
switches (to make a fallback to direct node/symlink creation):
dmsetup <dm_command> --manglename none --noudevrules --verifyudev ...
But, if your system uses udev, try to avoid this as much as possible!
Bypassing udev has many side effects, like missing information in
udev database (as the symlinks/nodes were not created by udev itself).
And this database could be read by other tools and they simply won't
see all the state. Reading udev database instead of scanning the
/dev directly is very common these days.
Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libdm: add "|" to _is_whitelisted_char()
2012-11-28 12:04 ` Peter Rajnoha
@ 2012-11-28 12:50 ` Peter Rajnoha
0 siblings, 0 replies; 3+ messages in thread
From: Peter Rajnoha @ 2012-11-28 12:50 UTC (permalink / raw)
To: device-mapper development
Cc: Sergey Vlasov, Michael Shigorin, Dmitry V. Levin
On 11/28/2012 01:04 PM, Peter Rajnoha wrote:
> Now, if you *really* intend to bypass this mangling and udev,
> you can use:
>
> dmsetup <dm_command> --manglename none ...
>
If you use libdevmapper to handle device-mapper devices, have
a look at libdevmapper.h. You can bypass default mangling with
dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE):
---
/*
* Mangling support
*
* Character whitelist: 0-9, A-Z, a-z, #+-.:=@_
* HEX mangling format: \xNN, NN being the hex value of the character.
* (whitelist and format supported by udev)
*/
typedef enum {
DM_STRING_MANGLING_NONE, /* do not mangle at all */
DM_STRING_MANGLING_AUTO, /* mangle only if not already mangled with hex, error when mixed */
DM_STRING_MANGLING_HEX /* always mangle with hex encoding, no matter what the input is */
} dm_string_mangling_t;
/*
* Set/get mangling mode used for device-mapper names and uuids.
*/
int dm_set_name_mangling_mode(dm_string_mangling_t name_mangling);
dm_string_mangling_t dm_get_name_mangling_mode(void);
---
Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-28 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 19:11 [PATCH] libdm: add "|" to _is_whitelisted_char() Michael Shigorin
2012-11-28 12:04 ` Peter Rajnoha
2012-11-28 12:50 ` Peter Rajnoha
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.