cryptsetup.c revision 0a1beeb64207eaa88ab9236787b1cbc2f704ae14
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering This file is part of systemd.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Copyright 2010 Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering (at your option) any later version.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is distributed in the hope that it will be useful, but
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Lesser General Public License for more details.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringstatic const char *arg_type = NULL; /* CRYPT_LUKS1, CRYPT_TCRYPT or CRYPT_PLAIN */
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringstatic unsigned arg_key_size = 0;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poetteringstatic unsigned arg_keyfile_size = 0;
cd61c3bfd718fb398cc53ced906266a9297782c9Lennart Poetteringstatic unsigned arg_keyfile_offset = 0;
d3152a09ac5804ec8603daee12f98cf03523cce0Lennart Poetteringstatic bool arg_readonly = false;
d3152a09ac5804ec8603daee12f98cf03523cce0Lennart Poetteringstatic bool arg_verify = false;
e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5eLennart Poetteringstatic bool arg_discards = false;
d3152a09ac5804ec8603daee12f98cf03523cce0Lennart Poetteringstatic bool arg_tcrypt_hidden = false;
97e67f1e52ddc0c21a88cfbcab57e83c59ee627dLennart Poetteringstatic bool arg_tcrypt_system = false;
adacb9575a09981fcf11279f2f661e3fc21e58ffLennart Poettering/* Options Debian's crypttab knows we don't:
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poetteringstatic int parse_one_option(const char *option) {
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering /* Handled outside of this tool */
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering if (streq(option, "noauto") || streq(option, "nofail"))
return log_oom();
arg_cipher = t;
return log_oom();
return log_oom();
arg_hash = t;
arg_readonly = true;
arg_verify = true;
arg_discards = true;
arg_tcrypt_hidden = true;
arg_tcrypt_system = true;
size_t l;
_cleanup_free_ char *o;
return -ENOMEM;
r = parse_one_option(o);
static const char name_fields[] =
return NULL;
return NULL;
if (!udev)
return NULL;
if (!device)
return NULL;
const char *name;
return NULL;
struct mntent *m;
return NULL;
return NULL;
while ((m = getmntent(f)))
return NULL;
char *id;
return log_oom();
if (!escaped_name)
return log_oom();
if (arg_verify) {
return log_oom();
return -EAGAIN;
return log_oom();
free(*p);
const char *name,
const char *key_file,
char **passwords,
if (arg_tcrypt_hidden)
if (arg_tcrypt_system)
if (key_file) {
return -EAGAIN;
return -EAGAIN;
const char *name,
const char *key_file,
char **passwords,
bool pass_volume_key = false;
if (arg_hash) {
} else if (!key_file)
if (arg_cipher) {
size_t l;
if (!truncated_cipher)
return log_oom();
if (key_file) {
return -EAGAIN;
if (pass_volume_key)
static int help(void) {
int r = EXIT_FAILURE;
help();
return EXIT_SUCCESS;
return EXIT_FAILURE;
log_open();
unsigned tries;
goto finish;
goto finish;
else if (mount_point)
else if (description)
log_oom();
goto finish;
goto finish;
r = EXIT_SUCCESS;
goto finish;
if (arg_readonly)
if (arg_discards)
if (arg_timeout > 0)
until = 0;
if (key_file) {
if (!key_file) {
if (k == -EAGAIN)
goto finish;
else if (k == -EAGAIN) {
} else if (k != -EPERM) {
goto finish;
r = EXIT_FAILURE;
goto finish;
goto finish;
goto finish;
goto finish;
r = EXIT_SUCCESS;
if (cd)