File systemd-38-r1.orig/.ipc_in is a fifo while file systemd-38-r1/.ipc_in is a fifo File systemd-38-r1.orig/.ipc_out is a fifo while file systemd-38-r1/.ipc_out is a fifo diff -ur systemd-38-r1.orig/work/systemd-38/src/cryptsetup/cryptsetup.c systemd-38-r1/work/systemd-38/src/cryptsetup/cryptsetup.c --- systemd-38-r1.orig/work/systemd-38/src/cryptsetup/cryptsetup.c 2012-02-02 02:55:51.730001038 -0800 +++ systemd-38-r1/work/systemd-38/src/cryptsetup/cryptsetup.c 2012-02-02 02:56:19.803001016 -0800 @@ -38,6 +38,7 @@ static unsigned opt_key_size = 0; static char *opt_hash = NULL; static unsigned opt_tries = 0; +static bool opt_gpg = false; static bool opt_readonly = false; static bool opt_verify = false; static usec_t opt_timeout = DEFAULT_TIMEOUT_USEC; @@ -97,6 +98,8 @@ opt_readonly = true; else if (streq(option, "verify")) opt_verify = true; + else if (streq(option, "gpg")) + opt_gpg = true; else if (streq(option, "luks")) opt_type = CRYPT_LUKS1; else if (streq(option, "plain") || @@ -226,6 +229,8 @@ const char *cipher = NULL, *cipher_mode = NULL, *hash = NULL, *name = NULL; char *description = NULL, *name_buffer = NULL, *mount_point = NULL; unsigned keyfile_size = 0; + char *cmd = NULL; + char *buffer = NULL; if (argc <= 1) { help(); @@ -344,7 +349,7 @@ strv_free(passwords); passwords = NULL; - if (!key_file) { + if (!key_file || (key_file && opt_gpg)) { char *text; char **p; @@ -393,8 +398,12 @@ strv_uniq(passwords); STRV_FOREACH(p, passwords) { + log_debug("pad? %s", *p); char *c; + if (opt_gpg) + continue; + if (strlen(*p)+1 >= opt_key_size) continue; @@ -453,7 +463,7 @@ crypt_get_volume_key_size(cd)*8, argv[3]); - if (key_file) + if (key_file && !opt_gpg) k = crypt_activate_by_keyfile(cd, argv[2], CRYPT_ANY_SLOT, key_file, keyfile_size, flags); else { char **p; @@ -462,8 +472,23 @@ if (pass_volume_key) k = crypt_activate_by_volume_key(cd, argv[2], *p, opt_key_size, flags); - else - k = crypt_activate_by_passphrase(cd, argv[2], CRYPT_ANY_SLOT, *p, strlen(*p), flags); + else { + if (opt_gpg) { + int l = 0; + int v; + char *buffer = malloc(1); + asprintf(&cmd, "echo \"%s\" | gpg -quiet --batch --no-tty --no-mdc-warning --passphrase-fd 0 --decrypt %s", *p, key_file); + FILE* f = popen(cmd, "r"); + while((v = fgetc(f)) != EOF) { + buffer = realloc(buffer, l+1); + buffer[l++] = v; + } + fclose(f); + k = crypt_activate_by_passphrase(cd, argv[2], CRYPT_ANY_SLOT, buffer, l, flags); + free(buffer); + } else + k = crypt_activate_by_passphrase(cd, argv[2], CRYPT_ANY_SLOT, *p, strlen(*p), flags); + } if (k >= 0) break; @@ -524,6 +549,7 @@ free(description); free(mount_point); free(name_buffer); + free(cmd); return r; }