Bug 255019 - ifconfig -f addr:host and ifconfig -f addr:fqdn return the same value
Summary: ifconfig -f addr:host and ifconfig -f addr:fqdn return the same value
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-12 20:55 UTC by jcaplan
Modified: 2021-04-12 20:55 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jcaplan 2021-04-12 20:55:20 UTC
Overview
--------

`ifconfig -f addr:host` does not properly truncate the fully qualify host name.

Steps to Reproduce
------------------

ifconfig vmx0 172.16.129.101/24 up
echo '172.16.129.101 dut.example.com' >> /etc/hosts
ifconfig -f addr:host vmx0 

Actual Results
--------------
inet dut.example.com netmask 0xffffff00 broadcast 172.16.129.255

Exepcted Results
----------------
inet dut netmask 0xffffff00 broadcast 172.16.129.255

Additional Information
----------------------
In getnameinfo_inet(), it seems that NI_NOFQDN flag is deliberately ignored because it's messy to determine whether or not the host is local.

#if 0
			/*
			 * commented out, since "for local host" is not
			 * implemented here - see RFC2553 p30
			 */
			if (flags & NI_NOFQDN) {
				char *p;
				p = strchr(hp->h_name, '.');
				if (p)
					*p = '\0';
			}
#endif


If no change is made to getnameinfo_inet(), at the very least ifconfig should perform the truncation.