You are not logged in.

#1 2012-09-21 18:11:06

sunite
Member
From: Freiburg i. Br., DE
Registered: 2012-05-14
Posts: 29
Website

Trying to setup systemd user instance

Hi guys!

For the past few days I have been trying to setup systemd to run a user instance (user is 'hans'). Sadly, I have been unable to find a lot of detail in doing this, so much of my work has been trial and error. Just recently I learned about the user@.service and also about loginctl enable-linger. However to what degree they are related to setting up a user instance, I do not know. I set the user 'hans' to 'linger' using the loginctl enable-linger hans command, however I think I might have misunderstood the significance of the command in relation to what I am trying to do.

What I want to for user 'hans' to have his own service file, i.e. irssi.service, and start/stop/enable/disable/etc that service independently of the system. I realize that I could use sudo and configure it to only allow certain commands, and more than that have individual 'system' services for each user, i.e. hansirssi.service, janeirssi.service, joeirssi.service, etc., but I don't want to have to do that unless there is no other option.

So Question 1:
Is it possible to setup up systemd user instances as I envision it? Or have I misunderstood something?

My system:

[root@ru ~]# uname -a
Linux ru 3.5.4-1-ARCH #1 SMP PREEMPT Sat Sep 15 08:12:04 CEST 2012 x86_64 GNU/Linux

The system is installed in a Proxmox virtual machine with a virtio virtual HDD and standard setup. It is a headless system. I have a complete systemd conversion as per the wiki plus polkit 0.107-2 for use with 'loginctl'.

I tried:

[root@ru ~]$ systemctl enable user@hans.service
The unit files have no [Install] section. They are not meant to be enabled using systemctl.
[root@ru ~]$ systemctl start user@hans.service
[root@ru ~]# systemctl status user@hans.service
user@hans.service - User Manager for hans
          Loaded: loaded (/usr/lib/systemd/system/user@.service; static)
          Active: active (running) since Fri, 21 Sep 2012 18:33:07 +0100; 42min ago
        Main PID: 23189 (systemd)
          Status: "Startup finished in 822us."
          CGroup: name=systemd:/user/hans/shared
                  â 23190 (sd-pam)
                  â systemd-23189
                    â 23189 /usr/lib/systemd/systemd --user

And on the user account hans I confirm that the service is running:

[hans@ru ~]$ systemctl status user@hans.service
user@hans.service - User Manager for hans
          Loaded: loaded (/usr/lib/systemd/system/user@.service; static)
          Active: active (running) since Fri, 21 Sep 2012 18:33:07 +0100; 13s ago
        Main PID: 23189 (systemd)
          Status: "Startup finished in 822us."
          CGroup: name=systemd:/user/hans/shared
                  â 23190 (sd-pam)
                  â systemd-23189
                    â 23189 /usr/lib/systemd/systemd --user

But in regard to actually starting/stopping/enabling a user specific service, I keep getting this error:

[hans@ru ~]$ systemctl start dummyservice.service
Failed to issue method call: Access denied

and when I try by accessing the 'user' instance, I get the following error:

[hans@ru ~]$ systemctl --user
Failed to get D-Bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

The thing is that dbus is running:

[root@ru ~]# systemctl status dbus
dbus.service - D-Bus System Message Bus
          Loaded: loaded (/usr/lib/systemd/system/dbus.service; static)
          Active: active (running) since Thu, 20 Sep 2012 18:19:18 +0100; 24h ago
        Main PID: 248 (dbus-daemon)
          CGroup: name=systemd:/system/dbus.service
                  â 248 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Sep 21 18:12:40 ru dbus-daemon[248]: dbus[248]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
Sep 21 18:12:40 ru dbus[248]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
Sep 21 18:17:50 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.26" (uid.../init ")
Sep 21 18:17:50 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.26" (uid=1000 pid=23167 c...n/init ")
Sep 21 18:32:46 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.31" (uid.../init ")
Sep 21 18:32:46 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.31" (uid=1000 pid=23185 c...n/init ")
Sep 21 18:35:45 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.34" (uid.../init ")
Sep 21 18:35:45 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.34" (uid=1000 pid=23195 c...n/init ")
Sep 21 18:36:06 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.35" (uid.../init ")
Sep 21 18:36:06 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.35" (uid=1000 pid=23197 c...n/init ")

Here is the full output from 'journalctl':

Sep 21 18:17:50 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.26" (uid=1000 pid=23167 comm="systemctl enable user@hans.service ") interface="org.freedesktop.systemd1.Manager" member="EnableUnitFiles" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:17:50 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.26" (uid=1000 pid=23167 comm="systemctl enable user@hans.service ") interface="org.freedesktop.systemd1.Manager" member="EnableUnitFiles" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:32:46 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.31" (uid=1000 pid=23185 comm="systemctl start user@hans.service ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:32:46 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.31" (uid=1000 pid=23185 comm="systemctl start user@hans.service ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:33:07 ru systemd[23189]: Failed to open private bus connection: Failed to connect to socket /run/user/hans/dbus/user_bus_socket: No such file or directory
Sep 21 18:35:45 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.34" (uid=1000 pid=23195 comm="systemctl start userservice ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:35:45 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.34" (uid=1000 pid=23195 comm="systemctl start userservice ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:36:06 ru dbus-daemon[248]: dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.35" (uid=1000 pid=23197 comm="systemctl start userservice.service ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")
Sep 21 18:36:06 ru dbus[248]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.35" (uid=1000 pid=23197 comm="systemctl start userservice.service ") interface="org.freedesktop.systemd1.Manager" member="StartUnit" error name="(unset)" requested_reply="0" destination="org.freedesktop.systemd1" (uid=0 pid=1 comm="/sbin/init ")

Question 2:
Why would dbus reject the 'messages', is there something I need to configure (permissions,...?) in order to get this to work?

I suspect that it is my lacking knowledge to blame for this problem, which is why I have sought help here.

EDIT#1:
I forgot to show you what 'loginctl' was doing:

[root@ru ~]# loginctl user-status hans
hans (1000)
           Since: Thu, 20 Sep 2012 18:19:18 +0100; 24h ago
           State: lingering
          CGroup: name=systemd:/user/hans
                  â shared
                    â 23190 (sd-pam)
                    â systemd-23189
                      â 23189 /usr/lib/systemd/systemd --user

Last edited by sunite (2012-09-21 18:17:35)

Offline

#2 2012-09-21 18:29:25

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Trying to setup systemd user instance

There are a few similar threads e.g. https://bbs.archlinux.org/viewtopic.php?id=148462 .

My admittedly vague understanding is that this aspect of systemd just isn't ready yet.

Offline

#3 2012-09-21 18:36:50

sunite
Member
From: Freiburg i. Br., DE
Registered: 2012-05-14
Posts: 29
Website

Re: Trying to setup systemd user instance

Yeah I remember seeing that topic, is it possible that the error as seen in the journalctl for dbus is related to the bug as mention in the topic?

Stebalien wrote:

Here is a bug report (w/ patch) about getting dbus --session and systemd --user to work together: https://bugs.freedesktop.org/show_bug.cgi?id=50962

Offline

#4 2012-09-21 19:02:42

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Trying to setup systemd user instance

yes, you need a patched dbus.
have a look at the user-session-units package, it also has a dependency on the patched dbus package: http://aur.archlinux.org/packages.php?ID=60349

You can get it to work (I have with a few workarounds), but it is still quite cumbersome to set up.

Offline

#5 2012-09-21 19:16:01

sunite
Member
From: Freiburg i. Br., DE
Registered: 2012-05-14
Posts: 29
Website

Re: Trying to setup systemd user instance

Thanks a lot 65kid, I'll have a go and install the patched dbus, perhaps then it'll work

Offline

#6 2012-09-21 21:18:56

sunite
Member
From: Freiburg i. Br., DE
Registered: 2012-05-14
Posts: 29
Website

Re: Trying to setup systemd user instance

I just went through the install process, read through the user-session-units doc, I was finally able to get the user instance working, no Dbus errors big_smile . However I decided to make sure and run 'dbus-monitor' within the user 'hans' and I got the following error message:

Failed to open private bus connection: Failed to connect to socket /run/user/1000/dbus/user_bus_socket: No such file or directory

I checked and there is no such file, however I checked the dbus.socket:

[root@ru user]# cat /usr/lib/systemd/user/dbus.socket
[Unit]
Description=D-Bus System Message Bus Socket

[Socket]
ListenStream=%t/dbus/user_bus_socket

And dbus.service:

[root@ru user]# dbus-monitor
Failed to open connection to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[root@ru user]# cat /usr/lib/systemd/user/dbus.service

[Unit]
Description=D-Bus System Message Bus
Requires=dbus.socket

[Service]
ExecStart=/usr/bin/dbus-daemon --session --address=systemd: --nofork --systemd-activation
ExecReload=/usr/bin/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig

and as far as I can tell everything see alright there.

EDIT#1:
I just restarted the system to see if my symlink worked for the user-session service. It did, sort of, however the following error occured during boot:

Sep 21 22:15:14 ru systemd[307]: Failed to open private bus connection: Failed to connect to socket /run/user/1000/dbus/user_bus_socket: No such file or directory

Last edited by sunite (2012-09-21 21:22:11)

Offline

#7 2012-09-21 21:22:57

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Trying to setup systemd user instance

are you actually starting dbus.socket from your users' default.target, i.e. does your default.target contain Wants=dbus.socket?

also check

systemctl --user status dbus.socket

Offline

#8 2012-09-21 21:30:59

sunite
Member
From: Freiburg i. Br., DE
Registered: 2012-05-14
Posts: 29
Website

Re: Trying to setup systemd user instance

Cheers, that's what it was...the fact that the socket was wasn't started, but more than that it was also the incorrect DBUS_SESSION_BUS_ADDRESS variable. lol

brilliant, now I think I can get on and finish some work, thanks everyone!

Offline

#9 2012-10-16 07:12:25

tweed
Member
Registered: 2011-03-18
Posts: 21

Re: Trying to setup systemd user instance

Hi, sorry to be a bit dense on this. I have a bunch of issues that after much searching
I believe are dbus related in a fashion similar to this thread.

//localhost/130/~/ systemctl --user
Failed to issue method call: Process /bin/false exited with status 1
//localhost/141/~/ systemctl --user status dbus.socket
Failed to issue method call: Process /bin/false exited with status 1
//localhost/1/~/ dbus-monitor
signal sender=org.freedesktop.DBus -> dest=:1.1 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.1"
method call sender=:1.1 -> dest=org.freedesktop.DBus serial=3 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "eavesdrop=true,type='method_call'"
method call sender=:1.1 -> dest=org.freedesktop.DBus serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "eavesdrop=true,type='method_return'"
method call sender=:1.1 -> dest=org.freedesktop.DBus serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "eavesdrop=true,type='error'"

Offline

#10 2012-10-16 19:53:54

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: Trying to setup systemd user instance

tweed wrote:

Hi, sorry to be a bit dense on this. I have a bunch of issues that after much searching
I believe are dbus related in a fashion similar to this thread.

//localhost/130/~/ systemctl --user
Failed to issue method call: Process /bin/false exited with status 1
//localhost/141/~/ systemctl --user status dbus.socket
Failed to issue method call: Process /bin/false exited with status 1
//localhost/1/~/ dbus-monitor
signal sender=org.freedesktop.DBus -> dest=:1.1 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.1"
method call sender=:1.1 -> dest=org.freedesktop.DBus serial=3 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "eavesdrop=true,type='method_call'"
method call sender=:1.1 -> dest=org.freedesktop.DBus serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "eavesdrop=true,type='method_return'"
method call sender=:1.1 -> dest=org.freedesktop.DBus serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "eavesdrop=true,type='error'"

You don't have a systemd user session started. This is a very different problem so you should probably start your own thread.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#11 2012-10-16 20:05:35

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: Trying to setup systemd user instance

tweed wrote:

appreciated. will do.

If you are wondering where your post went, your hit the 'report' link, not the 'reply' link smile

Edit: Hey, Jason -- once again, we are in sync

Last edited by ewaller (2012-10-16 20:06:32)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#12 2014-04-04 06:44:38

prudhvi
Member
Registered: 2014-04-04
Posts: 1

Re: Trying to setup systemd user instance

sunite wrote:

Cheers, that's what it was...the fact that the socket was wasn't started, but more than that it was also the incorrect DBUS_SESSION_BUS_ADDRESS variable. lol

what is the correct  DBUS_SESSION_BUS_ADDRESS variable?

Offline

#13 2014-04-04 10:10:22

sunite
Member
From: Freiburg i. Br., DE
Registered: 2012-05-14
Posts: 29
Website

Re: Trying to setup systemd user instance

prudhvi wrote:
sunite wrote:

Cheers, that's what it was...the fact that the socket was wasn't started, but more than that it was also the incorrect DBUS_SESSION_BUS_ADDRESS variable. lol

what is the correct  DBUS_SESSION_BUS_ADDRESS variable?


Hi prudhvi, have a look though the forum (https://bbs.archlinux.org/viewtopic.php?id=176528) or use Google. As far as I know, this variable isn't important anymore.

Offline

#14 2014-04-04 14:40:13

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: Trying to setup systemd user instance

I think sunite is correct.  I am going to go ahead and close this old thread.   If there is still an issue, please feel free to start a new thread and, if you still feel this thread is relevant, provide a link back to this thread from the new one.

Thanks


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB