You are not logged in.

#1 2014-04-19 07:08:50

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

pam_exec.so script access to systemd --user instance at login?

Hey guys,

I used to use a little bash script that would be executed by PAM on user login that would start a ssh-agent in the systemd --user instance and decrypt my private key using the password I used to login. Unfortunately since the upgrade of systemd 204+ (This was awhile ago, I know) the script no longer works as I am no longer starting my systemd --user instance at boot.

The systemd instance is started by pam_systemd.so. So I had thought that placing my script exec call after `-session   optional   pam_systemd.so` it would execute after the user@.service is started. That doesn't seem to be the case though.

Here's my /etc/pam.d/system-login file

#%PAM-1.0 
auth       required   pam_tally.so         onerr=succeed file=/var/log/faillog
auth       required   pam_shells.so
auth       requisite  pam_nologin.so
auth       include    system-auth

account    required   pam_access.so
account    required   pam_nologin.so
account    include    system-auth

password   include    system-auth

session    optional   pam_loginuid.so
session    include    system-auth
session    optional   pam_motd.so          motd=/etc/motd
session    optional   pam_mail.so          dir=/var/spool/mail standard quiet
-session   optional   pam_systemd.so
session    required   pam_env.so

auth       optional   pam_exec.so  expose_authtok /usr/lib/systemd/systemd-user-pam-ssh

(Note the last line)

However this still doesn't work. `systemctl is-active user@$(id -u ${PAM_USER})` returns "unknown" when the script is executed.

Any ideas how I can get my script to run AFTER the systemd user@.service is started when I login? Or maybe another way I can start up my --user ssh-agent.servicer and decrypt my key using my entered password?

Offline

#2 2014-04-19 18:52:36

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

Re: pam_exec.so script access to systemd --user instance at login?

You should be able to use my systemd-wait script (https://github.com/Stebalien/systemd-wait) to wait for the user service to start.


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

Offline

#3 2014-04-20 03:45:18

EvanPurkhiser
Member
From: San Francisco
Registered: 2010-08-17
Posts: 225
Website

Re: pam_exec.so script access to systemd --user instance at login?

I'm actually quite surprised nothing like that is already part of the systemd core utilities. That's very useful! I do somewhat wish it was written in C though. Maybe I'll take a crack porting it myself.

Thank you very much for linking that, it's much appreciated Stebalien.

Offline

#4 2014-04-20 14:25:45

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

Re: pam_exec.so script access to systemd --user instance at login?

I recommend re-writing it in Vala instead of C. Vala compiles to C but has nice GLib/DBus bindings.


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

Offline

Board footer

Powered by FluxBB