1) Record D-Bus pending call to restrict one user change call to be made
at a time. If there is a pending call report back EBUSY to differentiate
that process from the EALREADY reported when user is already set as the
one that is requested.
2) Send current uid to vpnd if it restarts after crash. This is achieved
by implementing a service watcher for vpnd that sets a bool for sending
the current uid to vpnd when it comes back to keep connmand and vpnd
synchronized. Removal detection is used to avoid sending the user change
when services are starting.
storage.c now also saves the current uid that was required for the vpnd
synchronization. This allows for more robust error replies in case the
uid is already set.
Added uid changed callback and use of it in uid changes. In order to
support both connmand and vpnd the notify functionality must be added as
a callback. Vpnd does not use notify, nor it does to save the uid.
When getting a reply from vpnd the uid in the request data may equal the
current_uid in case when vpnd has crashed and connmand has sent a user
change message after detecting vpnd to be back online. It is feasible to
stop processing at that point to avoid additional unnecessary calls to
In error cases when returning to root user use geteuid() instead of 0 as
3) Add functionality for sending a delayed user change when a) there is
already a pending user change waiting for a reply (timeout) b) a service
or D-Bus related error is reported back. This enables better error
tolerance and handling the potential crashes in between user change