[systemd-devel] Update .Xauthority on hostnamed change

Mantas Mikulėnas grawity at gmail.com
Thu Aug 22 13:14:15 UTC 2019


On Thu, Aug 22, 2019 at 3:50 PM Igor Chudov <nir at altlinux.org> wrote:

> Hello!
>
> I want to update user's .Xauthority file with cookies targeted at new
> hostname on hostname change via hostnamectl. I need an advice about the
> best possible approach for solving this problem. I tried to investigate
> several possible approaches:
>
> - Add xauth functions to systemd-hostnamed (or hostnamectl). This approach
> will require linking with Xorg libraries and efforts to maintain patch
> aside from mainstream;
> - Implement separate systemd service which is activated on request to
> D-Bus interface org.freedesktop.hostname1 . The problem is that I will need
> to know if systemd-hostnamed changed hostname correctly somehow and will
> also need to know previous hostname;
> - Implement separate application listening D-Bus for PropertiesChanged
> signal and somehow verify if required property changed.
>
> So... Is there any other (more sane) way to solve a problem? Maybe it is
> possible to create a hook for hostnamed?
>

Add an xhost entry "SI:localuser:$USER" or "SI:localuser:#$UID" from your
xserver startup script. This will tell Xorg to accept all connections from
its owner based on UID, removing the need for Xauthority in the first
place. (Several display managers already do this.)

Note that programs can use poll() on /proc/sys/kernel/hostname to know
about hostname updates independently from systemd-hostnamed.

-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190822/98e6f150/attachment.html>


More information about the systemd-devel mailing list