Skip to content

pkttyagent: Only restore tty flags if they were changed

Martin Kletzander requested to merge nertpinx/polkit:tcsetattr into master

First a signal is added to polkitagenttextlistener that notifies on the change (and restore) of tty attributes. This makes it possible to restore tty attributes from the caller binary only if they were actually changed.

Then that functionality is used from pkttyagent to only restore the attribues if they were changed.

This makes it possible to run pkttyagent from backgrounded processes or pkttyagent running in the background itself. Apart from an old bug:

https://bugzilla.redhat.com/show_bug.cgi?id=1726714

this solves an issue with virsh (from libvirt) which, for complicated reasons, starts one pkttyagent "just to make sure" and it gets stopped on some distros when ran in the background even when it gets no request. One of the reasons is that bash (and some other shells) mess with the tty attributes and they might change between running pkttyagent and it being stopped.

The libvirt issue is described here:

https://gitlab.com/libvirt/libvirt/-/issues/366

Merge request reports