cryptsetup-generator.c revision 1c7327004ab6f0b91bdceb06877a3094c5fe2a4b
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek This file is part of systemd.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek Copyright 2010 Lennart Poettering
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek (at your option) any later version.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic const char *arg_dest = "/tmp";
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic bool arg_enabled = true;
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic bool arg_read_crypttab = true;
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic char **arg_proc_cmdline_disks = NULL;
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic bool has_option(const char *haystack, const char *needle) {
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek while ((f = strstr(f, needle))) {
static int create_disk(
const char *name,
const char *device,
const char *password,
const char *options) {
r = -ENOMEM;
goto fail;
r = -ENOMEM;
goto fail;
r = -ENOMEM;
goto fail;
r = -ENOMEM;
goto fail;
r = -errno;
goto fail;
fprintf(f,
"Conflicts=umount.target\n"
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
"Before=umount.target\n",
if (!nofail)
fprintf(f,
"Before=cryptsetup.target\n");
fprintf(f,
name);
fprintf(f,
name);
fprintf(f,
name);
fflush(f);
if (ferror(f)) {
r = -errno;
goto fail;
r = -ENOMEM;
goto fail;
if (!noauto) {
if (!to) {
r = -ENOMEM;
goto fail;
r = -errno;
goto fail;
if (!nofail)
if (!to) {
r = -ENOMEM;
goto fail;
r = -errno;
goto fail;
if (!to) {
r = -ENOMEM;
goto fail;
r = -errno;
goto fail;
fail:
free(p);
free(n);
free(d);
free(e);
fclose(f);
static int parse_proc_cmdline(void) {
size_t l;
char *word;
if (!word) {
r = -ENOMEM;
goto finish;
arg_enabled = r;
if (in_initrd()) {
arg_enabled = r;
arg_read_crypttab = r;
if (in_initrd()) {
arg_read_crypttab = r;
r = -ENOMEM;
goto finish;
if (in_initrd()) {
r = -ENOMEM;
goto finish;
int r = EXIT_SUCCESS;
return EXIT_FAILURE;
log_open();
if (parse_proc_cmdline() < 0)
return EXIT_FAILURE;
if (!arg_enabled) {
r = EXIT_SUCCESS;
goto finish;
r = EXIT_FAILURE;
goto finish;
r = EXIT_FAILURE;
if (!arg_read_crypttab)
r = EXIT_SUCCESS;
r = EXIT_FAILURE;
goto finish;
r = EXIT_FAILURE;
goto next;
r = EXIT_FAILURE;
next:
fclose(f);