r = 0;
finish:
- if (notify >= 0)
- close_nointr_nofail(notify);
-
- if (fd >= 0)
- close_nointr_nofail(fd);
+ safe_close(notify);
+ safe_close(fd);
free(packet);
return -errno;
}
- r = config_parse(NULL, 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;
}
}
- if (pid > 0 &&
- kill(pid, 0) < 0 &&
- errno == ESRCH) {
+ if (pid > 0 && !pid_is_alive(pid)) {
r = 0;
goto finish;
}
} else {
int tty_fd = -1;
- char *password;
+ char *password = NULL;
if (arg_console)
if ((tty_fd = acquire_terminal("/dev/console", false, false, false, (usec_t) -1)) < 0) {
r = ask_password_tty(message, not_after, filename, &password);
if (arg_console) {
- close_nointr_nofail(tty_fd);
+ safe_close(tty_fd);
release_terminal();
}
finish:
fclose(f);
- if (socket_fd >= 0)
- close_nointr_nofail(socket_fd);
+ safe_close(socket_fd);
free(packet);
free(socket_name);
r = get_ctty_devnr(0, &devnr);
if (r < 0)
- return -r;
+ return r;
if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0)
return -ENOMEM;
return true;
/* What, we managed to open the pipe? Then this tty is filtered. */
- close_nointr_nofail(fd);
+ safe_close(fd);
return false;
}
free(p);
if (wall) {
- utmp_wall(wall, wall_tty_match);
+ utmp_wall(wall, NULL, wall_tty_match);
free(wall);
}
}
r = 0;
finish:
- if (notify >= 0)
- close_nointr_nofail(notify);
-
- if (signal_fd >= 0)
- close_nointr_nofail(signal_fd);
-
- if (tty_block_fd >= 0)
- close_nointr_nofail(tty_block_fd);
+ safe_close(notify);
+ safe_close(signal_fd);
+ safe_close(tty_block_fd);
return r;
}
{ "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 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}