RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 834734 - Luks doesn't do spaces right.
Summary: Luks doesn't do spaces right.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: cryptsetup-luks
Version: 6.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Milan Broz
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-23 03:08 UTC by LunaSilverMoon
Modified: 2013-03-01 04:11 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-25 07:48:03 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description LunaSilverMoon 2012-06-23 03:08:28 UTC
Description of problem:
When open a luks encryption specifying the name of the partition.  If used with as this "Support Mouse" in the /dev/mapper it comes out /dev/mapper/Support\x20Mouse.  Unforunatly this does not work correctly either trying to mount it in a directory for example /dev/mapper/"Support Mouse".  It would say not found.  Correct way to do it /dev/mapper/"Support\x20Mouse"

Version-Release number of selected component (if applicable):


How reproducible:
Open a encrypted partition give it a name that has a space in quotes.
cryptsetup luksOpen /dev/Support_Mouse_vg/LogVol06 "Support Mouse"

Steps to Reproduce:
1. cryptsetup luksOpen /dev/namofencryptedpartition "A name with spaces and quotes"
2.
3.
  
Actual results:
/dev/mapper/Support\x20Mouse

Expected results:
/dev/mapper/Support Mouse

Additional info:

Comment 2 Milan Broz 2012-06-23 08:42:29 UTC
This is udev/DM limitaton, you cannot create device name with spaces in /dev.

Just try dmsetup create "a b c" --table "0 8 zero". It will create the same problem. 

All I can do is to disable such names in cryptsetup completely.

Comment 3 Alasdair Kergon 2012-06-23 10:36:29 UTC
If you want to use spaces as input, you must also use the udev escaping rules elsewhere in your script.  'dmsetup mangle' can do this conversion for you.

       mangle [device_name]
              Ensure existing device-mapper device name is in the correct man‐
              gled form containing only whitelisted characters  (supported  by
              udev)  and  do  a  rename if necessary. Any character not on the
              whitelist will be mangled based on the --manglename settting.

       --manglename <mangling_mode>
              Mangle any character not on a whitelist using mangling_mode when
              processing  device-mapper device names. The names are mangled on
              input and unmangled on output where the mangling_mode is one of:
              none  (no mangling), hex (always do the mangling) and auto (only
              do the mangling if not mangled yet, do nothing if  already  man‐
              gled,  error  on  mixed;  this  is  used by default).  Character
              whitelist: 0-9, A-Z, a-z, #+-.:=@_. This whitelist is also  sup‐
              ported  by  udev.  Any  character not on a whitelist is replaced
              with its hex value (two digits) prefixed by \x.

Comment 4 LunaSilverMoon 2012-06-23 21:49:51 UTC
I did not know this was a limitation but before the upgrade 6.3 it worked fine without no problems.  I'll adjust scripts from what Alasdair Kergon said  about dmsetup mangle.

Comment 5 Alasdair Kergon 2012-06-23 22:35:20 UTC
In short:

a)  udev owns /dev now;

b)  udev only allows its whitelisted characters to be present in /dev;

c)  any other characters are "mangled" according to that formula;

d)  anything *directly* using /dev may need to be aware of udev mangling;

e)  device-mapper-based tools handle this transparently using libdevmapper so that users can continue to use non-conforming names in such tools.

Comment 6 Peter Rajnoha 2012-06-25 07:44:41 UTC
I think the problem here is that when using "Support Mouse" on cryptsetup input, it gives you a "Support\x20Mouse" in /dev/mapper which is perfectly fine - this conversion is done by libdevmapper. Otherwise, udev can't deal with such names (without this conversion, udev would assume these are two separate names, separated by a space so you would end up with "/dev/mapper/Support" and "/dev/mapper/Mouse" which is not what you would expect).

Working with such device name shold work fine, BUT you have to count with bash escaping (or whichever you use), so:

[1] rawhide/~ # cryptsetup luksOpen /dev/sda "Support Mouse"
Enter passphrase for /dev/sda: 

[1] rawhide/~ # ls /dev/mapper/
Support\x20Mouse  control

[1] rawhide/~ # mount /dev/mapper/Support\\x20Mouse /mnt/temp/

[1] rawhide/~ # df -h /mnt/temp/
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/Support\x20Mouse  125M  7.8M  111M   7% /mnt/temp

See the \\x20 - that's because you need to count with sh escaping as well! This is not bug imho.

And yes, if you have any existing device-mapper devices on your system without such mangling used (for example, if you have not rebooted your system, but you upgraded to that newer version of libdevmapper that supports mangling - libdevmapper v1.02.71/lvm2 v2.02.92), you should use "dmsetup mangle" command to translate these names as already advised in comment #3.

Comment 7 Milan Broz 2012-06-25 07:48:03 UTC
In RHEL5 it works, because libdevammper  (which is cryptsetup based on) create nodes without udev interference.

In early RHEL6 releases it can perhaps create name with space because of direct node creation fallback (libdevampper checks if node was created by udev and if not, it "fixes" it). This is bug (or misconception), not feature :)

Once libdevamapper started to use proper device name mangling, this fallback never applies - and you see the change here.

Cryptsetup cannot do anything here, it depends what is device-mapper library doing - if you think it is a bug, report bug against udev or device-mapper library (also see bug #736486).

Comment 8 Peter Rajnoha 2012-06-25 07:51:57 UTC
(In reply to comment #7)
> Cryptsetup cannot do anything here, it depends what is device-mapper library
> doing - if you think it is a bug, report bug against udev or device-mapper
> library (also see bug #736486).

Report against udev, please - libdevmapper can't do anything else with this problem as well if udev is used :)

Comment 9 Peter Rajnoha 2012-06-25 07:59:05 UTC
There's also a request to document this encoding in udev man page (which is, unfortunately, still not there yet): bug #790321. (this is the official encoding that udev supports to escape names with blacklisted characters)


Note You need to log in before you can comment on or make changes to this bug.