Bug 1217355

Summary: Syntax of localhost entry is wrong in /etc/hosts
Product: [openSUSE] openSUSE Tumbleweed Reporter: Thorsten Kukuk <kukuk>
Component: BasesystemAssignee: Danilo Spinella <danilo.spinella>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: Andreas.Stieger, beppe85
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 1177835    

Description Thorsten Kukuk 2023-11-21 08:29:51 UTC
Our /etc/hosts has:

127.0.0.1       localhost
# fallback hostname used by NetworkManager
127.0.0.1       localhost.localdomain

According to the documentation (man hosts), only one line per IP address is allowed. 
As result, the localhost.localdomain entry is not used:

# getent hosts 127.0.0.1
127.0.0.1       localhost


All hostnames for one IP must be in the same line.
Comment 1 Andreas Stieger 2023-11-25 18:47:33 UTC
Well then bug 1177835 / SR#907284 was fixed wrong.
Comment 3 André Werlang 2023-12-02 04:22:13 UTC
$ getent hosts
127.0.0.1       localhost
127.0.0.1       localhost.localdomain
Comment 4 Thorsten Kukuk 2023-12-02 10:12:37 UTC
(In reply to André Werlang from comment #3)
> $ getent hosts
> 127.0.0.1       localhost
> 127.0.0.1       localhost.localdomain

What do you want to tell us with this? That listening the file line by line works?
This does say nothing about if the syntax is correct or if the name is resolveable. And as I did show, 127.0.0.1 is not correct solveable.
And if you look at the glibc source code, you will see that for resolving a host, the code does not go through every line, but stops at the first matching line. So your second line is not reached.
Comment 5 Danilo Spinella 2024-01-12 16:02:38 UTC
The fix has been pushed to Factory, closing as fixed. Thank you for spotting this bug.