hostname and hostname -f don't match

Please post any bugs you have found
Post Reply
Message
Author
go2null
Posts: 11
Joined: Mon 24 Oct 2011, 02:04

hostname and hostname -f don't match

#1 Post by go2null »

This bug existed at least since the first commit to Woof of usr/sbin/hostname-set.

Bug exists as the canonical_hostname should be listed first, then aliases. [man hosts]
Bug:

Code: Select all

75    echo "127.0.0.1 localhost $NEW_HOSTNAME"  > /tmp/hostname-set-hosts
Fix:

Code: Select all

75    echo "127.0.0.1 $NEW_HOSTNAME localhost" > /tmp/hostname-set-hosts
I've opened a defect on Google Code.

[EDIT] Fixed typos
[EDIT] Added cause of bug, thanks to Karl Godt for the pointer.
[EDIT] Added link to Puppy Bug Tracker on Google Code.
Last edited by go2null on Sat 30 Mar 2013, 18:42, edited 2 times in total.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#2 Post by Karl Godt »

Example

127.0.0.1 localhost
192.168.1.10 foo.mydomain.org foo
192.168.1.13 bar.mydomain.org bar
146.82.138.7 master.debian.org master
209.237.226.90 www.opensource.org
http://linux.die.net/man/5/hosts
For each host a single line should be present with the following information:

IP_address canonical_hostname [aliases...]

Fields of the entry are separated by any number of blanks and/or tab characters. Text from a "#" character until the end of the line is a comment, and is ignored. Host names may contain only alphanumeric characters, minus signs ("-"), and periods ("."). They must begin with an alphabetic character and end with an alphanumeric character. Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost).
Slightly confusing the above . Dunno if localhost is the alias or the canonical name .
That puppypc12345 would be the canonical one, would mean canonical in the local network.
Since the above examples are like
192.168.1.10 foo.mydomain.org foo
and not
192.168.1.10 foo foo.mydomain.org

I doubt that your are right in this regard.
That your are false in posting to the Desktop section and also false not posting in the Bug section , that's for sure.
May I ask what your knowledge background is ?
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

go2null
Posts: 11
Joined: Mon 24 Oct 2011, 02:04

#3 Post by go2null »

@Karl: Thanks for the link. I didn't think of looking up the man page, as the issue seems fairly obvious.

However, the man page explains the bug. Namely, that the canonical_hostname should be listed first, then aliases.

Further, the man page, in the section that was quoted, even cites localhost as an example of an alias.
Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost).
WRT posting in the wrong forum, my apologies. I was reading WOOF version - QuickSETUP-FirstRUN "Personalize Settings"Bug as part of my research and just clicked on new topic without checking the forum. (I also got sidetracked as I had to reset my password - this is my 2nd post since joining the forum 2 years ago.) Hopefully a moderator will move to the appropriate forum.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

I have no local network, so cannot make exercises about this.
I did set the hostname so it shows up as prompt with
hostname Abracadabra
PS1='\H # '
in an older Puppy, which seems not to care about any configuration files.

But in my newer racy_5.1.x busybox hostname complains when called with the -s option. Has to be set in /etc/hosts too, and it should be as you describe it :

Code: Select all

puppypc4427 # hostname Abracadabra
puppypc4427 # PS1='\H #'
puppypc4427 #
puppypc4427 #hostname -s
hostname: Abracadabra: Unknown host
puppypc4427 #cat /etc/hostname
puppypc4427
puppypc4427 #echo Abracadabra>/etc/hostname
puppypc4427 #hostname -s
hostname: Abracadabra: Unknown host
puppypc4427 #cat /etc/hosts
127.0.0.1 localhost puppypc4427
changed puppypc4427 to Abracadabra in geany editor

Code: Select all

puppypc4427 #hostname -s
localhost
puppypc4427 #PS1='\H # '
puppypc4427 # 
opened another console:

Code: Select all

# PS1='\H # '
Abracadabra # hostname -s
localhost
Abracadabra #
looks like bash and busybox have different opinions about it :)

go2null
Posts: 11
Joined: Mon 24 Oct 2011, 02:04

#5 Post by go2null »


User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

This isn`t the forum for this subject. This is add-on software.

Not bug reports or cutting edge development. :wink:

go2null
Posts: 11
Joined: Mon 24 Oct 2011, 02:04

#7 Post by go2null »

sunburnt wrote:This isn`t the forum for this subject. This is add-on software.
Understood and agree. Please see my note above:
WRT posting in the wrong forum, my apologies. [...] Hopefully a moderator will move to the appropriate forum.

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#8 Post by Sailor Enceladus »

For those who don't know, what go2null's "patch" does is change /etc/hosts from this:

Code: Select all

127.0.0.1 localhost puppypc30202
192.168.1.1 pc2
192.168.1.2 pc3
192.168.1.3 pc4
To this:

Code: Select all

127.0.0.1 puppypc30202 localhost
192.168.1.1 pc2
192.168.1.2 pc3
192.168.1.3 pc4
This change creates at least two issues with Rox with all woof-ce based puppies:
http://www.murga-linux.com/puppy/viewtopic.php?t=107064

And I have not seen any benefit to it, so I've reverted back to the original order Barry used for now. I'm not sure if go2null even stayed in the community long enough to test his own code on a puppy that uses it. Does anyone else see a good reason to keep his change in woof-ce? I'm not sure if the post by gcmartin he linked to has anything to do with this topic, but gcmartin's post is so long-winded and all over the place that I'm not really sure what he is trying to say (it sounds like it's more about having a "QuickSetup launch" and /etc/hostname with the unique number than anything about the order or /etc/hosts I think?).

(if go2null's change is better/useful, I'm sure there could be a way to keep it and refresh/fix Rox at the same time though...)

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#9 Post by rcrsn51 »

I suspect that the whole issue of canonical host names, aliases and fully qualified domain names is irrelevant when it comes to the localhost.

Try this: Open your web browser and go to the CUPS web interface at localhost:631.

Then repeat using the puppypcxxxx:631 hostname.

Post Reply