Bug 32444

Summary: udiskctl can't connect to dbus after it moved from /var/run/ to /run/
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: udisks2Assignee: Yuri N. Sedunov <aris>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P3 CC: aen, aris, evg, sem, shaba, shrek
Version: unstable   
Hardware: all   
OS: Linux   
Bug Depends on: 32358    
Bug Blocks: 30940, 32322, 32659    

Description Ivan Zakharyaschev 2016-08-28 14:47:11 MSK
dbus-1.10.8-alt1
udev-229-alt6
udisks2-2.1.8-alt0.1

The new dbus-1.10.8-alt1 moved the socket from /var/run/ (where udiskctl expects it) to /run/ :

$ rpm -q dbus --changes-since=1.10.6
warning: Parsing non-standard test (>) for %|?{}:{}|.
* Sun Jul 24 2016 Valery Inozemtsev <shrek@altlinux.ru> 1.10.8-alt1
- 1.10.8
- moved /var/run/dbus to /run/dbus

In a systemd-system, this makes no difference (/run/ is bind-mounted to /var/run/ by /lib/systemd/system/var-run.mount IIUC), but in a SysVinit-system (like basealt-p8-wmaker-20160612-x86_64.iso), they are different: only /run/ is a tmpfs mounted by /etc/init.d/udevd :

prepare_filesystem()
{
...
        if test -d /run; then
                if ! mountpoint -q /run; then
                        mount $mount_n -t tmpfs -o mode=755,$tmpfs_options runfs /run
                        RETVAL=$[$RETVAL+$?]
                fi
                mkdir -p /run/udev 2>/dev/null
        fi
...
}

This results in:

$ udisksctl -h
Error connecting to the udisks daemon: Could not connect: Connection refused

After rm -rf /var/run/dbus (left over from the runs of previous releases of dbus):

$ udisksctl -h
Error connecting to the udisks daemon: Could not connect: No such file or directory

The real socket is now there:

$ l /run/dbus/
total 0
drwxr-xr-x 10 root root 240 Aug 28 05:59 ../
drwxr-xr-x  3 root root  80 Aug 28 05:59 ./
srwxrwxrwx  1 root root   0 Aug 28 05:59 system_bus_socket
drwxrwxrwt  2 root root  40 Aug 28 05:59 users/

Alternative suggestions:

1. bind-mount /run/ to /var/run/run/ in /etc/init.d/udevd , too (to be compatible with systemd-systems);

2. move the dnus socket back to /var/run/

3. teach all programs about the new location (not connect through the socket in /var/run/dbus/ , but rather use /run/dbus/ .
Comment 1 Ivan Zakharyaschev 2016-08-28 15:07:30 MSK
Workaround:

rm -rf /var/run/dbus
ln -s /run/dbus -T /var/run/dbus

This is also a possible alternative solution:

4. make such a symlink in dbus package (but not if /var/run/ already points to /run/ ; and special care must be taken for removing the old content in /var/run/dbus)

5. make a symlink /var/run pointing to /run in filesystem package (not good for rpm, because a directory is replaced by a symlink).

If any of the solutions is implemented, it would be nice reflect this in the dependencies of dbus package (so that installing it would guarantee that it works with other programs, e.g., Requires: udev >= X-altY)
Comment 2 Ivan Zakharyaschev 2016-08-28 15:18:30 MSK
$ cat /lib/systemd/system/var-run.mount 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=Runtime Directory
Before=local-fs.target
# skip mounting if the directory does not exist or is a symlink
ConditionPathIsDirectory=/var/run
ConditionPathIsSymbolicLink=!/var/run

[Mount]
What=/run
Where=/var/run
Type=bind
Options=bind
Comment 3 Alexey Shabalin 2016-08-28 22:44:09 MSK
Please, see bug #32358.
I am know, is not good for rpm, but i think is best for system.
Comment 4 Yuri N. Sedunov 2016-10-22 18:18:55 MSK
В задании №171245 собирается glib2-2.50.1-alt2 c патчем. Проверьте.

$ cat glib-2.50.1-alt-dbus_socket_path.patch
--- gio/gdbusaddress.c~	2016-10-22 18:04:51.465645168 +0300
+++ gio/gdbusaddress.c	2016-10-22 18:05:09.486853454 +0300
@@ -1601,7 +1601,7 @@
       ret = g_strdup (g_getenv ("DBUS_SYSTEM_BUS_ADDRESS"));
       if (ret == NULL)
         {
-          ret = g_strdup ("unix:path=/var/run/dbus/system_bus_socket");
+          ret = g_strdup ("unix:path=/run/dbus/system_bus_socket");
         }
       break;
Comment 5 AEN 2016-10-22 19:32:27 MSK
2imz@: проверьте, пожалуйста.
Comment 6 Repository Robot 2016-10-23 15:42:15 MSK
glib2-2.50.1-alt2 -> sisyphus:

* Sat Oct 22 2016 Yuri N. Sedunov <aris@altlinux> 2.50.1-alt2
- gio/gdbusaddress.c: s|var/run/dbus|/run/dbus| (ALT #32444, #32642)
Comment 7 Ivan Zakharyaschev 2016-10-24 16:02:45 MSK
(In reply to comment #4)
> В задании №171245 собирается glib2-2.50.1-alt2 c патчем. Проверьте.

Описанная проблема ушла.

> $ cat glib-2.50.1-alt-dbus_socket_path.patch
> --- gio/gdbusaddress.c~    2016-10-22 18:04:51.465645168 +0300
> +++ gio/gdbusaddress.c    2016-10-22 18:05:09.486853454 +0300
> @@ -1601,7 +1601,7 @@
>        ret = g_strdup (g_getenv ("DBUS_SYSTEM_BUS_ADDRESS"));
>        if (ret == NULL)
>          {
> -          ret = g_strdup ("unix:path=/var/run/dbus/system_bus_socket");
> +          ret = g_strdup ("unix:path=/run/dbus/system_bus_socket");
>          }
>        break;

А не добавить ли в пакет какой-нибудь

Conflicts: dbus < 1.10.8-alt1

чтобы не разъезжалось при обновлениях (отдельных пакетов; а также как гарантия того, что при всяких копированиях отдельных пакетов в бранчи не случится несоответствие).

Пакет dbus при установке должен пересоздавать сокет на новом месте, если это не так.
Comment 8 Alexey Shabalin 2016-10-24 16:26:04 MSK
(В ответ на комментарий №7)

> Пакет dbus при установке должен пересоздавать сокет на новом месте, если это не
> так.

перезапускать dbus при обновлении крайне нежелательно - падают все приложения, использующие dbus.