cryptsetup.c revision 7f4e08056de0184b205a20632e62db73d299937e
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <string.h>
#include <errno.h>
#include <libcryptsetup.h>
#include "log.h"
#include "util.h"
#include "ask-password-api.h"
static unsigned opt_tries = 0;
static char *opt_cipher = NULL;
static unsigned opt_size = 0;
static bool opt_readonly = false;
static bool opt_verify = false;
static usec_t arg_timeout = 0;
static int parse_one_option(const char *option) {
/* Handled outside of this tool */
return 0;
char *t;
return -ENOMEM;
opt_cipher = t;
log_error("size= parse failure, ignoring.");
return 0;
}
char *t;
return -ENOMEM;
opt_hash = t;
log_error("tries= parse failure, ignoring.");
return 0;
}
opt_readonly = true;
opt_verify = true;
log_error("timeout= parse failure, ignoring.");
return 0;
}
} else
return 0;
}
static int parse_options(const char *options) {
char *state;
char *w;
size_t l;
char *o;
int r;
if (!(o = strndup(w, l)))
return -ENOMEM;
r = parse_one_option(o);
free(o);
if (r < 0)
return r;
}
return 0;
}
"%s", msg);
}
int k;
return k;
}
int r = EXIT_FAILURE;
if (argc < 3) {
log_error("This program requires at least two arguments.");
return EXIT_FAILURE;
}
log_open();
int k;
if (argc < 4) {
log_error("attach requires at least two arguments.");
goto finish;
}
else
}
goto finish;
}
/* Format with random key and attach */
log_error("Formatting not yet supported.");
goto finish;
goto finish;
}
if (opt_readonly)
if (key_file) {
} else {
}
if (k < 0) {
goto finish;
}
int k;
goto finish;
}
goto finish;
}
} else {
goto finish;
}
r = EXIT_SUCCESS;
if (cd)
crypt_free(cd);
return r;
}