.message = msg1,
};
- r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ 0, /* flag_file= */ NULL, &a);
+ r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ 0, &a);
if (r < 0)
return log_error_errno(r, "Failed to query root password: %m");
if (strv_length(a) != 1)
req.message = msg2;
- r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ 0, /* flag_file= */ NULL, &b);
+ r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ 0, &b);
if (r < 0)
return log_error_errno(r, "Failed to query root password: %m");
if (strv_length(b) != 1)
const AskPasswordRequest *req,
usec_t until,
AskPasswordFlags flags,
- const char *flag_file,
char ***ret) {
_cleanup_close_ int fd = -EBADF, inotify_fd = -EBADF;
const char *message = req && req->message ? req->message : "Password:";
- if (flag_file) {
+ if (req->flag_file) {
inotify_fd = inotify_init1(IN_CLOEXEC|IN_NONBLOCK);
if (inotify_fd < 0)
return -errno;
- if (inotify_add_watch(inotify_fd, flag_file, IN_ATTRIB) < 0) /* for the link count */
+ if (inotify_add_watch(inotify_fd, req->flag_file, IN_ATTRIB) < 0) /* for the link count */
return -errno;
}
else
timeout = USEC_INFINITY;
- if (flag_file && access(flag_file, F_OK) < 0)
+ if (req->flag_file && access(req->flag_file, F_OK) < 0)
return -errno;
r = ppoll_usec(pollfd, n_pollfd, timeout);
const AskPasswordRequest *req,
usec_t until,
AskPasswordFlags flags,
- const char *flag_file,
char ***ret) {
bool reset_tty = false, dirty = false, use_color = false, press_tab_visible = false;
if (!FLAGS_SET(flags, ASK_PASSWORD_HIDE_EMOJI) && emoji_enabled())
message = strjoina(special_glyph(SPECIAL_GLYPH_LOCK_AND_KEY), " ", message);
- if (flag_file || (FLAGS_SET(flags, ASK_PASSWORD_ACCEPT_CACHED) && keyring)) {
+ if (req->flag_file || (FLAGS_SET(flags, ASK_PASSWORD_ACCEPT_CACHED) && keyring)) {
inotify_fd = inotify_init1(IN_CLOEXEC|IN_NONBLOCK);
if (inotify_fd < 0)
return -errno;
}
- if (flag_file) {
- if (inotify_add_watch(inotify_fd, flag_file, IN_ATTRIB /* for the link count */) < 0)
+ if (req->flag_file)
+ if (inotify_add_watch(inotify_fd, req->flag_file, IN_ATTRIB /* for the link count */) < 0)
return -errno;
- }
if (FLAGS_SET(flags, ASK_PASSWORD_ACCEPT_CACHED) && req && keyring) {
r = ask_password_keyring(req, flags, ret);
if (r >= 0)
else
timeout = USEC_INFINITY;
- if (flag_file) {
- r = RET_NERRNO(access(flag_file, F_OK));
+ if (req->flag_file) {
+ r = RET_NERRNO(access(req->flag_file, F_OK));
if (r < 0)
goto finish;
}
if (FLAGS_SET(flags, ASK_PASSWORD_NO_AGENT))
return -EUNATCH;
+ /* We don't support the flag file concept for now when querying via the agent logic */
+ if (req->flag_file)
+ return -EOPNOTSUPP;
+
assert_se(sigemptyset(&mask) >= 0);
assert_se(sigset_add_many(&mask, SIGINT, SIGTERM) >= 0);
assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) >= 0);
}
if (!FLAGS_SET(flags, ASK_PASSWORD_NO_TTY) && isatty_safe(STDIN_FILENO))
- return ask_password_tty(-EBADF, req, until, flags, NULL, ret);
+ return ask_password_tty(-EBADF, req, until, flags, ret);
if (!FLAGS_SET(flags, ASK_PASSWORD_NO_AGENT))
return ask_password_agent(req, until, flags, ret);
const char *icon; /* freedesktop icon spec name */
const char *id; /* some identifier used for this prompt for the "ask-password" protocol */
const char *credential; /* $CREDENTIALS_DIRECTORY credential name */
+ const char *flag_file; /* Once this flag file disappears abort the query */
} AskPasswordRequest;
-int ask_password_tty(int tty_fd, const AskPasswordRequest *req, usec_t until, AskPasswordFlags flags, const char *flag_file, char ***ret);
-int ask_password_plymouth(const AskPasswordRequest *req, usec_t until, AskPasswordFlags flags, const char *flag_file, char ***ret);
+int ask_password_tty(int tty_fd, const AskPasswordRequest *req, usec_t until, AskPasswordFlags flags, char ***ret);
+int ask_password_plymouth(const AskPasswordRequest *req, usec_t until, AskPasswordFlags flags, char ***ret);
int ask_password_agent(const AskPasswordRequest *req, usec_t until, AskPasswordFlags flag, char ***ret);
int ask_password_auto(const AskPasswordRequest *req, usec_t until, AskPasswordFlags flag, char ***ret);
.keyring = "da key",
};
- r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ ASK_PASSWORD_CONSOLE_COLOR, /* flag_file= */ NULL, &ret);
+ r = ask_password_tty(-EBADF, &req, /* until= */ 0, /* flags= */ ASK_PASSWORD_CONSOLE_COLOR, &ret);
if (r == -ECANCELED)
ASSERT_NULL(ret);
else {
AskPasswordRequest req = {
.message = message,
+ .flag_file = flag_file,
};
- r = ask_password_tty(tty_fd, &req, until, flags, flag_file, ret);
+ r = ask_password_tty(tty_fd, &req, until, flags, ret);
if (arg_console) {
assert(tty_fd >= 0);
if (arg_plymouth) {
AskPasswordRequest req = {
.message = message,
+ .flag_file = filename,
};
- r = ask_password_plymouth(&req, not_after, flags, filename, &passwords);
+ r = ask_password_plymouth(&req, not_after, flags, &passwords);
} else
r = agent_ask_password_tty(message, not_after, flags, filename, &passwords);
if (r < 0) {