You are not logged in.

#1 2013-07-22 16:29:17

oxez
Member
From: QC
Registered: 2009-08-26
Posts: 38
Website

[Solved] Multiple instances of systemd --user and gpg-agent

Hello.

In the process of hunting down a bug I noticed that each time I login as my own user (through slim), a new process (/usr/lib/systemd/systemd --user) is started. I did add it to my .xinitrc (as written in https://wiki.archlinux.org/index.php/Systemd/User). (I'm using slim as my login manager)

However if I logout and re-login, a new process is started. Is there a way to only have one running?

There's also this process: /usr/bin/gpg-agent --sh --daemon --enable-ssh-support --write-env-file /home/oxez/.cache/gpg-agent-info  --- This one I do not have in my .xinitrc, but the same question goes: Is there a way to prevent multiple instances of it?

Thanks!

Last edited by oxez (2013-07-24 17:35:53)

Offline

#2 2013-07-23 03:01:10

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,152

Re: [Solved] Multiple instances of systemd --user and gpg-agent

That page says to add it as an autostart application to your DE if using a DM rather than adding it to .xinitrc. I suspect you don't want to set it up this way if you are using slim.

It is problematic, I believe, to run more than one instance of gpg-agent. If you are using a DE, look there first. KDE was starting this in my case and I eventually uninstalled the relevant KDE service and replaced it with my own. It should check that another instance is not already running - see the wiki on setting up gpg-agent for use with ssh.

For example, here is my replacement for KDE's default:

$ cat /etc/kde/env/gpg-agent-startup.sh 
#!/bin/sh
# see https://wiki.archlinux.org/index.php/SSH_Keys

GPG_AGENT=/usr/bin/gpg-agent
## Run gpg-agent only if not already running, and available
if [ -x "${GPG_AGENT}" ] ; then

  # check validity of GPG_SOCKET (in case of session crash)
  GPG_AGENT_INFO_FILE=${HOME}/.gpg-agent-info
  if [ -f "${GPG_AGENT_INFO_FILE}" ]; then
    GPG_AGENT_PID=`cat ${GPG_AGENT_INFO_FILE} | grep GPG_AGENT_INFO | cut -f2 -d:`
    GPG_PID_NAME=`cat /proc/${GPG_AGENT_PID}/comm`
    if [ ! "x${GPG_PID_NAME}" = "xgpg-agent" ]; then
      rm -f "${GPG_AGENT_INFO_FILE}" 2>&1 >/dev/null
    else
       GPG_SOCKET=`cat "${GPG_AGENT_INFO_FILE}" | grep GPG_AGENT_INFO | cut -f1 -d: | cut -f2 -d=`
       if ! test -S "${GPG_SOCKET}" -a -O "${GPG_SOCKET}" ; then
         rm -f "${GPG_AGENT_INFO_FILE}" 2>&1 >/dev/null
       fi
    fi
    unset GPG_AGENT_PID GPG_SOCKET GPG_PID_NAME SSH_AUTH_SOCK
  fi

  if [ -f "${GPG_AGENT_INFO_FILE}" ]; then
    eval "$(cat "${GPG_AGENT_INFO_FILE}")"
    eval "$(cut -d= -f 1 "${GPG_AGENT_INFO_FILE}" | xargs echo export)"
    export GPG_TTY=$(tty)
  else
    eval "$(${GPG_AGENT} -s --enable-ssh-support --daemon --pinentry-program /usr/bin/pinentry-qt4 --write-env-file)"
  fi

fi

And then corresponding shutdown services.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-07-23 14:41:44

oxez
Member
From: QC
Registered: 2009-08-26
Posts: 38
Website

Re: [Solved] Multiple instances of systemd --user and gpg-agent

Hello, thanks for the reply. Got it working for gpg-agent, thanks to you.

However for systemd, even adding it to xfce's autostart list, everytime I Login there is a new process started of /usr/lib/systemd/systemd --user.

Note that I do not manage my xsession with systemd, all I do is: systemctl start slim, and slim execs my .xinitrc, which contains: exec startxfce4. Not sure if that makes a difference..

Offline

#4 2013-07-23 17:12:06

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,152

Re: [Solved] Multiple instances of systemd --user and gpg-agent

I don't think I'll be much help with that part of it but I'm sure somebody else will. I'm glad I was able to help with gpg-agent, at least.

I don't have even one systemd --user process running which I guess means KDE/KDM does not use it (and I've done nothing to enable it directly as that would likely screw with KDE/KDM). I don't know what xfce does as I've never used it on a system with systemd and I've never used slim period. For all I know, the behaviour you are seeing is entirely expected - I just know nothing about it.

EDIT: You could check the slim.service file in case that is starting it directly. I guess otherwise may starting xfce from .xinitrc must be responsible.

Last edited by cfr (2013-07-23 17:14:45)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2013-07-24 17:35:42

oxez
Member
From: QC
Registered: 2009-08-26
Posts: 38
Website

Re: [Solved] Multiple instances of systemd --user and gpg-agent

I solved the systemd issue by creating a serviio@.service file, and running it as: systemctl start serviio@oxez (as root). No need to run systemd --user, and thus, no problems anymore!

Offline

#6 2013-09-08 06:06:25

Sanjeev K Sharma
Member
Registered: 2013-08-14
Posts: 72

Re: [Solved] Multiple instances of systemd --user and gpg-agent

my situation and solution:

https://bbs.archlinux.org/viewtopic.php?id=168740

basically for every place I start user systemd I exit first - if you want to be paranoid put in several exits

At the moment I;m just using the user - run systemd for user control of timers. 

I was using systemd to control startx but I need to experiment wiht multiple X servers so @ the moment I only use it for the timers.

Last edited by Sanjeev K Sharma (2013-09-08 06:08:59)

Offline

Board footer

Powered by FluxBB