Changing hostname disturbs the system and DE’s like KDE, Gnome, etc… What can I do to allow it anyway

hostnamekde

Long time ago I started to develop some kind of stealthmode-demon in c++.
Part of this is to be only run as root and another part of it is, to change the hostname to a randomn generated one.
I experienced, that any change to my hostname ( either via virtual terminal or via my stealthdemon or via a dhcp-feature ) somehow disturbs the system.
One example is, that suddenly all KDE-apps cannot start, neither by shortcut nor by click. If I reset my hostname to the original one, then all seems to work perfect.

My questions are:

  1. What else is invoked, when issuing hostname via bash ?
  2. What else is invoked, when issuing hostname in a c/c++ code ?
  3. What is the reason for the strange behaviour? ( Although I guess,
    it can be,that either xorg or kde itself was somehow linked to the old
    hostname, but after the change they are not linked anymore )
  4. What can be done, to keep the system stable but still allowing
    to change a hostname , either by shell or by code ?

Thx in advance.

Best Answer

  1. X auth file (~/.Xauthority, /tmp/xauth-*, etc.) contains the system hostname. If it differs from the actual hostname (as shown by hostname(1)), an X application won’t start.

In my case, it prints “No protocol specified Could not connect to display :0”. But changing hostname in the X auth file to the actual value fixes the problem. (I used a hex editor to test that; well, there should be a better way to change it)

Related Question