Dec 4 17:21:00 host-192-168-10-234 dbus[2234654]: Encountered error 'Failed to open "/etc/dbus-1/system.d/tcmu-runner.conf": Permission denied'while parsing '/etc/dbus-1/system.d/tcmu-runner.conf';
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# For services that acquire a name on the DBus system bus, use Type=dbus and set BusName= accordingly. The service should not fork (daemonize). systemd will consider the service to be initialized once the name has been acquired on the system bus.
$ cat /usr/share/dbus-1/system-services/org.kernel.TCMUService1.service # When placed in /usr/share/dbus-1/system-services/, this should cause tcmu-runner # to be loaded and run by dbus-daemon when a client accesses the service name.
这里指定的 User 在配置使用 dbus-daemon-launch-helper 激活 SystemdService systemd 服务时无关紧要:
1 2 3
$ cat /usr/share/dbus-1/system.conf <!-- This is a setuid helper that is used to launch system services --> <servicehelper>/usr/lib/dbus-1.0/dbus-daemon-launch-helper</servicehelper>
调用 tcmu-runner dbus 服务
1
$ d-feet
1 2 3 4 5 6 7 8
$ sudo systemctl stop tcmu-runner $ systemctl status tcmu-runner ● tcmu-runner.service - LIO Userspace-passthrough daemon Loaded: loaded (/lib/systemd/system/tcmu-runner.service; enabled; vendor preset: enabled) Active: inactive (dead) since Sun 2020-11-22 15:03:49 CST; 1s ago Docs: man:tcmu-runner(8) Process: 1620445 ExecStart=/usr/bin/tcmu-runner (code=exited, status=0/SUCCESS) Main PID: 1620445 (code=exited, status=0/SUCCESS)
$ systemctl status tcmu-runner ● tcmu-runner.service - LIO Userspace-passthrough daemon Loaded: loaded (/lib/systemd/system/tcmu-runner.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2020-11-22 15:03:54 CST; 1s ago Docs: man:tcmu-runner(8) Main PID: 1620574 (tcmu-runner) Tasks: 6 (limit: 9355) Memory: 7.5M CGroup: /system.slice/tcmu-runner.service └─1620574 /usr/bin/tcmu-runner
dbus-daemon 配置
1 2 3
// $ man dbus-daemon --systemd-activation Enable systemd-style service activation. Only useful in conjunction with the systemd system and session manager on Linux.
<node> <interfacename="org.kernel.TCMUService1"> <propertyname="ConfigDesc"type="s"access="read"/> <!-- CheckConfig: The creation of a TCMU device is decoupled from the discovery and use by its backing handler, and there's no good way for errors in the handler-specific configstring to be visible to the user when creating the device. This method lets tools that are creating TCMU devices check that the configstring is valid before the device has been created. --> <methodname="CheckConfig"> <argtype="s"name="configstr"direction="in"/> <argtype="b"name="is_valid"direction="out"/> <argtype="s"name="message"direction="out"/> </method> </interface> <interfacename="org.kernel.TCMUService1.HandlerManager1"> <methodname="RegisterHandler"> <argtype="s"name="subtype"direction="in"/> <argtype="s"name="cfgstr_desc"direction="in"/> <argtype="b"name="succeeded"direction="out"/> <argtype="s"name="message"direction="out"/> </method> </interface> </node>
main /* Set up DBus name, see callback */ g_bus_own_name(G_BUS_TYPE_SYSTEM, "org.kernel.TCMUService1", G_BUS_NAME_OWNER_FLAGS_NONE, dbus_bus_acquired, dbus_name_acquired, // name acquired dbus_name_lost, // name lost NULL, // user data NULL// user date free func );
bus_activation_activate_service if(bus_context_get_systemd_activation (activation->context)){ if (strcmp (service_name, "org.freedesktop.systemd1") == 0) /* systemd itself is missing apparently. That can happen only during early startup. Let's just wait until systemd connects to us and do nothing. */ return TRUE;
if (entry->systemd_service) { message = dbus_message_new_signal (DBUS_PATH_DBUS, "org.freedesktop.systemd1.Activator", "ActivationRequest");
/* Check whether systemd is already connected */ registry = bus_connection_get_registry (connection); _dbus_string_init_const (&service_string, "org.freedesktop.systemd1"); service = bus_registry_lookup (registry, &service_string);
if (service != NULL) { /* Wonderful, systemd is connected, let's just send the msg */ retval = bus_dispatch_matches (activation_transaction, NULL, systemd, message, error); } else { /* systemd is not around, let's "activate" it. */ retval = bus_activation_activate_service (activation, NULL, activation_transaction, TRUE, message, "org.freedesktop.systemd1", error); } return TRUE; } /* OK, we have no configured systemd service, hence let's proceed with traditional activation. */ }
/* does the bus use a helper? */ servicehelper = bus_context_get_servicehelper (activation->context); _dbus_spawn_async_with_babysitter