Bug 1217355 - Syntax of localhost entry is wrong in /etc/hosts
Summary: Syntax of localhost entry is wrong in /etc/hosts
Status: RESOLVED FIXED
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Danilo Spinella
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 1177835
  Show dependency treegraph
 
Reported: 2023-11-21 08:29 UTC by Thorsten Kukuk
Modified: 2024-01-12 16:02 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.