autofs5 may fail if map contains utf8 characters

Bug #668933 reported by Alexey Loukianov
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
autofs5 (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Binary package hint: autofs5

This bug is not in autofs itself, but instead is in smbclient.
Surely a separate bug report should be fired against smbclient but this bug may be relatively easy workarounded in autofs5 auto.smb/auto.cifs maps.

Problem with smbclient may be easily demonstrated by examining the following output:

root@linuxws03:/etc# LANG="en+US.UTF-8" smbclient -N -gL linuxws03
Domain=[WG] OS=[Unix] Server=[Samba 3.4.7]
Disk|print$|Printer Drivers
IPC|IPC$|IPC Service (linuxws03 server (Samba, Ubuntu))
Disk|документы|
Disk|documents|
Domain=[WG] OS=[Unix] Server=[Samba 3.4.7]
Server|WGOFFICE|Office Linux Server (Samba 3.0.9-1.3E.16)
Server|LINUXWS03|linuxws03 server (Samba, Ubuntu)
Workgroup|WG|WGOFFICE

root@linuxws03:/etc# LANG="C" smbclient -N -gL linuxws03
Domain=[WG] OS=[Unix] Server=[Samba 3.4.7]
Disk|print$|Printer Drivers
IPC|IPC$|IPC Service (linuxws03 server (Samba, Ubuntu))
Disk|Disk|documents|
Domain=[WG] OS=[Unix] Server=[Samba 3.4.7]
Server|WGOFFICE|Office Linux Server (Samba 3.0.9-1.3E.16)
Server|LINUXWS03|linuxws03 server (Samba, Ubuntu)
Workgroup|WG|WGOFFICE

As you can see, the share named "документы" (this is russian word meaning "documents") gets lost when smbclient is being executed with "C" locale resulting in totally incorrect output "Disk|Disk|documents|" - in fact this should be two lines, one for "Disk|документы|" somehow mangled to be ASCII-friendly, and another one for "Disk|documents|". Yes, this is a bug in smbclient that should be reported at a separate bug report. To workaround this bug one may always use UFT-8 locale when running smbclient and optionally converting the output using something like " iconv -f utf8 -t ascii -c | grep -v 'Disk||' ".

My approach was for to modify auto.smb/auto.cifs by adding 'export LANG="en_US.UTF-8"' to the top of the file in order to fetch correct shares list. Then some modifications should be done to the awk script parsing the output:

$SMBCLIENT $smbopts -gL $key 2>/dev/null| awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN { ORS=""; first=1; }
        /Disk/ {
                    if (first) {
                        print opts
                        first=0
                    }
                    gsub(/ /, "\\ ", $2)
                    sub(/\$/, "\\$", $2)
                    print " \\\n\t \"/" $2 "\" \"://" key "/" $2 "\""
                }
        END {
                    if (!first)
                        print "\n"
                    else
                        exit 1
                }
        '

This would allow to mount shares with utf-8 names, including ones that contain space characters in their names.

Mathias Gug (mathiaz)
Changed in autofs5 (Ubuntu):
importance: Undecided → Low
Revision history for this message
Chuck Short (zulcss) wrote :

Can you create a patch for this?

Thanks
chuck

Changed in autofs5 (Ubuntu):
status: New → Confirmed
Revision history for this message
Alexey Loukianov (lexa2) wrote :

Well, generally speaking, yes, I can, but it would take a long time as I'm not using Ubuntu and its derived distros like Linux Mint at home or on any server I administer. Besides that I'm not sure that it should be patched into distro package exactly as I had posted here as the solution above was quick-n-dirty hack I had made in 5 minutes while being helping one of my customers to resolve the problems they been having with autofs5 + samba.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.