Bug 1685804

Summary: autofs doesn't expand macros in amd map selectors
Product: Red Hat Enterprise Linux 7 Reporter: Ian Kent <ikent>
Component: autofsAssignee: Ian Kent <ikent>
Status: CLOSED ERRATA QA Contact: Kun Wang <kunwan>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.7CC: jreznik, rhandlin, xzhou
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: autofs-5.0.7-106.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1685805 1768752 (view as bug list) Environment:
Last Closed: 2019-08-06 13:10:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1685805, 1768752    
Attachments:
Description Flags
Patch - workaround getaddrinfo(3) ai_canonname bug
none
Patch - improve hostname lookup error logging
none
Patch - allow period following macro in selector value
none
Patch - fix macro expansion in selector values none

Description Ian Kent 2019-03-06 07:04:15 UTC
Description of problem:

autofs is unable to mount amd map entries that have macro definitions within map entry selectors.

Version-Release number of selected component (if applicable):
All revisions that support amd format maps.

How reproducible:
Always.

Steps to Reproduce:
1. Setup an NFS server with at least one export. This example assumes a host names shadow.themaw.net.
2. Add "/amd/local	file,amd:/etc/amd.exports" to /etc/auto.master.
3. Create file /etc/amd.exports as:
/defaults       type:=auto;opts:=rw,hard,nosuid,intr,retrans=12,timeo=70
#
exports         fs:=${map};pref:=${key}/
exports/*       hostd==${/key}.themaw.net;type:=link;fs:=/ \
                hostd!=${/key}.themaw.net;type:=host;rhost:=${/key}.themaw.net;opts:=rw,hard,intr,nosuid,retrans=9,timeo=45;fs:=${autodir}/houston/${key}
4. Start autofs and try "ls /amd/local/exports/shadow".

Actual results:
An ENOENT error is returned.

Expected results:
The list of exports from the host is listed.

Additional info:
There are two problems, one the "." following a macro definition is not permitted by the parser, second the macro ${/key} is not expanded before use leading to an attempt to use an invalid host name which prevents getting the list of exports from the host.

Comment 2 Ian Kent 2019-03-07 05:36:52 UTC
Created attachment 1541672 [details]
Patch - workaround getaddrinfo(3) ai_canonname bug

Comment 3 Ian Kent 2019-03-07 05:38:06 UTC
Created attachment 1541673 [details]
Patch - improve hostname lookup error logging

Comment 4 Ian Kent 2019-03-07 05:39:00 UTC
Created attachment 1541674 [details]
Patch - allow period following macro in selector value

Comment 5 Ian Kent 2019-03-07 05:39:54 UTC
Created attachment 1541675 [details]
Patch - fix macro expansion in selector values

Comment 7 Kun Wang 2019-04-15 03:18:35 UTC
Verified based on below test result:

###########################################
#     on autofs-5.0.7-105.el7             #
###########################################

:: [ 23:14:44 ] :: [   LOG    ] :: rlServiceStart: Service autofs started successfully
[23:14:44 root@ ~~]# test_mount_lookup "${auto_dir}" "${export_dir}" "use_lofs"
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs for path /test/redhat/ibm-x3550m3-06/local/lfs0
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/x86_64-rhel3/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/x86_64-rhel3/chap/advance found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/i386-linux/chap/advance
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/ddm++/i386-linux for path /test/redhat/i386-linux/chap/ddm++
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/chap/advance
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs for path /test/redhat/net/hp-dl180g6-01.rhts.eng.bos.redhat.com/autofs
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/host/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/host/chap/advance
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/hp-dl180g6-01/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/hp-dl180g6-01/chap/advancels: cannot access /test/redhat/exports/hp-dl180g6-01/raven: No such file or directory
Failed to mount /test/redhat/exports/hp-dl180g6-01/raven
not found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/raven for path /test/redhat/exports/hp-dl180g6-01/raven
:: [ 23:16:04 ] :: [   FAIL   ] :: Running 'test_mount_lookup "${auto_dir}" "${export_dir}" "use_lofs"' (Expected 0, got 1)


################################################
#     on fixed version autofs-5.0.7-106.el7    #         
################################################
:: [ 23:05:27 ] :: [   LOG    ] :: rlServiceStart: Service autofs started successfully
[23:05:27 root@ ~~]# test_mount_lookup "${auto_dir}" "${export_dir}" "use_lofs"
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs for path /test/redhat/ibm-x3550m3-06/local/lfs0
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/x86_64-rhel3/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/x86_64-rhel3/chap/advance found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/i386-linux/chap/advance
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/ddm++/i386-linux for path /test/redhat/i386-linux/chap/ddm++
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/chap/advance
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs for path /test/redhat/net/hp-dl180g6-01.rhts.eng.bos.redhat.com/autofs
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/host/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/host/chap/advance
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/util/a2ps/x86_64-rhel3 for path /test/redhat/hp-dl180g6-01/util/a2ps
found: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/autofs/chap/advance/i386-linux for path /test/redhat/hp-dl180g6-01/chap/advancefound: mount hp-dl180g6-01.rhts.eng.bos.redhat.com:/raven for path /test/redhat/exports/hp-dl180g6-01/raven
:: [ 23:06:57 ] :: [   PASS   ] :: Running 'test_mount_lookup "${auto_dir}" "${export_dir}" "use_lofs"' (Expected 0, got 0)

Comment 9 errata-xmlrpc 2019-08-06 13:10:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:2250

Comment 10 Kun Wang 2019-11-12 06:59:12 UTC
Hi Bob,