You are not logged in.

#1 2014-02-28 18:37:54

gava
Member
Registered: 2014-02-26
Posts: 14

[SOLVED] Prompting for password in systemd service during boot

Every post related to this suggests the use of /bin/systemd-ask-password but I cant get it to work during boot.

Service:

[Unit]
Description=...
ConditionPathExists=/var/lib/some/lock

[Service]
ExecStart=/bin/sh -c '/usr/bin/testprompt somevar'
ExecStartPost=/bin/rm /var/lib/some/lock
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=default.target

/usr/bin/testprompt:

#!/bin/sh
KEY=$(systemd-ask-password "Gimme the pass: ")
echo "$KEY" > /tmp/key

If i run the service from a console I get the prompt and everything works fine.
If I enable the service I see the promp during boot but no user input is allowed, the rest of the boot messages and login ensue and the service marked as failed.
Any clues as to what's wrong?

Last edited by gava (2014-03-05 14:23:35)

Offline

#2 2014-02-28 22:25:44

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Prompting for password in systemd service during boot

What are you actually trying to achieve here?  Is this supposed to be a password for the system to continue booting?  Why doesn't the getty login or a display manager fit for your purposes?

Offline

#3 2014-02-28 22:49:57

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [SOLVED] Prompting for password in systemd service during boot

Services can't be interactive. What you're trying to do is the antithesis of what a service is.

Offline

#4 2014-03-05 12:14:27

gava
Member
Registered: 2014-02-26
Posts: 14

Re: [SOLVED] Prompting for password in systemd service during boot

Ok, then not a systemd service.
I need to promt the user for a system wide password during boot so that a process can
connect to a server (requires login+password for the pc). I cant store the password in the pc (security reasons, company policy and all that jazz).
The whole point of the system is for that process to be online.
Any thoughts?

Offline

#5 2014-03-05 12:22:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [SOLVED] Prompting for password in systemd service during boot

gava wrote:

... during boot ...

Why during boot?

What are you really trying to do?

Why not allow the user to log in to this server after booting if boot up suceeds without this connection?

Add the password prompt to a shell profile.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2014-03-05 13:50:07

gava
Member
Registered: 2014-02-26
Posts: 14

Re: [SOLVED] Prompting for password in systemd service during boot

I wanted to avoid creating a "guest" user just for this.
I've solved the issue in a different way now.
I needed whomever booted the system for the first time to enter a master key so that a process could contact the server and get its own credentials.
I've placed a copy of the key within an encrypted partition that was already there. The initramfs already prompts for a password for the encrypted partiton when the hooks are run so that's that.
Now the service checks if the master key file exists, uses it and removes it when the new credentials arrive.
Thank you for the help.

Offline

Board footer

Powered by FluxBB