summaryrefslogtreecommitdiffstats
path: root/src/shared/ask-password-api.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-11-10 16:30:30 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2023-11-13 15:17:05 +0100
commitaa25e19b474bb08ab607b363f83f0626a96c8d85 (patch)
tree79571d1645d081ea900e1f23963fcf9ee496cea0 /src/shared/ask-password-api.c
parentMerge pull request #29995 from keszybz/voidify-timestamp-getters (diff)
downloadsystemd-aa25e19b474bb08ab607b363f83f0626a96c8d85.tar.xz
systemd-aa25e19b474bb08ab607b363f83f0626a96c8d85.zip
util-lib: share plymouth client code
Let's add a new "plymouth-util.c" module with helpers for talking to plymouth. We so far had three places for this, let's unify the code doing this a bit.
Diffstat (limited to 'src/shared/ask-password-api.c')
-rw-r--r--src/shared/ask-password-api.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index a5cf8974db..0e323f4644 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -20,7 +20,6 @@
#include "alloc-util.h"
#include "ask-password-api.h"
-#include "constants.h"
#include "creds-util.h"
#include "fd-util.h"
#include "fileio.h"
@@ -36,6 +35,7 @@
#include "missing_syscall.h"
#include "mkdir-label.h"
#include "nulstr-util.h"
+#include "plymouth-util.h"
#include "process-util.h"
#include "random-util.h"
#include "signal-util.h"
@@ -211,7 +211,6 @@ int ask_password_plymouth(
const char *flag_file,
char ***ret) {
- static const union sockaddr_union sa = PLYMOUTH_SOCKET;
_cleanup_close_ int fd = -EBADF, notify = -EBADF;
_cleanup_free_ char *packet = NULL;
ssize_t k;
@@ -238,12 +237,9 @@ int ask_password_plymouth(
return -errno;
}
- fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
+ fd = plymouth_connect(SOCK_NONBLOCK);
if (fd < 0)
- return -errno;
-
- if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
- return -errno;
+ return fd;
if (FLAGS_SET(flags, ASK_PASSWORD_ACCEPT_CACHED)) {
packet = strdup("c");