On Di, 27.11.18 19:07, Dinesh Prasanth Moluguwan Krishnamoorthy (dmoluguw@xxxxxxxxxx) wrote: > Hi, > > I'm trying to write a Java program that queries user for password. The > difficulty I'm facing is, this java program is started using `systemd` > service. > > I'm aware that `systemd` services are meant to run non-interactively. > I'm trying to change it based on my program's need. > > I was reading about `ProcessBuilder` in Java to invoke `systemd-ask- > password` command. > > > public static void main(String arg[]) { > try { > ProcessBuilder pb = new > ProcessBuilder();// padd user nuxwdog:internalDB mkdtest1 @u"}); > pb.command("/bin/bash", "-c", "systemd-ask- > password internaldb: --no-output"); > > pb.inheritIO(); > Process p = pb.start(); > > Is there a way to query a password interactively from a Java program > started using a systemd service? If you run privileged you can implement this: https://www.freedesktop.org/wiki/Software/systemd/PasswordAgents/ i.e. listen on an AF_UNIX/SOCK_DGRAM socket (not sure you can do that from Java though?), then drop a file /run/systemd/ask-password that describes the question you want to ask, and wait until you get a reply on that socket. Then delete socket and file. Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/systemd-devel