#include "socket-util.h"
#include "ask-password-api.h"
#include "strv.h"
+#include "build.h"
static enum {
ACTION_LIST,
char ***_passphrases) {
int fd = -1, notify = -1;
- union sockaddr_union sa;
+ union sockaddr_union sa = {};
char *packet = NULL;
ssize_t k;
int r, n;
- struct pollfd pollfd[2];
+ struct pollfd pollfd[2] = {};
char buffer[LINE_MAX];
size_t p = 0;
enum {
goto finish;
}
- zero(sa);
sa.sa.sa_family = AF_UNIX;
strncpy(sa.un.sun_path+1, "/org/freedesktop/plymouthd", sizeof(sa.un.sun_path)-1);
if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1)) < 0) {
goto finish;
}
- zero(pollfd);
pollfd[POLL_SOCKET].fd = fd;
pollfd[POLL_SOCKET].events = POLLIN;
pollfd[POLL_INOTIFY].fd = notify;
return -errno;
}
- r = config_parse(filename, f, NULL, config_item_table_lookup, (void*) items, true, NULL);
+ r = config_parse(NULL, filename, f, NULL, config_item_table_lookup, (void*) items, true, false, NULL);
if (r < 0) {
log_error("Failed to parse password file %s: %s", filename, strerror(-r));
goto finish;
*wall ? "\r\n\r\n" : "",
message,
pid) < 0) {
- log_error("Out of memory");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
union {
struct sockaddr sa;
struct sockaddr_un un;
- } sa;
+ } sa = {};
size_t packet_length = 0;
assert(arg_action == ACTION_QUERY ||
}
if (arg_plymouth) {
- char **passwords = NULL;
+ _cleanup_strv_free_ char **passwords = NULL;
if ((r = ask_password_plymouth(message, not_after, filename, accept_cached, &passwords)) >= 0) {
char **p;
char *password;
if (arg_console)
- if ((tty_fd = acquire_terminal("/dev/console", false, false, false)) < 0) {
+ if ((tty_fd = acquire_terminal("/dev/console", false, false, false, (usec_t) -1)) < 0) {
r = tty_fd;
goto finish;
}
goto finish;
}
- zero(sa);
sa.un.sun_family = AF_UNIX;
strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0)
return -ENOMEM;
- mkdir_parents(p, 0700);
+ mkdir_parents_label(p, 0700);
mkfifo(p, 0600);
fd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
continue;
if (!(p = strappend("/run/systemd/ask-password/", de->d_name))) {
- log_error("Out of memory");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
};
int notify = -1, signal_fd = -1, tty_block_fd = -1;
- struct pollfd pollfd[_FD_MAX];
+ struct pollfd pollfd[_FD_MAX] = {};
sigset_t mask;
int r;
tty_block_fd = wall_tty_block();
- mkdir_p("/run/systemd/ask-password", 0755);
+ mkdir_p_label("/run/systemd/ask-password", 0755);
if ((notify = inotify_init1(IN_CLOEXEC)) < 0) {
r = -errno;
goto finish;
}
- zero(pollfd);
pollfd[FD_INOTIFY].fd = notify;
pollfd[FD_INOTIFY].events = POLLIN;
pollfd[FD_SIGNAL].fd = signal_fd;
printf("%s [OPTIONS...]\n\n"
"Process system password requests.\n\n"
" -h --help Show this help\n"
+ " --version Show package version\n"
" --list Show pending password requests\n"
" --query Process pending password requests\n"
" --watch Continuously process password requests\n"
ARG_WATCH,
ARG_WALL,
ARG_PLYMOUTH,
- ARG_CONSOLE
+ ARG_CONSOLE,
+ ARG_VERSION
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, ARG_VERSION },
{ "list", no_argument, NULL, ARG_LIST },
{ "query", no_argument, NULL, ARG_QUERY },
{ "watch", no_argument, NULL, ARG_WATCH },
{ "wall", no_argument, NULL, ARG_WALL },
{ "plymouth", no_argument, NULL, ARG_PLYMOUTH },
{ "console", no_argument, NULL, ARG_CONSOLE },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
switch (c) {
case 'h':
- help();
+ return help();
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_LIST:
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
int main(int argc, char *argv[]) {
int r;
+ log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();